forked from FOSS/BangleApps
commit
994c923c1d
|
@ -242,8 +242,8 @@
|
||||||
{ "id": "sweepclock",
|
{ "id": "sweepclock",
|
||||||
"name": "Sweep Clock",
|
"name": "Sweep Clock",
|
||||||
"icon": "sweepclock.png",
|
"icon": "sweepclock.png",
|
||||||
"version":"0.03",
|
"version":"0.04",
|
||||||
"description": "Smooth sweep secondhand with single hour numeral. Use button1 to toggle the numeral font, button 3 to change the colour theme and button 4 to change the date placement",
|
"description": "Smooth sweep secondhand with single hour numeral. Use button 1 to toggle the numeral font, button 3 to change the colour theme and button 4 to change the date placement",
|
||||||
"tags": "clock",
|
"tags": "clock",
|
||||||
"type":"clock",
|
"type":"clock",
|
||||||
"allow_emulator":true,
|
"allow_emulator":true,
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
0.01: Initial Release
|
0.01: Initial Release
|
||||||
0.02: Added Colour Themes
|
0.02: Added Colour Themes
|
||||||
0.03: Added Date
|
0.03: Added Date
|
||||||
|
0.04: Memory Footprint reduction
|
||||||
|
|
|
@ -12,7 +12,7 @@ Use Button 1 (the top right button) to change the numeral type
|
||||||
|
|
||||||
| Default clock face | Roman Numeral Font | No Digits |
|
| Default clock face | Roman Numeral Font | No Digits |
|
||||||
| ---- | ---- | ---- |
|
| ---- | ---- | ---- |
|
||||||
|  |  |  |
|
|  |  |  |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,14 +21,14 @@ Button 3 (bottom right button) is used to change the colour
|
||||||
|
|
||||||
| Red | Grey | Purple |
|
| Red | Grey | Purple |
|
||||||
| ---- | ---- | ---- |
|
| ---- | ---- | ---- |
|
||||||
|  |  |  |
|
|  |  |  |
|
||||||
|
|
||||||
### Button 4
|
### Button 4
|
||||||
Button 4 (bottom left of screen) is used to change the date positioning (or to remove from the screen)
|
Button 4 (bottom left of the screen) is used to change the date position. Note after cycling through the date positions there is the no date option.
|
||||||
|
|
||||||
| Top Right | Bottom Right | Bottom Left | Top Left |
|
| Top Right | Bottom Right | Bottom Left | Top Left |
|
||||||
| ---- | ---- | ---- | ---- |
|
| ---- | ---- | ---- | ---- |
|
||||||
|  |  |  |  |
|
|  |  |  |  |
|
||||||
|
|
||||||
## Further Details
|
## Further Details
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ For further details of design and working please visit [The Project Page](https:
|
||||||
|
|
||||||
## Requests
|
## Requests
|
||||||
|
|
||||||
Reach out to adrian@adriankirk.com if you have feature requests or notice bugs.
|
Please reach out to adrian@adriankirk.com if you have feature requests or notice bugs.
|
||||||
|
|
||||||
## Creator
|
## Creator
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/**
|
/**
|
||||||
* Adrian Kirk 2021-03
|
* Adrian Kirk 2021-03
|
||||||
* Simple Clock showing 1 numeral for the hour
|
* Simple Clock showing 1 numeral for the hour
|
||||||
* with a smooth sweep second.
|
* with a smooth sweep second.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const screen_center_x = g.getWidth()/2;
|
const screen_center_x = g.getWidth()/2;
|
||||||
const screen_center_y = 10 + g.getHeight()/2;
|
const screen_center_y = 10 + g.getHeight()/2;
|
||||||
|
@ -15,46 +15,40 @@ const color_schemes = [
|
||||||
name: "black",
|
name: "black",
|
||||||
background : [0.0,0.0,0.0],
|
background : [0.0,0.0,0.0],
|
||||||
second_hand: [1.0,0.0,0.0],
|
second_hand: [1.0,0.0,0.0],
|
||||||
minute_hand: [1.0,1.0,1.0],
|
|
||||||
hour_hand: [1.0,1.0,1.0],
|
|
||||||
numeral:[1.0,1.0,1.0]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "red",
|
name: "red",
|
||||||
background : [1.0,0.0,0.0],
|
background : [1.0,0.0,0.0],
|
||||||
second_hand: [1.0,1.0,0.0],
|
second_hand: [1.0,1.0,0.0],
|
||||||
minute_hand: [1.0,1.0,1.0],
|
|
||||||
hour_hand: [1.0,1.0,1.0],
|
|
||||||
numeral:[1.0,1.0,1.0]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "grey",
|
name: "grey",
|
||||||
background : [0.5,0.5,0.5],
|
background : [0.5,0.5,0.5],
|
||||||
second_hand: [0.0,0.0,0.0],
|
second_hand: [0.0,0.0,0.0],
|
||||||
minute_hand: [1.0,1.0,1.0],
|
|
||||||
hour_hand: [1.0,1.0,1.0],
|
|
||||||
numeral:[1.0,1.0,1.0]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "purple",
|
name: "purple",
|
||||||
background : [1.0,0.0,1.0],
|
background : [1.0,0.0,1.0],
|
||||||
second_hand: [1.0,1.0,0.0],
|
second_hand: [1.0,1.0,0.0],
|
||||||
minute_hand: [1.0,1.0,1.0],
|
|
||||||
hour_hand: [1.0,1.0,1.0],
|
|
||||||
numeral:[1.0,1.0,1.0]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "blue",
|
name: "blue",
|
||||||
background : [0.4,0.7,1.0],
|
background : [0.4,0.7,1.0],
|
||||||
second_hand: [0.5,0.5,0.5],
|
second_hand: [0.5,0.5,0.5],
|
||||||
minute_hand: [1.0,1.0,1.0],
|
|
||||||
hour_hand: [1.0,1.0,1.0],
|
|
||||||
numeral:[1.0,1.0,1.0]
|
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
let color_scheme_index = 0;
|
let color_scheme_index = 0;
|
||||||
|
|
||||||
|
const WHITE = [1.0,1.0,1.0];
|
||||||
|
function default_white(color){
|
||||||
|
if(color == null){
|
||||||
|
return WHITE;
|
||||||
|
} else {
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class Hand {
|
class Hand {
|
||||||
/**
|
/**
|
||||||
* Pure virtual class for all Hand classes to extend.
|
* Pure virtual class for all Hand classes to extend.
|
||||||
|
@ -106,7 +100,7 @@ class ThinHand extends Hand {
|
||||||
g.setColor(background[0],background[1],background[2]);
|
g.setColor(background[0],background[1],background[2]);
|
||||||
g.drawLine(this.centerX, this.centerY, this.last_x, this.last_y);
|
g.drawLine(this.centerX, this.centerY, this.last_x, this.last_y);
|
||||||
// Now draw the new hand line
|
// Now draw the new hand line
|
||||||
var hand_color = color_schemes[color_scheme_index][this.color_theme];
|
var hand_color = default_white(color_schemes[color_scheme_index][this.color_theme]);
|
||||||
g.setColor(hand_color[0],hand_color[1],hand_color[2]);
|
g.setColor(hand_color[0],hand_color[1],hand_color[2]);
|
||||||
var x2 = this.centerX + this.length*Math.sin(angle);
|
var x2 = this.centerX + this.length*Math.sin(angle);
|
||||||
var y2 = this.centerY - this.length*Math.cos(angle);
|
var y2 = this.centerY - this.length*Math.cos(angle);
|
||||||
|
@ -196,7 +190,7 @@ class ThickHand extends Hand {
|
||||||
// top left
|
// top left
|
||||||
var x4 = this.centerX + this.vertex_radius_top*Math.sin(angle - this.delta_top);
|
var x4 = this.centerX + this.vertex_radius_top*Math.sin(angle - this.delta_top);
|
||||||
var y4 = this.centerY - this.vertex_radius_top*Math.cos(angle - this.delta_top);
|
var y4 = this.centerY - this.vertex_radius_top*Math.cos(angle - this.delta_top);
|
||||||
var hand_color = color_schemes[color_scheme_index][this.color_theme];
|
var hand_color = default_white(color_schemes[color_scheme_index][this.color_theme]);
|
||||||
g.setColor(hand_color[0],hand_color[1],hand_color[2]);
|
g.setColor(hand_color[0],hand_color[1],hand_color[2]);
|
||||||
g.fillPoly([x1,y1,
|
g.fillPoly([x1,y1,
|
||||||
x2,y2,
|
x2,y2,
|
||||||
|
@ -275,13 +269,14 @@ var local = require('locale');
|
||||||
var last_date = null;
|
var last_date = null;
|
||||||
var last_datestr = null;
|
var last_datestr = null;
|
||||||
var last_coords = null;
|
var last_coords = null;
|
||||||
var date_coords = [
|
const date_coords = [
|
||||||
{ name: "topright", coords:[180,30]},
|
{ name: "topright", coords:[180,30]},
|
||||||
{ name: "bottomright", coords:[180,220]},
|
{ name: "bottomright", coords:[180,220]},
|
||||||
{ name: "bottomleft", coords: [5,220]},
|
{ name: "bottomleft", coords: [5,220]},
|
||||||
{ name: "topleft", coords:[5,30]},
|
{ name: "topleft", coords:[5,30]},
|
||||||
{ name: "offscreen", coords: [240,30]}
|
{ name: "offscreen", coords: [240,30]}
|
||||||
];
|
];
|
||||||
|
|
||||||
var date_coord_index = 0;
|
var date_coord_index = 0;
|
||||||
|
|
||||||
function draw_date(date){
|
function draw_date(date){
|
||||||
|
@ -297,7 +292,7 @@ function draw_date(date){
|
||||||
var coords = date_coords[date_coord_index].coords;
|
var coords = date_coords[date_coord_index].coords;
|
||||||
if(coords != null) {
|
if(coords != null) {
|
||||||
var date_format = local.dow(date,1) + " " + date.getDate();
|
var date_format = local.dow(date,1) + " " + date.getDate();
|
||||||
var numeral_color = color_schemes[color_scheme_index].numeral;
|
var numeral_color = default_white(color_schemes[color_scheme_index].numeral);
|
||||||
g.setColor(numeral_color[0], numeral_color[1], numeral_color[2]);
|
g.setColor(numeral_color[0], numeral_color[1], numeral_color[2]);
|
||||||
g.drawString(date_format, coords[0], coords[1]);
|
g.drawString(date_format, coords[0], coords[1]);
|
||||||
last_date = date;
|
last_date = date;
|
||||||
|
@ -319,7 +314,7 @@ function next_datecoords() {
|
||||||
function set_datecoords(date_name){
|
function set_datecoords(date_name){
|
||||||
console.log("setting date:" + date_name);
|
console.log("setting date:" + date_name);
|
||||||
for (var i=0; i < date_coords.length; i++) {
|
for (var i=0; i < date_coords.length; i++) {
|
||||||
if(date_coords[i].getName() == date_name){
|
if(date_coords[i].name == date_name){
|
||||||
date_coord_index = i;
|
date_coord_index = i;
|
||||||
force_redraw = true;
|
force_redraw = true;
|
||||||
console.log("date match");
|
console.log("date match");
|
||||||
|
@ -359,9 +354,9 @@ function draw_hours(date){
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We want to be able to change the font so we set up
|
* We want to be able to change the font so we set up
|
||||||
* pure virtual for all fonts implementtions to use
|
* pure virtual for all fonts implementtions to use
|
||||||
*/
|
*/
|
||||||
class NumeralFont {
|
class NumeralFont {
|
||||||
/**
|
/**
|
||||||
* The screen dimensions of what we are going to
|
* The screen dimensions of what we are going to
|
||||||
|
@ -391,27 +386,36 @@ class NoFont extends NumeralFont{
|
||||||
getName(){return "NoFont";}
|
getName(){return "NoFont";}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const COPASET_DIM_20x58 = [20,58];
|
||||||
|
const COPASET_DIM_30x58 = [30,58];
|
||||||
|
const COPASET_DIM_40x58 = [40,58];
|
||||||
|
const COPASET_DIM_50x58 = [50,58];
|
||||||
|
|
||||||
class CopasetFont extends NumeralFont{
|
class CopasetFont extends NumeralFont{
|
||||||
constructor(){
|
constructor(){
|
||||||
super();
|
super();
|
||||||
// dimesion map provides the dimesions of the character for
|
|
||||||
// each number for plotting and collision detection
|
|
||||||
this.dimension_map = {
|
|
||||||
1 : [20,58],
|
|
||||||
2 : [30,58],
|
|
||||||
3 : [30,58],
|
|
||||||
4 : [30,58],
|
|
||||||
5 : [30,58],
|
|
||||||
6 : [40,58],
|
|
||||||
7 : [30,58],
|
|
||||||
8 : [40,58],
|
|
||||||
9 : [40,58],
|
|
||||||
10: [50,58],
|
|
||||||
11: [40,58],
|
|
||||||
12: [40,58]
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
getDimensions(hour){return this.dimension_map[hour];}
|
getDimensions(hour){
|
||||||
|
switch(hour){
|
||||||
|
case 1: return COPASET_DIM_20x58;
|
||||||
|
case 2:
|
||||||
|
case 3:
|
||||||
|
case 4:
|
||||||
|
case 5:
|
||||||
|
case 7:
|
||||||
|
return COPASET_DIM_30x58;
|
||||||
|
case 6:
|
||||||
|
case 8:
|
||||||
|
case 9:
|
||||||
|
case 11:
|
||||||
|
case 12:
|
||||||
|
return COPASET_DIM_40x58;
|
||||||
|
case 10:
|
||||||
|
return COPASET_DIM_50x58;
|
||||||
|
default:
|
||||||
|
return COPASET_DIM_30x58;
|
||||||
|
}
|
||||||
|
}
|
||||||
hour_txt(hour){ return hour.toString(); }
|
hour_txt(hour){ return hour.toString(); }
|
||||||
draw(hour_txt,x,y){
|
draw(hour_txt,x,y){
|
||||||
/* going to leave this in here for future testing.
|
/* going to leave this in here for future testing.
|
||||||
|
@ -432,44 +436,60 @@ class CopasetFont extends NumeralFont{
|
||||||
getName(){return "Copaset";}
|
getName(){return "Copaset";}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const ROMAN_DIM_10x40 = [10,40];
|
||||||
|
const ROMAN_DIM_20x40 = [20,40];
|
||||||
|
const ROMAN_DIM_25x40 = [25,40];
|
||||||
|
const ROMAN_DIM_30x40 = [30,40];
|
||||||
|
const ROMAN_DIM_40x40 = [40,40];
|
||||||
|
const ROMAN_DIM_60x40 = [60,40];
|
||||||
|
const ROMAN_DIM_70x40 = [70,40];
|
||||||
class RomanNumeralFont extends NumeralFont{
|
class RomanNumeralFont extends NumeralFont{
|
||||||
constructor(){
|
constructor(){
|
||||||
super();
|
super();
|
||||||
// text map provides the mapping between hour and roman numeral
|
|
||||||
this.txt_map = {
|
|
||||||
1 : 'I',
|
|
||||||
2 : 'II',
|
|
||||||
3 : 'III',
|
|
||||||
4 : 'IV',
|
|
||||||
5 : 'V',
|
|
||||||
6 : 'VI',
|
|
||||||
7 : 'VII',
|
|
||||||
8 : 'VIII',
|
|
||||||
9 : 'IX',
|
|
||||||
10: 'X',
|
|
||||||
11: 'XI',
|
|
||||||
12: 'XII'
|
|
||||||
};
|
|
||||||
// dimesion map provides the dimesions of the characters for
|
|
||||||
// each hour for plotting and collision detection
|
|
||||||
this.dimension_map = {
|
|
||||||
1 : [10,40],
|
|
||||||
2 : [25,40],
|
|
||||||
3 : [40,40],
|
|
||||||
4 : [40,40],
|
|
||||||
5 : [30,40],
|
|
||||||
6 : [40,40],
|
|
||||||
7 : [60,40],
|
|
||||||
8 : [70,40],
|
|
||||||
9 : [40,40],
|
|
||||||
10: [20,40],
|
|
||||||
11: [40,40],
|
|
||||||
12: [60,40]
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
getDimensions(hour){ return this.dimension_map[hour];}
|
getText(hour){
|
||||||
hour_txt(hour){ return this.txt_map[hour]; }
|
switch (hour){
|
||||||
|
case 1 : return 'I';
|
||||||
|
case 2 : return 'II';
|
||||||
|
case 3 : return 'III';
|
||||||
|
case 4 : return 'IV';
|
||||||
|
case 5 : return 'V';
|
||||||
|
case 6 : return 'VI';
|
||||||
|
case 7 : return 'VII';
|
||||||
|
case 8 : return 'VIII';
|
||||||
|
case 9 : return 'IX';
|
||||||
|
case 10: return 'X';
|
||||||
|
case 11: return 'XI';
|
||||||
|
case 12: return 'XII';
|
||||||
|
default: return '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
getDimensions(hour){
|
||||||
|
switch (hour){
|
||||||
|
case 1:
|
||||||
|
return ROMAN_DIM_10x40;
|
||||||
|
case 2:
|
||||||
|
return ROMAN_DIM_25x40;
|
||||||
|
case 3:
|
||||||
|
case 4:
|
||||||
|
case 6:
|
||||||
|
case 9:
|
||||||
|
case 11:
|
||||||
|
case 12:
|
||||||
|
return ROMAN_DIM_40x40;
|
||||||
|
case 5:
|
||||||
|
return ROMAN_DIM_30x40;
|
||||||
|
case 7:
|
||||||
|
return ROMAN_DIM_60x40;
|
||||||
|
case 8:
|
||||||
|
return ROMAN_DIM_70x40;
|
||||||
|
case 10:
|
||||||
|
return ROMAN_DIM_20x40;
|
||||||
|
default:
|
||||||
|
return ROMAN_DIM_40x40;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
hour_txt(hour){ return this.getText(hour); }
|
||||||
draw(hour_txt,x,y){
|
draw(hour_txt,x,y){
|
||||||
g.setFontAlign(-1,-1,0);
|
g.setFontAlign(-1,-1,0);
|
||||||
g.setFont("Vector",40);
|
g.setFont("Vector",40);
|
||||||
|
@ -515,10 +535,10 @@ function rebasePositive(angle){
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Hour Scriber is responsible for drawing the numeral
|
* The Hour Scriber is responsible for drawing the numeral
|
||||||
* on the screen at the requested angle.
|
* on the screen at the requested angle.
|
||||||
* It allows for the font to be changed on the fly.
|
* It allows for the font to be changed on the fly.
|
||||||
*/
|
*/
|
||||||
class HourScriber {
|
class HourScriber {
|
||||||
constructor(radius, numeral_font, draw_test){
|
constructor(radius, numeral_font, draw_test){
|
||||||
this.radius = radius;
|
this.radius = radius;
|
||||||
|
@ -596,7 +616,7 @@ class HourScriber {
|
||||||
}
|
}
|
||||||
if(changed ||
|
if(changed ||
|
||||||
this.draw_test(this.angle_from, this.angle_to, this.last_draw_time) ){
|
this.draw_test(this.angle_from, this.angle_to, this.last_draw_time) ){
|
||||||
var numeral_color = color_schemes[color_scheme_index].numeral;
|
var numeral_color = default_white(color_schemes[color_scheme_index].numeral);
|
||||||
g.setColor(numeral_color[0],numeral_color[1],numeral_color[2]);
|
g.setColor(numeral_color[0],numeral_color[1],numeral_color[2]);
|
||||||
this.numeral_font.draw(this.curr_hour_str,this.curr_hour_x,this.curr_hour_y);
|
this.numeral_font.draw(this.curr_hour_str,this.curr_hour_x,this.curr_hour_y);
|
||||||
this.last_draw_time = new Date();
|
this.last_draw_time = new Date();
|
||||||
|
@ -608,8 +628,8 @@ class HourScriber {
|
||||||
let numeral_fonts = [new CopasetFont(), new RomanNumeralFont(), new NoFont()];
|
let numeral_fonts = [new CopasetFont(), new RomanNumeralFont(), new NoFont()];
|
||||||
let numeral_fonts_index = 0;
|
let numeral_fonts_index = 0;
|
||||||
/**
|
/**
|
||||||
* predicate for deciding when the digit has to be redrawn
|
* predicate for deciding when the digit has to be redrawn
|
||||||
*/
|
*/
|
||||||
let hour_numeral_redraw = function(angle_from, angle_to, last_draw_time){
|
let hour_numeral_redraw = function(angle_from, angle_to, last_draw_time){
|
||||||
var seconds_hand_angle = seconds_hand.angle;
|
var seconds_hand_angle = seconds_hand.angle;
|
||||||
// we have to cope with the 12 problem where the
|
// we have to cope with the 12 problem where the
|
||||||
|
@ -633,11 +653,11 @@ let hour_numeral_redraw = function(angle_from, angle_to, last_draw_time){
|
||||||
let hour_scriber = new HourScriber(70,
|
let hour_scriber = new HourScriber(70,
|
||||||
numeral_fonts[numeral_fonts_index],
|
numeral_fonts[numeral_fonts_index],
|
||||||
hour_numeral_redraw
|
hour_numeral_redraw
|
||||||
);
|
);
|
||||||
/**
|
/**
|
||||||
* Called from button 1 to change the numerals that are
|
* Called from button 1 to change the numerals that are
|
||||||
* displayed on the clock face
|
* displayed on the clock face
|
||||||
*/
|
*/
|
||||||
function next_font(){
|
function next_font(){
|
||||||
numeral_fonts_index = numeral_fonts_index + 1;
|
numeral_fonts_index = numeral_fonts_index + 1;
|
||||||
if(numeral_fonts_index >= numeral_fonts.length){
|
if(numeral_fonts_index >= numeral_fonts.length){
|
||||||
|
@ -680,9 +700,9 @@ function next_colorscheme(){
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* called from load_settings on startup to
|
* called from load_settings on startup to
|
||||||
* set the color scheme to named value
|
* set the color scheme to named value
|
||||||
*/
|
*/
|
||||||
function set_colorscheme(colorscheme_name){
|
function set_colorscheme(colorscheme_name){
|
||||||
console.log("setting color scheme:" + colorscheme_name);
|
console.log("setting color scheme:" + colorscheme_name);
|
||||||
for (var i=0; i < color_schemes.length; i++) {
|
for (var i=0; i < color_schemes.length; i++) {
|
||||||
|
@ -696,9 +716,9 @@ function set_colorscheme(colorscheme_name){
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* called from load_settings on startup
|
* called from load_settings on startup
|
||||||
* to set the font to named value
|
* to set the font to named value
|
||||||
*/
|
*/
|
||||||
function set_font(font_name){
|
function set_font(font_name){
|
||||||
console.log("setting font:" + font_name);
|
console.log("setting font:" + font_name);
|
||||||
for (var i=0; i < numeral_fonts.length; i++) {
|
for (var i=0; i < numeral_fonts.length; i++) {
|
||||||
|
@ -713,8 +733,8 @@ function set_font(font_name){
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called on startup to set the watch to the last preference settings
|
* Called on startup to set the watch to the last preference settings
|
||||||
*/
|
*/
|
||||||
function load_settings(){
|
function load_settings(){
|
||||||
try{
|
try{
|
||||||
var settings = require("Storage").readJSON("sweepclock.settings.json");
|
var settings = require("Storage").readJSON("sweepclock.settings.json");
|
||||||
|
@ -737,9 +757,15 @@ function load_settings(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function print_memoryusage(){
|
||||||
|
var m = process.memory();
|
||||||
|
var pc = Math.round(m.usage*100/m.total);
|
||||||
|
console.log("memory usage: " + pc + "%");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called on button press to save down the last preference settings
|
* Called on button press to save down the last preference settings
|
||||||
*/
|
*/
|
||||||
function save_settings(){
|
function save_settings(){
|
||||||
var settings = {
|
var settings = {
|
||||||
font : numeral_fonts[numeral_fonts_index].getName(),
|
font : numeral_fonts[numeral_fonts_index].getName(),
|
||||||
|
@ -748,6 +774,7 @@ function save_settings(){
|
||||||
};
|
};
|
||||||
console.log("saving:" + JSON.stringify(settings));
|
console.log("saving:" + JSON.stringify(settings));
|
||||||
require("Storage").writeJSON("sweepclock.settings.json",settings);
|
require("Storage").writeJSON("sweepclock.settings.json",settings);
|
||||||
|
print_memoryusage();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Boiler plate code for setting up the clock,
|
// Boiler plate code for setting up the clock,
|
||||||
|
@ -776,14 +803,12 @@ function scheduleDrawClock(){
|
||||||
}
|
}
|
||||||
|
|
||||||
function reset_clock(){
|
function reset_clock(){
|
||||||
g.clear();
|
|
||||||
force_redraw = true;
|
force_redraw = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Bangle.on('lcdPower', (on) => {
|
Bangle.on('lcdPower', (on) => {
|
||||||
if (on) {
|
if (on) {
|
||||||
console.log("lcdPower: on");
|
console.log("lcdPower: on");
|
||||||
Bangle.drawWidgets();
|
|
||||||
reset_clock();
|
reset_clock();
|
||||||
startTimers();
|
startTimers();
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue