Make top edge repeat grid selection

This commit is contained in:
Tanner Collin 2023-06-06 12:09:02 -06:00
parent 9edab1f230
commit 87f93e10d1

View File

@ -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 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 gridNum = -1;
let prevNum = -1;
let gridDir = -1; let gridDir = -1;
let paintFace = function() { let paintFace = function() {
@ -120,7 +121,7 @@ Graphics.prototype.setFontAnton = function(scale) {
text = "right"; text = "right";
gridDir = "right"; gridDir = "right";
} else if (truncY < 2) { } else if (truncY < 2) {
text = "top"; text = "Repeat";
gridDir = "top"; gridDir = "top";
} else if (truncY > 10) { } else if (truncY > 10) {
text = "Cancel"; text = "Cancel";
@ -168,6 +169,7 @@ Graphics.prototype.setFontAnton = function(scale) {
if (gridNum >= 0 && grid[gridNum]) { if (gridNum >= 0 && grid[gridNum]) {
myMessage = grid[gridNum]; myMessage = grid[gridNum];
prevNum = gridNum;
if (Bangle.http){ if (Bangle.http){
const options = {timeout:3000, method: "post", body: gridNum}; const options = {timeout:3000, method: "post", body: gridNum};
@ -180,6 +182,23 @@ Graphics.prototype.setFontAnton = function(scale) {
}); });
} }
gridNum = -1; 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") { } else if (gridDir == "bottom") {
myMessage = "Cancelled"; myMessage = "Cancelled";
Bangle.setLocked(true); Bangle.setLocked(true);