Added functionality to swap the key patterns to test them out - need to work on adding sound and navigational patterns to the app next.
Need to answer next - should the app framework handle interactions with the keyboard lighting and sound?
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
from .app_state import AppState
|
from .app_state import AppState
|
||||||
from app.options.options_app import OptionsApp
|
from .default_apps.options_app import OptionsApp
|
||||||
|
|
||||||
|
|
||||||
class AppRouter(object):
|
class AppRouter(object):
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
from light_patterns import *
|
from .light_patterns import *
|
||||||
|
from .sound_patterns import *
|
||||||
@@ -2,7 +2,7 @@ import terminalio
|
|||||||
from adafruit_display_text import label
|
from adafruit_display_text import label
|
||||||
from adafruit_displayio_layout.layouts.grid_layout import GridLayout
|
from adafruit_displayio_layout.layouts.grid_layout import GridLayout
|
||||||
|
|
||||||
from common.light_patterns import arrows_yes_no
|
from .common import arrows_yes_no, arrows_with_enter, up_down_enter
|
||||||
from ..abstract_app import App
|
from ..abstract_app import App
|
||||||
|
|
||||||
|
|
||||||
@@ -14,6 +14,7 @@ class OptionsApp(App):
|
|||||||
self.labels = []
|
self.labels = []
|
||||||
self.layout = GridLayout(x=0, y=9, width=128, height=54, grid_size=(4, 4), cell_padding=1)
|
self.layout = GridLayout(x=0, y=9, width=128, height=54, grid_size=(4, 4), cell_padding=1)
|
||||||
self.key_colors = arrows_yes_no
|
self.key_colors = arrows_yes_no
|
||||||
|
self.possible_key_colors = [arrows_yes_no, arrows_with_enter, up_down_enter]
|
||||||
self.title = label.Label(
|
self.title = label.Label(
|
||||||
y=4,
|
y=4,
|
||||||
font=terminalio.FONT,
|
font=terminalio.FONT,
|
||||||
@@ -21,6 +22,7 @@ class OptionsApp(App):
|
|||||||
text=f" OPTIONS MENU ",
|
text=f" OPTIONS MENU ",
|
||||||
background_color=0xFFFFFF,
|
background_color=0xFFFFFF,
|
||||||
)
|
)
|
||||||
|
self.counter = 0
|
||||||
|
|
||||||
def on_start(self):
|
def on_start(self):
|
||||||
print("on start from the app!")
|
print("on start from the app!")
|
||||||
@@ -50,6 +52,8 @@ class OptionsApp(App):
|
|||||||
def loop(self):
|
def loop(self):
|
||||||
self.process_key_presses()
|
self.process_key_presses()
|
||||||
self.light_keys()
|
self.light_keys()
|
||||||
|
self.key_colors = self.possible_key_colors[self.counter % len(self.possible_key_colors)]
|
||||||
|
self.counter+=1
|
||||||
|
|
||||||
def process_key_presses(self):
|
def process_key_presses(self):
|
||||||
key_event = self.macropad.keys.events.get()
|
key_event = self.macropad.keys.events.get()
|
||||||
@@ -57,11 +61,10 @@ class OptionsApp(App):
|
|||||||
if key_event.key_number < 12:
|
if key_event.key_number < 12:
|
||||||
if key_event.pressed:
|
if key_event.pressed:
|
||||||
self.macropad.stop_tone()
|
self.macropad.stop_tone()
|
||||||
self.macropad.start_tone(200)
|
self.macropad.start_tone(440)
|
||||||
else:
|
else:
|
||||||
self.macropad.stop_tone()
|
self.macropad.stop_tone()
|
||||||
|
|
||||||
def light_keys(self):
|
def light_keys(self):
|
||||||
for pixel in range(12):
|
for pixel in range(12):
|
||||||
print(pixel)
|
|
||||||
self.macropad.pixels[pixel] = self.key_colors[pixel]
|
self.macropad.pixels[pixel] = self.key_colors[pixel]
|
||||||
|
|||||||
Reference in New Issue
Block a user