Skip to content

Commit 0e4b543

Browse files
committed
M5: added keypad to demo application
1 parent af0c333 commit 0e4b543

File tree

4 files changed

+78
-17
lines changed

4 files changed

+78
-17
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### Updated
66
1. Fixed GPIO card constants.
7+
2. Added second page with keypad to demo application.
78

89

910
## [0.8.11](https://github.com/uhppoted/uhppoted-wiegand/releases/tag/v0.8.11) - 2025-07-30

m5-stack/Rev.0/coreS3/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
PORT = /dev/tty.usbmodem142201
1+
PORT = /dev/tty.usbmodem142101
22
# PORT = /dev/cu.usbmodem142201
33

44
flash:

m5-stack/Rev.0/coreS3/main.py

Lines changed: 71 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,43 @@
2121
RED = 0xC02020
2222
BORDER = 0xFC0000
2323

24+
PAGES = 2
25+
2426
IO1 = Pin(1, Pin.OUT)
2527
IO2 = Pin(2, Pin.OUT)
2628
uart1 = UART(1, baudrate=115200, tx=43, rx=44)
2729
uart2 = UART(2, baudrate=115200, tx=17, rx=18)
2830

31+
BTNA = Button(64, 248, 64, 32, "A", lambda: left())
32+
BTNB = Button(192, 248, 64, 32, "B", lambda: right())
33+
2934
B10058399 = Button(32, 8, 120, 48, "10058399", lambda: press(IO2))
3035
B10058400 = Button(32 + 136, 8, 120, 48, "10058400", lambda: press(IO1))
3136
B10058401 = Button(32, 8 + 64, 120, 48, "10058401", lambda: swipe(uart1, "10058401", None))
32-
C1357 = Button(32 + 136, 8 + 64, 120, 48, "1357#", lambda: keypad(uart1, "1357"))
33-
B10058402 = Button(32, 8 + 128, 256, 48, "10058402 + 7531#", lambda: swipe(uart2, "10058402", "7531"))
37+
C1357 = Button(32 + 136, 8 + 64, 120, 48, "1357#", lambda: keypad(uart1, "1357#"))
38+
B10058402 = Button(32, 8 + 128, 256, 48, "10058402 + 7531#", lambda: swipe(uart2, "10058402", "7531#"))
3439
LMSG = Label(0, 216, 320, 24, "")
3540

41+
KEY1 = Button(20, 1, 52, 44, "1", lambda: keypad(uart1, '1'))
42+
KEY2 = Button(88, 1, 52, 44, "2", lambda: keypad(uart1, '2'))
43+
KEY3 = Button(156, 1, 52, 44, "3", lambda: keypad(uart1, '3'))
44+
KEY4 = Button(20, 55, 52, 44, "4", lambda: keypad(uart1, '4'))
45+
KEY5 = Button(88, 55, 52, 44, "5", lambda: keypad(uart1, '5'))
46+
KEY6 = Button(156, 55, 52, 44, "6", lambda: keypad(uart1, '6'))
47+
KEY7 = Button(20, 110, 52, 44, "7", lambda: keypad(uart1, '7'))
48+
KEY8 = Button(88, 110, 52, 44, "8", lambda: keypad(uart1, '8'))
49+
KEY9 = Button(156, 110, 52, 44, "9", lambda: keypad(uart1, '9'))
50+
STAR = Button(20, 165, 52, 44, "*", lambda: keypad(uart1, '*'))
51+
KEY0 = Button(88, 165, 52, 44, "0", lambda: keypad(uart1, '0'))
52+
HASH = Button(156, 165, 52, 44, "#", lambda: keypad(uart1, '#'))
53+
SWIPE = Button(220, 16, 88, 64, "SWIPE",lambda: swipe(uart1, "10058400", None))
54+
3655
touched = None
3756
message = None
57+
page = 1
3858

59+
page1 = [ B10058399, B10058400, B10058401, B10058402, C1357 ]
60+
page2 = [ KEY1, KEY2, KEY3, KEY4, KEY5, KEY6, KEY7, KEY8, KEY9, STAR, KEY0, HASH, SWIPE ]
3961

4062
def setup():
4163
global IO1, IO2
@@ -46,20 +68,25 @@ def setup():
4668
# Power.setExtOutput(True)
4769

4870
def screen():
71+
global page
72+
4973
Widgets.setRotation(1)
5074
Widgets.fillScreen(BLACK)
51-
button(B10058399)
52-
button(B10058400)
53-
button(B10058401)
54-
button(B10058402)
55-
button(C1357)
5675
label(LMSG)
5776

77+
if page == 1:
78+
for b in page1:
79+
button(b)
80+
81+
if page == 2:
82+
for b in page2:
83+
button(b)
5884

5985
def button(b):
60-
offset = int(b.w / 2 - 12 * len(b.label) / 2)
86+
xoffset = int(b.w / 2 - 12 * len(b.label) / 2)
87+
yoffset = int(b.h / 2 - 6)
6188
Widgets.Rectangle(b.x, b.y, b.w, b.h, BORDER, BACKGROUND)
62-
Widgets.Label(b.label, b.x + offset, b.y + 14, 1.0, BLACK, BACKGROUND, Widgets.FONTS.DejaVu18)
89+
Widgets.Label(b.label, b.x + xoffset, b.y + yoffset, 1.0, BLACK, BACKGROUND, Widgets.FONTS.DejaVu18)
6390

6491

6592
def label(l):
@@ -109,7 +136,7 @@ def swipe(uart, card, code):
109136

110137
def keypad(uart, code):
111138
display("")
112-
uart.write(f"CODE {code}#\n")
139+
uart.write(f"CODE {code}\n")
113140

114141
return read(uart)
115142

@@ -146,11 +173,24 @@ def read(uart):
146173
return False
147174

148175

176+
def left():
177+
global page
178+
print("LEFT")
179+
if page > 1:
180+
page = page - 1
181+
screen()
182+
183+
def right():
184+
global page
185+
print("RIGHT")
186+
if page < PAGES:
187+
page = page + 1
188+
screen()
189+
149190
def display(msg):
150191
global message
151192
message.setText(f"%-128s" % f"{msg}")
152193

153-
154194
def loop():
155195
global touched
156196

@@ -169,25 +209,40 @@ def loop():
169209
touched = Point(point[0], point[1], now)
170210

171211
if dt > 250 or abs(dx) > 10 or abs(dy) > 10:
172-
if pressed(B10058399):
212+
if pressed(BTNA):
213+
BTNA.pressed()
214+
215+
if pressed(BTNB):
216+
BTNB.pressed()
217+
218+
if page == 1 and pressed(B10058399):
173219
if B10058399.pressed():
174220
Speaker.tone(784, 125) # G5
175221

176-
if pressed(B10058400):
222+
if page == 1 and pressed(B10058400):
177223
if B10058400.pressed():
178224
Speaker.tone(698, 125) # F5
179225

180-
if pressed(B10058401):
226+
if page == 1 and pressed(B10058401):
181227
if B10058401.pressed():
182228
Speaker.tone(880, 125) # A5
183229

184-
if pressed(B10058402):
230+
if page == 1 and pressed(B10058402):
185231
if B10058402.pressed():
186232
Speaker.tone(1046, 125) # C6'ish
187233

188-
if pressed(C1357):
234+
if page == 1 and pressed(C1357):
189235
if C1357.pressed():
190236
Speaker.tone(1174, 125) # D6'ish
237+
238+
if page == 2:
239+
for b in page2:
240+
if pressed(b):
241+
if b.pressed():
242+
Speaker.tone(784, 125) # G5
243+
break
244+
245+
191246
else:
192247
release()
193248

m5-stack/Rev.1/NOTES.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@
5252
- https://os.mbed.com/users/4180_1/notebook/rgb-leds
5353
- https://electronics.stackexchange.com/questions/48522/what-resistor-to-use-with-this-rgb-led
5454
- https://electronics.stackexchange.com/questions/373148/resistor-requirement-for-3-3-v-supply
55+
- https://electronics.stackexchange.com/questions/756253/ws2811-strip-kinda-works-with-diode-level-shifter-but-not-mosfet
56+
- https://electronics.stackexchange.com/questions/756103/is-it-ok-to-place-components-inside-the-pcb
57+
5558
19. Fix weirdly crossed signal lines between ISOW and line buffer
5659
20. Relook at ESD/protection diodes
5760
- https://hackaday.com/2025/06/19/hacker-tactic-esd-diodes
@@ -66,6 +69,8 @@
6669
- https://electronics.stackexchange.com/questions/415542/are-these-tiny-vertical-dual-row-pcb-mounted-connector-pins-standard/719876#719876
6770
28. PCB notch for CoreS3 power switch
6871
29. Slot in enclosure for USB cable
72+
30. WS2812 level translation
73+
- https://electronics.stackexchange.com/questions/756253/ws2811-strip-kinda-works-with-diode-level-shifter-but-not-mosfet
6974

7075
- https://hackaday.com/2025/09/09/freecad-foray-from-brick-to-shell/
7176
- (?) https://www.ti.com/product/MSPM0C1104

0 commit comments

Comments
 (0)