vitotai / BrewManiacEsp8266

BrewManiac on ESP8266. Only ESP8266 needed.
155 stars 71 forks source link

PWM of 100% causes LCD corruption #17

Closed allthepies closed 6 years ago

allthepies commented 6 years ago

https://github.com/vitotai/BrewManiacEsp8266/blob/50f790a6c3d7ea5c382f8b1879329ebfbc2ed994/src/ui.h#L849

The ui.h function to display the PWM value causes screen corruption for a PWM value of 100%, it's displayed as "1:0%". This is due to the middle character logic performing a div 10 and adding the result to the character '0'. So for 100 the result is '0' + 10 which gives the colon ":" character.

The calculation should used the modulus operator on the result of the DIV 10. e.g. '0' + ((pwm/10)%10)

There may be other examples of this in ui.h for other three digit values.

vitotai commented 6 years ago

That was found and fixed locally. I just distracted by other things and forgot to update.

if(pwm>=100){
    buffer[0]='1';
    buffer[1]='0';
}else{
    buffer[0]=' ';
    buffer[1]=(pwm/10)? ('0' +(pwm/10)):' ';
}
allthepies commented 6 years ago

Thanks.