Toggle digital time when BangleJS2 screen touched.
parent
3df8f688af
commit
4862219a2f
|
|
@ -2,7 +2,7 @@
|
||||||
A remix of word clock
|
A remix of word clock
|
||||||
by Gordon Williams https://github.com/gfwilliams
|
by Gordon Williams https://github.com/gfwilliams
|
||||||
- Changes the representation of time to be more general
|
- Changes the representation of time to be more general
|
||||||
- Shows accurate digital time when button 1 is pressed
|
- Shows accurate digital time when button 1 is pressed or
|
||||||
*/
|
*/
|
||||||
/* jshint esversion: 6 */
|
/* jshint esversion: 6 */
|
||||||
|
|
||||||
|
|
@ -35,7 +35,7 @@ const timeOfDay = {
|
||||||
|
|
||||||
|
|
||||||
var big = g.getWidth()>200;
|
var big = g.getWidth()>200;
|
||||||
// offsets and incerments
|
// offsets and increments
|
||||||
const xs = big ? 35 : 20;
|
const xs = big ? 35 : 20;
|
||||||
const ys = big ? 31 : 28;
|
const ys = big ? 31 : 28;
|
||||||
const dx = big ? 25 : 20;
|
const dx = big ? 25 : 20;
|
||||||
|
|
@ -140,15 +140,14 @@ function drawWordClock() {
|
||||||
hidxPrev = hidx;
|
hidxPrev = hidx;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display digital time while button 1 is pressed
|
// Display digital time when button is pressed or screen touched
|
||||||
g.clearRect(0, 215, 240, 240);
|
g.clearRect(0, big ? 215 : 160, big ? 240 : 176, big ? 240 : 176);
|
||||||
if (showDigitalTime){
|
if (showDigitalTime){
|
||||||
g.setColor(activeColor);
|
g.setColor(activeColor);
|
||||||
g.drawString(time, 120, 215);
|
g.drawString(time, big ? 120 : 90, big ? 215 : 160);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Bangle.on('lcdPower', function(on) {
|
Bangle.on('lcdPower', function(on) {
|
||||||
if (on) drawWordClock();
|
if (on) drawWordClock();
|
||||||
});
|
});
|
||||||
|
|
@ -166,10 +165,13 @@ if (global.BTN3) setWatch(function() {
|
||||||
}, BTN1, {repeat:true,edge:"both"});
|
}, BTN1, {repeat:true,edge:"both"});
|
||||||
|
|
||||||
// If LCD pressed (on Bangle.js 2) draw digital time
|
// If LCD pressed (on Bangle.js 2) draw digital time
|
||||||
Bangle.on('drag',e=>{
|
Bangle.on('touch',e=>{
|
||||||
var pressed = e.b!=0;
|
var pressed = e.b!=0;
|
||||||
if (pressed!=showDigitalTime) {
|
if (showDigitalTime){
|
||||||
showDigitalTime = pressed;
|
showDigitalTime = false;
|
||||||
|
drawWordClock();
|
||||||
|
} else {
|
||||||
|
showDigitalTime = true;
|
||||||
drawWordClock();
|
drawWordClock();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue