slidingtext 0.07: Support for Bangle.js 2 and themes

pull/830/head
Gordon Williams 2021-09-29 09:19:43 +01:00
parent ee60bda59b
commit c88614399d
3 changed files with 27 additions and 27 deletions

View File

@ -258,7 +258,7 @@
{ "id": "slidingtext",
"name": "Sliding Clock",
"icon": "slidingtext.png",
"version":"0.06",
"version":"0.07",
"description": "Inspired by the Pebble sliding clock, old times are scrolled off the screen and new times on. You are also able to change language on the fly so you can see the time written in other languages using button 1. Currently English, French, Japanese, Spanish and German are supported",
"tags": "clock",
"type":"clock",

View File

@ -4,3 +4,4 @@
0.04: Added German Language
0.05: BUGFIX: pedometer widget interfered with the clock Font Alignment
0.06: Use Bangle.setUI for button/launcher handling
0.07: Support for Bangle.js 2 and themes

View File

@ -146,12 +146,6 @@ class ShiftText {
//console.log("bgcolor:" + this.bg_color);
g.setColor(this.bg_color[0],this.bg_color[1],this.bg_color[2]);
g.drawString(this.txt, this.x, this.y);
/*g.fillPoly([this.x - 1, this.y,
240, this.y,
240, this.y + this.font_size,
this.x -1 , this.y + this.font_size,
]);
*/
}
setText(txt){
this.txt = txt;
@ -239,13 +233,21 @@ class ShiftText {
const CLOCK_TEXT_SPEED_X = 10;
// a list of display rows
let row_displays = [
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())
];
let row_displays;
function setRowDisplays(y, heights) {
var cols = [
main_color(), other_color(), other_color(), other_color(), main_color()
];
row_displays = [];
for (var i=0;i<heights.length;i++) {
row_displays.push(new ShiftText(g.getWidth(),y,'',"Vector",heights[i],CLOCK_TEXT_SPEED_X,1,10,cols[i],bg_color()));
y += heights[i];
}
}
if (g.getHeight()>200)
setRowDisplays(50, [40,30,30,30,40]);
else
setRowDisplays(34, [35,25,25,25,35]);
function nextColorTheme(){
//console.log("next color theme");
@ -274,11 +276,7 @@ function setColor(main_color,other_color,bg_color){
row_displays[row_displays.length - 1].setColor(main_color);
row_displays[row_displays.length - 1].setBgColor(bg_color);
g.setColor(bg_color[0],bg_color[1],bg_color[2]);
g.fillPoly([0,25,
0,240,
240,240,
240,25
]);
g.fillRect(0,24, g.getWidth(), g.getHeight());
}
// load the date formats and laguages required
@ -510,12 +508,14 @@ const PREFERENCE_FILE = "slidingtext.settings.json";
* Called on startup to set the watch to the last preference settings
*/
function load_settings(){
var setScheme = false;
try{
settings = require("Storage").readJSON(PREFERENCE_FILE);
if(settings != null){
console.log("loaded:" + JSON.stringify(settings));
if(settings.color_scheme != null){
set_colorscheme(settings.color_scheme);
setScheme = true;
}
if(settings.date_format != null){
set_dateformat(settings.date_format);
@ -526,6 +526,9 @@ function load_settings(){
} catch(e){
console.log("failed to load settings:" + e);
}
// just set up as default
if (!setScheme)
setColorScheme(color_schemes[color_scheme_index]);
}
/**
@ -636,11 +639,7 @@ Bangle.drawWidgets();
startTimers();
// Show launcher when button pressed
Bangle.setUI("clock");
// Handle button 1 being pressed
setWatch(button1pressed, BTN1,{repeat:true,edge:"falling"});
// Handle button 3 being pressed
setWatch(button3pressed, BTN3,{repeat:true,edge:"falling"});
Bangle.setUI("clockupdown", d=>{
if (d<0) button1pressed();
if (d>0) button3pressed();
});