diff --git a/1og/README.md b/1og/README.md index a96e6fd..c8aa528 100644 --- a/1og/README.md +++ b/1og/README.md @@ -1,21 +1,32 @@ # ButtonCtl + ![](./buttons-platzierung.png) ### Dependencies + - RPi python3-rpi.gpio + ```sh sudo apt install python3-rpi-gpio ``` + - OpenSSH client + ```sh sudo apt install openssh ``` + - circuitpython libraries for neopixel + ```sh pip3 install adafruit-circuitpython-neopixel ``` +- SPI + Enable SPI in raspi bootloader for GPIO10 + ### Install + ```sh cd buttonctl/1og ./service.sh # create systemd .service file @@ -23,25 +34,51 @@ sudo systemctl enable --now buttond # start and autostart at boot ``` ### Wiring -- pin 23: left button input (pull-down) + +- pin 23: left/aerie button input (pull-down) - pin 24: center button input (pull-down) -- pin 22: right button input (pull-down) -- pin 18: neopixel data +- pin 22: right/cellar button input (pull-down) +- pin 12: neopixel data - pin 4: (pull-down) +#### 6-pin socket + +**GPIO** + +| | Notch | | +|------|-------|----| +| 23 | 24 | 12 | +| 3.3V | GND | 22 | + +**KiCAD** + +| | Notch | | +|---|-------|---| +| 5 | 3 | 1 | +| 6 | 4 | 2 | + +**UV Klemme** + +| | Notch | | +|------------------------------------------------------------|---------------------------------------------------------------|-----------------------------------------------------------| +| grün | braun | blau | +| rot | schwarz | gelb | + ![](pins.png) - led strip: -``` -(25-36) (13-24) (1-12) - AERIE KELLER - (counter-clockwise) +``` +(1-12) (13-24) (25-36) +AERIE KELLER + + (counter-clockwise, top is first) ``` ## Usage ### Open Door + @@ -62,6 +99,7 @@ sudo systemctl enable --now buttond # start and autostart at boot ### Abort + @@ -77,6 +115,7 @@ sudo systemctl enable --now buttond # start and autostart at boot ### No-Op + diff --git a/1og/button.py b/1og/button.py index 81663a5..9463da3 100644 --- a/1og/button.py +++ b/1og/button.py @@ -122,14 +122,10 @@ class StateMenu: self.next_state = None self.reset_state() - self.mqtt = FoodoorMQTT(["oben", "unten"]) - self.mqtt.message_cbs.append(lambda *_: self.draw()) - self.mqtt.connect() - - self.strip = neopixel.NeoPixel(board.D18, 36, brightness=0.5, pixel_order=neopixel.GRB, auto_write=False) - self.strip_cellar = SubStrip(self.strip, pixel=list(range(12))) + self.strip = neopixel.NeoPixel(board.D12, 36, brightness=0.5, pixel_order=neopixel.GRB, auto_write=False) + self.strip_aerie = SubStrip(self.strip, pixel=list(range(12))) self.strip_center = SubStrip(self.strip, pixel=list(range(12, 24))) - self.strip_aerie = SubStrip(self.strip, pixel=list(range(24, 36))) + self.strip_cellar = SubStrip(self.strip, pixel=list(range(24, 36))) self.strip_loop = SubStrip(self.strip, [ 0, 1, 2, 3, 4, 5, 6, 7, 8, @@ -143,6 +139,10 @@ class StateMenu: "aerie": Door("10.42.1.28", "open", "close"), } + self.mqtt = FoodoorMQTT(["oben", "unten"]) + self.mqtt.message_cbs.append(lambda *_: self.draw()) + self.mqtt.connect() + def reset_state(self): self.state = StateMenu.SHOW_STATE self.change_target = None @@ -260,24 +260,24 @@ def main(): btn_aerie.switch_to_input(digitalio.Pull.DOWN) menu = StateMenu() - btn_locked = False # For waiting while a button is still pressed + btn_locked = 0 # For waiting while a button is still pressed try: while True: - if not btn_cellar.value: + if btn_cellar.value: if not btn_locked: menu.button_pressed("cellar") - btn_locked = True - elif not btn_center.value: + btn_locked = 10 + elif btn_center.value: if not btn_locked: menu.button_pressed("center") - btn_locked = True - elif not btn_aerie.value: + btn_locked = 10 + elif btn_aerie.value: if not btn_locked: menu.button_pressed("aerie") - btn_locked = True - else: - btn_locked = False + btn_locked = 10 + elif btn_locked: + btn_locked -= 1 menu.tick() time.sleep(.01) diff --git a/1og/pins.png b/1og/pins.png index f1474d7..ae82bc7 100644 Binary files a/1og/pins.png and b/1og/pins.png differ diff --git a/1og/pins.yaml b/1og/pins.yaml new file mode 100644 index 0000000..104aee7 --- /dev/null +++ b/1og/pins.yaml @@ -0,0 +1,93 @@ +title: Power Pi +board: rpi4 + +devices: + - name: S0 + pins: + - { name: S0-, role: GND } + - { name: S0+, role: gpio } + + - name: Buttons + pins: + - { name: Cellar, role: gpio } + - { name: Center, role: gpio } + - { name: Aerie, role: gpio } + - { name: WS2812, role: gpio } + - { name: Power, role: 5V } + - { name: Ground, role: GND } + + - name: I2C Repeater + pins: + - { name: 5V, role: 5V } + - { name: 3V3, role: 3V3 } + - { name: Ground, role: GND } + - { name: SDA, role: I2C_SDA } + - { name: SCL, role: I2C_SCL } + - { name: GPIO17, role: gpio } + +connections: + - board_pin: 15 # 22 + device: Buttons + device_pin: Cellar + color: yellow + - board_pin: 18 # 24 + device: Buttons + device_pin: Center + color: brown + - board_pin: 16 # 23 + device: Buttons + device_pin: Aerie + color: green + + - board_pin: 19 # 10 + device: Buttons + device_pin: WS2812 + color: blue + + - board_pin_role: GND + device: Buttons + device_pin: Ground + color: black + - board_pin_role: 5V + device: Buttons + device_pin: Power + color: red + + - board_pin_role: 5V + device: I2C Repeater + device_pin: 5V + color: red + - board_pin_role: 3V3 + device: I2C Repeater + device_pin: 3V3 + color: orange + - board_pin_role: GND + device: I2C Repeater + device_pin: Ground + color: black + + - board_pin: 3 # 2 + device: I2C Repeater + device_pin: SDA + color: green + - board_pin: 5 # 3 + device: I2C Repeater + device_pin: SCL + color: gray + - board_pin: 11 # 17 + device: I2C Repeater + device_pin: GPIO17 + color: pink + + - board_pin: 12 # 18 + device: S0 + device_pin: S0+ + color: yellow + components: + - type: resistor + value: 10kΩ + position: .9 + - board_pin_role: GND + device: S0 + device_pin: S0- + color: black