Skip to content

Commit

Permalink
removed some unnecessary things
Browse files Browse the repository at this point in the history
  • Loading branch information
mchilli committed Nov 8, 2024
1 parent 16a299a commit ffbb406
Showing 1 changed file with 13 additions and 23 deletions.
36 changes: 13 additions & 23 deletions circuitpython/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def _init_group_label(self) -> None:
padding_bottom=0,
padding_left=0,
padding_right=0,
color=0xFFFFFF,
color=0xffffff,
anchored_position=(
self.macropad.display.width // 2,
self.macropad.display.height - 10),
Expand All @@ -196,7 +196,7 @@ def _init_keys(self) -> None:
padding_bottom=1,
padding_left=4,
padding_right=4,
color=0xFFFFFF,
color=0xffffff,
anchored_position=(
(self.macropad.display.width - 2) / 2 * (i % 3) + 1,
self.macropad.display.height / 5 * (i // 3) + 2),
Expand Down Expand Up @@ -320,6 +320,11 @@ def go_to_root(self, *args) -> None:
def _update_tab(self) -> None:
""" update the current displayed group tab
"""
key_funcs = {
"macro": self.run_macro,
"group": self.open_group
}

for key in self.keys:
key.clear_props()

Expand All @@ -329,33 +334,18 @@ def _update_tab(self) -> None:
if key_id:
macro_data = json.loads(self.macro_store[str(key_id)])
key_type = macro_data["type"]

self.keys[i].type = key_type
self.keys[i].label = "" if key_type == "blank" else macro_data["label"]
self.keys[i].color = (0, 0, 0) if key_type == "blank" else macro_data["color"]
self.keys[i].set_func(self._get_key_func(key_type), (str(key_id), macro_data["content"]))

key = self.keys[i]
key.type = key_type
key.label = macro_data["label"]
key.color = macro_data["color"]
key.set_func(key_funcs.get(key_type), (str(key_id), macro_data["content"]))

self.group_label.text = group["label"]

for key in self.keys:
key.update_colors()

def _get_key_func(self, type: str) -> function:
""" get the specific function for the type
Args:
type (str): the item type
Returns:
function: return the function for type
"""
key_funcs = {
"blank": None,
"group": self.open_group
}

return key_funcs.get(type, self.run_macro)

def _update_encoder_macros(self) -> None:
""" update the rotary encoder macros defined for opened group
"""
Expand Down

0 comments on commit ffbb406

Please sign in to comment.