help again with scrolling without wrapping

This is a discussion on help again with scrolling without wrapping within the C Programming forums, part of the General Programming Boards category; Okay third time's a charm? The last two projects have not worked out very well. So i've re-written my code ...

  1. #1
    Registered User
    Join Date
    Sep 2007
    Location
    Boston
    Posts
    25

    help again with scrolling without wrapping

    Okay third time's a charm? The last two projects have not worked out very well. So i've re-written my code in the following structure.

    Print Buffer
    Clear Buffer
    Write to Buffer with (x,y cordin)

    I can print and clear fine. Those are just registers built into the LCD Cntrl.

    Its just the shifting part that im still have problems with. I'm trying to shift three things which i can put into arrays..... the alphabet in capitol letters, lower case letters, and numbers 0-9. But the catch is i need them to be scrolled without overlapping onto the next line. Its a 20x4 display, the top line has 20 places and i would like it to start on th right right and scroll from right to left... however... any time i put information in to scroll... my text goes down to the 2nd and 3rd lines...

    say the address for each space is 0x00, 01, 02.... 09, 0A, 0B, 0C....0F, 10, 12, 13

    the second line is 14, 15, 16.... 27

    third is 28, 29, 2A, 2B....

    4th ends at 4C


    so naturally my text should begin at 13 and scroll to 00...

    id like to be able to do this on each line...without overlapping to the next line

    here are some ideas i have going...

    Code:
    #define y2  write_lcd(REG, 0xC0); //location on LCD far right, line 2
    
    #define y3  write_lcd(REG, 0x94); //location on line 3
    
    #define y4  write_lcd(REG, 0xD4); //location on line 4
    
     
    
     
    
    void lcd_location(const char *s)
    
    {
    
                while(*s)
    
    //          lcd_puts("abcdefghijklmnopqrstuvwxyz");
    
                 *s++;
    
                 wait_msec(DELAY_5MSEC);
    
     
    
    }
    
     
    
     
    
     
    
    int msg_offset = 0;
    
     
    
                
    
     
    
     
    
     
    
     
    
    for (int line_offset = y2,line_offset <20,line_offset++;) {
    
     
    
                            if (line_offset >= 0 ) (
    
                                        line3[msg_offset] = msg[msg_offset]
    
                            }
    
                            msg_offset++
    
     
    
                            if (!msg[msg_offset])
    
                                        break;
    
     
    
    }


    so hopefully i can get some more ideas/help from you guys...

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,451
    I see poorly (make that very poorly) formatted code, and I have a sense of deja-vu...
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    You have to take specific control of how many char's you're printing on each line. If printing to the last char in a row causing your device to automatically line feed and carriage return to the next line, then you should leave a one char border (probably on both sides of the display, so it's even looking), on the left and the right sides of the display.

    With the char's being counted, and nothing being printed on an end of line space, the whole line printing can be handled nicely by a for loop.

    That's how I do it when I program a game or puzzle, for a scrolling text display, on a standard output display.

    You're over-thinking what you need here, imo. Get down and "dirty" with it, and it's ez.

  4. #4
    Registered User
    Join Date
    Sep 2007
    Location
    Boston
    Posts
    25
    Quote Originally Posted by Salem View Post
    I see poorly (make that very poorly) formatted code, and I have a sense of deja-vu...
    thanks for nothing

  5. #5
    Registered User
    Join Date
    Sep 2007
    Location
    Boston
    Posts
    25
    Quote Originally Posted by Adak View Post
    You have to take specific control of how many char's you're printing on each line. If printing to the last char in a row causing your device to automatically line feed and carriage return to the next line, then you should leave a one char border (probably on both sides of the display, so it's even looking), on the left and the right sides of the display.

    With the char's being counted, and nothing being printed on an end of line space, the whole line printing can be handled nicely by a for loop.

    That's how I do it when I program a game or puzzle, for a scrolling text display, on a standard output display.

    You're over-thinking what you need here, imo. Get down and "dirty" with it, and it's ez.
    No im really not over thinking it. Its not a carriage return. Picture a 80 character display only divided by 4. All the addresses are in line so naturally if it reaches the 0x13 address, the next address it will be going to is the 0x14 address.

  6. #6
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,451
    You're welcome - if you can't be bothered to present your case in an easy to read manner, then expect people to just ignore you rather than try to push you in the right direction.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  7. #7
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Quote Originally Posted by Dukefrukem View Post
    No im really not over thinking it. Its not a carriage return. Picture a 80 character display only divided by 4. All the addresses are in line so naturally if it reaches the 0x13 address, the next address it will be going to is the 0x14 address.
    Bad choice of words, on my part. I meant that the EFFECT on your display, was the same effect as a CR/LF combo. Same as on a regular monitor, you don't want to print something at the last address on the line, in order to avoid line wrapping.

    Although it can be done with one loop, I usually use two functions. The first has the "smarts", and sends the second (which actually does the printing), function the line # (an address in your case), and the content of the text char's to be displayed, which are already truncated to fit into the space that I need it to fit into.

    I use variables like start_row, stop_row, current_row, and margin, to make it ez to visualize just what needs to be done next, in the logic.

    If you'll give me a little sample of what you want for output, I'll hack up something to show you what I mean. It will be in rows, instead of addresses, but the idea is just the same.

    I'm not trying to belittle your efforts or be "combative", here. I'm just not good enough at programming to make hide nor hair out of your sample code. I only know one way to do this, (using one or two loops, but it's the same logic).

    When you say "scroll", show me EXACTLY what you want. If you're thinking that I'm thinking what you're thinking, we're both thinking down the wrong path, here. Please be precise, I won't do this twice.

    Edit: My understanding is you want each char to scroll from right to left on each line, and to have new text appear on the bottom line, and be moved upward by one line, as the next (new) line is being entered.

    Code:
    *****12345678901234567890
    *****==================
    Line 1 ==================
    Line 2 ==================
    Line 3 ==================
    Line 4 =================A
    
    Line 1 ==================
    Line 2 ==================
    Line 3 ==================
    Line 4 ===============A L
    
    Line 1 ==================
    Line 2 ==================
    Line 3 ==================
    Line 4 ==============A Lo
    
    Line 1 ==================
    Line 2 ==================
    Line 3 ==================
    Line 4 =============A Lon
    
    Line 1 ==================
    Line 2 ==================
    Line 3 ==================
    Line 4 ============A Long
    
    Line 1 ==================
    Line 2 ==================
    Line 3 ==================
    Line 4 ===========A Long T
    
    Line 1 ==================
    Line 2 ==================
    Line 3 ==================
    Line 4 ==========A Long Ti
    
    ~~~~~~~~~~~~~~~~~~~~
    Finally ending with:
    
    Line 1 A Long Time Ago =====
    Line 2 in a galaxy far, far ====
    Line 3 away, there were - ===
    Line 4 Star Wars! =========
    
    After this, the first line would scroll off the display, right?
    Do you want each line to move all the way to the leftmost position on that line, before the new line is added,
    causing that line to be moved upward?
    Last edited by Adak; 09-14-2007 at 08:42 PM.

  8. #8
    Registered User
    Join Date
    Sep 2007
    Location
    Boston
    Posts
    25
    Quote Originally Posted by Salem View Post
    You're welcome - if you can't be bothered to present your case in an easy to read manner, then expect people to just ignore you rather than try to push you in the right direction.
    And if you can't be bother to be nice and respectful to members looking for help that dont know much about what they are asking, then you're just another self centered coder who'd rather link to "how tos" then explain what it is i need to work on. I know too well your kind.

  9. #9
    Registered User
    Join Date
    Sep 2007
    Location
    Boston
    Posts
    25
    Quote Originally Posted by Adak View Post
    Bad choice of words, on my part. I meant that the EFFECT on your display, was the same effect as a CR/LF combo. Same as on a regular monitor, you don't want to print something at the last address on the line, in order to avoid line wrapping.

    Although it can be done with one loop, I usually use two functions. The first has the "smarts", and sends the second (which actually does the printing), function the line # (an address in your case), and the content of the text char's to be displayed, which are already truncated to fit into the space that I need it to fit into.

    I use variables like start_row, stop_row, current_row, and margin, to make it ez to visualize just what needs to be done next, in the logic.

    If you'll give me a little sample of what you want for output, I'll hack up something to show you what I mean. It will be in rows, instead of addresses, but the idea is just the same.

    I'm not trying to belittle your efforts or be "combative", here. I'm just not good enough at programming to make hide nor hair out of your sample code. I only know one way to do this, (using one or two loops, but it's the same logic).

    When you say "scroll", show me EXACTLY what you want. If you're thinking that I'm thinking what you're thinking, we're both thinking down the wrong path, here. Please be precise, I won't do this twice.

    Edit: My understanding is you want each char to scroll from right to left on each line, and to have new text appear on the bottom line, and be moved upward by one line, as the next (new) line is being entered.

    Code:
    *****12345678901234567890
    *****==================
    Line 1 ==================
    Line 2 ==================
    Line 3 ==================
    Line 4 =================A
    
    Line 1 ==================
    Line 2 ==================
    Line 3 ==================
    Line 4 ===============A L
    
    Line 1 ==================
    Line 2 ==================
    Line 3 ==================
    Line 4 ==============A Lo
    
    Line 1 ==================
    Line 2 ==================
    Line 3 ==================
    Line 4 =============A Lon
    
    Line 1 ==================
    Line 2 ==================
    Line 3 ==================
    Line 4 ============A Long
    
    Line 1 ==================
    Line 2 ==================
    Line 3 ==================
    Line 4 ===========A Long T
    
    Line 1 ==================
    Line 2 ==================
    Line 3 ==================
    Line 4 ==========A Long Ti
    
    ~~~~~~~~~~~~~~~~~~~~
    Finally ending with:
    
    Line 1 A Long Time Ago =====
    Line 2 in a galaxy far, far ====
    Line 3 away, there were - ===
    Line 4 Star Wars! =========
    
    After this, the first line would scroll off the display, right?
    Do you want each line to move all the way to the leftmost position on that line, before the new line is added,
    causing that line to be moved upward?
    This is actually the method i took.
    Thanks for taking the time to help.

    No i didn't want to the next to wrap down to the next line and I got a pretty nice working scroll going.

    Thanks again.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Scrolling background?
    By Deo in forum Game Programming
    Replies: 6
    Last Post: 06-09-2005, 05:40 PM
  2. Scrolling
    By PJYelton in forum Windows Programming
    Replies: 10
    Last Post: 03-24-2003, 09:04 AM
  3. Bitmap scrolling with scroll bars
    By solar3147 in forum Windows Programming
    Replies: 0
    Last Post: 03-17-2003, 01:39 AM
  4. SkyLock graphics demo (scrolling, etc.)
    By jdinger in forum Game Programming
    Replies: 9
    Last Post: 06-30-2002, 08:18 PM
  5. Vesa. Parallax scrolling.
    By r0x in forum Game Programming
    Replies: 5
    Last Post: 06-10-2002, 05:39 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21