PDA

View Full Version : universal lcd setup menu



ShoKre
- 13th March 2007, 00:02
has enyone build something like this

in my case i have 3*2 matrix key and 2x16 lcd
i want to be able to set some stuf like:

@ main loop pass: (wiew mode change, direct runings & setup entering)
@ setup:
menu1 -rtc (ds1307)
-eeprom vars : menu2 - prog 1,2,3 times
menu3 - 7 day scedule
menu4 - secret menu (licencing key)
menu5 - parametars seting

ShoKre
- 13th March 2007, 00:24
i didn't put whole code but this segment show you lcd dilema

how to get ride with unfamiliar users (i can write user manual)

this piece of code is not final is jusi in alpha phase....

(1.my eng. is far of good 2. pbp people please ignore my cro. comment)




'________________________________ matrix tipke 3x2 ______________________________
SCAN: 'SKENER TIPKOVNICE
PORTA.0=0
PORTA.1=1
KEY=PORTC & %00000111
PORTA.0=1
PORTA.1=0
KEY=KEY*10+(PORTC & %00000111)
PORTA.0=0
'---------------------- DELAY - DEBOUNCE - RELOOP ----------------------
IF PRESS THEN 'AKO JE NESTO STISNUTO
'IF W<1 THEN SOUND PORTC.5 [100,5] '| OBAVEZNO SLATI NA PR? M
W=W+1 '| BROJI STISKOVE A
IF W > CEKAJ_STISAK THEN PONAVLJAJ = DA'| T
ELSE '| DELAY DO RELOOPA R
W=0 '| I
PONAVLJAJ = NE '| X
ENDIF
RETURN '--------------- TIPKA STISNUTA (PRESS DA ILI NE) ----------------
TIPKA_STISNUTA:
IF KEY = 77 THEN
PRESS = NE
ELSE
PRESS = da
ENDIF
RETURN
'________________________________ lcd setup IZBORNIK _________________________
SETUP: '---------------- ----------------
lcdout $fe,1,"MENU PODESAVANJA",$FE,$C0,"<-|>+|<>IZ|EN-OK"
PAUSE 4000
MENU=0
SETUP_LOOP:
GOSUB SCAN
PAUSE 100
SELECT CASE KEY
CASE 65 '<- + ->
IF NOT PRESS THEN IZLAZ
CASE 73 'ENTER
IF NOT PRESS THEN BRANCHL MENU, [SET_SAT,PROGRAMI,TJEDNI,POSTAVKE,IZLAZ]
'ENDIF
CASE 67 '<-
IF NOT PRESS AND MENU >= 1 THEN MENU=MENU-1
CASE 75 '->
IF NOT PRESS AND MENU < 5 THEN MENU=MENU+1
CASE 16 '1 + 2 + 3
GOSUB SKRIVENI
END SELECT

SELECT CASE MENU
CASE 0 '---------------- '----------------
lcdout $fe,1, "NAMJESTANJE SATA",$FE,$C0,"EN-OK, <+> IZLAZ"
CASE 1 '---------------- '----------------
lcdout $fe,1, "IZMJENA PROGRAMA",$FE,$C0,"EN-OK, <+> IZLAZ"
CASE 2 '---------------- '----------------
lcdout $fe,1, "TJEDNI RASPORED ",$FE,$C0,"EN-OK, <+> IZLAZ"
CASE 3 '---------------- '----------------
lcdout $fe,1, "POSTAVKE SUSTAVA",$FE,$C0,"EN-OK, <+> IZLAZ"
CASE 4 '---------------- '----------------
lcdout $fe,1, "IZLAZ IZ POSTAVA",$FE,$C0,"EN-OK, <+> IZLAZ"
END SELECT

GOSUB TIPKA_STISNUTA
GOTO SETUP_LOOP
IZLAZ:
lcdout $fe,1, "IZLAZ IZ SETUP-a",$FE,$C0,"I NASTAVAK RADA "
PAUSE 2000
GOTO PRE_MAIN_LOOP
'----------------------- SETIRANJE TRAJANJA PROGRAMA -----------------------------
PROGRAMI: '---------------- '----------------
lcdout $fe,1, "<T-|>T+|EN-V|2+V",$FE,$C0,"3+PRG|<+> SPREMI"
PAUSE 3000
X=1:Y=1:Z=1:A=0
PROGRAMI_LOOP:
GOSUB KEY2VAR
IF Z>3 THEN Z=3
IF X>BROJ_VENTILA THEN X=BROJ_VENTILA
IF Y>99 THEN Y = 15
LOC = PROG_LOC + ((Z-1) * PROG_OFFSET)+x
READ LOC,TEMP
lcdout $fe,1,"PROG.=",#Z," VENT.=",#x,$FE,$C0,"MEM=",#TEMP," SET=",#y
IF TEMP != y THEN A=A+1
IF PRESS THEN A=0
IF A>30 THEN
WRITE LOC,y
A=0
ENDIF
GOTO PROGRAMI_LOOP
'________________________________ lcd LICENCA _____________________________________
SKRIVENI:
lcdout $fe,1,"LICENCNI KOOD",$FE,$C0
read (PARAM_LOC+59),Y 'NEVIDLJIV KOOD
read (PARAM_LOC+60),Z
X=1':Y=0:Z=0 'ILI VIDLJIV KOOD
SKRIVENI_LOOP:
GOSUB KEY2VAR
IF X>2 THEN SKRIVENI_OUT
lcdout $FE,$C0," ",dec3 Y,dec3 Z,"=",dec3 KOOD0,dec3 KOOD1
A=A+1
IF PRESS THEN A=0
IF A>100 THEN SKRIVENI_OUT
GOTO SKRIVENI_LOOP
SKRIVENI_OUT:
lcdout $fe,1," KOOD SPREMLJEN ",$FE,$C0,"POVRAT. NA IZBOR",$FE,$0C
IF A.LOWBYTE = KOOD0 AND A.HIGHBYTE = KOOD1 THEN
Write (PARAM_LOC+59),A.HIGHBYTE 'LICENCA
Write (PARAM_LOC+60),A.LOWBYTE
ELSE '----------------
lcdout $fe,2," KOOD NETOCAN ! "
ENDIF
PAUSE 2000
goto setup
'__________________________ lcd setup PARAMETRI_____________________________________
POSTAVKE:

POSTAVKE_LOOP
return
GOTO POSTAVKE_LOOP
'________________________________ RUCNI START _____________________________________
POKRENI:

GOTO POKRENI
START_OUT:
LCDOUT $FE,$C0,"START PROGRAM ",#PROGRAM_FLAG
GOTO PRE_MAIN_LOOP

RUCNI_TEST:
GOSUB KEY2VAR

'________________________________STELANJE SATA ____________________________________
SET_SAT: '________________
lcdout $fe,1," STIMANJE SATA :",$FE,$C0
X=0:Y=0:Z=0
PAUSE 2000
GOSUB CITAJ_SAT
SAT_LOOP:
LOOKUP2 Y,[SATI,MINUTA,DAN,DATUM,MJESEC,GOD],X 'STA CEMO MJENJATI
LOOKUP Y, [ 60 , 60 , 7 , 31 , 12 ,99 ],TEMP 'MAXIMUMI ZA VREM.MJERE
LOOKUP Y, [ 0 , 4 , 7 , 0 , 4 , 7 ],P 'MAPIRANJE KURSORA
GOSUB KEY2VAR
IF Z>3 THEN Z=3
IF X>TEMP THEN X=TEMP
IF Y>5 THEN Y = 5
SELECT CASE Y
CASE 0
SATI=X
CASE 1
MINUTA=X
CASE 2
DAN=X
CASE 3
DATUM=X
CASE 4
MJESEC=X
CASE 5
GOD=X
END SELECT
lcdout $FE,1,DEC2 SATI,":", DEC2 MINUTA,"DAN:",DEC1 DAN,"-",#X,#Y,#Z,$FE,$C0,_
DEC2 DATUM,".", DEC2 MJESEC,".20",DEC2 GOD,$FE,$0F,$FE,2
IF Y>2 THEN LCDOUT $FE,$C0
FOR C=0 TO P
LCDOUT $FE,$14 'MAKNI KURSOR DA BLINKA GDJE SE CACKA
NEXT C

A=A+1
IF PRESS THEN A=0
IF A=20 THEN GOSUB PISI_SAT 'SVAKI PUT 2 SEC NAKON RELEZA

GOTO SAT_LOOP
'_______________________________ TJEDNI ________________________________________
TJEDNI:




GOTO SETUP
'___________ VAR=X,Y,Z IZ TIPKI SA TIMEOUTOM I AUTO REPEATOM I DEBOUNCEROM _________
KEY2VAR:
GOSUB SCAN
PAUSE 100
SELECT CASE KEY
CASE 65 '<- + ->
IF NOT PRESS THEN '---------------- '----------------
lcdout $fe,1,"POHRANJENO. POV-",$FE,$C0,"RATAK U IZBORNIK"
PAUSE 2000
goto setup
ENDIF
CASE 56 '1 + 3
IF NOT PRESS THEN '---------------- '----------------
lcdout $fe,1,"POHRANJENO. POV-",$FE,$C0,"RATAK U NORMALU "
PAUSE 2000
goto setup
ENDIF
CASE 73 'ENTER GORE
IF NOT PRESS THEN x=x+1
IF PONAVLJAJ THEN x=x+1
CASE 67 '<- < + > y
IF NOT PRESS THEN y=y-1
IF PONAVLJAJ THEN y=y-1
CASE 75 '->
IF NOT PRESS THEN y=y+1
IF PONAVLJAJ THEN y=y+1
CASE 37 '2 DOLE DOLE + GORE 2 + ENT X
IF NOT PRESS THEN x=x-1
IF PONAVLJAJ THEN x=x-1
CASE 57 '1
IF NOT PRESS THEN Z=Z-1
IF PONAVLJAJ THEN Z=Z-1
CASE 76 '3 1 + 3 Z
IF NOT PRESS THEN Z=Z+1
IF PONAVLJAJ THEN Z=Z+1
CASE 16 '1 + 2 + 3
GOTO SKRIVENI
END SELECT
TIMEOUT=TIMEOUT+1
IF PRESS THEN TIMEOUT=NE
IF TIMEOUT = %11111111 THEN IZLAZ
GOSUB TIPKA_STISNUTA
RETURN
'_____________________________OCISTI X,Y,Z _______________________________________

Marin
- 7th August 2007, 11:08
Hello Shokre,,,,

Got problem...when I try to compile You're code, I've got error "bad expression" in every line where if IF command....do you know why?

I use Micro code PicBasic Pro compiler.

tnx!