initial commit

This commit is contained in:
2026-04-27 14:11:46 +02:00
parent 3d4c522f3d
commit 301c8309ab
8 changed files with 449 additions and 0 deletions

56
main.py Normal file
View File

@@ -0,0 +1,56 @@
#!/usr/bin/env python3
import queue
import threading
import traceback
import fan
import misc
try:
import oled
top_board = True
except Exception as ex:
traceback.print_exc()
top_board = False
q = queue.Queue()
lock = threading.Lock()
action = {
'none': lambda: 'nothing',
'slider': lambda: oled.slider(lock),
'switch': lambda: misc.fan_switch(),
'reboot': lambda: misc.check_call('reboot'),
'poweroff': lambda: misc.check_call('poweroff'),
}
def receive_key(q):
while True:
func = misc.get_func(q.get())
action[func]()
if __name__ == '__main__':
if top_board:
oled.welcome()
p0 = threading.Thread(target=receive_key, args=(q,), daemon=True)
p1 = threading.Thread(target=misc.watch_key, args=(q,), daemon=True)
p2 = threading.Thread(target=oled.auto_slider, args=(lock,), daemon=True)
p3 = threading.Thread(target=fan.running, daemon=True)
p0.start()
p1.start()
p2.start()
p3.start()
try:
p3.join()
except KeyboardInterrupt:
print("GoodBye ~")
oled.goodbye()
else:
p3 = threading.Thread(target=fan.running, daemon=False)
p3.start()