PCD 8544 driver question

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
dazer
 
Posts: 9
Joined: Fri Sep 21, 2012 10:02 am

PCD 8544 driver question

Post by dazer »

Hi,
I purchased the nokia 84 x48 LCD and the driver library works fine.
I however haave a question:
Im using

Code: Select all

  display.setTextSize(1);
  display.setTextColor(BLACK);
  display.setCursor(0,0);
My question is what if I need to go to line 1 on the display and print a character?
Is there an inbuilt function that can do this.
Ive tried lcd.setCursor(0, 1); however this moves by just one pixel.
I need to be able to move anywhere on the display simply by feeding xy values. But i do not want to have a pixel drawn i need the whole character there.

How can i do this ?

Thanks in advance.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: PCD 8544 driver question

Post by adafruit_support_rick »

This is a graphics display, not a character display, so it has no concept of text "lines". The included font is 5X8, that is, five pixels wide by eight pixels high. If you allow a blank row between lines, and a blank column between characters, then each character takes up 6 by 9 pixels.

So, you can go to the start of a particular text line by multiplying by 9:

Code: Select all

lcd.setCursor(0,0);  //start of line 0
lcd.setCursor(0,9);  //start of line 1
lcd.setCursor(0,18);  //start of line 2
The same logic applies to finding a character poison on a line. The x coordinate will be a multiple of 6.

Of course, you can write a function to do this for you.

Code: Select all

void SetCharPos(int line, int charPos)
{
    lcd.setCursor(charPos-1 * 6, line-1 * 9);   //subtract 1 so that we can number lines and charPos from 1 instead of from 0
}
After you set the position, you write the text with lcd.print, the same as with Serial.print:

Code: Select all

  lcd.print("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor");
  lcd.println(0xAB, HEX);
  lcd.print(99.99);
  lcd.println('%');
Last edited by adafruit_support_rick on Fri Sep 21, 2012 11:18 am, edited 1 time in total.
Reason: fix typo in first code block

User avatar
dazer
 
Posts: 9
Joined: Fri Sep 21, 2012 10:02 am

Re: PCD 8544 driver question

Post by dazer »

Thanks a ton :o
I actually did the same thing earlier, but i thought it might be wrong and that there was a built in function which i somehow missed.
But what helped was you pointing out that its a graphic display not character.
Dunno, but maybe you want to add
void SetCharPos(int line, int charPos)
{
lcd.setCursor(charPos-1 * 6, line-1 * 9); //subtract 1 so that we can number lines and charPos from 1 instead of from 0
}
this in the library for those like me :mrgreen:

Another question how do i erase a character that i have written at a particular point on the screen. Ive tried writing a ' ' blank ch
but there is no effect.

User avatar
adafruit_support_bill
 
Posts: 88088
Joined: Sat Feb 07, 2009 10:11 am

Re: PCD 8544 driver question

Post by adafruit_support_bill »

That's another property of graphical displays. The good news is that they allow you to overlay text & graphics. The bad news is that you have to manually repaint the background if you want to change the text. If you have a solid background color, this can be as simple as drawing a rectangle of that color in the character position you want to erase.

User avatar
dazer
 
Posts: 9
Joined: Fri Sep 21, 2012 10:02 am

Re: PCD 8544 driver question

Post by dazer »

hmmn, im a little stumped here.
So im using the Nokia pcd 8544 with an RTC module using the Arduino and the GFX library.
How then would i be able to update the seconds in the same place on the screen?
I have to manually paint the area white again?
Any clue coding you can share with me?

Thanks

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: PCD 8544 driver question

Post by adafruit_support_rick »

Set your location, draw a white 11x8 rectangle, and then write the two digits.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”