#Config
__CONFIG _FOSC_INTOSCIO & _MCLRE_OFF & _WDT_OFF & _PWRTE_ON & _BOREN_OFF & _LVP_OFF & _CPD_OFF & _CP_OFF
#EndConfig
Define OSC 4
DEFINE LCD_RSREG PORTA
DEFINE LCD_RSBIT 0
DEFINE LCD_RWREG PORTA
DEFINE LCD_RWBIT 1
DEFINE LCD_EREG PORTA
DEFINE LCD_EBIT 2
DEFINE LCD_DREG PORTB
DEFINE LCD_DBIT 4
DEFINE LCD_BITS 4
DEFINE LCD_LINES 2
DEFINE LCD_COMMANDUS 2000
DEFINE LCD_DATAUS 50
SCR var byte
T Var Word
V Var Word
F var word
On_Off var PortB.1
key var word
CMCON=7
TrisA=%11111001
TrisB=%00000011
pause 100
SCR=0:gosub DM
SCR=1:gosub DM
F=20
T=0
V=37
Low On_Off
main:
select case portA & $F0
case 16
toggle On_Off
SCR=1:Gosub DM
pause 500
case 48
'Menu
low on_off
scr=1:gosub DM
SCR=10:gosub Dm
Pause 500
case 32
'Left
if SCR>10 then SCR=SCR-1
Gosub DM
pause 500
case 96
'right
if SCR<12 then SCR=SCR+1
Gosub DM
pause 500
case 64
'Down
select case scr
case 100
if F>0 then f=f-1
case 110
if V>0 then V=v-1
case 120
if T>0 then T=T-1
end select
gosub DM
pause 500
case 192
'Up
select case scr
case 100
if F<40 then f=f+1
case 110
if V<75 then V=v+1
case 120
if T<99 then T=T+1
end select
gosub DM
pause 500
case 128
'enter
select case scr
Case 10,11,12
scr=scr*10
Case 100,110,120
scr=scr/10
end select
gosub DM
pause 500
end select
if On_Off then pwm PortB.2,V*255/75,2
Goto main
DM:
select case SCR
Case 0
lcdout $FE,$01
case 1
lcdout $FE,$01
lcdout $FE,$02,"Limpiar"
if On_Off then
lcdout $FE,$C0,"ON"
HPWM 1,127,F*1000
else
lcdout $FE,$C0,"OFF"
HPWM 1,0,0
endif
Case 10
lcdout $FE,$01
lcdout $FE,$02,"Menu"
lcdout $FE,$C0,"Frecuencia"
Case 100
lcdout $FE,$01
lcdout $FE,$02,"Frecuencia"
lcdout $FE,$C0,"KHz: ", dec F,rep " "\3
Case 11
lcdout $FE,$01
lcdout $FE,$02,"Menu"
lcdout $FE,$C0,"Potencia"
Case 110
lcdout $FE,$01
lcdout $FE,$02,"Potencia"
lcdout $FE,$C0,"Vatios: ", dec V,rep " "\3
Case 12
lcdout $FE,$01
lcdout $FE,$02,"Menu"
lcdout $FE,$C0,"Tiempo"
Case 120
lcdout $FE,$01
lcdout $FE,$02,"Tiempo"
lcdout $FE,$C0,"Minutos: ", dec T,REp " "\3
case 90
lcdout $FE,$02,"ULTRASONIC"
lcdout $FE,$C0,"CLEANER"
End select
return