-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why is CS pin controlled through GPIO and not with SPI? #36
Comments
Not sure if I understand your question correctly, but I guess it's like this because it's what the Waveshare examples have originally used. If you're using the IT8951, could you simply change the CS pin for it to some other pin from here: https://github.com/joukos/PaperTTY/blob/master/drivers/driver_it8951.py#L19 ? |
Changing the CS pin is not enough. There are two concurrently running parts now in the system for both devices connected to SPI. One is the kernel driver for MCP2515 and the other is this Python code for IT8951. This code and the kernel driver are concurrently sending over SPI. SPI for itself is not the problem, the kernel is able to separate both transfers. The problem is the Python code setting the CS pin, while the kernel driver for MCP2515 is currently transferring. Then both devices, MCP2515 and IT8951 will have their CS pins active and both will listen to the SPI data, although the data is meant for MCP2515. The problem is, that this Python code for IT8951 does not check, whether the CS pin for MCP2515 is active. If the transfer is done using spidev and letting spidev setting CS pin for IT8951, then it will check, whether there is currently CS pin for MCP2515 is already active. So, what I need, is, that every SPI transfer is done through the kernel, so only one CS pin is selected. |
Ah, now I see what you mean, thanks for the explanation. I suppose most just haven't tried to use more than one SPI device at a time with this code. There's a comment in the IT8951 driver about setting the SPI to I guess you could try to modify it to not control the CS itself, but the comment implies that it might not work as expected 🤔 |
Currently I can only read/write registers, set VCOM, read device info and so on, with letting the control of the CS pin to spidev. Transferring and displaying something does not work at all. I have absolutely no clue, what the problem could be? Especially as I can find absolutely no documentation, about how to transfer image data. Reading and writing registers is described very good including how the CS pin should be active or not. But for an image transfer I am missing all necessary specifications. I will try now your code, so I am able to display at least something and very, that the EPD is not broken. |
@fimad might have some pointers as he contributed the IT8951 code to PaperTTY. Also @GregDMeyer had a fork with another implementation of the IT8951 support (https://github.com/GregDMeyer/PaperTTY + python driver https://github.com/GregDMeyer/IT8951) so maybe it's worth a look too (discussion is here #25). The Waveshare displays can be a bit quirky sometimes and I've thought I'd broken mine a few times, but after just disconnecting everything and trying simple stuff repeatedly they've resumed their operation eventually. Sadly the docs aren't always friendly and may have a lot of timing diagrams and whatnot but seem to lack relevant info for implementing the software that drives the display... |
I could not get anything working without setting What are the issues you are having with drawing? Is the display completely non-responsive? Its been a little while since I've looked at this, so the details are a bit vague. Somethings that I recall giving me issues with drawing included:
|
My code is actually here. It is based on/copied from this code, which was already mentioned by @joukos. With my implementation I am able to read the device info, set and get registers and VCOM while spi-dev controls the CS pin. What is not working, is to display something. Maybe there are still problems with load image start, load image end, display image commands and/or the image transfer.
To summarize my efforts, I still need a lot more time, to understand this whole thing, to get the display working and to get the code as fast as possible. This should later be integrated into this code as normal Raspberry Pi displays are nearly not readable in sun light, that's why we want to add an e-Paper display. |
Sorry to be absent for a while---today I'm giving another try to using the python spidev module to handle all the communications here. @kleini did you ever have any luck getting images to show? FYI---the original reason I had stopped trying to use spidev was because I was running into the same issues you all were discussing above. I couldn't even get the controller to give me the system info back, so the fact that you were able to do that at least is promising! I'll take a look at your code, and see if I can get the data transfer to work too. |
My previous post is 4 month now old and a lot happened in the mean time. |
cool, sounds good! I'll keep playing with it and see if I can get all the display modes working, and also see if I can work on the speed a bit (it would be really nice for PaperTTY to get the updates working as fast as possible). I'll update when I have something! I'm looking forward to not needing sudo any more ;) |
FYI---I just rewrote the backend of my repo here to talk directly to |
Wow, that sounds superb! It would be awesome to integrate your solution with the rest of PaperTTY, but I don't have time right now to take a closer look at it - should it be a "simple" matter of replacing the SPI parts and adjusting the IT8951 code? Great work! |
I would like to use a second device on the SPI, which requires to let control of CS pin to spi-dev. Otherwise the code simply sets CS pin active while driver for second device currently has CS pin for second device active and transfers data. IT8951 would then receive data meant for second device.
The text was updated successfully, but these errors were encountered: