caemor / epd-waveshare

Drivers for various EPDs from Waveshare and others
ISC License
227 stars 137 forks source link

WeActStudio display support #201

Open avsaase opened 6 months ago

avsaase commented 6 months ago

Hi, I was wondering if anyone has had success with using this driver with WeActStudio displays sold on AliExpress. They are solde in 1.54, 2.13 and 2.9 inch sizes in B/W and B/W/R versions and are quite cheap. According to the product description the B/W versions support partial refreshes.

I have a 2.9 inch B/W version and I'm able to drive it using the epd2in9_v2 driver but I'm encountering a few problems. I'm able to draw basic lines on the screen but the background color is fixed to black and there's a white border around the screen. During a refresh the border flashes in the inverted color of the center of the display. It doesn't look like I'm able to draw within the white border.

Here's my test code for the RP2040 using the embassy-rp hal:

#![no_std]
#![no_main]

use defmt_rtt as _;
use embassy_executor::Spawner;
use embassy_rp::{
    gpio::{Input, Level, Output, Pull},
    spi::{Config, Spi},
};
use embassy_time::Delay;
use embedded_graphics::Drawable;
use embedded_graphics::{
    geometry::Point,
    primitives::{Line, Primitive, PrimitiveStyle},
};
use embedded_hal_bus::spi::ExclusiveDevice;
use epd_waveshare::{
    color::Color,
    epd2in9_v2::{Display2in9, Epd2in9},
    prelude::WaveshareDisplay,
};
use panic_probe as _;

#[embassy_executor::main]
async fn main(_spawner: Spawner) {
    let p = embassy_rp::init(Default::default());

    let busy = Input::new(p.PIN_16, Pull::Up);
    let res = Output::new(p.PIN_20, Level::Low);
    let dc = Output::new(p.PIN_21, Level::Low);
    let cs = Output::new(p.PIN_22, Level::High);
    let scl = p.PIN_18;
    let sda = p.PIN_19;
    let mut delay = Delay;

    let spi_bus = Spi::new_blocking_txonly(p.SPI0, scl, sda, Config::default());
    let mut spi_device = ExclusiveDevice::new(spi_bus, cs, Delay);

    let mut epd = Epd2in9::new(&mut spi_device, busy, dc, res, &mut delay, None).unwrap();

    epd.set_background_color(Color::White); // Changing this doesn't do anything
    epd.clear_frame(&mut spi_device, &mut delay).unwrap();
    epd.display_frame(&mut spi_device, &mut delay).unwrap();

    let mut display = Display2in9::default();

    let _ = Line::new(Point::new(64, 0), Point::new(64, 296))
        .into_styled(PrimitiveStyle::with_stroke(Color::Black, 5)) // When I change the color to white I get a white line
        .draw(&mut display);

    epd.update_and_display_frame(&mut spi_device, &display.buffer(), &mut delay)
        .unwrap();
}

IMG20240529232239

Clearly the driver is similar but not exactly compatible. I haven dug into the details yet, I wanted to post here first in case someone else already looked into it.

More info about the displays can be found in https://github.com/WeActStudio/WeActStudio.EpaperModule.

avsaase commented 6 months ago

I see now that some other displays have a function to set a border color so most likely this display has a single color border as well.