1
0
Fork 0

Merge pull request #1056 from lightnin/master

Updates for impwclock BangleJs2 compatibility
master
Gordon Williams 2021-12-13 08:50:09 +00:00 committed by GitHub
commit 20317a7efe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 22 deletions

View File

@ -538,7 +538,7 @@
"icon": "clock-impword.png", "icon": "clock-impword.png",
"type": "clock", "type": "clock",
"tags": "clock", "tags": "clock",
"supports": ["BANGLEJS"], "supports": ["BANGLEJS","BANGLEJS2"],
"screenshots": [{"url":"bangle1-impercise-word-clock-screenshot.png"}], "screenshots": [{"url":"bangle1-impercise-word-clock-screenshot.png"}],
"allow_emulator": true, "allow_emulator": true,
"storage": [ "storage": [

View File

@ -1,3 +1,4 @@
0.01: New App! 0.01: New App!
0.02: Stopped watchface from flashing every interval 0.02: Stopped watchface from flashing every interval
0.03: Move to Bangle.setUI to launcher support 0.03: Move to Bangle.setUI to launcher support
0.04: Tweaks for compatibility with BangleJS2

View File

@ -1,4 +1,4 @@
# Imprecise Word Clock # Imprecise Word Clock
This clock tells time in very rough approximation, as in "Late morning" or "Early afternoon." Good for vacations and weekends. Press button 1 to see the time in accurate, digital form. But do you really need to know the exact time? This clock tells time in very rough approximation, as in "Late morning" or "Early afternoon." Good for vacations and weekends. Touch the screen to see the time in accurate, digital form. But do you really need to know the exact time?

View File

@ -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 - Toggles showing of accurate digital time when screen touched.
*/ */
/* jshint esversion: 6 */ /* jshint esversion: 6 */
@ -34,14 +34,16 @@ const timeOfDay = {
}; };
var big = g.getWidth()>200;
// offsets and increments // offsets and increments
const xs = 35; const xs = big ? 35 : 20;
const ys = 31; const ys = big ? 31 : 28;
const dy = 22; const dx = big ? 25 : 20;
const dx = 25; const dy = big ? 22 : 16;
// font size and color // font size and color
const fontSize = 3; // "6x8" const fontSize = big ? 3 : 2; // "6x8"
const passivColor = 0x3186 /*grey*/ ; const passivColor = 0x3186 /*grey*/ ;
const activeColorNight = 0xF800 /*red*/ ; const activeColorNight = 0xF800 /*red*/ ;
const activeColorDay = 0xFFFF /* white */; const activeColorDay = 0xFFFF /* white */;
@ -115,6 +117,8 @@ function drawWordClock() {
// check whether we need to redraw the watchface // check whether we need to redraw the watchface
if (hidx !== hidxPrev) { if (hidx !== hidxPrev) {
// Turn off showDigitalTime
showDigitalTime = false;
// draw allWords // draw allWords
var c; var c;
var y = ys; var y = ys;
@ -138,15 +142,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();
}); });
@ -157,17 +160,14 @@ Bangle.drawWidgets();
setInterval(drawWordClock, 1E4); setInterval(drawWordClock, 1E4);
drawWordClock(); drawWordClock();
// Show digital time while top button is pressed (if we have physical buttons)
if (global.BTN3) setWatch(function() {
showDigitalTime = BTN1.read();
drawWordClock();
}, BTN1, {repeat:true,edge:"both"});
// If LCD pressed (on Bangle.js 2) draw digital time // If LCD pressed, toggle drawing digital time
Bangle.on('drag',e=>{ Bangle.on('touch',e=>{
var pressed = e.b!=0; if (showDigitalTime){
if (pressed!=showDigitalTime) { showDigitalTime = false;
showDigitalTime = pressed; drawWordClock();
} else {
showDigitalTime = true;
drawWordClock(); drawWordClock();
} }
}); });