mirror of https://github.com/espruino/BangleApps
slidingtext 0.07: Support for Bangle.js 2 and themes
parent
ee60bda59b
commit
c88614399d
|
@ -258,7 +258,7 @@
|
||||||
{ "id": "slidingtext",
|
{ "id": "slidingtext",
|
||||||
"name": "Sliding Clock",
|
"name": "Sliding Clock",
|
||||||
"icon": "slidingtext.png",
|
"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",
|
"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",
|
"tags": "clock",
|
||||||
"type":"clock",
|
"type":"clock",
|
||||||
|
|
|
@ -4,3 +4,4 @@
|
||||||
0.04: Added German Language
|
0.04: Added German Language
|
||||||
0.05: BUGFIX: pedometer widget interfered with the clock Font Alignment
|
0.05: BUGFIX: pedometer widget interfered with the clock Font Alignment
|
||||||
0.06: Use Bangle.setUI for button/launcher handling
|
0.06: Use Bangle.setUI for button/launcher handling
|
||||||
|
0.07: Support for Bangle.js 2 and themes
|
||||||
|
|
|
@ -146,12 +146,6 @@ class ShiftText {
|
||||||
//console.log("bgcolor:" + this.bg_color);
|
//console.log("bgcolor:" + this.bg_color);
|
||||||
g.setColor(this.bg_color[0],this.bg_color[1],this.bg_color[2]);
|
g.setColor(this.bg_color[0],this.bg_color[1],this.bg_color[2]);
|
||||||
g.drawString(this.txt, this.x, this.y);
|
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){
|
setText(txt){
|
||||||
this.txt = txt;
|
this.txt = txt;
|
||||||
|
@ -239,13 +233,21 @@ class ShiftText {
|
||||||
|
|
||||||
const CLOCK_TEXT_SPEED_X = 10;
|
const CLOCK_TEXT_SPEED_X = 10;
|
||||||
// a list of display rows
|
// a list of display rows
|
||||||
let row_displays = [
|
let row_displays;
|
||||||
new ShiftText(240,50,'',"Vector",40,CLOCK_TEXT_SPEED_X,1,10,main_color(),bg_color()),
|
function setRowDisplays(y, heights) {
|
||||||
new ShiftText(240,90,'',"Vector",30,CLOCK_TEXT_SPEED_X,1,10,other_color(),bg_color()),
|
var cols = [
|
||||||
new ShiftText(240,120,'',"Vector",30,CLOCK_TEXT_SPEED_X,1,10,other_color(),bg_color()),
|
main_color(), other_color(), other_color(), other_color(), main_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())
|
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(){
|
function nextColorTheme(){
|
||||||
//console.log("next color theme");
|
//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].setColor(main_color);
|
||||||
row_displays[row_displays.length - 1].setBgColor(bg_color);
|
row_displays[row_displays.length - 1].setBgColor(bg_color);
|
||||||
g.setColor(bg_color[0],bg_color[1],bg_color[2]);
|
g.setColor(bg_color[0],bg_color[1],bg_color[2]);
|
||||||
g.fillPoly([0,25,
|
g.fillRect(0,24, g.getWidth(), g.getHeight());
|
||||||
0,240,
|
|
||||||
240,240,
|
|
||||||
240,25
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// load the date formats and laguages required
|
// 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
|
* Called on startup to set the watch to the last preference settings
|
||||||
*/
|
*/
|
||||||
function load_settings(){
|
function load_settings(){
|
||||||
|
var setScheme = false;
|
||||||
try{
|
try{
|
||||||
settings = require("Storage").readJSON(PREFERENCE_FILE);
|
settings = require("Storage").readJSON(PREFERENCE_FILE);
|
||||||
if(settings != null){
|
if(settings != null){
|
||||||
console.log("loaded:" + JSON.stringify(settings));
|
console.log("loaded:" + JSON.stringify(settings));
|
||||||
if(settings.color_scheme != null){
|
if(settings.color_scheme != null){
|
||||||
set_colorscheme(settings.color_scheme);
|
set_colorscheme(settings.color_scheme);
|
||||||
|
setScheme = true;
|
||||||
}
|
}
|
||||||
if(settings.date_format != null){
|
if(settings.date_format != null){
|
||||||
set_dateformat(settings.date_format);
|
set_dateformat(settings.date_format);
|
||||||
|
@ -526,6 +526,9 @@ function load_settings(){
|
||||||
} catch(e){
|
} catch(e){
|
||||||
console.log("failed to load settings:" + 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();
|
startTimers();
|
||||||
// Show launcher when button pressed
|
// Show launcher when button pressed
|
||||||
Bangle.setUI("clock");
|
Bangle.setUI("clockupdown", d=>{
|
||||||
|
if (d<0) button1pressed();
|
||||||
|
if (d>0) button3pressed();
|
||||||
// Handle button 1 being pressed
|
});
|
||||||
setWatch(button1pressed, BTN1,{repeat:true,edge:"falling"});
|
|
||||||
|
|
||||||
// Handle button 3 being pressed
|
|
||||||
setWatch(button3pressed, BTN3,{repeat:true,edge:"falling"});
|
|
||||||
|
|
Loading…
Reference in New Issue