Make a tap on the page number key go to page 1 outright.
The converted key's "startup" page resolves to the current page on surfaces set to "use last page", so a tap did nothing. The tap page is now nav_tap_page in config.json (1). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -47,7 +47,7 @@ Row 0 holds the group buttons. Each one shows the first problem in its group, pl
|
|||||||
|
|
||||||
The **page number key** on every page follows the ALL button. It's green when everything is fine, flashes red when something is wrong, and turns purple if the watchdog stops. UP and DOWN stay normal. Which keys follow ALL is `"nav_keys"` in `config.json` (`["pagenum"]`; add `"pageup"` / `"pagedown"` to colour those too). The coloured key is Companion's own key converted to a regular button (`nav_templates.json`).
|
The **page number key** on every page follows the ALL button. It's green when everything is fine, flashes red when something is wrong, and turns purple if the watchdog stops. UP and DOWN stay normal. Which keys follow ALL is `"nav_keys"` in `config.json` (`["pagenum"]`; add `"pageup"` / `"pagedown"` to colour those too). The coloured key is Companion's own key converted to a regular button (`nav_templates.json`).
|
||||||
|
|
||||||
- **Tap the page number:** go to the start page (page 1), as before. It now acts when you let go, not when you press.
|
- **Tap the page number:** go to page 1 (`"nav_tap_page"` in `config.json`). It acts when you let go, not when you press.
|
||||||
- **Hold the page number for 1 second:** jump to the status page (page 19). The hold time is `"nav_hold_ms"` in `config.json`.
|
- **Hold the page number for 1 second:** jump to the status page (page 19). The hold time is `"nav_hold_ms"` in `config.json`.
|
||||||
|
|
||||||
- `python3 nav_keys.py` applies them to every page. Run it again after adding pages.
|
- `python3 nav_keys.py` applies them to every page. Run it again after adding pages.
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
"page_name": "19\\nStatus",
|
"page_name": "19\\nStatus",
|
||||||
"nav_keys": ["pagenum"],
|
"nav_keys": ["pagenum"],
|
||||||
"nav_hold_ms": 1000,
|
"nav_hold_ms": 1000,
|
||||||
|
"nav_tap_page": 1,
|
||||||
"variables": { "state": "sp_state", "heartbeat": "sp_hb", "command": "sp_cmd" },
|
"variables": { "state": "sp_state", "heartbeat": "sp_hb", "command": "sp_cmd" },
|
||||||
|
|
||||||
"service_windows": [
|
"service_windows": [
|
||||||
|
|||||||
+8
-5
@@ -136,12 +136,13 @@ NAV_LOCATIONS = {"pageup": ("0", "0"), "pagenum": ("1", "0"), "pagedown": ("2",
|
|||||||
NAV_MARKER = "STATUS nav key"
|
NAV_MARKER = "STATUS nav key"
|
||||||
|
|
||||||
|
|
||||||
def nav_key(kind, names, status_page=None, hold_ms=1000):
|
def nav_key(kind, names, status_page=None, hold_ms=1000, tap_page=1):
|
||||||
"""Companion's own UP / page number / DOWN key, coloured like the ALL button.
|
"""Companion's own UP / page number / DOWN key, coloured like the ALL button.
|
||||||
|
|
||||||
For the page number key, status_page adds: tap = Companion's usual "go to the
|
For the page number key, status_page adds: tap = go to tap_page (on release,
|
||||||
start page" (moved to release, so a hold does not flash through it first),
|
so a hold does not flash through it first), hold for hold_ms = go to the
|
||||||
hold for hold_ms = go to the status page.
|
status page. The tap names the page outright: the converted key's "startup"
|
||||||
|
means the current page on surfaces set to "use last page".
|
||||||
"""
|
"""
|
||||||
templates = json.load(open(os.path.join(HERE, "nav_templates.json")))
|
templates = json.load(open(os.path.join(HERE, "nav_templates.json")))
|
||||||
key = json.loads(json.dumps(templates[kind]))
|
key = json.loads(json.dumps(templates[kind]))
|
||||||
@@ -163,6 +164,7 @@ def nav_key(kind, names, status_page=None, hold_ms=1000):
|
|||||||
if kind == "pagenum" and status_page:
|
if kind == "pagenum" and status_page:
|
||||||
step = key["steps"]["0"]
|
step = key["steps"]["0"]
|
||||||
tap = step["action_sets"]["down"]
|
tap = step["action_sets"]["down"]
|
||||||
|
tap[0]["options"]["page"] = prop(tap_page)
|
||||||
hold = [{"type": "action", "id": stable_id("nav", "hold"), "definitionId": "set_page",
|
hold = [{"type": "action", "id": stable_id("nav", "hold"), "definitionId": "set_page",
|
||||||
"connectionId": "internal",
|
"connectionId": "internal",
|
||||||
"options": {"surfaceId": prop("self"), "page": prop(status_page)}, "children": {}}]
|
"options": {"surfaceId": prop("self"), "page": prop(status_page)}, "children": {}}]
|
||||||
@@ -177,7 +179,8 @@ def build(cfg):
|
|||||||
controls = {}
|
controls = {}
|
||||||
coloured = cfg.get("nav_keys", list(NAV_LOCATIONS)) # which nav keys follow the ALL button
|
coloured = cfg.get("nav_keys", list(NAV_LOCATIONS)) # which nav keys follow the ALL button
|
||||||
for kind, (r, c) in NAV_LOCATIONS.items():
|
for kind, (r, c) in NAV_LOCATIONS.items():
|
||||||
controls.setdefault(r, {})[c] = (nav_key(kind, cfg["variables"], cfg["page"], cfg.get("nav_hold_ms", 1000))
|
controls.setdefault(r, {})[c] = (nav_key(kind, cfg["variables"], cfg["page"], cfg.get("nav_hold_ms", 1000),
|
||||||
|
cfg.get("nav_tap_page", 1))
|
||||||
if kind in coloured else {"type": kind})
|
if kind in coloured else {"type": kind})
|
||||||
for tile in cfg["tiles"]:
|
for tile in cfg["tiles"]:
|
||||||
if "pos" not in tile:
|
if "pos" not in tile:
|
||||||
|
|||||||
Binary file not shown.
@@ -564,7 +564,7 @@ class TestPage(unittest.TestCase):
|
|||||||
step = key["steps"]["0"]
|
step = key["steps"]["0"]
|
||||||
self.assertEqual(step["action_sets"]["down"], [])
|
self.assertEqual(step["action_sets"]["down"], [])
|
||||||
tap, hold = step["action_sets"]["up"][0], step["action_sets"]["1000"][0]
|
tap, hold = step["action_sets"]["up"][0], step["action_sets"]["1000"][0]
|
||||||
self.assertEqual((tap["definitionId"], tap["options"]["page"]["value"]), (action, "startup"))
|
self.assertEqual((tap["definitionId"], tap["options"]["page"]["value"]), (action, 1)) # page 1 outright, not "startup"
|
||||||
self.assertEqual((hold["definitionId"], hold["options"]["page"]["value"]), ("set_page", 19))
|
self.assertEqual((hold["definitionId"], hold["options"]["page"]["value"]), ("set_page", 19))
|
||||||
self.assertEqual(step["options"]["runWhileHeld"], [1000])
|
self.assertEqual(step["options"]["runWhileHeld"], [1000])
|
||||||
box = [l for l in key["style"]["layers"] if l["type"] == "box"][0]
|
box = [l for l in key["style"]["layers"] if l["type"] == "box"][0]
|
||||||
|
|||||||
Reference in New Issue
Block a user