From 87f93e10d168d141eb99edebb9b0935a9d77a190 Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Tue, 6 Jun 2023 12:09:02 -0600 Subject: [PATCH] Make top edge repeat grid selection --- antonclk/antonclk.app.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/antonclk/antonclk.app.js b/antonclk/antonclk.app.js index 835dc04..9aab1fd 100644 --- a/antonclk/antonclk.app.js +++ b/antonclk/antonclk.app.js @@ -23,6 +23,7 @@ Graphics.prototype.setFontAnton = function(scale) { let grid = ["Office off", "Office 1/2", "Office on", "Kitchen off", "Kitchen 1/2", "Kitchen 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"]; let gridNum = -1; + let prevNum = -1; let gridDir = -1; let paintFace = function() { @@ -120,7 +121,7 @@ Graphics.prototype.setFontAnton = function(scale) { text = "right"; gridDir = "right"; } else if (truncY < 2) { - text = "top"; + text = "Repeat"; gridDir = "top"; } else if (truncY > 10) { text = "Cancel"; @@ -168,6 +169,7 @@ Graphics.prototype.setFontAnton = function(scale) { if (gridNum >= 0 && grid[gridNum]) { myMessage = grid[gridNum]; + prevNum = gridNum; if (Bangle.http){ const options = {timeout:3000, method: "post", body: gridNum}; @@ -180,6 +182,23 @@ Graphics.prototype.setFontAnton = function(scale) { }); } gridNum = -1; + } else if (gridDir == "top") { + if (prevNum >= 0) { + myMessage = grid[prevNum]; + + if (Bangle.http){ + const options = {timeout:3000, method: "post", body: prevNum}; + Bangle.http("https://api.home.dns.t0.vc/grid", options).then(event => { + myMessage = "ok" + if (paintFace) paintFace(); + }).catch((e)=>{ + myMessage = "POST error"; + if (paintFace) paintFace(); + }); + } + } else { + myMessage = "No repeat"; + } } else if (gridDir == "bottom") { myMessage = "Cancelled"; Bangle.setLocked(true);