Sliding Clock: get rid of the setup variables after the init to reduce the memory footprint

master
Adrian Kirk 2022-10-08 19:57:32 +01:00
parent ebc8d1ba8a
commit c09dd1af5a
No known key found for this signature in database
GPG Key ID: 5A448EB0FC623526
2 changed files with 28 additions and 23 deletions

View File

@ -265,7 +265,7 @@ function bangleVersion(){
return (g.getHeight()>200)? 1 : 2; return (g.getHeight()>200)? 1 : 2;
} }
const row_types = { var row_types = {
large: { large: {
color: 'major', color: 'major',
speed: 'medium', speed: 'medium',
@ -314,11 +314,11 @@ function initDisplay(settings) {
row_displays.push(create_row(row_type,j)); row_displays.push(create_row(row_type,j));
} }
}); });
initComplete();
} }
function mergeMaps(map1,map2){ function mergeMaps(map1,map2){
if(map2 == null){ if(map2 == null){
console.log("no merge:" + map2);
return; return;
} }
Object.keys(map2).forEach(key => { Object.keys(map2).forEach(key => {
@ -336,10 +336,7 @@ function mergeObjects(obj1, obj2){
return result; return result;
} }
var heights = {
const heights = {
tiny: [14,11],
vvsmall: [15,13], vvsmall: [15,13],
vsmall: [20,15], vsmall: [20,15],
ssmall: [22,17], ssmall: [22,17],
@ -351,14 +348,14 @@ const heights = {
vlarge: [60,50] vlarge: [60,50]
}; };
const rotations = { var rotations = {
0: 0, 0: 0,
90: 3, 90: 3,
180: 2, 180: 2,
270: 1, 270: 1,
}; };
const speeds = { var speeds = {
fast: 20, fast: 20,
medium: 10, medium: 10,
slow: 5, slow: 5,
@ -447,6 +444,13 @@ function create_row_type(row_type, row_def){
}; };
} }
function initComplete(){
row_types = null;
speeds = null;
rotations = null;
heights = null;
}
function create_row(row_type, row_no){ function create_row(row_type, row_no){
return new ShiftText(row_type.x(row_no), return new ShiftText(row_type.x(row_no),
row_type.y(row_no), row_type.y(row_no),
@ -605,7 +609,6 @@ function setColorScheme(colorscheme_name){
for (var i=0; i < color_schemes.length; i++) { for (var i=0; i < color_schemes.length; i++) {
if(color_schemes[i].name === colorscheme_name){ if(color_schemes[i].name === colorscheme_name){
color_scheme_index = i; color_scheme_index = i;
console.log("match");
updateColorScheme(); updateColorScheme();
break; break;
} }

View File

@ -8,10 +8,17 @@ const monthToText = require("slidingtext.utils.en.js").monthToText;
class EnglishDateFormatter extends DateFormatter { class EnglishDateFormatter extends DateFormatter {
constructor() { constructor() {
super(); super();
this.row_types = { }
small: {size: 'ssmall'} formatDate(date){
}; const hours_txt = hoursToText(date.getHours());
this.row_defs = [ const mins_txt = numberToText(date.getMinutes());
const day_of_week = dayOfWeek(date);
const date_txt = numberToDayNumberText(date.getDate()).join(' ');
const month = monthToText(date);
return [hours_txt,mins_txt[0],mins_txt[1],day_of_week,date_txt,month];
}
defaultRowTypes(){
return [
{ {
type: 'large', type: 'large',
init_coords: [0.05,0.07], init_coords: [0.05,0.07],
@ -32,17 +39,12 @@ class EnglishDateFormatter extends DateFormatter {
} }
]; ];
} }
formatDate(date){
const hours_txt = hoursToText(date.getHours());
const mins_txt = numberToText(date.getMinutes());
const day_of_week = dayOfWeek(date);
const date_txt = numberToDayNumberText(date.getDate()).join(' ');
const month = monthToText(date);
return [hours_txt,mins_txt[0],mins_txt[1],day_of_week,date_txt,month];
}
defaultRowTypes(){ return this.row_types;}
defaultRowDefs(){ return this.row_defs; } defaultRowDefs(){
return {
small: {size: 'ssmall'}
};
}
} }
module.exports = EnglishDateFormatter; module.exports = EnglishDateFormatter;