Guys, I'm having a brain fart and for the life of me can't get an LCD to display the value of a word variable as a percentage.
The word variable is CH1_PWM and ranges from 0 to 4095
I tried this
I know there must be a simple way of doing this, but it's been a long day and my brain just refuses to think straight !! I have a menu option that kind of works in reverse as it it uses a byte variable (maxbright) that ranges from 0 to 100 and it is used to set a word variable (in this case CH1_Max)
But not sure how to compliment it the other way into the LCD display.
Malc
The word variable is CH1_PWM and ranges from 0 to 4095
I tried this
Code:
If (CH1_PWM * 100)/4095 >= 100 then
lcdout $FE,$80,"CH1 ",$FE,$80+4,dec3 (CH1_PWM *100)/4095,"%"
endif
If (CH1_PWM * 100)/4095 <=0 or (CH1_PWM * 100)/4095 <10 then
lcdout $FE,$80,"CH1 ",$FE,$80+4,dec1 (CH1_PWM *100)/4095,"% "
endif
if (CH1_PWM * 100)/4095 >=10 and (CH1_PWM * 100)/4095 <100 then
lcdout $FE,$80,"CH1 ",$FE,$80+4,dec2 (CH1_PWM *10)/4095,"% "
endif
Code:
CH1_Max = maxbright */ 10484
Malc