caemor / epd-waveshare

Drivers for various EPDs from Waveshare and others
ISC License
226 stars 136 forks source link

Support more (Color) Displays? Includes a Howto #26

Open jamesmunns opened 5 years ago

jamesmunns commented 5 years ago

I recently ordered a collection of the WaveShare displays, including:

I'm happy to contribute or help test, as I plan to use these on a couple of embedded devices for my internet of streams project. I was wondering if you had any notes already on where I should be looking to help add support for the color displays.

caemor commented 5 years ago

Sorry for the late response.

AFAIK the colored ones just use two buffers instead of one so that also shouldn't be too complicated too add (where the biggest problem will be how to add/change color.rs and if 2 small buffers are better or one big buffer). I am really unsure about this problem.

Question to the naming convention: the call it 4in2(b) but wouldn't 4in2_red or something similar be better?

Steps that need to be done to add a display generally: (e.g for the 4in2 (b)/red one)

  1. Get the Command table from the datasheet (e.g here: https://www.waveshare.com/wiki/4.2inch_e-Paper_Module_(B)#Datasheets ) and add it to a command enum like here (https://github.com/caemor/epd-waveshare/blob/master/src/epd4in2/command.rs) in a epd4in2b folder. This can also be found in waveshares new github repo (e.g.: https://github.com/waveshare/e-Paper/blob/master/4.2inch_e-paper_b%26c_code/wiringpi/obj/EPD_4in2b.h but be aware of quite a lot of copy&paste errors like the wrong ifndef epd2in7b at the top and better crosscheck it once more)

  2. Optional: Add the LUT constants (like https://github.com/caemor/epd-waveshare/blob/master/src/epd4in2/constants.rs) if you can find any. But since the color ones only allow the default refresh they are most likely not included in the repos. This is also not too important/optional.

  3. Add following constants from the next four lines to epd4in2b/mod.rs (https://github.com/caemor/epd-waveshare/blob/master/src/epd4in2/mod.rs#L61): width, height, default_background_color (twice for red/black displays?), is_busy_low

  4. Implement WaveshareDisplay and InternalWiAdditions trait for your EPD4in2_Red struct. See https://github.com/caemor/epd-waveshare/blob/master/src/epd4in2/mod.rs#L76 and following for examples and crosscheck it with the waveshare repos for the differences between different devices

    The Traits that need to be implemented are explained here: https://github.com/caemor/epd-waveshare/blob/master/src/traits.rs

    Maybe some adoptions for either a twice as big sized buffer or double buffers need to be made.

    Communication is handled by the DisplayInterface and is working the same through all waveshare displays that I know besides that the busy_low pin is sometimes inverted.

    Now you can already draw to the display, but you might want to use the embedded_graphics ;-)

  5. Implement the graphics traits (Drawing & Display) e.g. like here: https://github.com/caemor/epd-waveshare/blob/master/src/epd4in2/graphics.rs

    The graphics.rs file is handling most of the graphics stuff for you: https://github.com/caemor/epd-waveshare/blob/master/src/graphics.rs

    But most likely there also need to be done some changes for the multicolor display.

Further stuff:

Good references are:

I am happy to help if you have more specific question but be aware that the colored displays are quite slow.

marcelbuesing commented 5 years ago

I just ordered a 4.2 B/W and a 7.5 Red/Black/White.

Has anyone started adding colored display support yet ? Otherwise I might also start looking into it once they arrive. @caemor thanks for those infos.

caemor commented 5 years ago

I haven't started working on it yet. I might have some time on Sunday at the Oxidize Conf.

caemor commented 5 years ago

I couldn't find any time on Sunday and gonna be travelling for the next 3 weeks, so you can just start if you want.

DanSGiesbrecht commented 4 years ago

I ordered a R/B/W display as well - I may have a go at this someday.

caemor commented 4 years ago

@jkristell added support for the 1in54 r/b/w display here: https://github.com/caemor/epd-waveshare/pull/35 and has an example on using it here: https://github.com/jkristell/nucleo-f401re/blob/add-eink-example/examples/eink.rs

caemor commented 4 years ago

Although multiple ones were added I am leaving this issue open since it also includes some documentation about how to add a display

Alexx-G commented 3 years ago

Thanks a lot @caemor for your effort! Is 3.7in b/w display supported? If no, is #35 still an accurate example of adding a new display?

jamesmunns commented 3 years ago

I recently ordered a couple newer displays, including the 3.7in b/w display. I haven't tried bringing it up yet, but if you need a second person to test, feel free to ping me!

Alexx-G commented 3 years ago

Thanks @jamesmunns ! I've started working on a PR yesterday, however I'm struggling finding a command table for 3.7 - https://www.waveshare.com/wiki/3.7inch_e-Paper_HAT

caemor commented 3 years ago

Thanks a lot @caemor for your effort! Is 3.7in b/w display supported?

Not yet.

If no, is #35 still an accurate example of adding a new display?

35 is is a red/black/white display so it is slightly different.

I believe the instructions from above might be more helpful but #35 as well as any of the other recent PRs adding a new display can help you, just be aware that your display differs in the colors.

Since your 3in7 b/w display seems to have some gray tones you need to define a new color type in color.rs similar to what is defined in their wiki: https://www.waveshare.com/wiki/3.7inch_e-Paper_HAT

So while finishing this I saw you already added a new comment :-D

Thanks @jamesmunns ! I've started working on a PR yesterday, however I'm struggling finding a command table for 3.7 - https://www.waveshare.com/wiki/3.7inch_e-Paper_HAT

If you click on ressources you can find the specifications. (e.g. Command table starting from page 14 onwards https://www.waveshare.com/w/upload/7/71/3.7inch_e-Paper_Specification.pdf)

And just feel free to make a WIP-PR and asks questions if you are stuck anywhere.

Alexx-G commented 3 years ago

Hey @caemor @jamesmunns , Thanks for pointers. I'm still figuring it out. I have some weird issues when I try to test the 3.7 display using a NRF52 board. Things I've checked so far - initialization and display sequence match C/Python examples, tried different LUT provided in those examples, width/height match as well, rotation only affects that tiny area where "circle" is shown. Have you encountered this kind of effect? an attempt to draw a circle

I got my hands on RPi and tested waveshare Python snippet with the same display, everything worked as expected. Digging into my implementation.

caemor commented 3 years ago

@Alexx-G lets move to issue #68

CyanBlob commented 2 years ago

Has anybody started working on the 7.5inch red/black/white yet? I've got a couple at home begging to be used for something! If nobody else has then I might take a look at adding support, but I'm pretty new to Rust so it may take me a while.

caemor commented 2 years ago

Hello @CyanBlob, I think @marcelbuesing has done some work on them here in https://github.com/caemor/epd-waveshare/pull/45, but you need to check if you have a v1 or v2 of the 7in5 display, since according to his messages there he should have used the v1 in the pr.

CyanBlob commented 2 years ago

Mine actually have v3 stickers on them, which is odd since I haven't been able to find much about a v3 anywhere. Here's what I bought: https://www.aliexpress.com/item/1005001760018474.html?spm=a2g0s.9042311.0.0.79404c4dusNtBe

There does seem to be a spec for the v3 (based on the URL): https://www.waveshare.com/w/upload/8/8c/7.5inch-e-paper-b-v3-specification.pdf

The PDF itself just calls it B model though. These are my first e-ink displays, so I'm really not sure what the v3/B means. How different would you expect them to be from v1?

caemor commented 2 years ago

I believe B/C is just the red/yellow difference mostly (D flexible, F "full" color,...). v1, v2, v3 are the same display size with sometimes better resolution,... and slightly different command tables.

So it looks like waveshare is currently slowly rolling out the v3s of the various display, but your doesn't seem to be implemented yet.

So what I would recommend you is to use https://github.com/waveshare/e-Paper/blob/master/RaspberryPi_JetsonNano/c/lib/e-Paper/EPD_7in5b_V2.c of the v2, the specification you linked: https://www.waveshare.com/w/upload/8/8c/7.5inch-e-paper-b-v3-specification.pdf and marcelbuesings version next to each other. First you could just update the command table. Panel setting is 0x00, panel setting 0x01 (r01h) and so on. Then you change the init function as needed, the size! (better resolution), and then the other functions. Most likely you can just use quite a lot of it as it is already, but better be safe and compare all versions for these parts to be sure and then try it out.

If you want to go a safer route, wait until waveshare has released their own code for your v3.

CyanBlob commented 2 years ago

Update! The display works! Kind of. It's currently kinda freaking out between white, black, red, and multicolor static right now when it should just be flipping back and forth between solid white and solid black. But I'm happy regardless. I ended up basing this off the 7in5_v2 version, so it doesn't handle the buffers properly (I think). I just wanted to get something happening because I never could before. Current work: https://github.com/CyanBlob/epd-waveshare/commit/77579f5bff12dbc9c40d83f9d62839c7679bf4c1

I'm gonna keep working on this soon. Hopefully fixing it isn't that big of a deal!

Anshorei commented 2 years ago

I've recently bought a Waveshare 7.5" Black/White/Red. It has a V3 sticker on the back.

@CyanBlob any updates on your progress?

CyanBlob commented 2 years ago

@Anshorei unfortunately I haven't had the time to figure out why my version is so broken, and I probably won't for quite a while. If you have the time I'd encourage you to take a look!

Anshorei commented 2 years ago

@CyanBlob Thanks for the update. I do want to look into it, I've also got a 2in13bc V3 that I could try to get working, but I'm not sure how much time it'll take -- and of course how much time I'll be able to make for this.

Anshorei commented 2 years ago

Worked on this a little and have a draft to support the 2in13b_v3 (#95 ) Everything I'm using in the example is working for me.

Anshorei commented 2 years ago

Have not had time to look at the 7"5 display yet, but I ordered one of the 2"9 inch tricolor and of the 5"65 heptacolor displays from waveshare as well to try out.

simon0356 commented 2 years ago

Hi everyone, I have implemented support for the 4.2" module v2 3 color (I use the following one : https://www.amazon.fr/gp/product/B075FRVC4L/ref=ppx_yo_dt_b_asin_title_o02_s00?ie=UTF8&psc=1) I'm not trying to create for a pull request for now since i'm not a rust guru and i'm not 100% sure of my implementation.

I use the crate with the experimental port of rust on ESP32, i will try as soon as i get a new raspberry pi to implement the example
I have already used the waveshare ESP32 Driver board with a Waveshare E-Paper 4.2" without PCB without applying any modification to the crate (this example is available here : https://github.com/ivmarkov/rust-esp32-std-demo) Since i broke my ESP32 Driver Board, i have bought a new 4.2" epaper with PCB wired to an AzDelivery ESP32. This new E-Paper screen is labeled V2 and didn't work as is so i implemented an epd4in2_v2 crate with three color support but without implementing partial refresh (I don't known if it's realy possible). To do this i completely copy-paste the behaviour of the driver here : https://www.waveshare.com/wiki/File:E-Paper_ESP32_Driver_Board_Code.7z (which is not up to date)

I'am waiting for a raspberry pi, and a new ESP32 Driver board to test further and maybe create a pull request

Here is my fork : https://github.com/simon0356/epd-waveshare IMG_20220203_161542

IMG_20220203_153306

Hope it could help anyone. Edit : Is there any way to determine exactly the IC and driver of the E-Paper display that we use ? I can't find any information readable on PCB/Module Simon

CyanBlob commented 2 years ago

@Anshorei I just checked and the V2 Python sample code from here https://github.com/waveshare/e-Paper/blob/master/RaspberryPi_JetsonNano/python/examples/epd_7in5b_V2_test.py works for the V3 7in5. I'm not sure why the epd-waveshare V2 version isn't working but now that I have something working I can start looking into it more

CyanBlob commented 2 years ago

7F4B3A3D-B4CF-4167-A415-B63E0920B55E Update, I have it mostly working. I copied the init process and the sleep timings from the Python project and then copied the TriColor display implementations from epd2in13bc.
It mostly works, but the colors are coming out wrong. I’m gonna get that working and then do some cleanup and then I should be done!
Doing this with my ESP32 has been fun but is definitely slowing things down since Rust support for it is still more or less in its infancy

simon0356 commented 2 years ago

I think i got the same issue, if I remenber the following line were important : https://github.com/simon0356/epd-waveshare/commit/7df315362acf71525efb30c7a4c48baa8afebbf5#diff-402c0d9cdd4ef7b8a30bf747d6556c063d0f763cf502a3602f10497397327963R98

"DisplayColorRendering::Positive"

marcelbuesing commented 2 years ago

7F4B3A3D-B4CF-4167-A415-B63E0920B55E Update, I have it mostly working. I copied the init process and the sleep timings from the Python project and then copied the TriColor display implementations from epd2in13bc. It mostly works, but the colors are coming out wrong. I’m gonna get that working and then do some cleanup and then I should be done! Doing this with my ESP32 has been fun but is definitely slowing things down since Rust support for it is still more or less in its infancy

The ESP32 integration is pretty cool, do you have some public repository to look at it? I am curious.

simon0356 commented 2 years ago

https://github.com/simon0356/rust-esp32-waveshare-4_2 with the v1 and waveshare esp32 board version out of the box You can use my fork https://github.com/simon0356/epd-waveshare of epd-waveshare to use with 4.2" v2 with three color

CyanBlob commented 2 years ago

Here's my current work: https://github.com/caemor/epd-waveshare/compare/main...CyanBlob:main

I can't get it to display white using 'clear_buffer'. I'm not sure what I'm missing. Can somebody familiar with three-color displays take a look? White is always displayed as black after using 'clear_buffer'. It seems to work fine when rendering text though. The docs are here: https://www.waveshare.com/wiki/7.5inch_e-Paper_HAT_(B)

I'm suspecting that the 7in5 V3 handles colors differently than other tricolor boards.

My code is here: https://gitlab.com/CyanBlob/e-paper-rust.

For those that want to try with an ESP32 themselves, you need to grab the toolchain from here: https://github.com/esp-rs/esp-idf-template. Some of my demo code came from here: https://github.com/ivmarkov/rust-esp32-std-demo

CyanBlob commented 2 years ago

Opened PR: https://github.com/caemor/epd-waveshare/pull/109

The problem was with how the 7in5 V3 handles colors. In the black/white buffer a 255 means white and 0 means black. But in the red/white buffer a 0 means white and a 255 means red, which is effectively inverted. That meant that when I did display.clear_buffer(TriColor::White), the B/W buffer would be set to white but the R/W buffer would be set to red. Red has the highest priority, which messed up my colors.
@SparkGirl for your information 👀

arlyon commented 2 years ago

@simon0356 great work, do you plan on opening a PR?

simon0356 commented 2 years ago

I'm currently try to make the screen work with my raspberry pi 1, i will try to produce a PR with that

Tnze commented 2 years ago

Hi, is 2.66inch e-Paper Module (B) supported?

caemor commented 2 years ago

Hi, is 2.66inch e-Paper Module (B) supported?

There is https://github.com/caemor/epd-waveshare/pull/107, which should have been version a. Version B isn't support yet.

piedoom commented 8 months ago

I'm looking to support the 4.2in b/w/r v2.1 display. I'm a little confused at the A vs B vs C etc - what letter would this display be?

Are the steps still valid in 2024? I was wondering if I could update simon's previously mentioned branch and have that work, or if I have a different version of the module.

Lastly (sorry for all the questions), do you have any guess as to what would happen if I used this repo's b/w 4.2 inch code as is on the b/w/r display? Would I see any update on the epaper display, or would you expect it to not work at all? I ask because it would make it easier for me to troubleshoot, as I'm not currently sure if my wiring and setup is correct, and that will help me know what to look for if I give this problem a try.

Thanks!

simon0356 commented 8 months ago

Hi, I remember that it was not really clear how to distingue different version too, Feel free to try my verson, i didn't get time to produce a proper version to open a PR sorry.

Simon