Implemented state for beans..

Including setting based on received messages.
This commit is contained in:
CiscoTheWolf 2023-05-31 18:56:15 +02:00
parent 4c2dda2211
commit bb23a24fa4
2 changed files with 26 additions and 3 deletions

View file

@ -15,6 +15,7 @@ class ProotState:
cls._instance.frame_canvas_prootScreen_2 = False
cls._instance.frame_canvas_prootScreen_3 = False
cls._instance.matrix = False
cls._instance.bean_states = [False] * 4
return cls._instance
def set_matrix(self, matrix):
@ -78,6 +79,27 @@ class ProotState:
matrix.SwapOnVSync(self.frame_canvas_prootScreen_2)
else:
matrix.SwapOnVSync(self.frame_canvas_prootScreen_3)
def set_bean(self, bean_number, bean_state):
self.bean_states[bean_number] = bean_state
class BeanSet:
def __init__(self, num_beans):
self.num_beans = num_beans
self.bean_states = [False] * num_beans # Initialize all beans as closed
def set_bean_state(self, index, state):
if 0 <= index < self.num_beans:
self.bean_states[index] = state
else:
print("Invalid bean index.")
def get_bean_state(self, index):
if 0 <= index < self.num_beans:
return self.bean_states[index]
else:
print("Invalid bean index.")
def update_screen(self, blinkFrameCanvases, matrix):