mirror of https://github.com/espruino/BangleApps
SLiding Clock: Added digital clock
parent
bc407c57e7
commit
d71bf76dd1
|
@ -339,11 +339,12 @@ function mergeObjects(obj1, obj2){
|
|||
|
||||
|
||||
const heights = {
|
||||
vvsmall: [20,15],
|
||||
vsmall: [22,17],
|
||||
vvsmall: [15,13],
|
||||
vsmall: [20,15],
|
||||
small: [25,20],
|
||||
msmall: [30,22],
|
||||
medium: [40,25],
|
||||
mlarge: [45,35],
|
||||
large: [50,40],
|
||||
vlarge: [60,50]
|
||||
};
|
||||
|
@ -511,6 +512,7 @@ function display_time(date){
|
|||
|
||||
function drawClock(){
|
||||
var date = new Date();
|
||||
date.setHours(12);
|
||||
|
||||
// we don't want the time to be displayed
|
||||
// and then immediately be trigger another time
|
||||
|
@ -652,8 +654,12 @@ function setDateformat(shortname){
|
|||
console.log("setting date format:" + shortname);
|
||||
try {
|
||||
if (date_formatter == null || date_formatter.shortName() !== shortname) {
|
||||
var date_formatter_class = require("slidingtext.locale." + shortname + ".js");
|
||||
date_formatter = new date_formatter_class();
|
||||
if(shortname === "default"){
|
||||
date_formatter = new DigitDateTimeFormatter();
|
||||
} else {
|
||||
var date_formatter_class = require("slidingtext.locale." + shortname + ".js");
|
||||
date_formatter = new date_formatter_class();
|
||||
}
|
||||
}
|
||||
} catch(e){
|
||||
console.log("Failed to load " + shortname);
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
const Locale = require('locale');
|
||||
|
||||
class DigitDateTimeFormatter {
|
||||
constructor() {
|
||||
this.row_types = {
|
||||
large: {
|
||||
scroll_off: ['down'],
|
||||
scroll_in: ['up'],
|
||||
size: 'large',
|
||||
speed: 'vslow'
|
||||
},
|
||||
small: {
|
||||
angle_to_horizontal: 0,
|
||||
scroll_off: ['left'],
|
||||
scroll_in: ['right'],
|
||||
}
|
||||
};
|
||||
|
||||
this.row_defs = [
|
||||
{
|
||||
type: 'large',
|
||||
row_direction: [0.8,0.0],
|
||||
init_coords: [0.1,0.35],
|
||||
rows: 5
|
||||
},
|
||||
{
|
||||
type: 'small',
|
||||
row_direction: [0.0,1.0],
|
||||
init_coords: [0.1,0.05],
|
||||
rows: 1
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
format00(num){
|
||||
var value = (num | 0);
|
||||
if(value > 99 || value < 0)
|
||||
throw "must be between in range 0-99";
|
||||
if(value < 10)
|
||||
return "0" + value.toString();
|
||||
else
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
formatDate(now){
|
||||
var hours = now.getHours() ;
|
||||
var time_txt = this.format00(hours) + ":" + this.format00(now.getMinutes());
|
||||
var date_txt = Locale.dow(now,1) + " " + this.format00(now.getDate());
|
||||
return [time_txt[0], time_txt[1],time_txt[2], time_txt[3],time_txt[4],date_txt];
|
||||
}
|
||||
|
||||
defaultRowTypes(){ return this.row_types; }
|
||||
|
||||
defaultRowDefs() { return this.row_defs; }
|
||||
}
|
||||
|
||||
module.exports = DigitDateTimeFormatter;
|
|
@ -56,7 +56,7 @@ class EnglishTraditionalDateFormatter extends DateFormatter {
|
|||
speed: 'superslow',
|
||||
scroll_off: ['down'],
|
||||
scroll_in: ['up'],
|
||||
size: 'vsmall',
|
||||
size: 'vvsmall',
|
||||
angle_to_horizontal: 90
|
||||
},
|
||||
small: {
|
||||
|
@ -69,6 +69,7 @@ class EnglishTraditionalDateFormatter extends DateFormatter {
|
|||
color: 'major',
|
||||
scroll_off: ['left'],
|
||||
scroll_in: ['left'],
|
||||
size: 'mlarge',
|
||||
angle_to_horizontal: 0
|
||||
}
|
||||
};
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
date_formatter: 'en',
|
||||
row_types: {
|
||||
large:{
|
||||
size: 'medium',
|
||||
size: 'mlarge',
|
||||
angle_to_horizontal: 90,
|
||||
scroll_off: ['down'],
|
||||
scroll_in: ['up'],
|
||||
|
@ -25,7 +25,7 @@
|
|||
row_defs: [
|
||||
{
|
||||
type: 'large',
|
||||
init_coords: [0.05,0.95],
|
||||
init_coords: [0.05,0.99],
|
||||
row_direction: [1.0,0.0],
|
||||
rows: 1
|
||||
},
|
||||
|
@ -90,6 +90,7 @@
|
|||
'de': { date_formatter: 'de'},
|
||||
'es': { date_formatter: 'es'},
|
||||
'jp': { date_formatter: 'jp'},
|
||||
'dgt': { date_formatter: 'dgt'},
|
||||
}
|
||||
var locales = Object.keys(locale_mappings);
|
||||
|
||||
|
|
Loading…
Reference in New Issue