touch interaction added

pull/3072/head
charlestietjen 2023-11-02 16:39:53 -04:00
parent a80a7f2162
commit 822dbf7811
3 changed files with 26 additions and 2 deletions

View File

@ -1,3 +1,4 @@
0.1: Initial release 0.1: Initial release
0.2: Added more descriptive approximations 0.2: Added more descriptive approximations
0.2f: Bug fixes: Incorrect hour drawn after 50 mins, incorrect quarter minute drawn after 50 mins 0.2f: Bug fixes: Incorrect hour drawn after 50 mins, incorrect quarter minute drawn after 50 mins
0.3: Added touch interaction to display exact time and date.

View File

@ -89,6 +89,24 @@ function queueDraw() {
}, 60000 - (Date.now() % 60000)); }, 60000 - (Date.now() % 60000));
} }
const drawTimeExact = () => {
var dateTime = Date();
var hours = dateTime.getHours();
var minutes = dateTime.getMinutes().toString().padStart(2,0);
var day = dateTime.getDay();
var date = dateTime.getDate();
var month = dateTime.getMonth();
var year = dateTime.getFullYear();
g.clear();
g.setBgColor(0,0,0);
g.clearRect(0,0,width, height);
g.setColor(1,1,1);
g.setFont("Vector", 30);
g.drawString(hours + ":" + minutes, (width - g.stringWidth(hours + ":" + minutes))/2, height * 0.3, false);
g.setFont("Vector", 26);
g.drawString(month + 1 + "/" + date + "/" + year, (width - g.stringWidth(month + 1 + "/" + date + "/" + year))/2, height * 0.6, false);
};
const drawTime = () => { const drawTime = () => {
//Grab time vars //Grab time vars
var date = Date(); var date = Date();
@ -127,6 +145,11 @@ Bangle.on('lcdPower', function (on) {
} }
}); });
Bangle.on('touch', function(button, xy){
drawTimeExact();
setTimeout(drawTime, 7000);
});
// Show launcher when button pressed // Show launcher when button pressed
Bangle.setUI("clock"); Bangle.setUI("clock");
Bangle.loadWidgets(); Bangle.loadWidgets();

View File

@ -1,7 +1,7 @@
{ "id": "approxclock", { "id": "approxclock",
"name": "Approximate Clock", "name": "Approximate Clock",
"shortName" : "Approx Clock", "shortName" : "Approx Clock",
"version": "0.2f", "version": "0.3",
"icon": "app.png", "icon": "app.png",
"description": "A really basic spelled out time display for people looking for the vague time at a glance.", "description": "A really basic spelled out time display for people looking for the vague time at a glance.",
"type": "clock", "type": "clock",