Waveshare V4 - AttributeError: module 'presentation.screens' has no attribute 'epd2in13bv4'
kiraitachi opened this issue · 2 comments
I have a Waveshare v4 screen for my raspberry pi zero w. Im trying to make it work...but for some reason Im not able to load it. I get the following errors:
module 'presentation.screens' has no attribute 'epd2in13bv4'
Traceback (most recent call last):
File "/home/kira/zero-btc-screen/config/builder.py", line 16, in bind
package = getattr(screens, screen.lower())
AttributeError: module 'presentation.screens' has no attribute 'epd2in13bv4'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/kira/zero-btc-screen/main.py", line 60, in <module>
main()
File "/home/kira/zero-btc-screen/main.py", line 40, in main
builder.bind(data_sink)
File "/home/kira/zero-btc-screen/config/builder.py", line 27, in bind
raise BtcConfigError(
config.builder.BtcConfigError: Cannot instantiate epd2in13bv4
What I did:
- Configuration.cfg
[base]
console_logs : false
#logs_file : /tmp/zero-btc-screen.log
dummy_data : false
refresh_interval_minutes : 15
currency : BTC
# Enabled screens or devices
screens : [
epd2in13bv4
# epd2in13v2
# epd2in13v3
# epd2in13bv3
# epd2in7
# epd3in7
# picture
# inkyWhatRBW
]
# Configuration per screen
# This doesn't make any effect if screens are not enabled above
[epd2in13v2]
#mode : line
mode : candle
[epd2in13v3]
mode : candle
[epd2in13bv4]
mode: line
[epd2in13bv3]
mode : line
[epd2in7]
mode : candle
[epd3in7]
mode : candle
[picture]
filename : /home/pi/output.png
mode : candle
[inkyWhatRBW]
mode : candle
I have also created this file within "presentations/screens" called epd2in13bv4.py
import os
from PIL import Image, ImageDraw, ImageFont
try:
from waveshare_epd import epd2in13b_V4
except ImportError:
pass
from data.plot import Plot
from presentation.observer import Observer
SCREEN_HEIGHT = 122
SCREEN_WIDTH = 250
FONT_SMALL = ImageFont.truetype(
os.path.join(os.path.dirname(__file__), os.pardir, 'Roses.ttf'), 7)
FONT_LARGE = ImageFont.truetype(
os.path.join(os.path.dirname(__file__), os.pardir, 'PixelSplitter-Bold.ttf'), 22)
class Epd2in13bv4(Observer):
def __init__(self, observable, mode):
super().__init__(observable=observable)
self.epd = epd2in13b_V4.EPD()
self.epd.init()
self.image_black = Image.new('1', (SCREEN_WIDTH, SCREEN_HEIGHT), 255)
self.image_ry = Image.new('1', (SCREEN_WIDTH, SCREEN_HEIGHT), 255)
self.draw_black = ImageDraw.Draw(self.image_black)
self.draw_ry = ImageDraw.Draw(self.image_ry)
self.mode = mode
def form_image(self, prices):
self.draw_black.rectangle((0, 0, SCREEN_WIDTH, SCREEN_HEIGHT), fill="white")
screen_draw = self.draw_black
if self.mode == "candle":
Plot.candle(prices, size=(SCREEN_WIDTH - 38, 79), position=(35, 0), draw=screen_draw)
else:
last_prices = [x[3] for x in prices]
Plot.line(last_prices, size=(SCREEN_WIDTH - 36, 79), position=(36, 0), draw=screen_draw)
flatten_prices = [item for sublist in prices for item in sublist]
Plot.y_axis_labels(flatten_prices, FONT_SMALL, (0, 0), (32, 76), draw=screen_draw)
screen_draw.line([(9, 83), (204, 83)])
screen_draw.line([(33, 3), (33, 80)])
screen_draw.line([(51, 87), (51, 101)])
Plot.caption(flatten_prices[len(flatten_prices) - 1], 81, SCREEN_WIDTH, FONT_LARGE, screen_draw)
def update(self, data):
self.form_image(data)
image_black_rotated = self.image_black.rotate(180)
image_ry_rotated = self.image_ry.rotate(180)
self.epd.display(
self.epd.getbuffer(image_black_rotated),
self.epd.getbuffer(image_ry_rotated)
)
def close(self):
self.epd.Dev_exit()
Wondering if you could maybe hint me where is the issue as Im not able to pinpoint why the screen is not loading. I would appreciate it a lot. Im looking to "rework" your code once the screen is working for the BTC tracker to make an Euribor Tracker for mortgages.
Again thanks for your time and work. I appreciate you shared this.
Cheers!
Just as a note, the screen does work perfectly fine running the demo ./EPD mentioned in the Waveshare v4 site.
For anyone reading this, I was able to fix it by checking the configs done by this fork: