Pages: [1]   Go Down
Author Topic: Rotate and reverse characters in LCD display  (Read 931 times)
0 Members and 1 Guest are viewing this topic.
New Jersey
Offline Offline
God Member
*****
Karma: 2
Posts: 517
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have a 128x64 LCD display and I want to rotate the text so the display can be read from the other side.  Basically the character would have to be inverted, then displayed right to left.  See attached images.

I'm using this library: https://github.com/adafruit/ST7565-LCD

The function that displays character is below.  Can someone tell me what changes to the code I can make to get the text to flip?

Code:
void ST7565::drawchar(uint8_t x, uint8_t line, char c) {
  for (uint8_t i =0; i<5; i++ ) {
    st7565_buffer[x + (line*128) ] = pgm_read_byte(font+(c*5)+i);
    x++;
  }
  updateBoundingBox(x, line*8, x+5, line*8 + 8);
}


* LCD Text 2.jpg (17.78 KB, 317x182 - viewed 29 times.)

* LCD Text 1.jpg (18.33 KB, 317x182 - viewed 27 times.)
Logged

France
Offline Offline
God Member
*****
Karma: 34
Posts: 987
Scientia potentia est.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Not sure if it's that easy, but maybe like this:

change everywhere you see "x", to "(128 - x)"
and everywhere you see "line", to "(8 - line)"

It's probably not only this, but it's a start smiley

It should reverse lines and character positions, but not the character itself, you have to try things to get the desired result smiley
« Last Edit: January 24, 2013, 09:39:22 pm by guix » Logged

Sydney, Australia
Offline Offline
Edison Member
*
Karma: 33
Posts: 1259
Big things come in large packages
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
pgm_read_byte(font+(c*5)+i);

This tells you that the character definitions are stored in an array called font.

You need to look at what the bit patterns in there are and then create the new bit pattern (reversed and upside down) either on the fly when you need to display or as a new font table.

The normal LCD libraries allow you to have text going right to left instead of the normal left to right. Combine the two and you should have what you need.

An alternative is to just mount the LCD display upside down :-)
« Last Edit: January 24, 2013, 11:30:55 pm by marco_c » Logged

Arduino libraries http://arduinocode.codeplex.com
Parola hardware & library http://parola.codeplex.com

Pages: [1]   Go Up
Jump to: