olikraus / u8glib

Arduino Monochrom Graphics Library for LCDs and OLEDs
https://github.com/olikraus/u8glib/wiki
Other
1.25k stars 314 forks source link

Add horizontal flip #426

Closed gcstr closed 4 years ago

gcstr commented 8 years ago

We are working on a project where we need to flip the entire screen. When working with shapes and primitives, it's ok, since it's just a matter of math.

But texts are not ok. It would be nice if the lib could support something like setHFlip and the screen flipped horizontally, something like setRot90, setRot180... but flipping the entire screen.

olikraus commented 8 years ago

You mean, the text should appear mirrored? So to say, readable only with a mirror?

gcstr commented 8 years ago

Exactly. Some wearables, like the one we are prototyping, might require that.

I managed to achieve the result I wanted playing with adafruit's library. C isn't really my main language, so the code I wrote is really simple, but did the trick for now:

void Adafruit_SSD1306::flip(void){
  for (int i=0; i<8; i++) {
    reverse(buffer, SSD1306_LCDWIDTH*i, SSD1306_LCDWIDTH*i+(SSD1306_LCDWIDTH-1));
  }
}

I simply iterate through the buffer reversing the array.

gcstr commented 8 years ago

Actually, I got the starting idea from here:

http://nerdclub-uk.blogspot.com.br/2016/03/adding-flip-function-to-adafruits.html?m=1

But it only rotates the screen, feature already in u8g.

I`d like to contribute to the repo, but as I said, it's not my main language. It's just a feature request. 😀

olikraus commented 8 years ago

you could try to change the value 0x0c8 to 0x0c0 in line 130 of u8g_dev_ssd1306_128x64.c (assumming you have this display)

gcstr commented 8 years ago

Yap, that's my display. I'll try that tonight.

olikraus commented 8 years ago

any success?

gcstr commented 8 years ago

Perfect! It worked. Thank you very much.

johnny-82 commented 6 years ago

Hi olikraus! sorry for my English. I need to flip horizontally my old "nokia 5210 lcd". I am using U8GLIB_PCD8544. Can you help me change the code? do I have to edit the file "u8g_dev_pcd8544_84x48.c"?

olikraus commented 6 years ago

what about using setRot180?

johnny-82 commented 6 years ago

when I use this library the screen appears reflected horizontally img_20180706_222229

olikraus commented 6 years ago

ok, I see. What about using u8g2 (which is u8glib version 2). It includes a mirror option should solve the problem.

johnny-82 commented 6 years ago

thanks a lot! It work with "U8G2_PCD8544_84X48_F_4W_SW_SPI u8g2(U8G2_MIRROR, /* clock=..." the only "problem" is that this library is a bit too heavy...

olikraus commented 6 years ago

HW SPI might be better

SteveC00k commented 5 years ago

I have a similar issue. The text is mirrored. I used this display setting:

u8g_dev_sbn1661_122x32.c

I altered the lines 54 and 59 to 0x0a and it did not mirror. See gfx below. (NOTE: Images are upside down. Sorry but thats how they uploaded.)

Here is what it looks like with the settings before altering. img_9709

Here is what it looks like after altering. img_9710

Back of LCD. img_9711

screenshot_10

SteveC00k commented 5 years ago

Here is the datasheet if anyone needs to see it. https://drive.google.com/open?id=1gbZHPdsXN4bUGbe_5cXVszRSPaIAwO8v

SteveC00k commented 5 years ago

Started to use the ug82 lib. I managed to get it working except half the text is chopped off on one of the examples.

SteveC00k commented 5 years ago

I have it working now. Found out how to get it going using this constructor in the examples. U8G2_SED1520_122X32_1 u8g2(U8G2_MIRROR, 8, 9, 10, 11, 4, 5, 6, 7, /dc=/ A0, /e1=/ A3, /e2=/ A2, / reset=/ U8X8_PIN_NONE); // Set R/W to low!