adafruit / Adafruit_EPD

e-paper display driver for Arduino
140 stars 56 forks source link

Color Inversion on 2.7in Tricolor Display #52

Closed Dratelle closed 2 years ago

Dratelle commented 3 years ago

Library issue with latest versions. Using: Adafruit 2.7in Tricolor Eink Display (4098) Arduino Nano 33 IoT Arduino IDE 1.8.15 Adafruit GFX Library 1.10.10 Adafruit EPD Library 4.4.1 When using EPD examples on the 2.7in displays, the colors are inverted/shifted. So EPD_Black shows up as Red, EPD_RED shows up as white, and EPD_White shows up as white as well. The newer ThinkInk examples do a slighly different remapping: (EPD_RED is black, EPD_WHITE is red, EPD_BLACK is Red). I tried swapping various components, and rechecked the wires multiple times. What did make the problem go away was reverting to an older EPD library. I tested a few library versions and found: 4.4.1: Inverted colors 4.3.0: Inverted colors 4.1.0: Inverted colors 4.0.5: Colors correct 4.0.4: Colors correct 4.0.0: Colors correct 3.0.0: Colors correct So the issue appears to be with 4.1.0 and beyond. Thank you. imgonline-com-ua-CompressToSize-lC3t0K0X1Ec

caternuson commented 2 years ago

Related: https://forums.adafruit.com/viewtopic.php?f=47&t=184969

makermelissa commented 2 years ago

Yeah, I kinda know what's going on. I think when the same issue was fixed for the 2.7" Shield (#48), it broke it for the 2.7" breakout. So they're like the reverse of each other. The correct fix should work for both displays, which might be having 2 different initializers or something.

sweig commented 2 years ago

Ok thanks for the link to #48. This workaround does work for now. A permanent fix by splitting the initializers is a good idea.

In EPD library 4.4.2 I modified two lines in ThinkInk_270_Tricolor_C44.h:

Line 38/39 NEW (fixed color inversion): setBlackBuffer(0, false); //was true setColorBuffer(1, false); //was true

But it only works for the ThinkInk examples (#include "Adafruit_ThinkInk.h" using ThinkInk_270_Tricolor_C44 display(...)) It does NOT work for EPD examples (#include "Adafruit_EPD.h" using Adafruit_IL91874 display(...)) For the Adafruit_IL91874 display(...) call I tried a similar mod by changing Adafruit_IL91874.cpp:

Line 151/152: setBlackBuffer(0, true); // left as true as false does not work at all setColorBuffer(1, false); // was true

Now the EPD examples show black as black. But red now shows as white. Not sure what needs to be changed in addition here.

Why are there two different includes (EPD vs ThinkInk) for the same display in the first place? Are they being maintained in parallel?

ladyada commented 2 years ago

EPD was the old library, which still works but was insufficient to describe 'panels' - which had different layers and properties than just the raw chips. EPD is the lower layer, we recommend folks use the ThinkInk layer!

makermelissa commented 2 years ago

Using the same driver, I get different results for the eInk on the shield vs the breakout. IMG_3944

makermelissa commented 2 years ago

Ok, so I set the Busy and Reset pins both to -1 (to match the shield config) and suddenly the inverted one looks fine.

makermelissa commented 2 years ago

Ok, it seems the reset pin is the culprit. Busy pin setting has no effect and I've ruled that out. This is kind of strange.

Dratelle commented 2 years ago

That is a rather strange cause, and not one I would have expected. I'm glad it was eventually identified. Thanks!

makermelissa commented 2 years ago

So in trying to find the root cause, I've been taking a look at older versions of code and how it worked and here's some things I found:

makermelissa commented 2 years ago

Ok, I'm making progress. It has to do with the init codes and buffer settings for the panel. I just need to find the right combination.