Hi
I have made a selection menu for my logging system. It works, but I think its a very long and ineffective program.
I'm pleased if anyone has comments on it on improvements.
Thanks
I have made a selection menu for my logging system. It works, but I think its a very long and ineffective program.
I'm pleased if anyone has comments on it on improvements.
Thanks
Code:
#slot 0
'This program is only the menu of my logging station. There are 5 menu items with Yes/No choice, and one with minute 0 -255.
'The menu states are written in bit 101 to 107.
'After choices are made, it runs Slot1-3. Here i reed the bits, and run the programs with YES.
'########MENU########
'1-Clock
'2-Pressure
'3-Temp 1-4
'4-Humidity
'5-Light
'6-Interval
'7-Start
'########PINS########
'Display b.5
'Open LOG write a.1
'Open LOG read
'LED b.7
'Temp T0 c.5
'Temp T1 c.6
'Temp T2 c.7
'Temp T3 b.0
'Temp T4 b.1
'Botton1 b.4
'Botton2 b.3
'Botton3 b.2
'I2C SDA TXI? c.4
'I2C SCL RXD? c.3
'#######SYMBOLS######
symbol arrow_up=pinb.4
symbol arrow_down=pinb.3
symbol ent=pinb.2
symbol prog=b0
symbol YN=b1
'#######START SCREEN#
serout b.5,T9600_8,(254,1)
serout b.5,T9600_8,(254, $01)
serout b.5,T9600_8,("Select program")
serout b.5,T9600_8,(254,192)
serout b.5,T9600_8,("UP/DOWN or RET")
top:
if arrow_up=1 then goto run_program
if arrow_down=1 then goto clock
pause 100
goto top
'########MENU########
clock:
pause 300
prog=101
serout b.5,T9600_8,(254,1)
serout b.5,T9600_8,(254, $01)
serout b.5,T9600_8,("Time and date")
peek prog,YN
gosub check
clock_select:
if arrow_up=1 then goto run_program
if arrow_down=1 then goto pressure
if ent=1 then gosub yes_no
goto clock_select
pressure:
pause 300
prog=102
serout b.5,T9600_8,(254,1)
serout b.5,T9600_8,(254, $01)
serout b.5,T9600_8,("Pressure")
peek prog,YN
gosub check
pressure_select:
if arrow_up=1 then goto clock
if arrow_down=1 then goto temp1_4
if ent=1 then gosub yes_no
goto pressure_select
temp1_4:
pause 300
prog=103
serout b.5,T9600_8,(254,1)
serout b.5,T9600_8,(254, $01)
serout b.5,T9600_8,("Temp 1-4")
peek prog,YN
gosub check
temp1_4_select:
if arrow_up=1 then goto pressure
if arrow_down=1 then goto humid
if ent=1 then gosub yes_no
goto temp1_4_select
humid:
pause 300
prog=104
serout b.5,T9600_8,(254,1)
serout b.5,T9600_8,(254, $01)
serout b.5,T9600_8,("Humid")
peek prog,YN
gosub check
humid_select:
if arrow_up=1 then goto temp1_4
if arrow_down=1 then goto light
if ent=1 then gosub yes_no
goto humid_select
light:
pause 300
prog=105
serout b.5,T9600_8,(254,1)
serout b.5,T9600_8,(254, $01)
serout b.5,T9600_8,("Light")
peek prog,YN
gosub check
light_select:
if arrow_up=1 then goto humid
if arrow_down=1 then goto interval
if ent=1 then gosub yes_no
goto light_select
interval:
pause 300
prog=106
serout b.5,T9600_8,(254,1)
serout b.5,T9600_8,(254, $01)
serout b.5,T9600_8,("Interval")
peek prog,YN
gosub check_int
interval_select:
if arrow_up=1 then goto light
if arrow_down=1 then goto run_program
if ent=1 then gosub int
goto interval_select
run_program:
pause 300
prog=107
serout b.5,T9600_8,(254,1)
serout b.5,T9600_8,(254, $01)
serout b.5,T9600_8,("Run_program")
peek prog,YN
gosub check
run_program_select:
if arrow_up=1 then goto pressure
if arrow_down=1 then goto clock
if ent=1 then goto Programs
goto run_program_select
'#######SUBS####
yes_no: '(change status YES/NO)
pause 300
peek prog,YN
branch YN,(yes,no)
no:
poke prog,0
serout b.5,T9600_8,(254,192)
serout b.5,T9600_8,("No ")
return
yes:
poke prog,1
serout b.5,T9600_8,(254,192)
serout b.5,T9600_8,("Yes")
return
check: '(check status YES/NO)
serout b.5,T9600_8,(254,192)
branch YN,(W_N,W_Y)
W_N:
serout b.5,T9600_8,("No ")
return
W_Y:
serout b.5,T9600_8,("Yes")
return
int:
pause 200
peek prog,YN
YN=YN+1
serout b.5,T9600_8,(254,1)
serout b.5,T9600_8,(254, $01)
serout b.5,T9600_8,("Interval")
serout b.5,T9600_8,(254,192)
serout b.5,T9600_8,("Every ",#YN,"min")
poke prog,YN
return
check_int:
serout b.5,T9600_8,(254,192)
serout b.5,T9600_8,("Every ",#YN,"min")
return
'#########PROGRAMS###################################################
Programs:
run 1