NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Project Help and Ideas » String manipulation
October 12, 2011 by claesz |
This is really embarrassing, but C is not my strong side and I just got my NK the other day and though I'd test it out by making a scrolling text through string manipulation. I know there are many examples of LCD scrollers on this forum that are all much better and more efficient, and this was just meant as a bit of practice for me. The thing works (though I must be overwriting some null str termination somewhere as it from time to time it will mess itself up). Now, my though was take a text string. Start by adding screen width number of spaces + text string. Only spaces will show. Next step add width-1 number of spaces + text. One letter will show, etc, etc. When number of spaces = 0, just write text+1, text+2 etc. If strlen less than screen width add spaces to fill up. The principle works of course, all though it is a silly way of making a scroller. However, and finally I get to my question. The line //printline[21] = 'x'; has been commented out. In my mind that should actually add an x just off the screen every time (or next line if you don't cut off the string), since the print function will print from start of array until end. Here I must have misunderstood something in how C works, because in reality it will add an "x" as the first letter of the text-to-show string (the first 20 chrs are spaces) and move it along the whole screen as it scrolls. Originally I wanted to add a "0" to avoid writing a string so long that it continued on to the next line. For testing purposes I have put X there now. What am I misunderstanding? I know this is not a NK question and I should have found a C forum to post this question in, but you guys seem friendly so I though I'd give it a shot.
|
---|---|
October 12, 2011 by claesz |
Sorry. I obviously posted this in the wrong forum. I can't move it so I will post again in the right "C programming" forum. My apologies. |
Please log in to post a reply.
Did you know that a piezoelectric buzzer can be used in reverse as a microphone? Learn more...
|