Pages: 1 [2]   Go Down
Author Topic: Running Text on a 16x2 LCD  (Read 13383 times)
0 Members and 1 Guest are viewing this topic.
Left Coast, USA
Offline Offline
Sr. Member
****
Karma: 7
Posts: 499
Sometimes I just can't help myself.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

...buffer[1] = '\0';
The loop in sendmsg (from your code) uses the zero byte to know when it has reached the end of the "string."  That's the way that "normal" C library functions handle these things, and it is a convention followed by C programmers everywhere (well, almost everywhere).

Here's the loop:

Code:
   while (*str) {
.
.
.
    ++str;
}
That means that the pointer is incremented each time through the loop.  When the pointer reaches the address of the zero byte, the "while" condition fails, and that's the end of the road.  The calling function puts a single character at the beginning of the buffer, followed by a zero byte, every time my program called the function.  That's just an example.  You could put any kind of C-style "string" in the buffer (always terminated by a zero byte).


Regards,

Dave

« Last Edit: February 04, 2011, 12:19:33 am by davekw7x » Logged

0
Offline Offline
Jr. Member
**
Karma: 1
Posts: 52
... indessen wandelt harmlos droben das Gestirn
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

@davekw7x

Thanks for your explanation. I understood.

My misunderstanding came from the way I wanted to implement the storage of chars. In the first go I wanted /want to use a two dimensional array (matrix) (something like char lines [16] [10]) so that I am able to retrieve a longer text on the display via the buttons on the LCD shield. The control of the matrix should be done by loops. I was not aware that a transition from "normal" array to string was triggered.

Now I see that it is easier to go with strings incl. termination. Oh dear, perhaps I should have stayed with things I know how to handle.

Again thanks for your time and engagement.
Logged

---
... indessen wandelt harmlos droben das Gestirn

Pages: 1 [2]   Go Up
Jump to: