diff --git a/README.md b/README.md index bb91855..ef4a030 100644 --- a/README.md +++ b/README.md @@ -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`). -- **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`. - `python3 nav_keys.py` applies them to every page. Run it again after adding pages. diff --git a/config.json b/config.json index 98fbddd..0477f1e 100644 --- a/config.json +++ b/config.json @@ -4,6 +4,7 @@ "page_name": "19\\nStatus", "nav_keys": ["pagenum"], "nav_hold_ms": 1000, + "nav_tap_page": 1, "variables": { "state": "sp_state", "heartbeat": "sp_hb", "command": "sp_cmd" }, "service_windows": [ diff --git a/make_page.py b/make_page.py index afb1a3b..f24ab03 100644 --- a/make_page.py +++ b/make_page.py @@ -136,12 +136,13 @@ NAV_LOCATIONS = {"pageup": ("0", "0"), "pagenum": ("1", "0"), "pagedown": ("2", 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. - For the page number key, status_page adds: tap = Companion's usual "go to the - start page" (moved to release, so a hold does not flash through it first), - hold for hold_ms = go to the status page. + For the page number key, status_page adds: tap = go to tap_page (on release, + so a hold does not flash through it first), hold for hold_ms = go to the + 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"))) 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: step = key["steps"]["0"] tap = step["action_sets"]["down"] + tap[0]["options"]["page"] = prop(tap_page) hold = [{"type": "action", "id": stable_id("nav", "hold"), "definitionId": "set_page", "connectionId": "internal", "options": {"surfaceId": prop("self"), "page": prop(status_page)}, "children": {}}] @@ -177,7 +179,8 @@ def build(cfg): controls = {} coloured = cfg.get("nav_keys", list(NAV_LOCATIONS)) # which nav keys follow the ALL button 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}) for tile in cfg["tiles"]: if "pos" not in tile: diff --git a/status-page.companionconfig b/status-page.companionconfig index fd30f6d..17ca892 100644 Binary files a/status-page.companionconfig and b/status-page.companionconfig differ diff --git a/tests/test_status_panel.py b/tests/test_status_panel.py index 0aecce4..37f2d97 100644 --- a/tests/test_status_panel.py +++ b/tests/test_status_panel.py @@ -564,7 +564,7 @@ class TestPage(unittest.TestCase): step = key["steps"]["0"] self.assertEqual(step["action_sets"]["down"], []) 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(step["options"]["runWhileHeld"], [1000]) box = [l for l in key["style"]["layers"] if l["type"] == "box"][0]