Noob needs some help please...


Results 1 to 12 of 12

Threaded View

  1. #6
    Join Date
    May 2008
    Posts
    31


    Did you find this post helpful? Yes | No

    Default Re: Noob needs some help please...

    That bit has been reworked as follows...

    Code:
    check_button:
            if btn_up = 0 OR btn_dwn = 0 OR btn_back = 0 _  ' If any button is pressed... 
                OR btn_nxt = 0 OR btn_entr = 0 _            ' and the LCD Backlight is on...
                and lcd_lite = 1 then                       ' Then Go to button loop
                goto button_loop
            endif
            if btn_up = 0 OR btn_dwn = 0 OR btn_back = 0 _  ' If any button is pressed...
                OR btn_nxt = 0 OR btn_entr = 0 _            ' and the LCD backlight is not on...
                and lcd_lite = 0 then                       ' Then turn on the backlight...
                high lcd_lite                               ' ...and pause 2 seconds
                pause 2000               ' Holding the button longer than 2 sec. gets you to...
            endif                        ' the button loop VIA the mainloop & check_button and...
            return                       ' IF statement above.
    But the GOTO / GOSUB seems ok... At least is seems to be working.

    Code:
    button_loop:
    '
    if btn_up = 1 and btn_dwn = 1 and btn_back = 1 _  ' If no buttons are pressed go to mainloop...
        and btn_nxt = 1 and btn_entr = 1 then 
     goto mainloop                                 
        endif                                         ' Otherwise continue...
    
    button_set_loop:
    if btn_up = 0 then up                   ' If the up button is pressed go to the Up loop
    if btn_dwn = 0 then down                ' If the down button is pressed go to the Down loop
    if btn_back = 0 then back               ' If the back button is pressed go to the Back loop
    if btn_nxt = 0 then forward             ' If the next button is pressed go to the Next loop
    if btn_entr = 0 then                    ' If the enter button is pressed go to the Enter loop
            goto enter
        else
            goto button_loop                ' If no buttons are pressed run the button loop again...
    endif                                   '   ... which takes you to the main loop.
    
    up:
    while btn_up = 0                ' While the Up button is pressed do this loop...                    
    pause 30                        ' pause for 30 milliseconds
    alrm_set = alrm_set + 1         ' increase alarm set point by one degree F
    lcdout $FE, 1, "Alarm Set ", _  ' Display the alarm set point as it's changed
    dec (alrm_set),$DF, "F"
    pause 300
    wend                            ' Repeat, increasing it 1 degree F every ~1/3...
    lite_timer = 0                     '   ... second until the switch is released
    goto button_loop
    
    down:
    while btn_dwn = 0
    pau... (and it continues)
    The check_button loop returns to the main loop, the button_loop series all end with a GOTO mainloop so it finds its way back. In the code above what I wanted to accomplish was that any button press would turn on the LCD backlight but not increment the variable in button_loop in doing so. The above code work pretty well though I may back off the 2 second pause.
    I'm aware that there is much room for improvement in both the code and the hardware... I'm learning as I go. I'm working with a deadline of April 17th so I don't have the time to pretty it up. The hardware is functional with some software work-arounds... Rev B will be awesome!
    The IF statement about all the buttons being "1" (not pressed) is likely not necessary since it was a button press that got me there in the first place. Cleaning up that stuff will come later, right now it doesn't break anything and I'm not tight on space yet.

    Thanks for looking it over I'm grateful for any tips.

    PS I know... interrupts and timers... in Rev B
    Last edited by Neosec; - 15th April 2013 at 02:20. Reason: typo

Similar Threads

  1. PICKit2 vs. JDM (Noob question)
    By loamobn in forum General
    Replies: 4
    Last Post: - 19th September 2010, 18:19
  2. NOOB in need of help
    By studysession in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 26th January 2009, 23:01
  3. Help a noob out?
    By yasiryassin in forum mel PIC BASIC
    Replies: 2
    Last Post: - 15th January 2008, 06:37
  4. (noob)hello world?
    By m4gill4 in forum mel PIC BASIC
    Replies: 2
    Last Post: - 30th November 2007, 00:23
  5. Uber noob needs clarity!
    By bill12780 in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 23rd July 2007, 21:40

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