New Cable, debounce

This commit is contained in:
T
2026-06-25 23:52:18 +02:00
parent 95580bb3eb
commit b8a56829f3
4 changed files with 155 additions and 23 deletions
+46 -7
View File
@@ -1,21 +1,32 @@
# ButtonCtl # ButtonCtl
![](./buttons-platzierung.png) ![](./buttons-platzierung.png)
### Dependencies ### Dependencies
- RPi python3-rpi.gpio - RPi python3-rpi.gpio
```sh ```sh
sudo apt install python3-rpi-gpio sudo apt install python3-rpi-gpio
``` ```
- OpenSSH client - OpenSSH client
```sh ```sh
sudo apt install openssh sudo apt install openssh
``` ```
- circuitpython libraries for neopixel - circuitpython libraries for neopixel
```sh ```sh
pip3 install adafruit-circuitpython-neopixel pip3 install adafruit-circuitpython-neopixel
``` ```
- SPI
Enable SPI in raspi bootloader for GPIO10
### Install ### Install
```sh ```sh
cd buttonctl/1og cd buttonctl/1og
./service.sh # create systemd .service file ./service.sh # create systemd .service file
@@ -23,25 +34,51 @@ sudo systemctl enable --now buttond # start and autostart at boot
``` ```
### Wiring ### Wiring
- pin 23: left button input (pull-down)
- pin 23: left/aerie button input (pull-down)
- pin 24: center button input (pull-down) - pin 24: center button input (pull-down)
- pin 22: right button input (pull-down) - pin 22: right/cellar button input (pull-down)
- pin 18: neopixel data - pin 12: neopixel data
- pin 4: (pull-down) - 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 | |
|------------------------------------------------------------|---------------------------------------------------------------|-----------------------------------------------------------|
| <span style="background: green; color: white;">grün</span> | <span style="background: brown; color: white;">braun</span> | <span style="background: blue; color: white;">blau</span> |
| <span style="background: red;">rot</span> | <span style="background: black; color: white;">schwarz</span> | <span style="background: yellow">gelb</span> |
![](pins.png) ![](pins.png)
- led strip: - 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 ## Usage
### Open Door ### Open Door
<span style="color:red">&#9724;</span> <span style="color:red">&#9724;</span>
<span style="color:black">&#9724;</span> <span style="color:black">&#9724;</span>
<span style="color:red">&#9724;</span> <span style="color:red">&#9724;</span>
@@ -62,6 +99,7 @@ sudo systemctl enable --now buttond # start and autostart at boot
<span style="color:red">&#9724;</span> <span style="color:red">&#9724;</span>
### Abort ### Abort
<span style="color:red">&#9724;</span> <span style="color:red">&#9724;</span>
<span style="color:black">&#9724;</span> <span style="color:black">&#9724;</span>
<span style="color:red">&#9724;</span> <span style="color:red">&#9724;</span>
@@ -77,6 +115,7 @@ sudo systemctl enable --now buttond # start and autostart at boot
<span style="color:red">&#9724;</span> <span style="color:red">&#9724;</span>
### No-Op ### No-Op
<span style="color:red">&#9724;</span> <span style="color:red">&#9724;</span>
<span style="color:black">&#9724;</span> <span style="color:black">&#9724;</span>
<span style="color:red">&#9724;</span> <span style="color:red">&#9724;</span>
+16 -16
View File
@@ -122,14 +122,10 @@ class StateMenu:
self.next_state = None self.next_state = None
self.reset_state() self.reset_state()
self.mqtt = FoodoorMQTT(["oben", "unten"]) self.strip = neopixel.NeoPixel(board.D12, 36, brightness=0.5, pixel_order=neopixel.GRB, auto_write=False)
self.mqtt.message_cbs.append(lambda *_: self.draw()) self.strip_aerie = SubStrip(self.strip, pixel=list(range(12)))
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_center = SubStrip(self.strip, pixel=list(range(12, 24))) 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, [ self.strip_loop = SubStrip(self.strip, [
0, 1, 2, 3, 4, 5, 6, 7, 8, 0, 1, 2, 3, 4, 5, 6, 7, 8,
@@ -143,6 +139,10 @@ class StateMenu:
"aerie": Door("10.42.1.28", "open", "close"), "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): def reset_state(self):
self.state = StateMenu.SHOW_STATE self.state = StateMenu.SHOW_STATE
self.change_target = None self.change_target = None
@@ -260,24 +260,24 @@ def main():
btn_aerie.switch_to_input(digitalio.Pull.DOWN) btn_aerie.switch_to_input(digitalio.Pull.DOWN)
menu = StateMenu() 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: try:
while True: while True:
if not btn_cellar.value: if btn_cellar.value:
if not btn_locked: if not btn_locked:
menu.button_pressed("cellar") menu.button_pressed("cellar")
btn_locked = True btn_locked = 10
elif not btn_center.value: elif btn_center.value:
if not btn_locked: if not btn_locked:
menu.button_pressed("center") menu.button_pressed("center")
btn_locked = True btn_locked = 10
elif not btn_aerie.value: elif btn_aerie.value:
if not btn_locked: if not btn_locked:
menu.button_pressed("aerie") menu.button_pressed("aerie")
btn_locked = True btn_locked = 10
else: elif btn_locked:
btn_locked = False btn_locked -= 1
menu.tick() menu.tick()
time.sleep(.01) time.sleep(.01)
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 119 KiB

After

Width:  |  Height:  |  Size: 408 KiB

+93
View File
@@ -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