From eccca550efee4188033624e1e6f963d9a9668392 Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Sat, 7 Sep 2024 11:49:51 -0600 Subject: [PATCH] Add quad menu, ignore more messages --- antonclk/antonclk.app.js | 24 ++++++++++++++++-------- messagegui/messagegui.app.js | 6 +++++- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/antonclk/antonclk.app.js b/antonclk/antonclk.app.js index d315328..049a2b7 100644 --- a/antonclk/antonclk.app.js +++ b/antonclk/antonclk.app.js @@ -4,7 +4,6 @@ Graphics.prototype.setFontAnton = function(scale) { g.setFontCustom(atob("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAf/gAAAAAAAAAAf/gAAAAAAAAAAf/gAAAAAAAAAAf/gAAAAAAAAAAf/gAAAAAAAAAAf/gAAAAAAAAAAf/gAAAAAAAAAAf/gAAAAAAAAAAf/gAAAAAAAAAAf/gAAAAAAAAAAf/gAAAAAAAAAAf/gAAAAAAAAAAf/gAAAAAAAAAAf/gAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAA/gAAAAAAAAAAP/gAAAAAAAAAH//gAAAAAAAAB///gAAAAAAAAf///gAAAAAAAP////gAAAAAAD/////gAAAAAA//////gAAAAAP//////gAAAAH///////gAAAB////////gAAAf////////gAAP/////////gAD//////////AA//////////gAA/////////4AAA////////+AAAA////////gAAAA///////wAAAAA//////8AAAAAA//////AAAAAAA/////gAAAAAAA////4AAAAAAAA///+AAAAAAAAA///gAAAAAAAAA//wAAAAAAAAAA/8AAAAAAAAAAA/AAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//////AAAAAB///////8AAAAH////////AAAAf////////wAAA/////////4AAB/////////8AAD/////////+AAH//////////AAP//////////gAP//////////gAP//////////gAf//////////wAf//////////wAf//////////wAf//////////wA//8AAAAAB//4A//wAAAAAAf/4A//gAAAAAAP/4A//gAAAAAAP/4A//gAAAAAAP/4A//wAAAAAAf/4A///////////4Af//////////wAf//////////wAf//////////wAf//////////wAP//////////gAP//////////gAH//////////AAH//////////AAD/////////+AAB/////////8AAA/////////4AAAP////////gAAAD///////+AAAAAf//////4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP/gAAAAAAAAAAP/gAAAAAAAAAAf/gAAAAAAAAAAf/gAAAAAAAAAAf/AAAAAAAAAAA//AAAAAAAAAAA/+AAAAAAAAAAB/8AAAAAAAAAAD//////////gAH//////////gAP//////////gA///////////gA///////////gA///////////gA///////////gA///////////gA///////////gA///////////gA///////////gA///////////gA///////////gA///////////gA///////////gAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAH/4AAAAB/gAAD//4AAAAf/gAAP//4AAAB//gAA///4AAAH//gAB///4AAAf//gAD///4AAA///gAH///4AAD///gAP///4AAH///gAP///4AAP///gAf///4AAf///gAf///4AB////gAf///4AD////gA////4AH////gA////4Af////gA////4A/////gA//wAAB/////gA//gAAH/////gA//gAAP/////gA//gAA///8//gA//gAD///w//gA//wA////g//gA////////A//gA///////8A//gA///////4A//gAf//////wA//gAf//////gA//gAf/////+AA//gAP/////8AA//gAP/////4AA//gAH/////gAA//gAD/////AAA//gAB////8AAA//gAA////wAAA//gAAP///AAAA//gAAD//8AAAA//gAAAP+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB/+AAAAAD/wAAB//8AAAAP/wAAB///AAAA//wAAB///wAAB//wAAB///4AAD//wAAB///8AAH//wAAB///+AAP//wAAB///+AAP//wAAB////AAf//wAAB////AAf//wAAB////gAf//wAAB////gA///wAAB////gA///wAAB////gA///w//AAf//wA//4A//AAA//wA//gA//AAAf/wA//gB//gAAf/wA//gB//gAAf/wA//gD//wAA//wA//wH//8AB//wA///////////gA///////////gA///////////gA///////////gAf//////////AAf//////////AAP//////////AAP/////////+AAH/////////8AAH///+/////4AAD///+f////wAAA///8P////gAAAf//4H///+AAAAH//gB///wAAAAAP4AAH/8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/wAAAAAAAAAA//wAAAAAAAAAP//wAAAAAAAAB///wAAAAAAAAf///wAAAAAAAH////wAAAAAAA/////wAAAAAAP/////wAAAAAB//////wAAAAAf//////wAAAAH///////wAAAA////////wAAAP////////wAAA///////H/wAAA//////wH/wAAA/////8AH/wAAA/////AAH/wAAA////gAAH/wAAA///4AAAH/wAAA//+AAAAH/wAAA///////////gA///////////gA///////////gA///////////gA///////////gA///////////gA///////////gA///////////gA///////////gA///////////gA///////////gA///////////gA///////////gA///////////gAAAAAAAAH/4AAAAAAAAAAH/wAAAAAAAAAAH/wAAAAAAAAAAH/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB//8AAA/////+B///AAA/////+B///wAA/////+B///4AA/////+B///8AA/////+B///8AA/////+B///+AA/////+B////AA/////+B////AA/////+B////AA/////+B////gA/////+B////gA/////+B////gA/////+A////gA//gP/gAAB//wA//gf/AAAA//wA//gf/AAAAf/wA//g//AAAAf/wA//g//AAAA//wA//g//gAAA//wA//g//+AAP//wA//g////////gA//g////////gA//g////////gA//g////////gA//g////////AA//gf///////AA//gf//////+AA//gP//////+AA//gH//////8AA//gD//////4AA//gB//////wAA//gA//////AAAAAAAH////8AAAAAAAA////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//////gAAAAB///////+AAAAH////////gAAAf////////4AAB/////////8AAD/////////+AAH//////////AAH//////////gAP//////////gAP//////////gAf//////////wAf//////////wAf//////////wAf//////////wAf//////////4A//wAD/4AAf/4A//gAH/wAAP/4A//gAH/wAAP/4A//gAP/wAAP/4A//gAP/4AAf/4A//wAP/+AD//4A///wP//////4Af//4P//////wAf//4P//////wAf//4P//////wAf//4P//////wAP//4P//////gAP//4H//////gAH//4H//////AAH//4D/////+AAD//4D/////8AAB//4B/////4AAA//4A/////wAAAP/4AP////AAAAB/4AD///4AAAAAAAAAH/8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//AAAAAAAAAAA//gAAAAAAAAAA//gAAAAAAAAAA//gAAAAAAADgA//gAAAAAAP/gA//gAAAAAH//gA//gAAAAB///gA//gAAAAP///gA//gAAAD////gA//gAAAf////gA//gAAB/////gA//gAAP/////gA//gAB//////gA//gAH//////gA//gA///////gA//gD///////gA//gf///////gA//h////////gA//n////////gA//////////gAA/////////AAAA////////wAAAA///////4AAAAA///////AAAAAA//////4AAAAAA//////AAAAAAA/////4AAAAAAA/////AAAAAAAA////8AAAAAAAA////gAAAAAAAA///+AAAAAAAAA///4AAAAAAAAA///AAAAAAAAAA//4AAAAAAAAAA/+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//gB///wAAAAP//4H///+AAAA///8P////gAAB///+f////4AAD///+/////8AAH/////////+AAH//////////AAP//////////gAP//////////gAf//////////gAf//////////wAf//////////wAf//////////wA///////////wA//4D//wAB//4A//wB//gAA//4A//gA//gAAf/4A//gA//AAAf/4A//gA//gAAf/4A//wB//gAA//4A///P//8AH//4Af//////////wAf//////////wAf//////////wAf//////////wAf//////////gAP//////////gAP//////////AAH//////////AAD/////////+AAD///+/////8AAB///8f////wAAAf//4P////AAAAH//wD///8AAAAA/+AAf//AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAH//gAAAAAAAAB///+AA/+AAAAP////gA//wAAAf////wA//4AAB/////4A//8AAD/////8A//+AAD/////+A///AAH/////+A///AAP//////A///gAP//////A///gAf//////A///wAf//////A///wAf//////A///wAf//////A///wA///////AB//4A//4AD//AAP/4A//gAB//AAP/4A//gAA//AAP/4A//gAA/+AAP/4A//gAB/8AAP/4A//wAB/8AAf/4Af//////////wAf//////////wAf//////////wAf//////////wAf//////////wAP//////////gAP//////////gAH//////////AAH/////////+AAD/////////8AAB/////////4AAAf////////wAAAP////////AAAAB///////4AAAAAD/////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAf/AAB/8AAAAAA//AAD/8AAAAAA//AAD/8AAAAAA//AAD/8AAAAAA//AAD/8AAAAAA//AAD/8AAAAAA//AAD/8AAAAAA//AAD/8AAAAAA//AAD/8AAAAAA//AAD/8AAAAAA//AAD/8AAAAAA//AAD/8AAAAAA//AAD/8AAAAAA//AAD/8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=="), 46, atob("EiAnGicnJycnJycnEw=="), 78 + (scale << 8) + (1 << 16)); }; - { // must be inside our own scope here so that when we are unloaded everything disappears // we also define functions using 'let fn = function() {..}' for the same reason. function decls are global const STATE_IDLE = 0; @@ -22,12 +21,12 @@ Graphics.prototype.setFontAnton = function(scale) { let lockTimer = null; let swipeLockout = false; - let grid = ["Office off", "Office 1/2", "Office on", "Kitchen off", "Kitchen 1/2", "Kitchen on", "Closet off", "Closet 1/2", "Closet on", "Window off", "Window 1/2", "Window on", "LStairs off", "LStairs 1/2", "LStairs on", "Nook off", "Nook 1/2", "Nook on", "SideEnt off", "SideEnt 1/2", "SideEnt on", "Theatre off", "Theatre 1/2", "Theatre on", "FPot off", "FPot 1/2", "FPot on", "SPot off", "SPot 1/2", "SPot on", "GuestBth off", "GuestBth 1/2", "GuestBth on", "Lab off", "Lab on", "Number off", "Number on", "BathFan off", "BathFan on", "VentFan off", "VentFan on", "Grow off", "Grow on", "", "", "Nook Air off", "Nook Air on", "Lab Air off", "Lab Air on", "Seeds off", "Seeds on", "Lamp off", "Lamp on", "Bed Air off", "Bed Air on", "Garage Plug off", "Garage Plug on", "Volume Down", "Volume Up", "Prev", "Next", "Pause", "Play", "", "Show Time", "Movie Time", "Guest 0", "Guest 1", "", "", "Motn Lk 0", "Motn Lk 1", "Refresh Grid", "Mark Time", "Disarm", "Arm Stay", "Arm Away", "Unlock Door", "Garage Door", "Test Alert", "Kill server"]; + let grid = require("Storage").readJSON("grid.json", true); + let prevNum = require("Storage").readJSON("prevNum.json", true) || -1; let gridNum = -1; - let prevNum = -1; let gridDir = -1; - let menu = {"lights": {"upper": {"closet": {"off": null, "1/4": null, "1/2": null, "on": null}, "window": {"off": null, "1/4": null, "1/2": null, "on": null}, "guest bath": {"off": null, "1/4": null, "1/2": null, "on": null}, "office": {"off": null, "1/4": null, "1/2": null, "on": null}}, "middle": {"kitchen": {"off": null, "1/4": null, "1/2": null, "on": null}, "nook": {"off": null, "1/4": null, "1/2": null, "on": null}, "side ent": {"off": null, "1/4": null, "1/2": null, "on": null}}, "lower": {"lstairs": {"off": null, "1/4": null, "1/2": null, "on": null}, "theatre": {"off": null, "1/4": null, "1/2": null, "on": null}, "lab": {"off": null, "1/4": null, "1/2": null, "on": null}}, "misc": {"fpot": {"off": null, "1/4": null, "1/2": null, "on": null}, "spot": {"off": null, "1/4": null, "1/2": null, "on": null}, "number": {"off": null, "1/4": null, "1/2": null, "on": null}}}, "switches": {"fans": {"bath on": null, "bath off": null, "vent on": null, "vent off": null}, "hydro": {"grow on": null, "grow off": null, "seeds on": null, "seeds off": null}, "living": {"lr on": null, "lr off": null, "lamp on": null, "lamp off": null}, "air": {"bed on": null, "bed off": null, "lab on": null, "lab off": null}}, "states": {"scenes": {"bed time": null, "woke up": null, "show time": null, "movie time": null}, "modes": {"guest on": null, "guest off": null, "mlock on": null, "mlock off": null}}, "commands": {"media": {"prev": null, "next": null, "pause": null, "play": null}, "volume": {"up 10": null, "up 30": null, "down 10": null, "down 30": null}, "util": {"kill server": null, "arm stay": null, "test alert": null, "mark time": null}, "door": {"arm away": null, "disarm": null, "unlock": null, "garage": null}}}; + let menu = require("Storage").readJSON("menu.json", true); let subMenu = null; let menuCommand = ""; @@ -139,7 +138,7 @@ Graphics.prototype.setFontAnton = function(scale) { gridNum = gridY * 9 + gridX; rank = "ABCDEFGHI"[gridY]; - text = grid[gridNum]; + text = grid[gridNum] || gridNum; } g.setFontAlign(0, 0).setFont("Vector", 26).drawString(text, x, y-45); @@ -174,9 +173,16 @@ Graphics.prototype.setFontAnton = function(scale) { swipeLockout = false; }, 2000); - if (gridNum >= 0 && grid[gridNum]) { + if (gridNum == 72) { + myMessage = "Refresh Grid"; + require("Storage").writeJSON("grid.json", false); + grid = false; + gridNum = -1; + load(); + } else if (gridNum >= 0 && grid[gridNum]) { myMessage = grid[gridNum]; prevNum = gridNum; + require("Storage").writeJSON("prevNum.json", prevNum); if (Bangle.http){ const options = {timeout:3000, method: "post", body: gridNum}; @@ -309,11 +315,12 @@ Graphics.prototype.setFontAnton = function(scale) { if (paintFace) paintFace(); Bangle.drawWidgets(); } - } + }; - if (Bangle.http){ + if (Bangle.http && (!grid || !menu)){ Bangle.http("https://api.home.dns.t0.vc/grid", {timeout:3000}).then(event => { grid = JSON.parse(event.resp); + require("Storage").writeJSON("grid.json", grid); //console.log(grid); }).catch((e)=>{ myMessage = "Grid error"; @@ -322,6 +329,7 @@ Graphics.prototype.setFontAnton = function(scale) { Bangle.http("https://api.home.dns.t0.vc/menu", {timeout:3000}).then(event => { menu = JSON.parse(event.resp); + require("Storage").writeJSON("menu.json", menu); //console.log(grid); }).catch((e)=>{ myMessage = "Menu error"; diff --git a/messagegui/messagegui.app.js b/messagegui/messagegui.app.js index 9e4e9fa..17884b4 100644 --- a/messagegui/messagegui.app.js +++ b/messagegui/messagegui.app.js @@ -195,7 +195,7 @@ function showMessageScroller(msg) { var bodyFont = fontLarge; g.setFont(bodyFont); var lines = []; - if (msg.title) lines = g.wrapString(msg.title, g.getWidth()-10) + if (msg.title) lines = g.wrapString(msg.title, g.getWidth()-10); lines = [lines[0]]; var titleCnt = lines.length; //if (titleCnt) lines.push(""); // add blank line after title @@ -369,7 +369,11 @@ function checkMessages(options) { var goBack = false; while (MESSAGES.length && ( MESSAGES[0].title == "Timer" || + MESSAGES[0].title == "Clock" || + MESSAGES[0].title == "Stopwatch" || + MESSAGES[0].title == "Navigation" || MESSAGES[0].title.startsWith("Protostable Chatspace") || + MESSAGES[0].title.includes("Jason") || MESSAGES[0].body.toLowerCase().startsWith("!chat") || MESSAGES[0].body.toLowerCase().startsWith("! chat") )) {