PDA

View Full Version : Menu selection



lerameur
- 19th November 2010, 02:42
OOOoookk
Here it is. I am doing something and I am not sure how to..

Ok I have a while loop, .. well for starters I have two button, 1-Start 2-go th the recorded time
here is the while loop:

While PORTB.2 != 1 ' if start button is not push do this loop

While voltage_percent != 100 ' Charge the battery
Gosub Charge_TwelveVolt
Gosub Battery_Charging 'LCD out battery charging and percentage
Wend

Gosub Wait_60_Minutes 'wait 60 min

While voltage_check <= 325 ' DisCharge the battery until its empty
PORTB.3 = 1 'Turn relay ON, Lights will turn on
I2CREAD SDA,SCL,$D1,$00,[STR DB0\8] ' Read 8 bytes from DS1307
Gosub Check_voltage 'Check battery voltage, stay in this loop while it is not empty
if (voltage_check <= TwelveVoltLimit) and (voltage_check > 325) then
voltage_percent = (((voltage_check -325) * 3500 ) / 100 )
if (voltage_check <= 325) then
voltage_percent = 0
else
voltage_percent = 100
endif
endif
Gosub Battery_DisCharging 'LCD out the battery discharge information
Voltage_Array_Charge_time(Battery_Cycle_Counter) = timer_time
Voltage_Array_Discharge_time (Battery_Cycle_Counter) = timer_time
Battery_Cycle_Counter = Battery_Cycle_Counter + 1
Wend
Wend

'Now we are of the loop and
'Show time battery discharge times chronologically. You have a button that goes through ll 'the times that has been recoded in the array.... and if no button is selected for 15 seconds, then the program returns to While PORTB.2 != 1 loop This is where I have no idea what to do..

help ? ;)
maybe I am too sleepy

K

mackrackit
- 19th November 2010, 07:38
Not sure what you are asking...

START:
While PORTB.2 != 1 ' if start button is not push do this loop

While voltage_percent != 100 ' Charge the battery
Gosub Charge_TwelveVolt

###SNIP####

Gosub Battery_DisCharging 'LCD out the battery discharge information
Voltage_Array_Charge_time(Battery_Cycle_Counter) = timer_time
Voltage_Array_Discharge_time (Battery_Cycle_Counter) = timer_time
Battery_Cycle_Counter = Battery_Cycle_Counter + 1
Wend
Wend
GOTO START

lerameur
- 19th November 2010, 13:38
Ok basically I am looking for :
The LCD module will show the discharging/charging percentage of the battery.
The time of each discharge and charge cycle are accumulated in an array.

when the user hit a button, it will put him into a menu. On another button the user can go through the array and view the charge dicharge time one by one. When no selection is done for 15 seconds, The program returns to the previous state.

K

malc-c
- 19th November 2010, 17:14
Ok basically I am looking for :
The LCD module will show the discharging/charging percentage of the battery.
The time of each discharge and charge cycle are accumulated in an array.

when the user hit a button, it will put him into a menu. On another button the user can go through the array and view the charge dicharge time one by one. When no selection is done for 15 seconds, The program returns to the previous state.

K

I use something similar in one of my projects - uses a 4 x 20 LCD



mainmenu:

LCDOUT $FE,2,"Main Menu"
lcdout $FE, $C0, "Select Option"

IF Option = 1 THEN lcdout $FE, $D4, "option 1 "
if option = 2 then lcdout $FE, $D4, "option 2 "
if option = 3 then lcdout $FE, $D4, "option 3 "
if option = 4 then lcdout $FE, $D4, "option 4 "
if option = 5 then lcdout $FE, $D4, "option 5 "
if option = 6 then lcdout $FE, $D4, "option 6 "


IF !H_butt THEN Option = option + 1
pause 200
if option >6 then option = 1

If option = 1 Then
If S_butt = 0 Then
LCDOUT $FE,1
Gosub SetButtonRelease
goto option_one
endif
endif


If option = 2 Then
If S_butt = 0 Then
LCDOUT $FE,1
Gosub SetButtonRelease
goto option_two
endif
endif

.... etc etc for all remaining options



To do the time out you could use something like




Pause 1 ' Kill 1mS
TimeOut=TimeOut+1
If TimeOut>20000 then goto mainprogram


Obviously you need to either set or use your own variables

Hope that helps

lerameur
- 23rd November 2010, 18:48
Hi, the problem is that I need sub menus.


This is the end of my program which I am trying to create menus and sub_menus

PORTC.3 is use to switch to the next result, but if PORTC.3 is not press for 10 seconds it returns to the previous condition now shown here. My problem is making the menus and the 10 seconds limit.
Anyone can help me ???

K



'Show time battery discharge times, Here is hte result of a push on PORTC.3
lcdout $FE,1, " Appuyé sur Suivant "
lcdout $FE,$C0, "Press on next"
pause 100

if PORTC.3 != 1 then 'show the array time- NEXT button; PORTC.3 is the 'Next' button
if Battery_Cycle_Discharge_Counter = 0 then
lcdout $FE,1, " Aucun test "
lcdout $FE,$C0, "No test"
pause 1000
Endif

if Battery_Cycle_Charge_Counter = 0 then
lcdout $FE,1, " Aucun test "
lcdout $FE,$C0, "No test"
pause 1000
Endif

if Battery_Cycle_Charge_Counter > 0 then ' Only display if there is something in the array. Show the time for 10 seconds, if PORTC.3 is not press then go back to Mainloop
BCCC = Battery_Cycle_Charge_Counter
Counter = 0
While BCCC != 0
While PORTC.3 != 1 'Hold the time on LCD until 'NEXT' button is pushed again or max 10 seconds
lcdout $FE,1, " Charge time: " dec Counter
lcdout $FE,$C0, dec Voltage_Array_Charge_time_RTCDay[Counter]," jour ",dec Voltage_Array_Charge_time_RTCHour[Counter],dec Voltage_Array_Charge_time_RTCMin[Counter],dec Voltage_Array_Charge_time_RTCSec[Counter]
pause 1000
Gosub Hold_menu_1 'Pause until PORTC.3 != 1 ..or ten seconds
Wend
BCCC = BCCC - 1
Counter = Counter + 1
Wend
Endif

Gosub Hold_menu_2

' if PORTC.4 != 1 then 'show the array time Previous....to be completed... similar to NEXT menu


endif

Return

'/////////////////////////////
'/////// Hold_Menu_1 ////////
'/////////////////////////////
Hold_Menu_1:

for i = 1 to 100
if PORTC.3 != 1 then
goto Here_to_return
Endif
pause 100
next i
Goto mainloop

Here_to_return
Return

'/////////////////////////////
'/////// Hold_Menu_2 ////////
'/////////////////////////////
Hold_Menu_2:

for i = 1 to 100
lcdout $FE,1, " Waiting 10 sec. "
lcdout $FE,$C0, "Or click next"
pause 100
if PORTC.3 != 1 then goto Mainloop
next i
Goto Mainloop

Return

mackrackit
- 24th November 2010, 09:52
I am not completely clear about your setup but the BRANCH command might be what you need/want.

You could have a VAR that increments every time the button is pressed.

IF BUTTON = 1 THEN
CNT = CNT + 1
Then the BRANCH

BRANCH CNT,[MENU1,MENU2,MENU3,...]

lerameur
- 24th November 2010, 15:02
Hi,

well this is not exactly whT I am looking for:
Mainly I have a battery tester which will charge a battery, record the time it took to charge, wait 60 min, discharge the battery, record the time ot took to discharge, and repeat this cycle indefinately. I want the user to be able to SEE the recorded time any time they want to. Here is my Sub routine that does this, although this subroutine gave me a Fatal error- out of memory:


'////////////////////////////////////////
'/// Display_Charge_Discharge_Time /////
'////////////////////////////////////////
Display_Charge_Discharge_Time:


'Show time battery discharge times, Here is the result of a push on PORTB.3
lcdout $FE,1, " Appuyé sur Suivant "
lcdout $FE,$C0, "Press on next"
pause 100

if Battery_Cycle_Discharge_Counter = 0 then
lcdout $FE,1, " Aucun test Decharge"
lcdout $FE,$C0, "No DisC test"
pause 5000
Endif

if Battery_Cycle_Charge_Counter = 0 then
lcdout $FE,1, " Aucun test Charge"
lcdout $FE,$C0, "No Charge test"
pause 5000
Endif

if (Battery_Cycle_Charge_Counter = 0) AND (Battery_Cycle_Discharge_Counter = 0) then
lcdout $FE,1, " Aucun Cycle "
lcdout $FE,$C0, "en mémoire :("
pause 5000
Return
Endif

if Battery_Cycle_Charge_Counter > 0 then ' Only display if there is something in the array. Show the time for 10 seconds, if PORTB.3 is not press then go back to Mainloop
BCCC = Battery_Cycle_Charge_Counter
Counter = 0
While BCCC != 0
While PORTB.3 != 1 'Hold the time on LCD until 'NEXT' button is pushed again or max 10 seconds
lcdout $FE,1, " Charge time: " dec Counter
lcdout $FE,$C0, dec Voltage_Array_Charge_time_RTCDay[Counter]," jour ",dec Voltage_Array_Charge_time_RTCHour[Counter],dec Voltage_Array_Charge_time_RTCMin[Counter],dec Voltage_Array_Charge_time_RTCSec[Counter]
pause 1000
Gosub Hold_menu_1 'Pause until PORTB.3 != 1 ..or ten seconds
Wend
BCCC = BCCC - 1
Counter = Counter + 1
Wend



if Battery_Cycle_DisCharge_Counter > 0 then ' Only display if there is something in the array. Show the time for 10 seconds, if PORTB.3 is not press then go back to Mainloop
BCCC = Battery_Cycle_DisCharge_Counter
Counter = 0
While BCCC != 0
While PORTB.3 != 1 'Hold the time on LCD until 'NEXT' button is pushed again or max 10 seconds
lcdout $FE,1, " DisCharge time: " dec Counter
lcdout $FE,$C0, dec Voltage_Array_DisCharge_time_RTCDay[Counter]," jour ",dec Voltage_Array_DisCharge_time_RTCHour[Counter],dec Voltage_Array_DisCharge_time_RTCMin[Counter],dec Voltage_Array_DisCharge_time_RTCSec[Counter]
pause 1000
Gosub Hold_menu_1 'Pause until PORTB.3 != 1 ..or ten seconds
Wend
BCCC = BCCC - 1
Counter = Counter + 1
Wend
Else
return
Endif

Gosub Hold_menu_2
endif

Return

'/////////////////////////////
'/////// Hold_Menu_1 ////////
'/////////////////////////////
Hold_Menu_1:

for i = 1 to 100
if PORTB.3 != 1 then
Return
Endif
pause 100
next i
Goto mainloop

Here_to_return
Return

'/////////////////////////////
'/////// Hold_Menu_2 ////////
'/////////////////////////////
Hold_Menu_2:

for i = 1 to 100
lcdout $FE,1, " Waiting 10 sec. "
lcdout $FE,$C0, "Or click next"
pause 100
if PORTB.3 != 1 then goto Mainloop
next i
Goto Mainloop

Return

Archangel
- 24th November 2010, 20:43
You know . . . they sell these things for automotive batteries, but they do not DEEP CYCLE the battery as your device will. The automotive units charge the battery then discharge for about 10 seconds and check the residual voltage as a measure of the battery's overall fitness.