feat: Adding support for json apps. Updated Macropad_os.py to automatically load in the python and json apps at launch.
This commit is contained in:
@@ -1,54 +0,0 @@
|
||||
{
|
||||
"profileName" : "",
|
||||
"sortOrder" : 99,
|
||||
|
||||
"key1" : {
|
||||
"text" : [""],
|
||||
"value" : [""]
|
||||
},
|
||||
"key2" : {
|
||||
"text" : [""],
|
||||
"value" : [""]
|
||||
},
|
||||
"key3" : {
|
||||
"text" : [""],
|
||||
"value" : [""]
|
||||
},
|
||||
"key4" : {
|
||||
"text" : [""],
|
||||
"value" : [""]
|
||||
},
|
||||
"key5" : {
|
||||
"text" : [""],
|
||||
"value" : [""]
|
||||
},
|
||||
"key6" : {
|
||||
"text" : [""],
|
||||
"value" : [""]
|
||||
},
|
||||
"key7" : {
|
||||
"text" : [""],
|
||||
"value" : [""]
|
||||
},
|
||||
"key8" : {
|
||||
"text" : [""],
|
||||
"value" : [""]
|
||||
},
|
||||
"key9" : {
|
||||
"text" : [""],
|
||||
"value" : [""]
|
||||
},
|
||||
"key10" : {
|
||||
"text" : [""],
|
||||
"value" : [""]
|
||||
},
|
||||
"key11" : {
|
||||
"text" : [""],
|
||||
"value" : [""]
|
||||
},
|
||||
"key12" : {
|
||||
"text" : [""],
|
||||
"value" : [""]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,54 +1,53 @@
|
||||
{
|
||||
"profileName" : "Gamepad",
|
||||
"profileName" : "Gamepad Json",
|
||||
"sortOrder" : 1,
|
||||
|
||||
"key1" : {
|
||||
"text" : ["ESC"],
|
||||
"value" : ["ESCAPE"]
|
||||
"text" : "ESC",
|
||||
"values" : ["ESCAPE"]
|
||||
},
|
||||
"key2" : {
|
||||
"text" : ["Tab"],
|
||||
"value" : ["TAB"]
|
||||
"text" : "Tab",
|
||||
"values" : ["TAB"]
|
||||
},
|
||||
"key3" : {
|
||||
"text" : ["R"],
|
||||
"value" : ["R"]
|
||||
"text" : "R",
|
||||
"values" : ["R"]
|
||||
},
|
||||
"key4" : {
|
||||
"text" : ["Q"],
|
||||
"value" : ["Q"]
|
||||
"text" : "Q",
|
||||
"values" : ["Q"]
|
||||
},
|
||||
"key5" : {
|
||||
"text" : ["W"],
|
||||
"value" : ["W"]
|
||||
"text" : "W",
|
||||
"values" : ["W"]
|
||||
},
|
||||
"key6" : {
|
||||
"text" : ["E"],
|
||||
"value" : ["E"]
|
||||
"text" : "E",
|
||||
"values" : ["E"]
|
||||
},
|
||||
"key7" : {
|
||||
"text" : ["A"],
|
||||
"value" : ["A"]
|
||||
"text" : "A",
|
||||
"values" : ["A"]
|
||||
},
|
||||
"key8" : {
|
||||
"text" : ["S"],
|
||||
"value" : ["S"]
|
||||
"text" : "S",
|
||||
"values" : ["S"]
|
||||
},
|
||||
"key9" : {
|
||||
"text" : ["D"],
|
||||
"value" : ["D"]
|
||||
"text" : "D",
|
||||
"values" : ["D"]
|
||||
},
|
||||
"key10" : {
|
||||
"text" : ["Shift"],
|
||||
"value" : [""]
|
||||
"text" : "Shift",
|
||||
"values" : ["SHIFT"]
|
||||
},
|
||||
"key11" : {
|
||||
"text" : ["C"],
|
||||
"value" : ["C"]
|
||||
"text" : "C",
|
||||
"values" : ["C"]
|
||||
},
|
||||
"key12" : {
|
||||
"text" : ["Space"],
|
||||
"value" : ["SPACEBAR"]
|
||||
"text" : "Space",
|
||||
"values" : ["SPACEBAR"]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,53 +1,52 @@
|
||||
{
|
||||
"profileName" : "NumPad",
|
||||
"profileName" : "Numpad Json",
|
||||
"sortOrder" : 0,
|
||||
|
||||
"key1" : {
|
||||
"text" : ["7"],
|
||||
"value" : ["SEVEN"]
|
||||
"text" : "7",
|
||||
"values" : ["SEVEN"]
|
||||
},
|
||||
"key2" : {
|
||||
"text" : ["8"],
|
||||
"value" : ["EIGHT"]
|
||||
"text" : "8",
|
||||
"values" : ["EIGHT"]
|
||||
},
|
||||
"key3" : {
|
||||
"text" : ["9"],
|
||||
"value" : ["NINE"]
|
||||
"text" : "9",
|
||||
"values" : ["NINE"]
|
||||
},
|
||||
"key4" : {
|
||||
"text" : ["4"],
|
||||
"value" : ["FOUR"]
|
||||
"text" : "4",
|
||||
"values" : ["FOUR"]
|
||||
},
|
||||
"key5" : {
|
||||
"text" : ["5"],
|
||||
"value" : ["FIVE"]
|
||||
"text" : "5",
|
||||
"values" : ["FIVE"]
|
||||
},
|
||||
"key6" : {
|
||||
"text" : ["6"],
|
||||
"value" : ["SIX"]
|
||||
"text" : "6",
|
||||
"values" : ["SIX"]
|
||||
},
|
||||
"key7" : {
|
||||
"text" : ["1"],
|
||||
"value" : ["ONE"]
|
||||
"text" : "1",
|
||||
"values" : ["ONE"]
|
||||
},
|
||||
"key8" : {
|
||||
"text" : ["2"],
|
||||
"value" : ["TWO"]
|
||||
"text" : "2",
|
||||
"values" : ["TWO"]
|
||||
},
|
||||
"key9" : {
|
||||
"text" : ["3"],
|
||||
"value" : ["THREE"]
|
||||
"text" : "3",
|
||||
"values" : ["THREE"]
|
||||
},
|
||||
"key10" : {
|
||||
"text" : ["0"],
|
||||
"value" : ["ZERO"]
|
||||
"text" : "0",
|
||||
"values" : ["ZERO"]
|
||||
},
|
||||
"key11" : {
|
||||
"text" : ["."],
|
||||
"value" : ["PERIOD"]
|
||||
"text" : ".",
|
||||
"values" : ["PERIOD"]
|
||||
},
|
||||
"key12" : {
|
||||
"text" : ["ENT"],
|
||||
"value" : ["RETURN"]
|
||||
"text" : "ENT",
|
||||
"values" : ["RETURN"]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
{
|
||||
"profileName" : "",
|
||||
"sortOrder" : 99,
|
||||
|
||||
"key1" : {
|
||||
"text" : "",
|
||||
"values" : [""]
|
||||
},
|
||||
"key2" : {
|
||||
"text" : "",
|
||||
"values" : [""]
|
||||
},
|
||||
"key3" : {
|
||||
"text" : "",
|
||||
"values" : [""]
|
||||
},
|
||||
"key4" : {
|
||||
"text" : "",
|
||||
"values" : [""]
|
||||
},
|
||||
"key5" : {
|
||||
"text" : "",
|
||||
"values" : [""]
|
||||
},
|
||||
"key6" : {
|
||||
"text" : "",
|
||||
"values" : [""]
|
||||
},
|
||||
"key7" : {
|
||||
"text" : "",
|
||||
"values" : [""]
|
||||
},
|
||||
"key8" : {
|
||||
"text" : "",
|
||||
"values" : [""]
|
||||
},
|
||||
"key9" : {
|
||||
"text" : "",
|
||||
"values" : [""]
|
||||
},
|
||||
"key10" : {
|
||||
"text" : "",
|
||||
"values" : [""]
|
||||
},
|
||||
"key11" : {
|
||||
"text" : "",
|
||||
"values" : [""]
|
||||
},
|
||||
"key12" : {
|
||||
"text" : "",
|
||||
"values" : [""]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,14 +16,12 @@ COLOR_UPDATE_RATE = 33000000 # .033 seconds
|
||||
class NumpadApp(App):
|
||||
def __init__(self, macropad, config):
|
||||
super().__init__(macropad, config)
|
||||
self.name = "Numpad"
|
||||
self.name = "NumpadApp"
|
||||
self.wheel_offset = 0
|
||||
self.lit_keys = [False] * 12
|
||||
self.labels = []
|
||||
self.title = "Numpad"
|
||||
self.modifier_pressed = False
|
||||
self.last_color_update = 0
|
||||
self.modifier_pressed = False
|
||||
self.macros = MacroSet(
|
||||
[
|
||||
Macro("7", Keycode.SEVEN), Macro("8", Keycode.EIGHT), Macro("9", Keycode.NINE),
|
||||
@@ -36,7 +34,7 @@ class NumpadApp(App):
|
||||
encoder_down=Macro("-", Keycode.KEYPAD_MINUS),
|
||||
)
|
||||
self.mod_macros = MacroSet([
|
||||
Macro("<", Keycode.SHIFT, Keycode.COMMA), Macro(">", Keycode.SHIFT, Keycode.PERIOD), Macro("&", Keycode.SHIFT, Keycode.SEVEN),
|
||||
Macro("<", Keycode.SHIFT, Keycode.COMMA), Macro(">", Keycode.SHIFT, Keycode.PERIOD), Macro("BACKSP", Keycode.BACKSPACE),
|
||||
|
||||
Macro("(", Keycode.SHIFT, Keycode.NINE), Macro(")", Keycode.SHIFT, Keycode.ZERO),Macro("%", Keycode.SHIFT, Keycode.FIVE),
|
||||
|
||||
@@ -62,7 +60,6 @@ class NumpadApp(App):
|
||||
print("on start from the app!")
|
||||
self.set_layout(GridLayout(x=0, y=9, width=128, height=54, grid_size=(3, 4), cell_padding=1))
|
||||
self.set_title(self.title)
|
||||
self.lit_keys = [True] * 12
|
||||
for i in range(12):
|
||||
self.labels.append(Label(terminalio.FONT, text=self.active_macros.get_macro_from_key(i).name))
|
||||
for index in range(12):
|
||||
@@ -93,11 +90,8 @@ class NumpadApp(App):
|
||||
if last_update_ago > COLOR_UPDATE_RATE:
|
||||
self.last_color_update = monotonic_ns()
|
||||
for pixel in range(12):
|
||||
if self.lit_keys[pixel]:
|
||||
(r, g, b) = rgb_from_int(colorwheel((pixel / 12 * 256) + self.wheel_offset))
|
||||
colors.append((r, g, b))
|
||||
else:
|
||||
colors.append((0, 0, 0))
|
||||
(r, g, b) = rgb_from_int(colorwheel((pixel / 12 * 256) + self.wheel_offset))
|
||||
colors.append((r, g, b))
|
||||
self.set_colors(colors)
|
||||
|
||||
def process_keys_pressed_callback(self, key_event):
|
||||
|
||||
Reference in New Issue
Block a user