This repository was archived by the owner on Jan 8, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_module2.py
More file actions
77 lines (63 loc) · 2.13 KB
/
_module2.py
File metadata and controls
77 lines (63 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
from interface import Interface
from machine import Pin, Timer
import time
from buttonhandler import ButtonHandler
import joystick
import monitor
from rotary import Rotary
import switches
import led
from jack import Jack
class Module2(Interface):
def __init__(self):
self.left_jack = Jack("L")
self.c_jack = Jack("C")
self.right_jack = Jack("R")
self.c_jack.write()
self.button_left = ButtonHandler(20, Pin.PULL_UP) # This one doesn't work with PULL_DOWN
self.button_right = ButtonHandler(10, Pin.PULL_DOWN) # This one handles either
self.rotary = Rotary()
self.rotary_value = 0
self.button_right.subscribe_pressed(self.right_pressed)
self.button_right.subscribe_released(self.right_released)
self.button_left.subscribe_pressed(self.left_pressed)
self.button_left.subscribe_released(self.left_released)
self.rotary.subscribe(self.rotary_changed)
led.initialize()
def left_pressed(self):
pass
def left_released(self):
pass
def right_pressed(self):
pass
def right_released(self):
pass
def rotary_changed(self, value):
pass
def step(self):
try:
while True:
monitor.display("Not implemented")
time.sleep(1)
except KeyboardInterrupt:
self.shutdown()
finally:
self.shutdown()
def shutdown(self):
try:
self.button_right.unsubscribe(self.right_pressed)
self.button_right.unsubscribe(self.right_released)
self.button_left.unsubscribe(self.left_pressed)
self.button_left.unsubscribe(self.left_released)
monitor.shutdown()
led.shutdown()
self.left_jack.off()
self.c_jack.off()
self.right_jack.off()
print("System shutdown completed.")
except Exception as e:
print("Error during shutdown:", e)
# The main execution block should be outside any class definitions
if __name__ == "__main__":
combine_instance = Module2()
combine_instance.step()