Hi:)
I want to show a progress bar on a display 64x128px, special here is, that i have to always use "complete rows) so the 128px can be adressed individually, but the 64px only in blocks of 8, so "row" is 0,1,2,3,4,5,6,7 not in px like "20".
My current code is like this:
//init
int bar = sampletime/10; //sample time in ms divided by 10 to get 10% steps
int last_bar = millis();
int bar_level = 85 ;
//event if 100% (sample time reached)
bar_level = 85;
last_bar=millis();
//loop
if ( (millis()+bar) > last_bar ) {
bar_level = bar_level+4; //125px - 85px = 40 /10 = 4px per 10%
DOG.rectangle(85,1,125,1,0); //draw an empty rectangle to clear just that part of the screen
DOG.rectangle(85,1,bar_level,1,255); //draw a filled rectangle to the current position
last_bar =millis();
This works currently, but has a lot of disadvantages
- if somewhere in the code a DOG.clear (clears complete display) is calles, the bar is invisible until the next 10% step is arrived. This can be up to 1min!
- When using a short sample period (5s,10s) its clearly visible, if used a long period (10min) it will be "frozen" up to 1min, so it would be better if the steps were smaller at high sample times.
Could someone help me make this function better?
PS. Here is an explanation how the display call works:
DOG.rectangle(start_col, start_page, end_col, end_page, pattern
so if you want to draw rectangle that goes from 0 to 50px, and is 8px high, you have to use:
DOG.rectangle(0,0,50,1,pattern);
pattern can be from 0-255, 0 is "invisible", 255 is black, all in between is some kind of bit pattern