fix relative progress bounds

This commit is contained in:
Adrien Marquès 2020-06-01 17:11:15 +02:00
parent 7082f348ee
commit e81ac251cb
Signed by: xdrm-brackets
GPG Key ID: D75243CA236D825E
1 changed files with 4 additions and 4 deletions

View File

@ -196,11 +196,11 @@ void Display::progress(const short progress, const uint8_t startLine, const uint
setPixel(64, endLine, true); setPixel(64, endLine, true);
} }
uint16_t scaledProgress = (progress+7) / 8; int16_t scaledProgress = (progress+7) / 8;
// draw absolute progression // draw absolute progression
if( absolute ){ if( absolute ){
for( uint8_t x = 0 ; x < scaledProgress ; x++ ){ for( uint8_t x = 0 ; x < scaledProgress && x < 128 ; x++ ){
for( uint8_t y = startLine+1 ; y < endLine ; y++ ){ for( uint8_t y = startLine+1 ; y < endLine ; y++ ){
setPixel(x, y, true); setPixel(x, y, true);
} }
@ -211,7 +211,7 @@ void Display::progress(const short progress, const uint8_t startLine, const uint
// draw left relative progression // draw left relative progression
if( progress < 512 ){ if( progress < 512 ){
for( uint8_t x = scaledProgress ; x < 64 ; x++ ){ for( int16_t x = 64 ; x > scaledProgress && x >= 0 ; x-- ){
for( uint8_t y = startLine+1 ; y < endLine ; y++ ){ for( uint8_t y = startLine+1 ; y < endLine ; y++ ){
setPixel(x, y, true); setPixel(x, y, true);
} }
@ -220,7 +220,7 @@ void Display::progress(const short progress, const uint8_t startLine, const uint
// draw right relative progression // draw right relative progression
} else { } else {
for( uint8_t x = 64 ; x < scaledProgress ; x++ ){ for( uint8_t x = 64 ; x < scaledProgress && x < 128 ; x++ ){
for( uint8_t y = startLine+1 ; y < endLine ; y++ ){ for( uint8_t y = startLine+1 ; y < endLine ; y++ ){
setPixel(x, y, true); setPixel(x, y, true);
} }