mirror of https://github.com/espruino/BangleApps
update APIs
parent
1d3079528a
commit
36a1678931
18
apps.json
18
apps.json
|
@ -206,9 +206,9 @@
|
|||
{ "id": "wclock",
|
||||
"name": "Word Clock",
|
||||
"icon": "clock-word.png",
|
||||
"version":"0.02",
|
||||
"version":"0.03",
|
||||
"description": "Display Time as Text",
|
||||
"tags": "clock",
|
||||
"tags": "clock,b2",
|
||||
"type":"clock",
|
||||
"allow_emulator":true,
|
||||
"storage": [
|
||||
|
@ -325,9 +325,9 @@
|
|||
{ "id": "clock2x3",
|
||||
"name": "2x3 Pixel Clock",
|
||||
"icon": "clock2x3.png",
|
||||
"version":"0.04",
|
||||
"version":"0.05",
|
||||
"description": "This is a simple clock using minimalist 2x3 pixel numerical digits",
|
||||
"tags": "clock",
|
||||
"tags": "clock,b2",
|
||||
"type": "clock",
|
||||
"allow_emulator":true,
|
||||
"storage": [
|
||||
|
@ -878,7 +878,7 @@
|
|||
{ "id": "vibrclock",
|
||||
"name": "Vibrate Clock",
|
||||
"icon": "app.png",
|
||||
"version":"0.02",
|
||||
"version":"0.03",
|
||||
"description": "When BTN1 is pressed, vibrate out the time as a series of buzzes, one digit at a time. Hours, then Minutes. Zero is signified by one long buzz. Otherwise a simple digital clock.",
|
||||
"tags": "clock",
|
||||
"type":"clock",
|
||||
|
@ -1119,9 +1119,9 @@
|
|||
{ "id": "boldclk",
|
||||
"name": "Bold Clock",
|
||||
"icon": "bold_clock.png",
|
||||
"version":"0.03",
|
||||
"version":"0.04",
|
||||
"description": "Simple, readable and practical clock",
|
||||
"tags": "clock",
|
||||
"tags": "clock,b2",
|
||||
"type":"clock",
|
||||
"allow_emulator":true,
|
||||
"storage": [
|
||||
|
@ -1132,7 +1132,7 @@
|
|||
{ "id": "widclk",
|
||||
"name": "Digital clock widget",
|
||||
"icon": "widget.png",
|
||||
"version":"0.04",
|
||||
"version":"0.05",
|
||||
"description": "A simple digital clock widget",
|
||||
"tags": "widget,clock",
|
||||
"type":"widget",
|
||||
|
@ -2477,7 +2477,7 @@
|
|||
"name": "World Clock - 4 time zones",
|
||||
"shortName":"World Clock",
|
||||
"icon": "app.png",
|
||||
"version":"0.03",
|
||||
"version":"0.04",
|
||||
"description": "Current time zone plus up to four others",
|
||||
"tags": "clock",
|
||||
"type" : "clock",
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
0.01: First commit
|
||||
0.02: Made Date more visible
|
||||
0.03: setUI and support for different screens
|
||||
|
|
|
@ -4,8 +4,9 @@ require("Font7x11Numeric7Seg").add(Graphics);
|
|||
// Check settings for what type our clock should be
|
||||
var is12Hour = (require("Storage").readJSON("setting.json",1)||{})["12hour"];
|
||||
// position on screen
|
||||
const X = 160, Y = 140;
|
||||
|
||||
const big = g.getWidth()>200;
|
||||
const X = big?160:135, Y = big?140:100;
|
||||
|
||||
function draw() {
|
||||
// work out how to display the current time
|
||||
var d = new Date();
|
||||
|
@ -25,13 +26,13 @@ function draw() {
|
|||
g.setFont("7x11Numeric7Seg",2);
|
||||
g.drawString(("0"+d.getSeconds()).substr(-2), X+35, Y, true /*clear background*/);
|
||||
// draw the date, in a normal font
|
||||
g.setFont("6x8", 3);
|
||||
g.setFont("6x8", big?3:2);
|
||||
g.setFontAlign(0,1); // align center bottom
|
||||
// pad the date - this clears the background if the date were to change length
|
||||
var dateStr = " "+require("locale").date(d)+" ";
|
||||
g.drawString(dateStr, g.getWidth()/2, Y+35, true /*clear background*/);
|
||||
}
|
||||
|
||||
|
||||
// Clear the screen once, at startup
|
||||
g.clear();
|
||||
// draw immediately at first
|
||||
|
@ -46,12 +47,15 @@ Bangle.on('lcdPower',on=>{
|
|||
draw(); // draw immediately
|
||||
}
|
||||
});
|
||||
|
||||
// Show launcher when button pressed
|
||||
Bangle.setUI("clockupdown", btn=>{
|
||||
if (btn==0) vibrateTime();
|
||||
});
|
||||
// Load widgets
|
||||
Bangle.loadWidgets();
|
||||
Bangle.drawWidgets();
|
||||
// Show launcher when middle button pressed
|
||||
setWatch(Bangle.showLauncher, BTN2, { repeat: false, edge: "falling" });
|
||||
|
||||
|
||||
// ====================================== Vibration
|
||||
// vibrate 0..9
|
||||
function vibrateDigit(num) {
|
||||
|
@ -74,24 +78,21 @@ function vibrateNumber(num) {
|
|||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
var vibrateBusy;
|
||||
function vibrateTime() {
|
||||
if (vibrateBusy) return;
|
||||
vibrateBusy = true;
|
||||
|
||||
|
||||
var d = new Date();
|
||||
var hours = d.getHours(), minutes = d.getMinutes();
|
||||
if (is12Hour) {
|
||||
if (hours == 0) hours = 12;
|
||||
else if (hours>12) hours -= 12;
|
||||
}
|
||||
|
||||
|
||||
vibrateNumber(hours.toString()).
|
||||
then(() => new Promise(resolve=>setTimeout(resolve,500))).
|
||||
then(() => vibrateNumber(minutes.toString())).
|
||||
then(() => vibrateBusy=false);
|
||||
}
|
||||
|
||||
// when BTN1 pressed, vibrate
|
||||
setWatch(vibrateTime, BTN1, {repeat:true,edge:"rising"});
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
0.02: Modified for use with new bootloader and firmware
|
||||
0.03: setUI and support for different screens
|
||||
|
|
|
@ -36,16 +36,18 @@ const mins = {
|
|||
7: ["TO", 43, 53]
|
||||
};
|
||||
|
||||
var big = g.getWidth()>200
|
||||
// offsets and incerments
|
||||
const xs = 35;
|
||||
const ys = 31;
|
||||
const dy = 22;
|
||||
const dx = 25;
|
||||
const xs = big ? 35 : 20;
|
||||
const ys = big ? 31 : 28;
|
||||
const dx = big ? 25 : 20;
|
||||
const dy = big ? 22 : 16;
|
||||
|
||||
// font size and color
|
||||
const fontSize = 3; // "6x8"
|
||||
const passivColor = 0x3186 /*grey*/ ;
|
||||
const activeColor = 0xF800 /*red*/ ;
|
||||
const fontSize = big ? 3 : 2; // "6x8"
|
||||
const lowBPP = g.getBPP && (g.getBPP()<12);
|
||||
const passivColor = lowBPP ? "#788" : "#333" /*grey*/ ;
|
||||
const activeColor = lowBPP ? "#F00" : "#F00" /*red*/ ;
|
||||
|
||||
function drawWordClock() {
|
||||
|
||||
|
@ -112,8 +114,8 @@ function drawWordClock() {
|
|||
|
||||
// display digital time
|
||||
g.setColor(activeColor);
|
||||
g.clearRect(0, 215, 240, 240);
|
||||
g.drawString(time, 120, 215);
|
||||
g.clearRect(0, g.getHeight()-fontSize*8, g.getWidth(), g.getHeight());
|
||||
g.drawString(time, g.getWidth()/2, g.getHeight()-fontSize*8);
|
||||
}
|
||||
|
||||
Bangle.on('lcdPower', function(on) {
|
||||
|
@ -126,5 +128,5 @@ Bangle.drawWidgets();
|
|||
setInterval(drawWordClock, 1E4);
|
||||
drawWordClock();
|
||||
|
||||
// Show launcher when middle button pressed
|
||||
setWatch(Bangle.showLauncher, BTN2, {repeat:false,edge:"falling"});
|
||||
// Show launcher when button pressed
|
||||
Bangle.setUI("clock");
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
0.02: Now refresh battery monitor every minute if LCD on
|
||||
0.03: Ensure redrawing works with variable size widget system
|
||||
0.04: Fix regression stopping correct widget updates
|
||||
0.05: Don't show clock widget if already showing clock app
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
(() => {
|
||||
(function() {
|
||||
// don't show widget if we know we have a clock app running
|
||||
if (Bangle.CLOCK) return;
|
||||
|
||||
let intervalRef = null;
|
||||
var width = 5 * 6*2
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
0.01: First try
|
||||
0.02: Update custom.html for refactor; add README
|
||||
0.03: Update for larger secondary timezone display (#610)
|
||||
0.04: setUI, different screen sizes
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
/* jshint esversion: 6 */
|
||||
|
||||
const big = g.getWidth()>200;
|
||||
// Font for primary time and date
|
||||
const primaryTimeFontSize = 6;
|
||||
const primaryDateFontSize = 3;
|
||||
const primaryTimeFontSize = big?6:5;
|
||||
const primaryDateFontSize = big?3:2;
|
||||
|
||||
// Font for single secondary time
|
||||
const secondaryTimeFontSize = 4;
|
||||
|
@ -16,9 +17,9 @@ const xcol2 = g.getWidth() - xcol1;
|
|||
const font = "6x8";
|
||||
|
||||
const xyCenter = g.getWidth() / 2;
|
||||
const yposTime = 75;
|
||||
const yposDate = 130;
|
||||
const yposWorld = 170;
|
||||
const yposTime = big ? 75 : 60;
|
||||
const yposDate = big ? 130 : 90;
|
||||
const yposWorld = big ? 170 : 120;
|
||||
|
||||
const OFFSET_TIME_ZONE = 0;
|
||||
const OFFSET_HOURS = 1;
|
||||
|
@ -135,6 +136,8 @@ function drawSimpleClock() {
|
|||
|
||||
// clean app screen
|
||||
g.clear();
|
||||
// Show launcher when button pressed
|
||||
Bangle.setUI("clock");
|
||||
Bangle.loadWidgets();
|
||||
Bangle.drawWidgets();
|
||||
|
||||
|
@ -153,6 +156,3 @@ drawSimpleClock();
|
|||
if (Bangle.isLCDOn()) {
|
||||
secondInterval = setInterval(drawSimpleClock, 15e3);
|
||||
}
|
||||
|
||||
// Show launcher when middle button pressed
|
||||
setWatch(Bangle.showLauncher, BTN2, { repeat: false, edge: "falling" });
|
||||
|
|
Loading…
Reference in New Issue