diff --git a/.gitignore b/.gitignore index 6ae5b379..47a850c2 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ src/seedsigner.egg-info/ .nova .vscode src/seedsigner/models/settings_definition.json +.idea diff --git a/README.md b/README.md index b4469cb4..3754dd76 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ If you have specific questions about the project, our [Telegram Group](https://t To build a SeedSigner, you will need: -* Raspberry Pi Zero (preferably version 1.3 with no WiFi/Bluetooth capability, but any Raspberry Pi 2/3/4 or Zero model will work) +* Raspberry Pi Zero (preferably version 1.3 with no WiFi/Bluetooth capability, but any Raspberry Pi 2/3/4 or Zero model will work, Raspberry Pi 1 devices will require a hardware modification to the Waveshare LCD Hat, as per the [instructions here](./docs/legacy_hardware.md)) * Waveshare 1.3" 240x240 pxl LCD (correct pixel count is important, more info at https://www.waveshare.com/wiki/1.3inch_LCD_HAT) * Pi Zero-compatible camera (tested to work with the Aokin / AuviPal 5MP 1080p with OV5647 Sensor) diff --git a/docs/img/legacy_hardware_remapped_pins.jpg b/docs/img/legacy_hardware_remapped_pins.jpg new file mode 100644 index 00000000..f6af8b47 Binary files /dev/null and b/docs/img/legacy_hardware_remapped_pins.jpg differ diff --git a/docs/img/legacy_hardware_remapped_pins_photo.jpg b/docs/img/legacy_hardware_remapped_pins_photo.jpg new file mode 100644 index 00000000..a7abcccc Binary files /dev/null and b/docs/img/legacy_hardware_remapped_pins_photo.jpg differ diff --git a/docs/legacy_hardware.md b/docs/legacy_hardware.md new file mode 100644 index 00000000..09daaaab --- /dev/null +++ b/docs/legacy_hardware.md @@ -0,0 +1,22 @@ +# Legacy Hardware Modifications + +Older Raspberry Pi devices have a smaller GPIO header, 26 pin as opposed to the 40 pin header found on more recent models. The Waveshare LCD hat uses some of the pins between 26 and 40 for the buttons, meaning that these will need to be reassigned (and remapped in software) when used with an older device. + +## Hardware Changes + +A suggested remapping can be found here: +![Remapped Pins Shematic](./img/legacy_hardware_remapped_pins.jpg) + +This remapping can be done by soldering wires on to the Waveshare hat as below: +![Remapped Pins Photo](./img/legacy_hardware_remapped_pins_photo.jpg) + +Alternatively, you could do this by connecting the LCD hat on with individual breadboard jumper wires. + +Once you have re-mapped the pins, it is advised to do an IO Test to ensure that everything works. + +**Warning: Some of the GPIO pins on contain 5 volt output. Raspberry Pi GPIO pins are NOT 5V tolerant, meaning that if you accidentally connect a 5V supply pin to a GPIO input pin, you risk permanent damage.** + +## Software Changes +The Seedsigner software will automatically detect which hardware revision you are using and if the older hardware is detected, will remap the software to match the above modifications to the Waveshare hat. + +If you are using a pre-built Seedsigner image that hasn't yet has this incorporated, you can simply take the file "buttons.py" (/src/seedsigner/hardware/ int his repository) and overwrite same file on your Seedsigner SD card. (The easiest way to do this is to copy it on to the /boot/ partitition of the SD card then copy it over via the command line while connected to your Pi via monitor+keyboard) O \ No newline at end of file diff --git a/src/seedsigner/hardware/buttons.py b/src/seedsigner/hardware/buttons.py index d1ae20e4..44a33d60 100644 --- a/src/seedsigner/hardware/buttons.py +++ b/src/seedsigner/hardware/buttons.py @@ -3,18 +3,30 @@ import time from seedsigner.models.singleton import Singleton - class HardwareButtons(Singleton): - KEY_UP_PIN = 6 - KEY_DOWN_PIN = 19 - KEY_LEFT_PIN = 5 - KEY_RIGHT_PIN = 26 - KEY_PRESS_PIN = 13 + if GPIO.RPI_INFO['P1_REVISION'] == 3: #This indicates that we have revision 3 GPIO + print("Detected 40pin GPIO (Rasbperry Pi 2 and above)") + KEY_UP_PIN = 6 + KEY_DOWN_PIN = 19 + KEY_LEFT_PIN = 5 + KEY_RIGHT_PIN = 26 + KEY_PRESS_PIN = 13 - KEY1_PIN = 21 - KEY2_PIN = 20 - KEY3_PIN = 16 + KEY1_PIN = 21 + KEY2_PIN = 20 + KEY3_PIN = 16 + else: + print("Assuming 26 Pin GPIO (Raspberry P1 1)") + KEY_UP_PIN = 3 + KEY_DOWN_PIN = 17 + KEY_LEFT_PIN = 2 + KEY_RIGHT_PIN = 22 + KEY_PRESS_PIN = 4 + + KEY1_PIN = 23 + KEY2_PIN = 18 + KEY3_PIN = 14 @classmethod def get_instance(cls): @@ -165,14 +177,25 @@ class HardwareButtons(Singleton): # TODO: Implement `release_lock` functionality as a global somewhere. Mixes up design # patterns to have a static constants class plus a settable global value. class HardwareButtonsConstants: - KEY_UP = 6 - KEY_DOWN = 19 - KEY_LEFT = 5 - KEY_RIGHT = 26 - KEY_PRESS = 13 - KEY1 = 21 - KEY2 = 20 - KEY3 = 16 + if GPIO.RPI_INFO['P1_REVISION'] == 3: #This indicates that we have revision 3 GPIO + KEY_UP = 6 + KEY_DOWN = 19 + KEY_LEFT = 5 + KEY_RIGHT = 26 + KEY_PRESS = 13 + KEY1 = 21 + KEY2 = 20 + KEY3 = 16 + else: + KEY_UP = 3 + KEY_DOWN = 17 + KEY_LEFT = 2 + KEY_RIGHT = 22 + KEY_PRESS = 4 + KEY1 = 23 + KEY2 = 18 + KEY3 = 14 + OVERRIDE = 1000 ALL_KEYS = [