Menu selection


Closed Thread
Results 1 to 8 of 8

Thread: Menu selection

Hybrid View

  1. #1
    Join Date
    Sep 2006
    Posts
    747

    Default Menu selection

    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
    Last edited by lerameur; - 19th November 2010 at 02:57.

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Not sure what you are asking...
    Code:
    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
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    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

  4. #4
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    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

    Code:
    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

    Code:
    	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
    Last edited by malc-c; - 19th November 2010 at 17:16.

  5. #5
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    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

    Code:
    '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
    Last edited by ScaleRobotics; - 24th November 2010 at 15:17. Reason: added code tags

  6. #6
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    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.
    Code:
    IF BUTTON = 1 THEN 
    CNT = CNT + 1
    Then the BRANCH
    Code:
    BRANCH CNT,[MENU1,MENU2,MENU3,...]
    Dave
    Always wear safety glasses while programming.

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts