cliock 0.14: Fix BTN1 (fix #853)

Add light/dark theme support
master
Gordon Williams 2021-10-20 08:49:53 +01:00
parent 1e0f6cd675
commit b6d333ae74
3 changed files with 14 additions and 13 deletions

View File

@ -1371,7 +1371,7 @@
"name": "Commandline-Clock", "name": "Commandline-Clock",
"shortName":"CLI-Clock", "shortName":"CLI-Clock",
"icon": "app.png", "icon": "app.png",
"version":"0.13", "version":"0.14",
"description": "Simple CLI-Styled Clock", "description": "Simple CLI-Styled Clock",
"tags": "clock,cli,command,bash,shell,b2", "tags": "clock,cli,command,bash,shell,b2",
"type":"clock", "type":"clock",

View File

@ -5,3 +5,5 @@
0.11: added Heart Rate Monitor status and ability to turn on/off 0.11: added Heart Rate Monitor status and ability to turn on/off
0.12: added support for different locales 0.12: added support for different locales
0.13: Use setUI, work with smaller screens and themes 0.13: Use setUI, work with smaller screens and themes
0.14: Fix BTN1 (fix #853)
Add light/dark theme support

View File

@ -20,6 +20,8 @@ const HRT_FN_MODE = "fn_hrt";
let infoMode = NONE_MODE; let infoMode = NONE_MODE;
let functionMode = NONE_FN_MODE; let functionMode = NONE_FN_MODE;
let textCol = g.theme.dark ? "#0f0" : "#080";
function drawAll(){ function drawAll(){
updateTime(); updateTime();
updateRest(new Date()); updateRest(new Date());
@ -45,9 +47,7 @@ function writeLineStart(line){
function writeLine(str,line){ function writeLine(str,line){
var y = marginTop+line*fontheight; var y = marginTop+line*fontheight;
g.setFont("6x8",fontsize); g.setFont("6x8",fontsize);
//g.setColor(0,1,0); g.setColor(textCol).setFontAlign(-1,-1);
g.setColor("#0f0");
g.setFontAlign(-1,-1);
g.clearRect(0,y,((str.length+1)*20),y+fontheight-1); g.clearRect(0,y,((str.length+1)*20),y+fontheight-1);
writeLineStart(line); writeLineStart(line);
g.drawString(str,25,y); g.drawString(str,25,y);
@ -56,7 +56,7 @@ function writeLine(str,line){
function drawInfo(line) { function drawInfo(line) {
let val; let val;
let str = ""; let str = "";
let col = "#0f0"; // green let col = textCol; // green
//console.log("drawInfo(), infoMode=" + infoMode + " funcMode=" + functionMode); //console.log("drawInfo(), infoMode=" + infoMode + " funcMode=" + functionMode);
@ -64,7 +64,7 @@ function drawInfo(line) {
case NONE_FN_MODE: case NONE_FN_MODE:
break; break;
case HRT_FN_MODE: case HRT_FN_MODE:
col = "#0ff"; // cyan col = g.theme.dark ? "#0ff": "#088"; // cyan
str = "HRM: " + (hrtOn ? "ON" : "OFF"); str = "HRM: " + (hrtOn ? "ON" : "OFF");
drawModeLine(line,str,col); drawModeLine(line,str,col);
return; return;
@ -72,7 +72,7 @@ function drawInfo(line) {
switch(infoMode) { switch(infoMode) {
case NONE_MODE: case NONE_MODE:
col = "#fff"; col = g.theme.bg;
str = ""; str = "";
break; break;
case HRT_MODE: case HRT_MODE:
@ -104,9 +104,8 @@ function drawModeLine(line, str, col) {
g.setColor(col); g.setColor(col);
var y = marginTop+line*fontheight; var y = marginTop+line*fontheight;
g.fillRect(0, y, 239, y+fontheight-1); g.fillRect(0, y, 239, y+fontheight-1);
g.setColor(0); g.setColor(g.theme.bg).setFontAlign(0, 0);
g.setFontAlign(0, -1); g.drawString(str, g.getWidth()/2, y+fontheight/2);
g.drawString(str, g.getWidth()/2, y);
} }
function changeInfoMode() { function changeInfoMode() {
@ -193,7 +192,7 @@ Bangle.on('lcdPower',function(on) {
var click = setInterval(updateTime, 1000); var click = setInterval(updateTime, 1000);
// Show launcher when button pressed // Show launcher when button pressed
Bangle.setUI("clockupdown", btn=>{ Bangle.setUI("clockupdown", btn=>{
if (btn==0) changeInfoMode(); if (btn<0) changeInfoMode();
if (btn==1) changeFunctionMode(); if (btn>0) changeFunctionMode();
drawAll(); drawAll();
}); });