NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Microcontroller Programming » LCD - and programming questions

January 20, 2011
by SpaceGhost
SpaceGhost's Avatar

I have a few questions about writing text messages to the LCD:

First of all, what's the difference between -

fprintf_P(&lcd_stream, PSTR("   YOUR TEXT HERE   "));

and,

lcd_write_string(PSTR("   YOUR TEXT HERE   "));

?

Also, is

lcd_line_one();

the same as

lcd_home();

?

What is the best way to put two separate (small) messages on the same line? For instance, if I wanted to display information on two halfs of one line -

 { lcd_line_one();
   fprintf_P(&lcd_stream, PSTR("LEFT                "));
 }

And,

 { lcd_line_one();
   fprintf_P(&lcd_stream, PSTR("               RIGHT"));
 }

Would this be the best way to do it? Is there another way to do it without adding extra spaces between the quotation marks?

Dave

January 20, 2011
by bretm
bretm's Avatar

The difference between fprintf_P and lcd_write_string is that fprintf_P allows formatting characters such as %s, %d, etc., along with additional parameters which would get formatted and inserted into the string. lcd_write_string doesn't do this as far as I know. But for that specific example without any formatting characters or additional parameters there isn't a difference.

I believe lcd_line_one is the same as lcd_home. There may be a subtle difference in the case where you enable the LCD's scrolling mode, but the Nerdkits LCD library doesn't do that.

That's not the best way to put two things on the same line. Wouldn't work, actually, because the spaces would overwrite anything else that's there. There's a function called lcd_goto_position which takes a row number and column number (starting from 0). So you could do lcd_goto_position(0, 10) to go to the middle of the first row, for example.

January 20, 2011
by SpaceGhost
SpaceGhost's Avatar

Hey, thanks bretm, that has cleared a few things up for me... Especially the lcd_goto_position information - that helps me out quite a bit!

Dave

January 20, 2011
by Ralphxyz
Ralphxyz's Avatar

SpaceGhost, please let us see how you are using lcd_goto_position.

This is the first time I have heard of such a thing, course I have not looked into the lcd.h file.

Ralph

January 21, 2011
by SpaceGhost
SpaceGhost's Avatar

Hi Ralph, I have been experimenting with putting different messages on the LCD to represent, identify or correspond with different pushbutton states.

I had tried putting two such messages on one line; the example I gave only worked when I had one of the messages before the while loop in the main program, as well as in the loop itself.

Putting the code like this instead:

{ lcd_line_one();
  fprintf_P(&lcd_stream, PSTR("LEFT"));
}

{ lcd_line_one();
  lcd_goto_position(0, 15);
  fprintf_P(&lcd_stream, PSTR("RIGHT"));
}

Puts the word "RIGHT" on the same line, but puts it 15 places to the right. "LEFT" already starts and sits on the left side of the line, of course.

Am I explaining that right, bretm?

February 20, 2011
by hariharan
hariharan's Avatar

How to do animations or graphics with lcd? like moving the text left to right, up to down and vice versa?

March 31, 2011
by lnino
lnino's Avatar

I would be also interested how to get text moving from the left to the right.

When I started the MCU the first time, there was a text movement on the display. Where the text "Hardware is okay" moved from one side to another. You can I make this?

March 31, 2011
by lnino
lnino's Avatar

Hi,

after I spend some time in the "search-machine" of the nerdkits forum I found what I was looking for.

For all who are interested in the same thing, here is the thread about scrolling text: Here

March 31, 2011
by Ralphxyz
Ralphxyz's Avatar

Gee, Inino that took you 15 minutes to find your answer, I apologize to you and hariharan I had not seen your post I could have given you the link, there are a number of threads about scrolling text on the LCD.

Ralph

March 31, 2011
by lnino
lnino's Avatar

No problem Ralph, 15 minutes was a good time. Somtimes it is good to solve problems on your own. That has a higher learning factor. So now I know how to use the searching machinery of the forum. :-) I hope I do. smile

Post a Reply

Please log in to post a reply.

Did you know that you can use printf and scanf functions to talk to your computer from your USB NerdKit? Learn more...