Thread: Scrolling Characters Output

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

    Scrolling Characters Output

    Hey guys. Great forums.

    C programming n00b here hoping some of you can help me with a problem I'm working on.



    The overall goal I'm trying to achieve is scroll every character of the alphabet on an LCD screen.

    I've already written two functions that can print out definitions (which can be set to the hex table they represent) and another function where i can simply print out anything I have in quotes. However, I'd like to scroll through the entire alphabet and I'm a noob so I'm no too sure how to do this.

    Some ideas I have are:

    Code:
    char characHI[] = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
    char characLO[] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
    int characNU[] = {'1','2','3','4','5','6','7','8','9','0'};
    int i;
    
    for ( i = 0; i < 10; ++i )
    write_lcd(REG, characNU[i]);
    The write_lcd function prints out characNU as a test (for the numbers). REG is = 1. But this doesn't work. I'm just throwing ideas out right now but any help is appreciated. Thanks in advance.

    -Duke

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    > and another function where i can simply print out anything I have in quotes.
    So this bit works right?

    > However, I'd like to scroll through the entire alphabet
    And this bit doesn't ?

    Unless your LCD has a specific command to scroll (without assistance from your program), you basically have to do it yourself and regenerate the entire display from scratch for each scrolling step.

    Say
    Code:
    char msg[] = "abcde";
    
    Then a loop
    for ( i = 0 ; i < 5 - 3 ; i++ ) {
      displaySubString( &msg[i], 3 );  // abc, then bcd, then cde
    }
    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.

  3. #3
    Registered User
    Join Date
    Sep 2007
    Location
    Boston
    Posts
    25
    Quote Originally Posted by Salem View Post
    > and another function where i can simply print out anything I have in quotes.
    So this bit works right?

    > However, I'd like to scroll through the entire alphabet
    And this bit doesn't ?

    Unless your LCD has a specific command to scroll (without assistance from your program), you basically have to do it yourself and regenerate the entire display from scratch for each scrolling step.

    Say
    Code:
    char msg[] = "abcde";
    
    Then a loop
    for ( i = 0 ; i < 5 - 3 ; i++ ) {
      displaySubString( &msg[i], 3 );  // abc, then bcd, then cde
    }


    Ah i didn't think of it that way. Brilliant!!

    Yes the function that is made where I can print anything out in quotes works. I can put in words "hello" and it will print it out respectively.

    Thanks for the quick response. I've been lookin for a good programming board for a while now and I think I just found it.

  4. #4
    Registered User
    Join Date
    Sep 2007
    Location
    Boston
    Posts
    25
    another quick question.

    displaySubString would act as what? a function?

  5. #5
    Registered User
    Join Date
    Sep 2007
    Location
    Boston
    Posts
    25
    to make myself a bit more clear:

    Code:
    char displaySubString;
    int i;
    
    char msg[] = "abcde";
    
    for ( i = 0 ; i < 5 - 3 ; i++ ) {
      displaySubString( &msg[i], 3 );  // abc, then bcd, then cde
    }
    
    lcd_puts(displaySubString);
    and im getting an error: banner.c:132: error: called object '&displaySubString' is not a function

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Yes, displaySubString() is a function, which displays the specified number of characters using whatever LCD specific function you choose.
    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.

  7. #7
    Registered User
    Join Date
    Sep 2007
    Location
    Boston
    Posts
    25
    Quote Originally Posted by Salem View Post
    Yes, displaySubString() is a function, which displays the specified number of characters using whatever LCD specific function you choose.
    Hmmm then why am i getting this error?

  8. #8
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    I believe it is a hypothetical function, that you are to replace with what ever function you have for displaying text.

  9. #9
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    because you didn't make it yet. it's not a standard function.

  10. #10
    Registered User
    Join Date
    Sep 2007
    Location
    Boston
    Posts
    25
    omg im a n00b.

    k i just replaced it with my lcd_puts function.

    what does the 3 represent in:
    Code:
    msg[i], 3

  11. #11
    Registered User
    Join Date
    Apr 2007
    Posts
    51
    Quote Originally Posted by Dukefrukem View Post
    omg im a n00b.

    k i just replaced it with my lcd_puts function.

    what does the 3 represent in:
    Code:
    msg[i], 3
    Based on the example, I am guessing the number of characters you can display at once. Again, based on your function to the LCD.

  12. #12
    Technical Lead QuantumPete's Avatar
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    894
    Quote Originally Posted by Dukefrukem View Post
    omg im a n00b.
    Yeah, and that kind of spelling literally screams it. :S

    QuantumPete
    "No-one else has reported this problem, you're either crazy or a liar" - Dogbert Technical Support
    "Have you tried turning it off and on again?" - The IT Crowd

  13. #13
    Registered User
    Join Date
    Sep 2007
    Location
    Boston
    Posts
    25
    Quote Originally Posted by QuantumPete View Post
    Yeah, and that kind of spelling literally screams it. :S

    QuantumPete
    Well obviously I'm not a newbie to internet forums. Im just trying to exaggerate my level of C programming.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help for my output array
    By qwertysingh in forum C Programming
    Replies: 1
    Last Post: 02-17-2009, 03:08 PM
  2. Formatting output into even columns?
    By Uncle Rico in forum C Programming
    Replies: 2
    Last Post: 08-16-2005, 05:10 PM
  3. Strange characters in output Need Help ASAP
    By KristTlove in forum C++ Programming
    Replies: 2
    Last Post: 12-14-2003, 06:35 PM
  4. printing non-ASCII characters (in unicode)
    By dbaryl in forum C Programming
    Replies: 1
    Last Post: 10-25-2002, 01:00 PM
  5. output of characters
    By deleeuw in forum C++ Programming
    Replies: 1
    Last Post: 08-30-2001, 11:17 PM