dr-mod/zero-btc-screen

Waveshare Red-Black-White Screen

holmesha opened this issue · 6 comments

Hello, I already have the Waveshare red/black/white e-ink screen. Any idea on how to modify the code to account for the different screen? I can't seem to figure out how to get it to even turn on. Can I add the appropriate screen in myself on the screen configuration? EPD2in13bc I think is the one I need.

Hi @holmesha , to add support for the EPD2in13bc screen, you can take a look at https://github.com/dr-mod/zero-btc-screen/blob/main/presentation/screens/epd2in13bv3.py they should be very similar, it might just boil down to substituting the driver class.

I have the same red/black/white e-paper screen from Waveshare as @holmesha. I'm no fluent Python programmer but was able to get the screen properly working in black/white currently.

Basic steps taken:
Copy epd2in13bv3.py to epd2in13bc.py and apply following changes:

--- presentation/screens/epd2in13bv3.py 2022-01-22 14:26:20.000000000 +0100
+++ presentation/screens/epd2in13bc.py  2022-01-25 16:34:01.185380751 +0100
@@ -2,25 +2,26 @@

 from PIL import Image, ImageDraw, ImageFont
 try:
-    from waveshare_epd import epd2in13b_V3
+    from waveshare_epd import epd2in13bc
 except ImportError:
     pass
 from data.plot import Plot
 from presentation.observer import Observer
+from logs import logger

 SCREEN_HEIGHT = 104
 SCREEN_WIDTH = 212

 FONT_SMALL = ImageFont.truetype(
-    os.path.join(os.path.dirname(__file__), os.pardir, 'Roses.ttf'), 7)
+    os.path.join(os.path.dirname(__file__), os.pardir, 'Roses.ttf'), 8)
 FONT_LARGE = ImageFont.truetype(
     os.path.join(os.path.dirname(__file__), os.pardir, 'PixelSplitter-Bold.ttf'), 22)

-class Epd2in13bv3(Observer):
+class Epd2in13bc(Observer):

     def __init__(self, observable, mode):
         super().__init__(observable=observable)
-        self.epd = epd2in13b_V3.EPD()
+        self.epd = epd2in13bc.EPD()

         self.epd.init()
         self.image_black = Image.new('1', (SCREEN_WIDTH, SCREEN_HEIGHT), 255)

Edit file configuration.cfg:

diff --git a/configuration.cfg b/configuration.cfg
index 4e67afe..6d734e6 100644
--- a/configuration.cfg
+++ b/configuration.cfg
@@ -2,13 +2,14 @@
 console_logs             : false
 #logs_file                : /tmp/zero-btc-screen.log
 dummy_data               : false
-refresh_interval_minutes : 15
+refresh_interval_minutes : 5
 currency                : BTC

 # Enabled screens or devices
 screens : [
-    epd2in13v2
+#    epd2in13v2
 #    epd2in13bv3
+    epd2in13bc
 #    picture
 #    inkyWhatRBW
   ]
@@ -20,6 +21,9 @@ screens : [
 mode : candle

 [epd2in13bv3]
+mode  : candle
+
+[epd2in13bc]
 mode  : line

 [picture]

Add black/white/red screen driver:

diff --git a/presentation/screens/__init__.py b/presentation/screens/__init__.py
index 53b7a12..58e4497 100644
--- a/presentation/screens/__init__.py
+++ b/presentation/screens/__init__.py
@@ -1 +1 @@
-from . import epd2in13v2, epd2in13bv3, picture, inkywhatrbw
+from . import epd2in13v2, epd2in13bv3, epd2in13bc, picture, inkywhatrbw

More changes are required to display e.g. "loosing" candles in red color. I haven't implemented this, yet. On Reddit one guy did this, but he hadn't replied to me after I asked for some code snippets. Apparently he didn't provide a push request here, too.

Thanks so much for digging into my question! I'm new to all of this and the code has been a bit of a struggle so far.

At the moment I can't assist further to add the red color where appropriate. I need to get more used to Python first.
As far as I've seen in the example code of Waveshare, everything in red color has to be drawn into a separate image buffer and then the buffers for b&w and red are handed over to be displayed in the correct order. No rocket science involved...

epd2in13bv3.py works fine for me out of the box with the 2.13" Red/White/Black E-Ink Waveshare display hat, but it only displays in black and white.

+1 for red color support.