Display outside temperature

This commit is contained in:
Tanner Collin 2023-01-10 19:17:09 -07:00
parent 8356481b27
commit 0c7fcabf24

View File

@ -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";