Bit of a fudge, but it works well enough
Code:
'*******************************************************************************
' Set Brightness levels for each channel
brightness:
B_max = (4095/100)*maxbright
Lcdout $FE,2
LCDOUT $FE,$80,"Set Max Brightness"
IF H_butt = 0 THEN GOSUB up
IF M_butt = 0 THEN GOSUB down
If maxbright = 100 then
LCDOUT $FE,$C0,"Channel 1 "
LCDOut $FE,$D4,#maxbright,"%"
endif
If maxbright =0 or maxbright <10 then
LCDOUT$FE,$C0,"Channel 1 "
LCDOut $FE,$D4,dec1 maxbright,"% "
endif
if maxbright >=10 and maxbright <100 then
LCDOUT$FE,$C0,"Channel 1 "
LCDOut $FE,$D4,dec2 maxbright,"% "
endif
If S_butt = 0 then
pause 100
goto brightness2
endif
goto brightness
brightness2:
W_max = (4095/100)*maxbright
Lcdout $FE,2
LCDOUT $FE,$80,"Set Max Brightness"
IF H_butt = 0 THEN GOSUB up
IF M_butt = 0 THEN GOSUB down
If maxbright = 100 then
LCDOUT $FE,$C0,"Channel 2 "
LCDOut $FE,$D4,#maxbright,"%"
endif
If maxbright =0 or maxbright <10 then
LCDOUT$FE,$C0,"Channel 2 "
LCDOut $FE,$D4,dec1 maxbright,"% "
endif
if maxbright >=10 and maxbright <100 then
LCDOUT$FE,$C0,"Channel 2 "
LCDOut $FE,$D4,dec2 maxbright,"% "
endif
pause 200
If S_butt = 0 then
pause 100
LCDOUT $FE,1
goto mainmenu
endif
goto brightness2
up:
maxbright = maxbright + 1
IF maxbright >= 100 THEN maxbright = 100
pause 250
RETURN
down:
maxbright = maxbright - 1
IF maxbright <= 0 THEN maxbright = 0
pause 250
RETURN
Again, the lack of floating point maths in PBP means the calculations are not exact, but this way every 1% increment equals a block of 41 steps on the PCA chip, so 50% brightness = 2050 but that's close enough to the 2047 is should be and to be honest I doubt if the human eye could distinguish the difference
Bookmarks