Skip to content

Commit

Permalink
slidertest: clarifying comments
Browse files Browse the repository at this point in the history
... and minor restructuring.
  • Loading branch information
thyttan committed Sep 9, 2023
1 parent cac55c5 commit 37657c6
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions apps/slidertest/app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
Bangle.setLCDTimeout(0) // Easier to read the screen while developing.

// Callbacks for use with the sliders

let callback = (mode,fb)=>{
if (mode =="map") Bangle.musicControl({cmd:"volumesetlevel",extra:Math.round(100*fb/30)});
if (mode =="incr") Bangle.musicControl(fb>0?"volumedown":"volumeup");
Expand All @@ -21,6 +23,11 @@ let callback2 = (mode,fb)=>{
//print("#drag handlers: " + Bangle["#ondrag"].length)
};

// Drawing operations

Bangle.loadWidgets();
let R = Bangle.appRect;

let draw = (rect)=>{
g.reset();
if (rect) g.setClipRect(rect.x1, rect.y1, rect.x2, rect.y2);
Expand All @@ -34,6 +41,8 @@ g.reset().setColor(0,1,0).fillRect(R.x2/2-5,R.y2/2-5,R.x2/2+5,R.y2/2+5);
setTimeout(()=>{g.reset().setColor(1,0,0).fillRect(R.x2/2-5,R.y2/2-5,R.x2/2+5,R.y2/2+5);},100);},0);
};

// Functional logic

let sliderObject2;
let initSlider2 = ()=>{
sliderObject2 = require("SliderInput").interface(
Expand Down Expand Up @@ -74,10 +83,6 @@ let messageHandler = (type, msg)=>{
}
Bangle.on('message', messageHandler);

Bangle.loadWidgets();
let R = Bangle.appRect;
init();

let ebLast = 0; // Used for fix/Hack needed because there is a timeout before the slider is called upon.
let sliderObject=require("SliderInput").interface(
callback,
Expand All @@ -102,5 +107,8 @@ Bangle.on('drag', (e)=>{
ebLast = e.b;
}
);

init();

//print("#drag handlers: " + Bangle["#ondrag"].length)
}

0 comments on commit 37657c6

Please sign in to comment.