Updated entry point
This commit is contained in:
@@ -111,7 +111,7 @@ def create_char(location, pattern):
|
|||||||
|
|
||||||
# example code
|
# example code
|
||||||
if __name__=="__main__":
|
if __name__=="__main__":
|
||||||
setText("Hello world\nThis is an LCD chesscog-bck")
|
setText("Hello world\nThis is an LCD")
|
||||||
setRGB(0,128,64)
|
setRGB(0,128,64)
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
for c in range(0,255):
|
for c in range(0,255):
|
||||||
20
rpi/hardware/screen/screen.py
Normal file
20
rpi/hardware/screen/screen.py
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
from grove_rgb_lcd import *
|
||||||
|
import led
|
||||||
|
import sys
|
||||||
|
import select
|
||||||
|
|
||||||
|
class Screen:
|
||||||
|
def __init__(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def enableBackground(self):
|
||||||
|
setRGB(255,255,255)
|
||||||
|
|
||||||
|
def displayMessage(self, message : str):
|
||||||
|
setText(message)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
pass
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
|
|
||||||
from grove_rgb_lcd import *
|
|
||||||
import led
|
|
||||||
import sys
|
|
||||||
import select
|
|
||||||
|
|
||||||
whiteTime = 5 * 60
|
|
||||||
blackTime = 5 * 60
|
|
||||||
current = "white"
|
|
||||||
|
|
||||||
def compute_seconds(total_seconds):
|
|
||||||
return total_seconds % 60
|
|
||||||
|
|
||||||
def compute_minutes(total_seconds):
|
|
||||||
return total_seconds // 60
|
|
||||||
|
|
||||||
def update_timer(white_total_time, black_total_time):
|
|
||||||
white_minutes = compute_minutes(white_total_time)
|
|
||||||
white_seconds = compute_seconds(white_total_time)
|
|
||||||
|
|
||||||
black_minutes = compute_minutes(black_total_time)
|
|
||||||
black_seconds = compute_seconds(black_total_time)
|
|
||||||
|
|
||||||
setText(f"W {white_minutes:02d}:{white_seconds:02d}\nB {black_minutes:02d}:{black_seconds:02d}")
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
led.off()
|
|
||||||
led.on()
|
|
||||||
setRGB(255, 255, 255)
|
|
||||||
while whiteTime > 0 and blackTime > 0:
|
|
||||||
currentTime = 0
|
|
||||||
if current == "white":
|
|
||||||
whiteTime -= 1
|
|
||||||
else:
|
|
||||||
blackTime -= 1
|
|
||||||
|
|
||||||
update_timer(whiteTime, blackTime)
|
|
||||||
|
|
||||||
# wait up to 1 second for Enter
|
|
||||||
rlist, _, _ = select.select([sys.stdin], [], [], 1)
|
|
||||||
|
|
||||||
if rlist:
|
|
||||||
sys.stdin.readline() # consume Enter
|
|
||||||
current = "black" if current == "white" else "white"
|
|
||||||
|
|
||||||
led.off()
|
|
||||||
27
rpi/main.py
27
rpi/main.py
@@ -1,14 +1,21 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
from board_mate_client import ApiClient, Configuration
|
from hardware.screen.screen import Screen
|
||||||
from controllers.board_mate_controller import ApiController
|
from hardware.rfid.reader import RfidReader
|
||||||
from models.clock import Clock
|
from services.mqtt_service import MQTTService
|
||||||
from scripts.timer.grove_rgb_lcd import setRGB, setText
|
|
||||||
import threading
|
|
||||||
import queue
|
|
||||||
import time
|
|
||||||
|
|
||||||
|
def publish(uid : int) :
|
||||||
|
screen = Screen()
|
||||||
|
screen.displayMessage(str(uid))
|
||||||
|
service.publish("app", "game/start", str(uid), 0)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
service = MQTTService("127.0.0.1", 1883)
|
||||||
|
reader = RfidReader("/dev/serial0", 9600)
|
||||||
|
reader.subscribe(publish)
|
||||||
|
reader.start()
|
||||||
|
|
||||||
|
"""
|
||||||
def get_move(prompt, move_queue):
|
def get_move(prompt, move_queue):
|
||||||
while True:
|
while True:
|
||||||
move = input(prompt)
|
move = input(prompt)
|
||||||
@@ -16,9 +23,7 @@ def get_move(prompt, move_queue):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
config = Configuration(
|
config = Configuration(host="http://192.168.15.120:8000")
|
||||||
host="http://192.168.15.120:8000"
|
|
||||||
)
|
|
||||||
setRGB(255, 255, 255)
|
setRGB(255, 255, 255)
|
||||||
controller = ApiController(config)
|
controller = ApiController(config)
|
||||||
|
|
||||||
@@ -64,4 +69,4 @@ if __name__ == "__main__":
|
|||||||
except queue.Empty:
|
except queue.Empty:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
time.sleep(1)
|
time.sleep(1)"""
|
||||||
|
|||||||
Reference in New Issue
Block a user