-
Notifications
You must be signed in to change notification settings - Fork 84
Description
I have bought waveshare e-paper 7.5 inch V2 B. I have set the env.sh properly, I can see the generated png image contains some text in red (as shown in readme template 4), yet the e-paper display does not show any red text. The supposedly red text is shown in gray (very funny because this display is not grayscale!).
Hardware is connected properly - when I run waveshare example epd_7in5b_V2_test.py, I can see various images perfectly with some parts in red and some in black.
Looking at the waveshare code, I can see e.g. following:
Himage = Image.open(os.path.join(picdir, '7in5_V2_r.bmp'))
Himage_Other = Image.open(os.path.join(picdir, '7in5_V2_b.bmp'))
epd.display(epd.getbuffer(Himage),epd.getbuffer(Himage_Other))
So the first input of function epd.display is black and white bmp image, and the black is displayed as red on the display. The second input is black and white bmp image, and the black is shown as black on the display.
Looking into the code displaying the calendar, display.py, the relevant part is at line 42:
if waveshare_epd75_version == "2B":
Limage_Other = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame
epd.display(epd.getbuffer(Himage), epd.getbuffer(Limage_Other))
I do not get this code. It seems to me the variable Limage_other contains only white image, so it cannot be used as red layer.
I have found that PIL library got function image.split, that splits the image by channels. So in this way I can remove a color channel. The split generates three images by channels, but every channel image contains also pixels that were originally black. So I do not know how to remove black parts of the image. Because the cairosvg use anti-aliasing, the generated image contains not only purely black, white and red pixels, but also many gray and light red pixels. Thus simple pixel arithmetic does not help (e.g. if pixel == (255,0,0)).
I could circumvent the issue by changing svg file, and set every part originally in black to e.g. green, keep red parts as red, and than split the image by channels, and display it:
if waveshare_epd75_version == "2B":
(red, green, blue) = Himage.split()
epd.display(epd.getbuffer(red), epd.getbuffer(green))
This works and shows proper black and red texts on the display. However this is very strange method and there have to be something more intelligent. And also I have to change all icons to green so it is very stupid method. Yet I am not used to image processing so I do not know better way.