1
0
forked from MDL29/JacoBot

Send instructions from JacoPad via Redis MDL29/JacoBot#18

This commit is contained in:
Romain 2024-04-20 15:40:41 +02:00
parent fa390c8530
commit e52488249f
2 changed files with 15 additions and 5 deletions

View File

@ -1,7 +1,13 @@
import arcade
import os.path
import redis
SCREEN_MULTILPLIER = 2
# Redis setting
host = "localhost"
channel = "jacobot-instructions"
SCREEN_MULTILPLIER = 1.5
SCREEN_MULTILPLIER /= 4
# Screen title and size
@ -104,6 +110,10 @@ class Cubito(arcade.Window):
# Set background color
arcade.set_background_color(BACKGROUND_COLOR)
# Connection to Redis
self.r = redis.Redis(host=host)
# List of tokens
self.token_list = None
@ -283,7 +293,6 @@ class Cubito(arcade.Window):
"""Called when the user presses key"""
if symbol == arcade.key.R:
self.setup()
cubito.reset()
print("Restart !")
if symbol == arcade.key.Q:
@ -306,11 +315,11 @@ class Cubito(arcade.Window):
if arcade.check_for_collision(token, mat):
token_type = str(token.token_type)
if token_type == "up":
cubito.fordward()
self.r.publish(channel, "FORWARD")
if token_type == "left":
cubito.left()
self.r.publish(channel, "LEFT")
if token_type == "right":
cubito.right()
self.r.publish(channel, "RIGHT")
if token_type == "function":
if function:
return

View File

@ -8,6 +8,7 @@ readme = "README.md"
[tool.poetry.dependencies]
python = "^3.11"
arcade = "^2.6.17"
redis = "^5.0.3"
[build-system]