Skip to content

Commit ae23db5

Browse files
committed
learning how to declar variables in js
1 parent a5c6c6d commit ae23db5

File tree

1 file changed

+19
-20
lines changed

1 file changed

+19
-20
lines changed

apps/dsky_clock/app.js

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ var Layout = require("Layout");
33
require("Font7x11Numeric7Seg").add(Graphics);
44
require("FontTeletext5x9Ascii").add(Graphics);
55

6-
borders = 1;
7-
Light_on='#fff';
8-
Light_off='#554';
9-
Light_warn='#f90';
10-
Light_COMPACTY='#0F0';
11-
Light_width=43;
12-
Light_height=25;
13-
EL7_height=30;
14-
LightFont='Teletext5x9Ascii';
15-
DataFont='7x11Numeric7Seg:2';
16-
mode = 0;
6+
const borders = 1;
7+
const Light_on='#fff';
8+
const Light_off='#554';
9+
const Light_warn='#f90';
10+
const Light_COMPACTY='#0F0';
11+
const Light_width=43;
12+
const Light_height=25;
13+
const EL7_height=30;
14+
const LightFont='Teletext5x9Ascii';
15+
const DataFont='7x11Numeric7Seg:2';
16+
var mode = 0;
1717

1818
var layout = new Layout(
1919
{type:"h", c:[
@@ -61,7 +61,7 @@ layout.update();
6161
//support functions
6262

6363
function getWeather() {
64-
weather = require("Storage").readJSON('weather.json', 1).weather;
64+
var weather = require("Storage").readJSON('weather.json', 1).weather;
6565
return weather;
6666
}
6767

@@ -80,7 +80,7 @@ function getdatetime(){
8080
}
8181

8282
function getSteps(){
83-
steps=Bangle.getHealthStatus("day").steps;
83+
let steps=Bangle.getHealthStatus("day").steps;
8484
steps = typeof steps !== 'undefined' ? steps:0;
8585
return steps;
8686
}
@@ -111,7 +111,7 @@ function getTemperature(){
111111
}
112112

113113
function getHRM(){
114-
hrm=Bangle.getHealthStatus('last');
114+
let hrm=Bangle.getHealthStatus('last');
115115
hrm = typeof hrm !== 'undefined' ? hrm:0;
116116
return hrm;
117117
}
@@ -121,7 +121,7 @@ function isBTConnected(){
121121
}
122122

123123
function getBattery(){
124-
battlevel = E.getBattery();
124+
let battlevel = E.getBattery();
125125
if (Bangle.isCharging()) {
126126
battlevel = -1;
127127
} else if (battlevel >= 100) {
@@ -157,10 +157,9 @@ function setLight(id,label,check,onColour,offColour){
157157

158158
function setDATA(id,label) {
159159
layout.clear(layout[id]);
160+
let data='-----';
160161
try {
161-
if (isNaN(label)) {
162-
data='-----';
163-
} else {
162+
if (!isNaN(label)) {
164163
if (label < 0) {
165164
label=Math.abs(label);
166165
sign='-';
@@ -204,7 +203,7 @@ function draw_bg(){
204203

205204
// actual display
206205
function drawMain(){
207-
datetime=getdatetime();
206+
let datetime=getdatetime();
208207

209208
setDATA('R1',datetime.localtime);
210209
setDATA('R2',datetime.utctime);
@@ -285,7 +284,7 @@ function mode_HRM() {
285284
}
286285

287286
function mode_weather() {
288-
weather=getWeather();
287+
let weather=getWeather();
289288
weather.temp = Math.round(weather.temp-273.15);
290289
setDATA('R1',weather.temp);
291290
setDATA('R2',weather.hum);

0 commit comments

Comments
 (0)