Sliding Clock: Added hybrid clock

pull/2178/head
Adrian Kirk 2022-10-11 21:09:55 +01:00
parent 8ed98163e7
commit f8f064d459
No known key found for this signature in database
GPG Key ID: 5A448EB0FC623526
3 changed files with 83 additions and 6 deletions

View File

@ -322,7 +322,7 @@ function initDisplay(settings) {
const row_type_overide = date_formatter.defaultRowTypes();
mergeMaps(row_types,row_type_overide);
mergeMaps(row_types,settings.row_types);
const row_defs = (settings.row_defs != null && settings.row_defs.length > 0)?
var row_defs = (settings.row_defs != null && settings.row_defs.length > 0)?
settings.row_defs : date_formatter.defaultRowDefs();
var heights = {
@ -334,7 +334,8 @@ function initDisplay(settings) {
medium: [40,25],
mlarge: [45,35],
large: [50,40],
vlarge: [60,50]
vlarge: [60,50],
slarge: [100,90]
};
var rotations = {
@ -451,6 +452,7 @@ function initDisplay(settings) {
}
});
// dereference the setup variables to release the memory
row_defs = null;
row_types = null;
heights = null;
rotations = null;

View File

@ -0,0 +1,73 @@
const DateFormatter = require("slidingtext.dtfmt.js");
const numberToText = require("slidingtext.utils.en.js").numberToText;
const dayOfWeek = require("slidingtext.utils.en.js").dayOfWeek;
class EnglishDateFormatter extends DateFormatter {
constructor() {
super();
}
format00(num){
const 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(date){
const hours_txt = this.format00(date.getHours());
const mins_txt = numberToText(date.getMinutes());
const day_of_week = dayOfWeek(date);
const date_txt = day_of_week + " " + this.format00(date.getDate());
return [hours_txt,mins_txt[0],mins_txt[1],date_txt];
}
defaultRowTypes() {
return {
large: {
size: 'slarge',
scroll_off: ['left','down'],
scroll_in: ['up','left'],
},
medium: {
scroll_off: ['down'],
scroll_in: ['up'],
angle_to_horizontal: 90
},
small: {
size: 'ssmall',
scroll_off: ['left','right'],
scroll_in: ['left','right'],
}
};
}
defaultRowDefs(){
return [
{
type: 'large',
init_coords: [0.05,0.35],
row_direction: [0.0,1.0],
rows: 1
},
{
type: 'medium',
init_coords: [0.7,0.95],
row_direction: [1.0,0.0],
angle_to_horizontal: 90,
rows: 2
},
{
type: 'small',
init_coords: [0.05, 0.1],
row_direction: [0.0, 1.0],
rows: 1
}
];
}
}
module.exports = EnglishDateFormatter;

View File

@ -10,7 +10,7 @@
console.log("loaded:" + JSON.stringify(settings));
const locale_mappings = (bangleVersion > 1)? {
'en' : { date_formatter: 'en' },
'en p': {
'en alt': {
date_formatter: 'en',
row_types: {
large:{
@ -53,7 +53,7 @@
]
},
'en2': { date_formatter: 'en2' },
'en2 p': { date_formatter: 'en2',
'en2 alt': { date_formatter: 'en2',
row_types: {
vsmall: {
color: 'minor',
@ -109,14 +109,16 @@
'de': { date_formatter: 'de'},
'es': { date_formatter: 'es'},
'jp': { date_formatter: 'jp'},
'dgt': { date_formatter: 'dgt'},
'hybrid': { date_formatter: 'hyb'},
'digits': { date_formatter: 'dgt'},
} : {
'en' : { date_formatter: 'en' },
'fr': { date_formatter:'fr'},
'de': { date_formatter: 'de'},
'es': { date_formatter: 'es'},
'jp': { date_formatter: 'jp'},
'dgt': { date_formatter: 'dgt'},
'hybrid': { date_formatter: 'hyb'},
'digits': { date_formatter: 'dgt'},
}
const locales = Object.keys(locale_mappings);