-
-
Notifications
You must be signed in to change notification settings - Fork 209
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
XPT2046 portduino tweaks #559
Conversation
99d49c9
to
7afd000
Compare
After a couple false starts, this finally works. I'll point out that @mverch67 thinks this is not a great approach, and has an idea to re-use the cfg.spi_host value to specify the SPI device. Not sure how we want to handle this. Maybe pull this code once it's in shape, and then revisit when he writes his alternative? Related to that, is arduino_default used by anything other than Portduino/Meshtastic? I'm assuming it is, which is why I'm trying to keep the code that goes in there minimal, and as broadly applicable as I can. |
As discussed (internally) I think this is not a good design to pass pointers of lowers layers through the entire architecture. Also the lovyanGFX interface becomes now rather ugly because of this inconsistency and the artificial dependency to a lower layer which is not necessary. My preferred solution would be:
That should do it. |
Here, this ctor is missing in the portduino-framework and this is exactly the reason why we are having the issue to configure the SPI interface properly: |
yup Touch.hpp should stay pure from any bus class and I'm not sure all those ifdefs should spread that far outside platforms/arduino_default lets keep this PR open for the meantime and see if a lighter approach is possible |
I've struggled with how to make this lighter, and yet support all the needed cases. We can't define an SPI bus on Linux with just a single int. Is new HardwareSPI(1) referring to spidev0.1 or spidev1.0? Also, declaring a new HardwareSPI could be a problem for the cases where we actually want to use the same SPI device, and let the LovyanGFX library manage the CS line. To handle all the edge cases is to move further and further away from the arduino API we're trying to use. I'm about convinced that the way forward here is to just create three global SPI devices in Portduino instead of just one, and use spi_host to pick the right one. |
can this be addressed ? this would solve a few problems if not, then maybe it'll be easier to just create a platforms/portduino folder and put the modified bus in there? here's what I suggest for this PR: only keep the changes in |
They don't do anything by themselves. isSPI() will always return false, if CS is set to a negative value. Should we remove the isSPI() call for touch devices that are SPI only? |
according to the readme the XPT2046 support is for SPI versions only so it's fine to remove that |
7afd000
to
0dedad6
Compare
@tobozo Minimized this PR to the XPT2046 change. We have a workable solution for the SPI bus issue, that I'll make a separate PR once it's fully tested. |
This works for me, but may be a problem for other targets. If so, I think we can add some ifdef ARDUINO to fix it up. Feedback welcome.
The basic idea here is that some targets (namely Portduino) may have SPI devices that automatically manage their Chip Select lines, and are not just the "SPI" device. So this adds a configurable SPI device for touch, and doesn't fail when CS is unset.