Pages: [1]   Go Down
Author Topic: PCD8544 - Inverting Characters  (Read 1355 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi

Im trying to invert characters on this Nokia-LCD

with...
Code:
lcd.setInverse(0x0d);
it inverts the whole Display,but I only want to invert some sentences or chars like on this picture

Deck A...


In the german section of this forum I got this hint :
" In the program you have a variable who store the value of every char (5 bytes). This function writes these 5 bytes in the RAM and then transfer it to the display
  Try to create (copy) a function who invert this value. Use for this a XOR with 255."

Im sorry, but Im not that C-Pro and want to ask if anyone can explain me that with some democode or something...

Best Regards
MTE
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 180
Posts: 8108
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The character drawing is done inside the library.  You'll have to modify the library to add inverted text drawing.  The new function will be very similar to the existing 'write' except for two lines:

Code:
    // Output one column at a time...
    for (unsigned char i = 0; i < 5; i++) {
        this->send(PCD8544_DATA, ~glyph[i]);  //// Invert each column...
    }

    // One column between characters...
    this->send(PCD8544_DATA, 0xFF);  //// ...and the space between characters.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yayyy works smiley

only for one character, not for sentences, but Im a big step forward.....thank you !

Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

OK, the code goes huge when I write char by char inverted....is there any chance that I make a function to write whole sentences inverted ?
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 180
Posts: 8108
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You could add code to the PD8544 object to maintain an inverseText flag and test the flag inside write().  Then the print functions which call write() will display in inverse as long as that flag is set:

Code:
LCD.setInverseText();
LCD.println("This text will display in inverse.");
LCD.println("So will this.");
LCD.setNormalText();
LCD.println("but this line will be normal");
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
LCD.setInverseText();
LCD.println("This text will display in inverse.");
LCD.println("So will this.");
LCD.setNormalText();
LCD.println("but this line will be normal");


This is logic for me, Ive trying this since days smiley but my C-knowledge isnt that like yours smiley

I need some hints how I implement this into the driver...

like
Code:
for (unsigned char i = 0; i < 5; i++) {
        this->send(PCD8544_DATA, ~glyph[i]); 

and

Code:
this->send(PCD8544_DATA, 0xFF);

smiley
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 180
Posts: 8108
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Try these:

http://pastebin.com/WVwLaqNY
http://pastebin.com/DPHM7z50

The syntax is:
Code:
LCD.setInverseText(true);
LCD.println("This text will display in inverse.");
LCD.println("So will this.");
LCD.setInverseText(false);
LCD.println("but this line will be normal");

Note: I have not actually tested this code.  It is a fairly simple change so I don't anticipate any problems. smiley
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Works like a charm smiley

Thank you so much !!!!
Logged

Pages: [1]   Go Up
Jump to: