diff --git a/apps.json b/apps.json index 31a88a352..b637d48c9 100644 --- a/apps.json +++ b/apps.json @@ -226,6 +226,7 @@ {"name":"slidingtext.app.js","url":"slidingtext.js"}, {"name":"slidingtext.img","url":"slidingtext-icon.js","evaluate":true}, {"name":"slidingtext.local.en.js","url":"slidingtext.local.en.js"}, + {"name":"slidingtext.local.en2.js","url":"slidingtext.local.en2.js"}, {"name":"slidingtext.local.fr.js","url":"slidingtext.local.fr.js"}, {"name":"slidingtext.local.jp.js","url":"slidingtext.local.jp.js"}, {"name":"slidingtext.dtfmt.js","url":"slidingtext.dtfmt.js"} diff --git a/apps/slidingtext/slidingtext.js b/apps/slidingtext/slidingtext.js index ff07ca5bf..2d91a9fa3 100644 --- a/apps/slidingtext/slidingtext.js +++ b/apps/slidingtext/slidingtext.js @@ -233,17 +233,16 @@ class ShiftText { } } - +const CLOCK_TEXT_SPEED_X = 10; // a list of display rows let row_displays = [ - new ShiftText(240,60,'',"Vector",40,10,1,10,main_color(),bg_color()), - new ShiftText(240,100,'',"Vector",30,10,1,10,other_color(),bg_color()), - new ShiftText(240,130,'',"Vector",30,10,1,10,other_color(),bg_color()), - new ShiftText(240,160,'',"Vector",30,10,1,10,other_color(),bg_color()) + new ShiftText(240,50,'',"Vector",40,CLOCK_TEXT_SPEED_X,1,10,main_color(),bg_color()), + new ShiftText(240,90,'',"Vector",30,CLOCK_TEXT_SPEED_X,1,10,other_color(),bg_color()), + new ShiftText(240,120,'',"Vector",30,CLOCK_TEXT_SPEED_X,1,10,other_color(),bg_color()), + new ShiftText(240,150,'',"Vector",30,CLOCK_TEXT_SPEED_X,1,10,other_color(),bg_color()), + new ShiftText(240,180,'',"Vector",40,CLOCK_TEXT_SPEED_X,1,10,main_color(),bg_color()) ]; - - function nextColorTheme(){ //console.log("next color theme"); color_scheme_index += 1; @@ -261,10 +260,12 @@ function nextColorTheme(){ function setColor(main_color,other_color,bg_color){ row_displays[0].setColor(main_color); row_displays[0].setBgColor(bg_color); - for(var i=1; i= date_formatters.length){ date_formatter_idx = 0; } - //console.log("changing to formatter " + date_formatter_idx); + console.log("changing to formatter " + date_formatter_idx); date_formatter = date_formatters[date_formatter_idx]; reset_clock(); draw_clock(); - // now announce the formatter by name - format_name_display.setTextYPosition(date_formatter.name(),-10); - format_name_display.moveToY(15); - // and then move back - format_name_display.onFinished( - function(){ - format_name_display.moveToY(-10); + command_stack_high_priority.unshift( + function() { + //console.log("move in new:" + txt); + // first select the top or bottom to display the formatter name + // We choose the first spare row without text + var format_name_display = row_displays[row_displays.length - 1]; + if (format_name_display.txt != '') { + format_name_display = row_displays[0]; + } + if (format_name_display.txt != ''){ + return; + } + format_name_display.speed_x = 3; + format_name_display.onFinished(function(){ + format_name_display.speed_x = CLOCK_TEXT_SPEED_X; + console.log("return speed to:" + format_name_display.speed_x) + next_command(); + }); + format_name_display.setTextXPosition(date_formatter.name(),220); + format_name_display.moveToX(-date_formatter.name().length * format_name_display.font_size); } ); + } function reset_clock(){ //console.log("reset_clock"); for (var i = 0; i < row_displays.length; i++) { + row_displays[i].speed_x = CLOCK_TEXT_SPEED_X; row_displays[i].reset(); } reset_commands(); } let last_draw_time = null; -const next_minute_boundary_secs = 5; +const next_minute_boundary_secs = 7.5; function draw_clock(){ var date = new Date(); @@ -362,14 +375,16 @@ function draw_clock(){ function display_row(display,txt){ if(display.txt == ''){ - command_stack_high_priority.unshift( - function(){ - //console.log("move in new:" + txt); - display.onFinished(next_command); - display.setTextXPosition(txt,240); - display.moveToX(20); - } - ); + if(txt != '') { + command_stack_high_priority.unshift( + function () { + //console.log("move in new:" + txt); + display.onFinished(next_command); + display.setTextXPosition(txt, 240); + display.moveToX(20); + } + ); + } } else if(txt != display.txt && display.txt != null){ command_stack_high_priority.push( function(){