Can someone help me to modify Darrel Taylor's STRINGS.PBP


Closed Thread
Results 1 to 19 of 19

Hybrid View

  1. #1
    jessey's Avatar
    jessey Guest

    Default Can someone help me to modify Darrel Taylor's STRINGS.PBP

    Hello Everyone

    I'm looking for a way to modify Darrel's program but I don't understand the ASM portion of his code. I've managed to modify parts of the PBP portion of the program and it works like a charm. Has anyone here used Darrel Taylor's STRINGS.PBP? http://www.pbpgroup.com/modules/wfse...p?articleid=10 It's a great routine that saves heaps of code space when printing to an Lcd. I'm using it in a program for printing multiple instructions (over 150 prints @ 18 words ea) to the Lcd which explains to the user how the program functions and how to program the different variables needed to have the program operate efficiently. Probably as good as having a printed manual but one that you can't loose. I'm also using it for each button press to display (while the button is pressed) where the program is going and what's happening, which I think makes it easier to navigate all the user functions.

    The strings.pbp code is set up (thanks to Darrel's help) with two pushbuttons to control the instruction functions, one to view the first print then each additional press of the same pushbutton prints the next screen. The other pushbutton ends the viewing and returns to the main program loop.

    What I'd like to be able to do, is to implement in the asm code portion of the routine, additional code so that a third pushbutton could be used to view the previous print in the Inst1: subroutine if that's possible? Having a "view previous print pushbutton" would be the icing on the cake for my program! Can anyone help me out with this one? I've included some parts of my program that relates to Darrel's code in an attachment below that shows how my pushbuttons are set up to use Darrel's code.

    Thanks
    jessey
    Attached Files Attached Files

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Hi jessey,

    Wow, there's 15 set's of instructions in there now? There were only 2 when the chip was "Maxed Out" to begin with. Cool!

    It should be pretty easy, but it's been over a year since I've seen this program. Give me a little time to digest it again, and I'll get back to you.

    .
    DT

  3. #3
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Oh, that wasn't too tough afterall.

    First, you need to declare the button's input, and add a variable.
    Code:
    PrevButton   VAR PORTB.0  ' Or, wherever it is
    PrevPressed  VAR BIT
    Then change the routines shown here. Modifications are in Red.
    Code:
    ShowInstructions:
            ButtonDown = 1                         ' Button was pressed to get here
            If T = 1 THEN PauseTime = PageTime     ' display each screen for 20ms
            If S = 1 THEN PauseTime = PageTime2    ' display each screen for 1ms
            DisplayCount = 0                       ' Reset the loop counter
        ShowAgain:                                 ' Start from 1st instruction
            Finished = 0
            Addr = CurrentInst                     ' Set the address of the Instruction text
        NextPage:  
            LCDOUT $FE,2                           ' Home cursor
            GOSUB DisplayPage                      ' Display 1 Page
        KeepWaiting:
            GOSUB ButtonPause                      ' Check buttons while pausing
            IF PrevPressed = 1 THEN
                PrevPressed = 0
                IF Addr - 36 >= CurrentInst THEN
                    Addr = Addr - 36
                ELSE
                    GOTO KeepWaiting
                ENDIF
            ENDIF
            If Finished = 1 THEN InstructionsDone  ' if The_Lcd_Push_Button Finished=1
            Readcode Addr, TwoChars                ' Check for END of instructions
            if (TwoChars & $7F) = $7E THEN InstructionsDone
            goto NextPage                          ' if not EOF display next page
        InstructionsDone:
            DisplayCount = DisplayCount + 1
            if DisplayCount = MaxShows THEN Finished = 1
            If Finished = 0 THEN ShowAgain
    Return
    
    ' ------------------------------------------[ Watch buttons while Pausing ]-----
    ButtonPause:                             
        for PauseLoop = 1 to PauseTime            ' approx. 1 ms per loop
            pauseUS 980
     
            If ButtonDown = 1 THEN                ' If a button is already Pressed
                GOSUB DebounceButtons             ' wait for it to be released
            Else                                  ' ELSE If ButtonDown = 0 THEN 
                IF S = 1 THEN                     ' Display description of button press
                    ButtonDown = 1                ' set var           
                    Finished = 1                  ' Indicate that we're done reading
                    S = 0                         ' this is set to = 1 in mainloop 1ms
                    Return                        ' Go back to mainloop with 1ms pause 
                endif
    
              if The_Lcd_Push_Button = Is_Pressed THEN
                ButtonDown = 1                   ' set var
                Finished = 1                     ' Indicate that we're done reading
                T = 0                            ' this is set to = 1 in mainloop 20 sec 
                Return                           ' go back to the mainloop.
              EndIF
                                           
               If View_Instructions_Push_Button = Is_Pressed THEN
                  ButtonDown = 1                ' set var
                  PWM Buzzer,175,1              ' indicate were going to the next page
                  Return                        ' Stop pausing and Goto next Page
               EndIf
    
               IF PrevButton = Is_Pressed THEN
                  ButtonDown = 1
                  PrevPressed = 1
                  RETURN
               ENDIF
     
            EndIf
        next PauseLoop
    Return
    
    DebounceButtons:
       If The_Lcd_Push_Button = Is_Not_Pressed THEN
        IF View_Instructions_Push_Button = Is_Not_Pressed THEN
         IF PrevButton = Is_Not_Pressed THEN
            PAUSE 20
            IF PrevButton = Is_Not_Pressed THEN
              If The_Lcd_Push_Button = Is_Not_Pressed THEN
                IF View_Instructions_Push_Button = Is_Not_Pressed THEN ButtonDown = 0
              ENDIF
            ENDIF
         ENDIF
        ENDIF
       ENDIF
    RETURN
    Completely Un-Tested though.

    .
    DT

  4. #4
    jessey's Avatar
    jessey Guest


    Did you find this post helpful? Yes | No

    Default

    Hi Darrel

    Wow that was quick, I sure appreciate your help. I'll try implementing your changes and get to you as soon as possible with the results.

    Thanks Again
    jessey

  5. #5
    jessey's Avatar
    jessey Guest


    Did you find this post helpful? Yes | No

    Default Your PrevPressed code works like a charm

    Hi Darrel

    Thanks for your improvements. Your PrevPressed code works like a charm but I noticed that when the Inst1: subroutine reaches the end print that it doesn't return like it should. All the other ones that are used for button press descriptions work to return though. Any ideas on what I did wrong or what I can do to get it to work as intended? I managed to get it to return by using a counter to return when the last print is counted but it dosen't display the last screen.

    I've spent the last few nights (late nights) working on your code with great results. I've managed to add code to your STRINGS.PBP that allows me to navigate through the 148 prints of instructions with relative ease. I've included the code I wrote to compliment your PrevPressed routine for you to look at.

    In the main portion of my program, I have a few variables that are user adjustable using up and down pushbuttons, so I used those 2 existing push buttons to go up and down to view
    the next and previous screens for the instructions. Then I added some more code and using another existing push button that when pressed together with either the up or down pushbutton performs a sort of auto repeat that advances or reverses the prints to the Lcd very quickly. I used counters to keep track of which print was showing to the Lcd then added IF..THEN's before the counters to be able to stop at certain prints (preset numbers) that will be the beginning of an instruction topic to make it easy to find the different topics without having to go through all 148 prints to find them. It took a few late nights to get it working properly but it sure was worth it.

    I'd appreciate it if you could have a look at it to see if you see any hidden got ya's in my new updated routines. Another question, I've maxed out the amount of prints I can get in my program without getting an error when compiling, is there a way to get more prints to the Lcd with your program?

    Thanks for your help
    jessey
    Attached Files Attached Files

  6. #6
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Jessey,

    I haven't found anything that would cause a problem with just Inst1:

    The only thing i can think of is that maybe one on the DA statements has the wrong number of characters in it. The Prev button relies on there being exactly 18 bytes per "print" to work properly. The lastest program you posted looks fine in that respect, but it's not the real data, so maybe you could check them.

    As for packing more text in the program, well, it may be time for a bigger chip, or to move it all off chip into some eeprom. uggg

    .
    DT

  7. #7
    jessey's Avatar
    jessey Guest


    Did you find this post helpful? Yes | No

    Default Moving up to the 18F452

    Quote Originally Posted by Darrel Taylor
    Jessey,

    I haven't found anything that would cause a problem with just Inst1:

    The only thing i can think of is that maybe one on the DA statements has the wrong number of characters in it. The Prev button relies on there being exactly 18 bytes per "print" to work properly. The lastest program you posted looks fine in that respect, but it's not the real data, so maybe you could check them.

    As for packing more text in the program, well, it may be time for a bigger chip, or to move it all off chip into some eeprom. uggg

    .
    Hello Darrel,

    I finally got my package delivered and switched my code for your strings over to a bigger chip, I'm now using a 18F452. I have my DS1820 thermostat code running on the 18F452 and everything is working good now but I can't seem to get your STRINGS example for the 16-bit pic's to work using the LCDOUT command. It was over a year ago now, if you can remember back that far (no pun intended LOL), that you helped me set up the strings for the 14-bit 16F877 using push buttons for multiple prints and switching the hserout to LCDOUT commands.

    I have since modified your strings example for the 16F877 code and it works like a charm, I even got it to return with the last print now. Now I'd like to be able add more prints hopefully by switching over to this bigger chip. I really hate to bother you with this but I've exhausted all attempts at modifying your example for the 18F's. If you get some time, could you please look over my code and offer any suggestions, I'd sure appreciate it. I did get it to work with limited success but am really struggling. Maybe I should be looking to switch my LCDOUT commands to using HSEROUT but I can't seem to find any code examples that explain how to do that. I've included the strings as I have it written for the 16f877.

    Thanks
    jessey
    Attached Files Attached Files

  8. #8
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Hi Jessey,

    Yeah, the 18F's work with bytes instead of words, so the addressing needs to be different.

    I think you should be able to change this
    Code:
      NextWord:
        Addr = Addr + 1         ' Point to next two characters
        goto DisplayPage        ' Continue with rest of the string
      PageDone:
        Addr = Addr + 1         ' Point to next two characters
    to this
    Code:
      NextWord:
        Addr = Addr + 2         ' Point to next two characters
        goto DisplayPage        ' Continue with rest of the string
      PageDone:
        Addr = Addr + 2         ' Point to next two characters
    But then that sounds too easy to be true.

    .
    DT

Similar Threads

  1. Interrupt RPM and Taylors Elapsed time on 18F4620
    By Tobias in forum mel PIC BASIC Pro
    Replies: 70
    Last Post: - 3rd February 2010, 17:12
  2. darrel taylor's instant interrupt compiler error
    By delta_boogie in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 20th October 2009, 20:07
  3. using darrel taylor's instant interrupts
    By Michael Wakileh in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 31st July 2007, 05:07
  4. Darrel Taylor's Interrupt Stuff & CDLite
    By picster in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 11th March 2006, 14:43
  5. Read Modify Write problem?
    By markedwards in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 18th November 2005, 22:02

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