Add Daisy. Change Date pannel to info-panel with BAT, TEMP, DATE data
parent
4ad3f59561
commit
51e0adbc78
|
|
@ -5,4 +5,4 @@
|
|||
0.05: use 12/24 hour clock from settings
|
||||
0.06: Performance refactor, and enhanced graphics!
|
||||
0.07: Swipe right to change between Mario and Toad characters, swipe left to toggle night mode
|
||||
0.08: Add Readme. Add Princes Daisy
|
||||
0.08: Add Readme. Add Princes Daisy. Update date panel to be info panel toggling between Date, Battery and Temperature
|
||||
|
|
@ -7,12 +7,13 @@ Enjoy watching Mario, or one of the other game characters run through a level wh
|
|||
|
||||
## Features
|
||||
|
||||
* Multiple characters - swipe the screen right to change the character
|
||||
* Multiple characters - swipe the screen right to change the character between `Mario`, `Toad`, and `Daisy`
|
||||
* Night and Day modes - swipe left to toggle mode
|
||||
* Smooth animation
|
||||
* Awesome 8-bit style grey-scale graphics
|
||||
* Mario jumps to change the time, every minute
|
||||
* You can make Mario jump by pressing the top button (Button 1) on the watch
|
||||
* Toggle the info pannel bettween `Date`, `Battery level`, and `Temperature` by pressing the bottom button (Button 3).
|
||||
|
||||
## Requests
|
||||
|
||||
|
|
|
|||
|
|
@ -55,10 +55,18 @@ const pyramidSprite = {
|
|||
};
|
||||
|
||||
const ONE_SECOND = 1000;
|
||||
const DATE_MODE = "date";
|
||||
const BATT_MODE = "batt";
|
||||
const TEMP_MODE = "temp";
|
||||
|
||||
let timer = 0;
|
||||
let backgroundArr = [];
|
||||
let nightMode = false;
|
||||
let infoMode = DATE_MODE;
|
||||
|
||||
// Used to stop values flapping when displayed on screen
|
||||
let lastBatt = 0;
|
||||
let lastTemp = 0;
|
||||
|
||||
function genRanNum(min, max) {
|
||||
return Math.floor(Math.random() * (max - min + 1) + min);
|
||||
|
|
@ -303,13 +311,78 @@ function drawTime(date) {
|
|||
g.drawString(mins, 47, 29);
|
||||
}
|
||||
|
||||
function drawDate(date) {
|
||||
g.setFont("6x8");
|
||||
g.setColor(LIGHTEST);
|
||||
function buildDateStr(date) {
|
||||
let dateStr = locale.date(date, true);
|
||||
dateStr = dateStr.replace(date.getFullYear(), "").trim().replace(/\/$/i,"");
|
||||
dateStr = locale.dow(date, true) + " " + dateStr;
|
||||
g.drawString(dateStr, (W - g.stringWidth(dateStr))/2, 1);
|
||||
|
||||
return dateStr;
|
||||
}
|
||||
|
||||
function buildBatStr() {
|
||||
let batt = parseInt(E.getBattery());
|
||||
const battDiff = Math.abs(lastBatt - batt);
|
||||
|
||||
// Suppress flapping values
|
||||
// Only update batt if it moves greater than +-2
|
||||
if (battDiff > 2) {
|
||||
lastBatt = batt;
|
||||
} else {
|
||||
batt = lastBatt;
|
||||
}
|
||||
|
||||
const battStr = `Bat: ${batt}%`;
|
||||
|
||||
return battStr;
|
||||
}
|
||||
|
||||
function buildTempStr() {
|
||||
let temp = parseInt(E.getTemperature());
|
||||
const tempDiff = Math.abs(lastTemp - temp);
|
||||
|
||||
// Suppress flapping values
|
||||
// Only update temp if it moves greater than +-2
|
||||
if (tempDiff > 2) {
|
||||
lastTemp = temp;
|
||||
} else {
|
||||
temp = lastTemp;
|
||||
}
|
||||
const tempStr = `Temp: ${temp}'c`;
|
||||
|
||||
return tempStr;
|
||||
}
|
||||
|
||||
function drawInfo(date) {
|
||||
let str = "";
|
||||
switch(infoMode) {
|
||||
case TEMP_MODE:
|
||||
str = buildTempStr();
|
||||
break;
|
||||
case BATT_MODE:
|
||||
str = buildBatStr();
|
||||
break;
|
||||
case DATE_MODE:
|
||||
default:
|
||||
str = buildDateStr(date);
|
||||
}
|
||||
|
||||
g.setFont("6x8");
|
||||
g.setColor(LIGHTEST);
|
||||
g.drawString(str, (W - g.stringWidth(str))/2, 1);
|
||||
}
|
||||
|
||||
function changeInfoMode() {
|
||||
switch(infoMode) {
|
||||
case BATT_MODE:
|
||||
infoMode = TEMP_MODE;
|
||||
break;
|
||||
case TEMP_MODE:
|
||||
infoMode = DATE_MODE;
|
||||
break;
|
||||
case DATE_MODE:
|
||||
default:
|
||||
infoMode = BATT_MODE;
|
||||
}
|
||||
}
|
||||
|
||||
function redraw() {
|
||||
|
|
@ -324,7 +397,7 @@ function redraw() {
|
|||
drawPyramid();
|
||||
drawTrees();
|
||||
drawTime(date);
|
||||
drawDate(date);
|
||||
drawInfo(date);
|
||||
drawCharacter(date);
|
||||
drawCoin();
|
||||
|
||||
|
|
@ -377,12 +450,18 @@ function init() {
|
|||
setWatch(() => {
|
||||
if (intervalRef && !characterSprite.isJumping) characterSprite.isJumping = true;
|
||||
resetDisplayTimeout();
|
||||
}, BTN1, {repeat:true});
|
||||
}, BTN1, {repeat: true});
|
||||
|
||||
// Close watch and load launcher app
|
||||
setWatch(() => {
|
||||
Bangle.setLCDMode();
|
||||
Bangle.showLauncher();
|
||||
}, BTN2, {repeat:false,edge:"falling"});
|
||||
}, BTN2, {repeat: false, edge: "falling"});
|
||||
|
||||
// Change info mode
|
||||
setWatch(() => {
|
||||
changeInfoMode();
|
||||
}, BTN3, {repeat: true});
|
||||
|
||||
Bangle.on('lcdPower', (on) => on ? startTimers() : clearTimers());
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue