Go Down

Topic: Rotate and reverse characters in LCD display (Read 1 time) previous topic - next topic

ScottG

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: [Select]

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);
}

guix

#1
Jan 25, 2013, 03:37 am Last Edit: Jan 25, 2013, 03:39 am by guix Reason: 1
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 :)

It should reverse lines and character positions, but not the character itself, you have to try things to get the desired result :)

marco_c

#2
Jan 25, 2013, 05:28 am Last Edit: Jan 25, 2013, 05:30 am by marco_c Reason: 1
Code: [Select]
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 :-)
Arduino libraries http://arduinocode.codeplex.com
Parola hardware & library http://parola.codeplex.com

Go Up