reformatting the default_app structure and worked on options menu.
This commit is contained in:
@@ -1,6 +1,4 @@
|
|||||||
import displayio
|
from macropad_os import AppRouter, DebugApp
|
||||||
|
|
||||||
from app import AppRouter, DebugApp
|
|
||||||
from config import Config
|
from config import Config
|
||||||
|
|
||||||
from adafruit_macropad import MacroPad
|
from adafruit_macropad import MacroPad
|
||||||
@@ -11,9 +9,7 @@ config = Config("config.json")
|
|||||||
|
|
||||||
ar = AppRouter(macropad, config, [
|
ar = AppRouter(macropad, config, [
|
||||||
DebugApp(macropad, config, "DEBUG 1"),
|
DebugApp(macropad, config, "DEBUG 1"),
|
||||||
DebugApp(macropad, config, "DEBUG 2"),
|
DebugApp(macropad, config, "DEBUG 2")
|
||||||
# DebugApp(macropad, config, "debug 2"),
|
|
||||||
# DebugApp(macropad, config, "debug 3")
|
|
||||||
])
|
])
|
||||||
|
|
||||||
ar.start()
|
ar.start()
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
from .abstract_app import App
|
from .abstract_app import App
|
||||||
from .app_state import AppState, InvalidStateUpdateError
|
from .app_state import AppState, InvalidStateUpdateError
|
||||||
from .app_router import AppRouter
|
from .app_router import AppRouter
|
||||||
from .debug_app import DebugApp
|
from macropad_os.default_apps.debug_app import DebugApp
|
||||||
from .options_app import OptionsApp
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
from .app_state import AppState
|
from .app_state import AppState
|
||||||
from .options_app import OptionsApp
|
from app.options.options_app import OptionsApp
|
||||||
|
|
||||||
|
|
||||||
class AppRouter(object):
|
class AppRouter(object):
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
from light_patterns import *
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
arrows_with_enter = [
|
||||||
|
(0, 0, 0), (0, 0, 0), (0, 0, 0),
|
||||||
|
(0, 0, 0), (0, 0, 100), (0, 0, 0),
|
||||||
|
(0, 0, 100), (100, 0, 0), (0, 0, 100),
|
||||||
|
(0, 0, 0), (0, 0, 100), (0, 0, 0)
|
||||||
|
]
|
||||||
|
|
||||||
|
up_down_enter = [
|
||||||
|
(0, 0, 0), (0, 0, 0), (0, 0, 0),
|
||||||
|
(0, 0, 0), (0, 0, 100), (0, 0, 0),
|
||||||
|
(0, 0, 0), (100, 0, 0), (0, 0, 0),
|
||||||
|
(0, 0, 0), (0, 0, 100), (0, 0, 0)
|
||||||
|
]
|
||||||
|
|
||||||
|
arrows_yes_no = [
|
||||||
|
(0, 0, 0), (0, 0, 0), (0, 0, 0),
|
||||||
|
(0, 0, 0), (0, 0, 100), (0, 0, 0),
|
||||||
|
(0, 0, 0), (100, 0, 0), (0, 0, 0),
|
||||||
|
(0, 100, 0), (0, 0, 100), (100, 0, 0)
|
||||||
|
]
|
||||||
@@ -3,7 +3,7 @@ from adafruit_display_text import bitmap_label as label
|
|||||||
from adafruit_displayio_layout.layouts.grid_layout import GridLayout
|
from adafruit_displayio_layout.layouts.grid_layout import GridLayout
|
||||||
from rainbowio import colorwheel
|
from rainbowio import colorwheel
|
||||||
|
|
||||||
from .abstract_app import App
|
from macropad_os.abstract_app import App
|
||||||
|
|
||||||
|
|
||||||
def rgb_from_int(rgb):
|
def rgb_from_int(rgb):
|
||||||
@@ -56,10 +56,8 @@ class DebugApp(App):
|
|||||||
|
|
||||||
def on_pause(self):
|
def on_pause(self):
|
||||||
print("Pausing")
|
print("Pausing")
|
||||||
|
|
||||||
self.display_group.remove(self.title)
|
self.display_group.remove(self.title)
|
||||||
self.display_group.remove(self.layout)
|
self.display_group.remove(self.layout)
|
||||||
# self.macropad.display.show(None)
|
|
||||||
|
|
||||||
|
|
||||||
def on_stop(self):
|
def on_stop(self):
|
||||||
@@ -68,6 +66,7 @@ class DebugApp(App):
|
|||||||
def loop(self):
|
def loop(self):
|
||||||
self.process_key_presses()
|
self.process_key_presses()
|
||||||
self.light_keys()
|
self.light_keys()
|
||||||
|
self.light_keys()
|
||||||
|
|
||||||
def process_key_presses(self):
|
def process_key_presses(self):
|
||||||
key_event = self.macropad.keys.events.get()
|
key_event = self.macropad.keys.events.get()
|
||||||
@@ -1,22 +1,19 @@
|
|||||||
import terminalio
|
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 rainbowio import colorwheel
|
|
||||||
|
|
||||||
from .abstract_app import App
|
from common.light_patterns import arrows_yes_no
|
||||||
from .debug_app import rgb_from_int
|
from ..abstract_app import App
|
||||||
|
|
||||||
|
|
||||||
class OptionsApp(App):
|
class OptionsApp(App):
|
||||||
|
|
||||||
def __init__(self, macropad, config):
|
def __init__(self, macropad, config):
|
||||||
super().__init__(macropad, config)
|
super().__init__(macropad, config)
|
||||||
self.tones = [196, 220, 246, 262, 294, 330, 349, 392, 440, 494, 523, 587]
|
|
||||||
self.wheel_offset = 0
|
|
||||||
self.send_keyboard_inputs = 0
|
self.send_keyboard_inputs = 0
|
||||||
self.lit_keys = [False] * 12
|
|
||||||
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.title = label.Label(
|
self.title = label.Label(
|
||||||
y=4,
|
y=4,
|
||||||
font=terminalio.FONT,
|
font=terminalio.FONT,
|
||||||
@@ -58,21 +55,13 @@ class OptionsApp(App):
|
|||||||
key_event = self.macropad.keys.events.get()
|
key_event = self.macropad.keys.events.get()
|
||||||
if key_event:
|
if key_event:
|
||||||
if key_event.key_number < 12:
|
if key_event.key_number < 12:
|
||||||
if key_event.pressed :
|
if key_event.pressed:
|
||||||
self.labels[key_event.key_number].text = "KEY{}".format(key_event.key_number)
|
|
||||||
print(self.macropad.keys)
|
|
||||||
self.lit_keys[key_event.key_number] = not self.lit_keys[key_event.key_number]
|
|
||||||
self.macropad.stop_tone()
|
self.macropad.stop_tone()
|
||||||
self.macropad.start_tone(self.tones[key_event.key_number])
|
self.macropad.start_tone(200)
|
||||||
else:
|
else:
|
||||||
self.labels[key_event.key_number].text = ""
|
|
||||||
self.macropad.stop_tone()
|
self.macropad.stop_tone()
|
||||||
|
|
||||||
def light_keys(self):
|
def light_keys(self):
|
||||||
self.wheel_offset += 1
|
for pixel in range(12):
|
||||||
for pixel in range(4):
|
print(pixel)
|
||||||
if self.lit_keys[pixel]:
|
self.macropad.pixels[pixel] = self.key_colors[pixel]
|
||||||
(r, g, b) = rgb_from_int(colorwheel((pixel / 4 * 256) + self.wheel_offset))
|
|
||||||
self.macropad.pixels[pixel] = (r * .1, g * .1, b * .1)
|
|
||||||
else:
|
|
||||||
self.macropad.pixels[pixel] = 0
|
|
||||||
Reference in New Issue
Block a user