mirror of https://github.com/espruino/BangleApps
Merge branch 'master' of github.com:espruino/BangleApps
commit
735ab75b39
|
@ -27,4 +27,5 @@ widgets would still be loaded when they weren't supposed to.
|
|||
immediately follows the correct theme.
|
||||
0.22: Bangle 2: Change to not automatically marking the first app on a page
|
||||
when moving pages. Add caching for faster startups.
|
||||
0.23: Bangle 1: Fix issue with missing icons, added touch screen interactions
|
||||
|
||||
|
|
|
@ -6,6 +6,10 @@ Bangle 1:
|
|||
|
||||
In the picture above, the Settings app is selected.
|
||||
|
||||
|
||||

|
||||
|
||||
|
||||
Bangle 2:
|
||||
|
||||

|
||||
|
@ -25,6 +29,12 @@ Bangle 2:
|
|||
|
||||
**Swipe Right** - move to previous page of app icons
|
||||
|
||||
**Touch Left(1) area** - "Back" to Clock
|
||||
|
||||
**Touch Right(2) area** - move forward through app icons
|
||||
|
||||
**Touch Middle(1+2) area** - run the selected app
|
||||
|
||||
## Controls- Bangle 2
|
||||
|
||||
**Touch** - icon to select, second touch launches app
|
||||
|
|
|
@ -13,13 +13,13 @@ function wdog(handle,timeout){
|
|||
wdog.timeout = timeout;
|
||||
}
|
||||
if(wdog.timer){
|
||||
clearTimeout(wdog.timer)
|
||||
clearTimeout(wdog.timer);
|
||||
}
|
||||
wdog.timer = setTimeout(wdog.handle,wdog.timeout)
|
||||
wdog.timer = setTimeout(wdog.handle,wdog.timeout);
|
||||
}
|
||||
|
||||
// reset after two minutes of inactivity
|
||||
wdog(load,120000)
|
||||
wdog(load,120000);
|
||||
|
||||
var s = require("Storage");
|
||||
var apps = s.list(/\.info$/).map(app=>{
|
||||
|
@ -49,7 +49,13 @@ function draw_icon(p,n,selected) {
|
|||
var y = n>2?130:40;
|
||||
(selected?g.setColor(0.3,0.3,0.3):g.setColor(0,0,0)).fillRect(x,y,x+79,y+89);
|
||||
g.setColor(g.theme.fg);
|
||||
g.drawImage(s.read(apps[p*6+n].icon),x+10,y+10,{scale:1.25});
|
||||
//bad g.drawImage(s.read(apps[p*6+n].icon),x+10,y+10,{scale:1.25});
|
||||
if ((apps[p*6+n].icon)){
|
||||
if (s.read(apps[p*6+n].icon)) //ensure that graph exist
|
||||
g.drawImage(s.read(apps[p*6+n].icon),x+10,y+10,{scale:1.25});
|
||||
else console.log("icon file NOT exist :"+apps[p*6+n].icon);
|
||||
}
|
||||
else console.log("icon property NOT exist");
|
||||
g.setColor(-1).setFontAlign(0,-1,0).setFont("6x8",1);
|
||||
var txt = apps[p*6+n].name.split(" ");
|
||||
for (var i = 0; i < txt.length; i++) {
|
||||
|
@ -65,10 +71,31 @@ function drawPage(p){
|
|||
if (!apps[p*6+i]) return i;
|
||||
draw_icon(p,i,selected==i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// case was not working
|
||||
Bangle.on("touch", function(tzone){
|
||||
//(tzone)=>{
|
||||
//console.log("tzone"+tzone);
|
||||
switch(tzone){
|
||||
case 1: //left managed by
|
||||
console.log("1, left or back to clock?");
|
||||
load();//clock
|
||||
//nextapp(-1);
|
||||
break;
|
||||
case 2: // right
|
||||
nextapp(1);
|
||||
break;
|
||||
case 3: //center 1+2 no for emul
|
||||
doselect();
|
||||
break;
|
||||
default:
|
||||
console.log("no match");
|
||||
}
|
||||
});
|
||||
|
||||
Bangle.on("swipe",(dir)=>{
|
||||
wdog()
|
||||
wdog();
|
||||
selected = 0;
|
||||
oldselected=-1;
|
||||
if (dir<0){
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"id": "dtlaunch",
|
||||
"name": "Desktop Launcher",
|
||||
"version": "0.22",
|
||||
"version": "0.23",
|
||||
"description": "Desktop style App Launcher with six (four for Bangle 2) apps per page - fast access if you have lots of apps installed.",
|
||||
"screenshots": [{"url":"shot1.png"},{"url":"shot2.png"},{"url":"shot3.png"}],
|
||||
"icon": "icon.png",
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 5.0 KiB |
|
@ -1,2 +1,3 @@
|
|||
0.01: 1st version !
|
||||
0.02: Supports bottom widgets and UI based in UI4swatch!
|
||||
0.03: Added compatibility with BJS2, improvements
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
A cross cultural hello world!/hola mundo! app
|
||||
The most common testing sentence in several languages ;)
|
||||
|
||||
|
||||
## Pictures:
|
||||
|
||||
Launcher icon
|
||||
|
@ -14,6 +13,10 @@ Screen - Spanish
|
|||
|
||||

|
||||
|
||||
Screenshot BJS2 emul
|
||||
|
||||

|
||||
|
||||
Screen - English
|
||||
|
||||

|
||||
|
@ -22,6 +25,10 @@ Screen - Japanese
|
|||
|
||||

|
||||
|
||||
Screenshot BJS1 emul
|
||||
|
||||

|
||||
|
||||
|
||||
|
||||
## Usage
|
||||
|
@ -31,17 +38,32 @@ interact to change language, color or quit.
|
|||
|
||||
## Features
|
||||
|
||||
Colours, all inputs , graph, widgets loaded
|
||||
Counter for Times Display
|
||||
- Compatible Bangle.js1 Bangle.js2
|
||||
- Bottom Widget compatible
|
||||
- Change FG/BG colors,
|
||||
- Usage of many input events
|
||||
|
||||
|
||||
## Controls
|
||||
## Pending/future Features
|
||||
- replace UI hardcoded colors for dynamic based on theme
|
||||
- BJS2 change BTN1 from quit to Change FG Color (conflict wit setUI?)
|
||||
|
||||
finger swipe
|
||||
button 1,2 and 3
|
||||
touch screen left, center or right
|
||||
|
||||
## Controls/UI
|
||||
- Left area: Back/Exit/launcher
|
||||
- BTN3 (long press)(BJS1): default Exit/kill app
|
||||
|
||||
- BTN1 (BJS2): Back/Exit/launcher
|
||||
- BTN1 (BJS1): Change Language
|
||||
- BTN2 (BJS1): Change FG Color
|
||||
- BTN3 (BJS1): Quit
|
||||
|
||||
- Right area: Change BG Color
|
||||
- Swipe left: Change Language
|
||||
- Swipe right: Change Language
|
||||
|
||||
|
||||
## Creator
|
||||
|
||||
Daniel Perez
|
||||
This app is so basic that probably the easiest is to just edit the code
|
||||
Otherwise you can contact me [here](https://github.com/dapgo/my_espruino_smartwatch_things)
|
|
@ -1,40 +1,62 @@
|
|||
//HolaMundo v202103
|
||||
//HolaMundo v202212
|
||||
// place your const, vars, functions or classes here
|
||||
{
|
||||
var contador=1;
|
||||
var v_color_statictxt='#e56e06';
|
||||
var v_color_b_area='#111111'; //orange RGB format rrggbb //white,Orange,DarkGreen,Yellow,Maroon,Blue,green,Purple,cyan,olive,DarkCyan,pink
|
||||
var v_mode_debug=0;
|
||||
var v_model=process.env.BOARD;
|
||||
|
||||
var v_color_statictxt='#b30000';
|
||||
//var v_color_b_area='#111111';
|
||||
//orange RGB format rrggbb //white,Orange,DarkGreen,Yellow,Maroon,Blue,green,Purple,cyan,olive,DarkCyan,pink
|
||||
var a_colors= Array(0xFFFF,0xFD20,0x03E0,0xFFE0,0x7800,0x001F,0x07E0,0x780F,0x07FF,0x7BE0,0x03EF,0xF81F);
|
||||
|
||||
var x_max_screen=g.getWidth();
|
||||
var y_max_screen=g.getHeight();
|
||||
var y_wg_bottom=g.getHeight()-25;
|
||||
var y_wg_top=25;
|
||||
|
||||
//EMSCRIPTEN,EMSCRIPTEN2
|
||||
if (v_model=='BANGLEJS'||v_model=='EMSCRIPTEN') {
|
||||
var v_color_lines=0xFFFF; //White hex format
|
||||
//new
|
||||
var v_color_text=0x07E0;
|
||||
var v_color_text=0x07E0;
|
||||
var v_font1size=10; //out of quotes
|
||||
var v_font2size=12;
|
||||
var v_font_banner_size=30;
|
||||
var v_font3size=12;
|
||||
var x_btn_area=215;
|
||||
var x_max_usable_area=x_btn_area;//Pend! only for bangle.js
|
||||
var y_btn2=124; //harcoded for bangle.js cuz it is not the half of display height
|
||||
var graph_y=120;
|
||||
var box_x2=195;
|
||||
var box_y2=150;
|
||||
}else{ //BJS2
|
||||
//176x176
|
||||
var v_color_lines="#000"; //White hex format
|
||||
var v_color_text="#000";
|
||||
var v_font1size=9; //out of quotes
|
||||
var v_font2size=9;
|
||||
var v_font_banner_size=16;
|
||||
var v_font3size=8;
|
||||
//g.setColor("#000"); //black or dark
|
||||
x_max_usable_area=176;
|
||||
var graph_y=60;
|
||||
var box_x2=128;
|
||||
var box_y2=104;
|
||||
}
|
||||
if (v_mode_debug>0) console.log("device="+v_model);
|
||||
var v_arraypos=0;
|
||||
var v_acolorpos=0;
|
||||
var v_acolorpos=0; //for fg
|
||||
var v_aBGcolorPos=5; //for bg
|
||||
var a_string1 = Array('hola', 'hello', 'saluton', 'ola','ciao', 'salut','czesc','konnichiwa');
|
||||
var a_string2 = Array('mundo!', 'world!', 'mondo!','mundo!','mondo!','monde!','swiat!','sekai!');
|
||||
var mem=process.memory();
|
||||
var v_model=process.env.BOARD;
|
||||
console.log("device="+v_model);
|
||||
|
||||
var x_max_screen=g.getWidth();//240;
|
||||
var y_max_screen=g.getHeight(); //240;
|
||||
var y_wg_bottom=g.getHeight()-25;
|
||||
var y_wg_top=25;
|
||||
if (v_model=='BANGLEJS') {
|
||||
var x_btn_area=215;
|
||||
var x_max_usable_area=x_btn_area;//Pend! only for bangle.js
|
||||
var y_btn2=124; //harcoded for bangle.js cuz it is not the half of display height
|
||||
} else x_max_usable_area=240;
|
||||
|
||||
|
||||
}
|
||||
|
||||
console.log("*** UI dimensions***");
|
||||
console.log("x="+x_max_screen);
|
||||
console.log("y_wg_bottom="+y_wg_bottom);
|
||||
|
||||
if (v_mode_debug>0) {
|
||||
console.log("*** UI dimensions***");
|
||||
console.log("x="+x_max_screen);
|
||||
console.log("y_wg_bottom="+y_wg_bottom);
|
||||
}
|
||||
|
||||
// special function to handle display switch on
|
||||
Bangle.on('lcdPower', (on) => {
|
||||
|
@ -47,17 +69,15 @@
|
|||
});
|
||||
|
||||
//Clear/fill dynamic area except widget area, right and bottom status line
|
||||
function ClearActiveArea(){
|
||||
g.setColor(v_color_b_area);
|
||||
//harcoded values to avoid clearing areas
|
||||
g.fillRect(0,y_wg_top,195,150);
|
||||
function ClearActiveArea(){
|
||||
g.setColor(a_colors[v_aBGcolorPos]); //dynamic color
|
||||
g.fillRect(0,y_wg_top,box_x2,box_y2);
|
||||
g.flip();
|
||||
}
|
||||
|
||||
function DrawBangleButtons(){
|
||||
g.setFontVector(v_font1size);
|
||||
g.setColor(v_color_lines);//White
|
||||
|
||||
g.setColor(v_color_lines);//White
|
||||
|
||||
g.drawString("Lang", x_max_screen-g.stringWidth("Lang"),y_wg_top+v_font1size+1);
|
||||
//above Btn2
|
||||
|
@ -93,7 +113,7 @@ function DrawBottomInfoBanner(){
|
|||
function PrintHelloWorld(){
|
||||
ClearActiveArea(); //except widgets and bottom
|
||||
|
||||
console.log("drawing a "+a_string1[v_arraypos]+" "+a_string2[v_arraypos]);
|
||||
if (v_mode_debug>0) console.log("drawing a "+a_string1[v_arraypos]+" "+a_string2[v_arraypos]);
|
||||
|
||||
g.setColor(a_colors[v_acolorpos]); //dynamic color
|
||||
g.setFont("Vector",v_font_banner_size);
|
||||
|
@ -106,55 +126,62 @@ function DrawBottomInfoBanner(){
|
|||
g.drawString(a_string2[v_arraypos],5,85);
|
||||
g.flip();
|
||||
|
||||
g.setFont("Vector",v_font3size);
|
||||
g.setColor(0,0,1); //blue
|
||||
g.drawString("Display count: "+contador ,10,115);
|
||||
mem=process.memory();
|
||||
//console.log("Mem free/total: "+mem.free+"/"+mem.total);
|
||||
g.drawString("Free mem: "+mem.free+"/"+mem.total,10,135);
|
||||
g.setFont("Vector",v_font3size);
|
||||
g.setColor(v_color_statictxt);
|
||||
g.drawString("Display on/off: "+contador ,10,box_y2+7);
|
||||
//var mem=process.memory();
|
||||
//if (v_mode_debug>0) console.log("Mem free/total: "+mem.free+"/"+mem.total);
|
||||
g.flip();
|
||||
}
|
||||
|
||||
function PrintMainStaticArea(){
|
||||
g.setColor(v_color_statictxt);
|
||||
g.setFont("Vector",v_font3size);
|
||||
g.drawString("#by DPG #bangle.js",10,170);
|
||||
g.drawString("#javascript #espruino",10,185);
|
||||
g.drawString("#by DPG #bangle.js",10,box_y2+5+(v_font3size*2));
|
||||
g.drawString("#javascript #espruino",10,box_y2+5+(v_font3size*3));
|
||||
|
||||
var img_obj_RedHi = {
|
||||
width : 40, height : 40, bpp : 4,
|
||||
transparent : 0,
|
||||
buffer : require("heatshrink").decompress(atob("AFkM7vd4EAhoTNhvQhvcgHdAQIAL5oWCFIPdExo+CEoIZCABI0DhvADIZhJL4IXDHRkMEAQmOCYgmOAAIOBHwImNRQgmPHgYmCUIIXMJobfB3jgCWZJNDEga1JYQQQCMYZoJJAJNDBwgTICQPdCY7lDRQx4DVIwTIHYZzEHZATFBwblDCZRKEO5ITFWAbIJCYrHBAAImICYwEB5raKCYwAMCYXc5gADE5hLDAAgTIBJLkBBJAyKHw5hKBRJJKKJSuII5Q0IhqPKCbjRKCc4AgA=="))
|
||||
}
|
||||
g.drawImage(img_obj_RedHi,155,160);
|
||||
g.drawImage(img_obj_RedHi,box_x2+2,graph_y);
|
||||
g.flip();
|
||||
}
|
||||
|
||||
|
||||
//inc var postion for text array
|
||||
function ChangeLang(){
|
||||
if (v_arraypos<a_string1.length-1) v_arraypos++;
|
||||
else v_arraypos=0;
|
||||
//console.log("ChangeLang, Langpos: "+v_arraypos);
|
||||
function ChangeLang(dir){
|
||||
if (v_mode_debug>0) console.log("ChangeLang, dir, Prev pos: "+dir+" , "+v_arraypos);
|
||||
|
||||
if ((dir==1) && (v_arraypos<a_string1.length-1)) v_arraypos++;
|
||||
else if ((dir== 1) && (v_arraypos==a_string1.length-1)) v_arraypos=0;
|
||||
else if ((dir== -1) && (v_arraypos>0)) v_arraypos--;
|
||||
else if ((dir== -1) && (v_arraypos==0)) v_arraypos=a_string1.length-1;
|
||||
PrintHelloWorld();
|
||||
}
|
||||
|
||||
//inc var postion for color array
|
||||
function ChangeColor(){
|
||||
//console.log("ChangeColor, colpos: "+v_acolorpos);
|
||||
//if (v_mode_debug>0) console.log("ChangeColor, colpos: "+v_acolorpos);
|
||||
if (v_acolorpos<a_colors.length-2) v_acolorpos++;
|
||||
else v_acolorpos=0;
|
||||
PrintHelloWorld();
|
||||
}
|
||||
|
||||
function ChangeBGColor(){
|
||||
if (v_aBGcolorPos<a_colors.length-2) v_aBGcolorPos++;
|
||||
else v_aBGcolorPos=0;
|
||||
ClearActiveArea(); //except widgets and bottom
|
||||
PrintHelloWorld();
|
||||
}
|
||||
function UserInput(){
|
||||
Bangle.on('touch', function(button){
|
||||
switch(button){
|
||||
case 1:
|
||||
ChangeLang();//left
|
||||
ChangeLang();//left area
|
||||
break;
|
||||
case 2:
|
||||
ChangeColor();//right
|
||||
ChangeBGColor();//right
|
||||
break;
|
||||
case 3:
|
||||
ChangeColor();
|
||||
|
@ -162,23 +189,29 @@ function DrawBottomInfoBanner(){
|
|||
break;
|
||||
}
|
||||
});
|
||||
|
||||
setWatch(ChangeLang, BTN1, { repeat: true });//func to quit
|
||||
|
||||
if (v_model=='BANGLEJS'||v_model=='EMSCRIPTEN') {
|
||||
setWatch(ChangeLang, BTN1, { repeat: true });//func to quit
|
||||
setWatch(ChangeColor, BTN2, { repeat: true });
|
||||
setWatch(Bangle.showLauncher, BTN3, { repeat: true });
|
||||
//touchscreen to quit
|
||||
Bangle.on('swipe', dir => {
|
||||
if(dir == 1) ChangeLang(); //func load() to quit
|
||||
else ChangeLang();
|
||||
});
|
||||
} //touchscreen to quit
|
||||
else setWatch(ChangeColor, BTN1, { repeat: true });//func to quit
|
||||
Bangle.on('swipe', dir => {
|
||||
if(dir == 1) ChangeLang(1); //right
|
||||
else ChangeLang(-1); //left
|
||||
});
|
||||
}
|
||||
|
||||
console.log("**************************");
|
||||
console.log("Log: *** hola mundo app");
|
||||
if (v_mode_debug>0) console.log("**************************");
|
||||
if (v_mode_debug>0) console.log("Log: *** hola mundo app");
|
||||
g.clear();
|
||||
Bangle.loadWidgets();
|
||||
Bangle.drawWidgets();
|
||||
if (v_model=='BANGLEJS') DrawBangleButtons();
|
||||
Bangle.setUI({
|
||||
mode : "custom",
|
||||
back : function() {load();}
|
||||
});
|
||||
if (v_model=='BANGLEJS'||v_model=='EMSCRIPTEN') DrawBangleButtons();
|
||||
DrawBottomInfoBanner();
|
||||
UserInput();
|
||||
PrintMainStaticArea();
|
|
@ -2,14 +2,15 @@
|
|||
"id": "helloworld",
|
||||
"name": "hello, world!",
|
||||
"shortName": "hello world",
|
||||
"version": "0.02",
|
||||
"version": "0.03",
|
||||
"description": "A cross cultural hello world!/hola mundo! app with colors and languages",
|
||||
"icon": "app.png",
|
||||
"tags": "input,interface,buttons,touch",
|
||||
"supports": ["BANGLEJS"],
|
||||
"screenshots": [{"url":"screenshot.png"}],
|
||||
"supports": ["BANGLEJS","BANGLEJS2"],
|
||||
"readme": "README.md",
|
||||
"storage": [
|
||||
{"name":"helloworld.app.js","url":"app.js"},
|
||||
{"name":"helloworld.app.js","url":"helloworld.app.js"},
|
||||
{"name":"helloworld.img","url":"app-icon.js","evaluate":true}
|
||||
]
|
||||
}
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 5.1 KiB |
Binary file not shown.
After Width: | Height: | Size: 5.1 KiB |
Binary file not shown.
After Width: | Height: | Size: 3.3 KiB |
Loading…
Reference in New Issue