From 0c7fcabf24c6681e127cdaf6f4d56bbc9e773098 Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Tue, 10 Jan 2023 19:17:09 -0700 Subject: [PATCH] Display outside temperature --- tannerwatch/code.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tannerwatch/code.js b/tannerwatch/code.js index 8626b62..ff9dc66 100644 --- a/tannerwatch/code.js +++ b/tannerwatch/code.js @@ -5,6 +5,7 @@ Graphics.prototype.setFontAnton = function(scale) { }; let myMessage = ""; + let temperature = ""; { // 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 @@ -20,8 +21,8 @@ Graphics.prototype.setFontAnton = function(scale) { var timeStr = require("locale").time(date, 1); // Hour and minute g.setFontAlign(0, 0).setFont("Anton").drawString(timeStr, x, y+20); // Show date and day of week - var dateStr = require("locale").date(date, 0).toUpperCase().substring(0, 5)+" "+ - require("locale").dow(date, 0).toUpperCase().substring(0, 3); + const days = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]; + var dateStr = date.getDate() + " " + days[date.getDay()] + " " + temperature; g.setFontAlign(0, 0).setFont("Vector", 26).drawString(dateStr, x, y+70); //var wrapped = g.wrapString(myMessage, g.getWidth()-10).join("\n"); @@ -32,8 +33,9 @@ Graphics.prototype.setFontAnton = function(scale) { let draw = function() { if (Bangle.http){ Bangle.http("https://api.home.dns.t0.vc/bangle", {timeout:3000}).then(event => { - let result = event.resp.trim(); - myMessage = result; + let result = JSON.parse(event.resp); + myMessage = result.context; + temperature = result.temperature; if (paint) paint(); }).catch((e)=>{ myMessage = "GET error";