updates to options and debug apps allowing them to run side by side.

This commit is contained in:
Lucas
2022-04-27 10:53:44 -04:00
parent 5486f8a9e7
commit 43104ac2d2
4 changed files with 15 additions and 14 deletions
+6 -4
View File
@@ -14,10 +14,15 @@ class AppRouter(object):
self.current_app = apps[self.app_index]
self.config = config
self.encoder_state = False
self.options_time = 1000000000 # .5 seconds in nanoseconds
self.options_time = 500000000 # .5 seconds in nanoseconds
self.click_time = 0
def swap_to_app(self, app):
"""
TODO: Calculate the size of the stack and the max size of hte stack and then fully close apps if need be.
:param app:
:return:
"""
print("Pausing current app")
self.current_app.pause()
print("Selecting new app")
@@ -55,9 +60,6 @@ class AppRouter(object):
print("released encoder")
if self.encoder_state and self.click_time:
self.release_time = time.monotonic_ns()
print(self.release_time)
print(self.click_time)
print(self.release_time - self.click_time)
if (time.monotonic_ns() - self.click_time) > self.options_time:
self.macropad.play_tone(1000, .1)
self.swap_to_app(self.options)
+1 -1
View File
@@ -40,7 +40,7 @@ class DebugApp(App):
self.labels.append(label.Label(terminalio.FONT, text=""))
for index in range(12):
x = index % 3 + 1
x = index % 3
y = index // 3
self.layout.add_content(self.labels[index], grid_position=(x, y), cell_size=(1, 1))
+5 -8
View File
@@ -16,7 +16,7 @@ class OptionsApp(App):
self.send_keyboard_inputs = 0
self.lit_keys = [False] * 12
self.labels = []
self.layout = GridLayout(x=0, y=9, width=128, height=54, grid_size=(4, 1), cell_padding=1)
self.layout = GridLayout(x=0, y=9, width=128, height=54, grid_size=(4, 4), cell_padding=1)
self.title = label.Label(
y=4,
font=terminalio.FONT,
@@ -28,22 +28,19 @@ class OptionsApp(App):
def on_start(self):
print("on start from the app!")
self.lit_keys = [False] * 4
# self.macropad.display.show(self.display_group)
for _ in range(4):
self.labels.append(label.Label(terminalio.FONT, text=""))
for index in range(4):
x = index % 3 + 1
y = index // 3
self.layout.add_content(self.labels[index], grid_position=(x, y), cell_size=(1, 1))
x = 0
y = index
self.layout.add_content(self.labels[index], grid_position=(x, y), cell_size=(3, 1))
def on_resume(self):
print("resume from the options app!")
self.display_group.append(self.title)
self.display_group.append(self.layout)
self.macropad.display.show(self.display_group)
print(self.display_group)
print(id(self.display_group))
def on_pause(self):
print("Pausing")
@@ -60,7 +57,7 @@ class OptionsApp(App):
def process_key_presses(self):
key_event = self.macropad.keys.events.get()
if key_event:
if key_event.key_number < 4:
if key_event.key_number < 12:
if key_event.pressed :
self.labels[key_event.key_number].text = "KEY{}".format(key_event.key_number)
print(self.macropad.keys)