-
I have a similar problem on the Bangle.js 2:
I am creating a special countdown app fot football referees. So the button has to start / stop the stopwatch. But right now I have to press the button twice (wake up the watch and then start the clock). Can this be done in one step? Or what would be best practice in this case?
-
-
-
As the topic: in LCD-Mode 'doublebuffered' the widget bar at the top turns on and off, every time any button is pressed. Why the menu doesn't fill the whole screen? Is there a solution or workaround?
Minimum example:
Bangle.setLCDMode("doublebuffered"); Bangle.loadWidgets(); let menu = { "": { title: '--- DUMMY ---' }, "Foo": 'Bar', "Exit": function() { E.showMenu(); } }; setWatch(function() { E.showMenu(menu); }, BTN2, { repeat: true, edge: 'rising'}); Bangle.drawWidgets(); g.clear(); g.flip(); E.showMenu(menu);
-
Hi @Gordon. Happy new year and thank you for the hints. Didn't know about the E-getSizeOf(x)-method. Very helpful. I will search for my memory eaters.
-
Hello everybody.
This is my second attempt to write an app for Football Officiating and ran into problems again. Graphics and Buffers are not my friends, I think.
The code is growing, but the simple switch from my main screen and the menu (BTN3) back and forth is somehow poluting my memory (it grows 1% every switch).
Before using the Menu-Component I thought my solution with resizing and clearing the buffer is a good idea. Maybe someone has a better solution for a non flickering output?
Code is attached (too long).
-
-
Yep, that's right :) Another option is to go for a half-res image
(120x120) and then use a higher bit depth...So can I find that somewhere in the documentation? Which resolution works with how many colors? Or is this something that can be calculated?
Would it be better to use multiple buffers for different areas on the screen or is this not advisable?
-
@NebbishHacker & @Gordon, thank you both so much. Removing
g.clear()
did the job and I will check for the brightness in the settings-file.With the buffer I recognized that the normal
buf.setColor(r,g,b)
does not work and I have to use a color palette (Array) of 2/4/16 elements.buf.setColor(1)
is then the index inside the array? That works for me with indexes not larger 3 (4-element-array). -
Okay, now I mixed up a sample of your two suggestions. But now I have heavy flickering again:
require("FontDylex7x13").add(Graphics); let fnt = 'Dylex7x13'; let pal2color = new Uint16Array([0x0000,0xffff,0x07ff,0xC618],0,2); let buf = Graphics.createArrayBuffer(240,192,2,{msb:true}); const pad = (number, length) => { let str = '' + number; while (str.length < length) { str = '0' + str; } return str; }; const printClock = ts => { if(ts === undefined) { ts = new Date(); } h = ts.getHours(); m = ts.getMinutes(); s = ts.getSeconds(); return `${pad(h,2)}:${pad(m,2)}:${pad(s,2)}`; }; const renderMain = () => { g.clear(); buf.clear(); buf.setColor(1); buf.setFontAlign(0,-1); buf.setFont(fnt,5); buf.drawLine(0,0,240,0); buf.drawString("Hello",120,0); buf.setFont(fnt,3); buf.setColor(2); buf.drawString(printClock(),120,60); g.drawImage({width:buf.getWidth(),height:buf.getHeight(),bpp:2,buffer:buf.buffer,palette:pal2color},0,48); }; const ticker = () => { renderMain(); // g.flip(); }; setInterval(ticker,1000);
I guess I have still a big misunderstanding of the usage of rendering with the Bangle.js.
-
-
Hi Gordon. Thank you for the quick feedback. I will try the offscreen buffer this evening. Is there a maximum size or can I use the full 240x240px?
I also came over another little thing: it would be nice to get the acual brightness or the default value from settings. This is maybe possible already (didn't find it in the Reference).
Thank you again so much!
-
Hello everyone!
Yesterday my Bangle finally arrived. I immediatly started with my project to develop a timer app for Football Officiating and came unpleasant problem of the flickering screen. I red the tutorial with the possibility to Buffer the Screen output and gave it a try.
If the display is on, the countdown timer will draw every second a new screen with g.flip(). But this always resets the Screen timeout so the Display stays on forever, until the countdown timer stops or ist interrupted.
Is there a workaround or best practice to get along with this or is it no problem to keep the display on for a longer period? If we officiate a tournament, I need the clock for ~ 6 hours.
Thank you for support. :)
Thank you.
Really LCD and LockScreen both prevent the button from executing it's 'primary' event?
I hope the battery will last with this settings for a game or a tournament. I will give it a try this evening.
Will these settings be restored after the user is exiting the app to his preferences?