mrworf / photoframe

Software to pull random photos from Google Photos and show them, like a photo frame
GNU General Public License v3.0
215 stars 38 forks source link

Set GPIO shutdown pin dynamically based on detecting a photo module. #194

Open dadr opened 3 years ago

dadr commented 3 years ago

Photoframe had pin 37 (GPIO 26) used for shutdown, but then the default was changed to pin 5 (GPIO 3) because that one can also restart a halted system. But, pin 3 conflicts with the color module i2c bus. As I was updating the readme to explain this, it occurred to me that it should be possible to try to detect the photo module first, and then default the shutdown to GPIO 3 or 26 accordingly.

mrworf commented 2 years ago

The issue is that it will make it less deterministic. However, it seems that development of Rasbian has added some cool stuff, including multiple i2c buses :) See https://www.instructables.com/Raspberry-PI-Multiple-I2c-Devices/ so it might be doable to use another i2c bus and free up GPIO3 to be used for on/off and not having to pick one or the other. Have yet to try it myself though

dadr commented 2 years ago

That's a very interesting link. Given this capability really works, I think it makes sense to use GPIO3 (pin 5) for on/off. I've been planning to use GPIO18 (pin 12) for PWM to change brightness on LCD inverters. (Just haven't gotten around to doing that yet ;-) So maybe use GPIO 17 for SDA and 27 for SCL (Pins 13 & 15) for the photo module, and make that bus 3. We could also set up GPIO 23 for SDA and 24 for SCL on a bus 4 to potentially support some additional device with duplicate address (or not). I had also intended to try adding a temperature and humidity module, but I think that it can share the bus with the photo module. Lastly, for completeness, I enable i2C-2 in order to talk to monitors that can adjust brightness and color temp. It does not interfere with the above, but the bus does get exposed to the OS - where the default is not.