Display outside temperature
This commit is contained in:
parent
8356481b27
commit
0c7fcabf24
|
@ -5,6 +5,7 @@ Graphics.prototype.setFontAnton = function(scale) {
|
||||||
};
|
};
|
||||||
|
|
||||||
let myMessage = "";
|
let myMessage = "";
|
||||||
|
let temperature = "";
|
||||||
|
|
||||||
{ // must be inside our own scope here so that when we are unloaded everything disappears
|
{ // 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
|
// 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
|
var timeStr = require("locale").time(date, 1); // Hour and minute
|
||||||
g.setFontAlign(0, 0).setFont("Anton").drawString(timeStr, x, y+20);
|
g.setFontAlign(0, 0).setFont("Anton").drawString(timeStr, x, y+20);
|
||||||
// Show date and day of week
|
// Show date and day of week
|
||||||
var dateStr = require("locale").date(date, 0).toUpperCase().substring(0, 5)+" "+
|
const days = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
||||||
require("locale").dow(date, 0).toUpperCase().substring(0, 3);
|
var dateStr = date.getDate() + " " + days[date.getDay()] + " " + temperature;
|
||||||
g.setFontAlign(0, 0).setFont("Vector", 26).drawString(dateStr, x, y+70);
|
g.setFontAlign(0, 0).setFont("Vector", 26).drawString(dateStr, x, y+70);
|
||||||
|
|
||||||
//var wrapped = g.wrapString(myMessage, g.getWidth()-10).join("\n");
|
//var wrapped = g.wrapString(myMessage, g.getWidth()-10).join("\n");
|
||||||
|
@ -32,8 +33,9 @@ Graphics.prototype.setFontAnton = function(scale) {
|
||||||
let draw = function() {
|
let draw = function() {
|
||||||
if (Bangle.http){
|
if (Bangle.http){
|
||||||
Bangle.http("https://api.home.dns.t0.vc/bangle", {timeout:3000}).then(event => {
|
Bangle.http("https://api.home.dns.t0.vc/bangle", {timeout:3000}).then(event => {
|
||||||
let result = event.resp.trim();
|
let result = JSON.parse(event.resp);
|
||||||
myMessage = result;
|
myMessage = result.context;
|
||||||
|
temperature = result.temperature;
|
||||||
if (paint) paint();
|
if (paint) paint();
|
||||||
}).catch((e)=>{
|
}).catch((e)=>{
|
||||||
myMessage = "GET error";
|
myMessage = "GET error";
|
||||||
|
|
Loading…
Reference in New Issue
Block a user