forked from FOSS/BangleApps
libslider: new library with conf. slider
parent
36f76cb09e
commit
89f0df15c5
|
@ -0,0 +1 @@
|
|||
0.01: New App!
|
|
@ -0,0 +1,30 @@
|
|||
# App Name
|
||||
|
||||
More information on making apps:
|
||||
|
||||
* http://www.espruino.com/Bangle.js+First+App
|
||||
* http://www.espruino.com/Bangle.js+App+Loader
|
||||
|
||||
Describe the app...
|
||||
|
||||
Add screen shots (if possible) to the app folder and link then into this file with 
|
||||
|
||||
## Usage
|
||||
|
||||
Describe how to use it
|
||||
|
||||
## Features
|
||||
|
||||
Name the function
|
||||
|
||||
## Controls
|
||||
|
||||
Name the buttons and what they are used for
|
||||
|
||||
## Requests
|
||||
|
||||
Name who should be contacted for support/update requests
|
||||
|
||||
## Creator
|
||||
|
||||
Your name
|
|
@ -0,0 +1 @@
|
|||
require("heatshrink").decompress(atob("mEwwJC/AH4A/AH4AgA=="))
|
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
|
@ -0,0 +1,76 @@
|
|||
// Constants for the indicator:
|
||||
const X_START = 87;
|
||||
const WIDTH = 50;
|
||||
const Y_START = 5;
|
||||
const HEIGHT = 165;
|
||||
const STEPS = 10;
|
||||
const STEP_SIZE = HEIGHT/STEPS;
|
||||
const OVERSIZE = 0.5;
|
||||
|
||||
// Initialize the level
|
||||
let level = 0; // TODO: Depend on parameter.
|
||||
let lastLevel;
|
||||
let levelHeight;
|
||||
let smoothpastedge = true;
|
||||
|
||||
let continDrag = (e)=>{
|
||||
// If draging on the indicator, adjust one-to-one.
|
||||
if (e.x>X_START-OVERSIZE*WIDTH && e.x<X_START+OVERSIZE*WIDTH) {
|
||||
draw('map', e.y);
|
||||
} else if (true) {
|
||||
|
||||
dy += e.dy;
|
||||
//if (!e.b) dy=0;
|
||||
while (Math.abs(dy)>32) {
|
||||
if (dy>0) { dy-=32; draw('incr',1) }
|
||||
else { dy+=32; draw('incr',-1) }
|
||||
Bangle.buzz(20);
|
||||
}
|
||||
}
|
||||
E.stopEventPropagation&&E.stopEventPropagation();
|
||||
};
|
||||
|
||||
let ovr = Graphics.createArrayBuffer(WIDTH,HEIGHT,1,{msb:true});
|
||||
|
||||
let draw = (mode, input)=>{
|
||||
input = Math.min(input,170);
|
||||
// Draw the indicator.
|
||||
// Should be displayed when a relevant drag event is detected.
|
||||
// Should time out.
|
||||
// If user drags directly on the draw area, adjust level one-to-one.
|
||||
// Pauses and resets the time out when interacted with.
|
||||
// TODO: Lazy, keep track of last level and only draw again if it changed.
|
||||
|
||||
if (mode=='incr') {
|
||||
level = Math.min(Math.max(level-input,0),STEPS);
|
||||
}
|
||||
|
||||
if (mode=='map') {
|
||||
input = Math.round(input/STEP_SIZE);
|
||||
level = Math.min(Math.max(STEPS-input,0),STEPS);
|
||||
if (level == lastLevel) return;
|
||||
}
|
||||
|
||||
levelHeight = level==0?WIDTH:level*STEP_SIZE;
|
||||
//levelHeight = Math.max(level*STEP_SIZE,STEP_SIZE);
|
||||
lastLevel = level;
|
||||
|
||||
ovr.clear().setColor(1).
|
||||
fillRect({x:0,y:0,w:WIDTH,y2:ovr.getHeight(),r:30}). // To get outer border...
|
||||
setColor(0).
|
||||
fillRect({x:2,y:2,w:WIDTH-5,y2:ovr.getHeight()-2,r:30}). // ... and here it's made hollow.
|
||||
setColor(0==level?0:1).
|
||||
fillRect({x:4,y:ovr.getHeight()-levelHeight+4,w:WIDTH-9,y2:ovr.getHeight()-4,r:30}); // Here the bar is drawn.
|
||||
Bangle.setLCDOverlay({
|
||||
width:ovr.getWidth(), height:ovr.getHeight(),
|
||||
bpp:1, transparent:0,
|
||||
buffer:ovr.buffer
|
||||
},X_START,Y_START);
|
||||
|
||||
print(level, input);
|
||||
//print(process.memory().usage);
|
||||
};
|
||||
|
||||
let dy = 0;
|
||||
Bangle.prependListener('drag', continDrag);
|
||||
g.setColor(1,0,0).fillRect(Bangle.appRect).reset();
|
|
@ -0,0 +1,13 @@
|
|||
{ "id": "libslider",
|
||||
"name": "My app's human readable name",
|
||||
"shortName":"Short Name",
|
||||
"version":"0.01",
|
||||
"description": "A detailed description of my great app",
|
||||
"icon": "app.png",
|
||||
"tags": "",
|
||||
"supports" : ["BANGLEJS2"],
|
||||
"readme": "README.md",
|
||||
"storage": [
|
||||
{"name":"7chname.img","url":"app-icon.js","evaluate":true}
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue