AbnormalDistributions / e_paper_weather_display

Raspberry Pi weather display using Waveshare e-paper display and Open Weather Map API
MIT License
365 stars 32 forks source link

FileNotFoundError #23

Closed Henry-277 closed 3 days ago

Henry-277 commented 3 years ago

Hi!

I keep getting those Errors:

Traceback (most recent call last): File "/home/pi/Downloads/e_paper_weather_display-master/weather.py", line 12, in from waveshare_epd import epd7in5_V2 File "lib/waveshare_epd/epd7in5_V2.py", line 32, in from . import epdconfig File "lib/waveshare_epd/epdconfig.py", line 146, in implementation = RaspberryPi() File "lib/waveshare_epd/epdconfig.py", line 50, in init self.SPI = spidev.SpiDev(0, 0) FileNotFoundError: [Errno 2] No such file or directory

Can someone help? I am a bit lost :(

Henry-277 commented 3 years ago

When I'm running it with the console i am getting different errors:

Traceback (most recent call last): File "weather.py", line 234, in write_to_screen(screen_output_file, 600) File "weather.py", line 34, in write_to_screen epd.display(epd.getbuffer(h_image)) TypeError: display() missing 1 required positional argument: 'imagered'

AbnormalDistributions commented 3 years ago

Make sure you have downloaded and have access to the lib/waveshare_epd directory in the repository. See if that helps. :)

testataaaa commented 2 years ago

I had the same issue as OP, solved it by setting up dependencies as follows:

sudo apt update && sudo apt upgrade

sudo apt install git gsfonts python3 python3-pip cairosvg pigpio python3-pigpio

sudo pip3 install python-dateutil astral spidev RPi.GPIO Pillow google-api-python-client google-auth-httplib2 google-auth-oauthlib msal

sudo sed -i s/#dtparam=spi=on/dtparam=spi=on/ /boot/config.txt

sudo reboot

xelemorf commented 8 months ago

When I'm running it with the console i am getting different errors:

Traceback (most recent call last): File "weather.py", line 234, in write_to_screen(screen_output_file, 600) File "weather.py", line 34, in write_to_screen epd.display(epd.getbuffer(h_image)) TypeError: display() missing 1 required positional argument: 'imagered'

I think this "imagered" issue is coming from a multi-color screen which includes apart from BW an additional RED color, which also needs to be handled; unless I've misunderstood

In my example, I am working with these display drivers: "epd2in13_V4" - which is black/white "epd2in13b_V4" which is black/white/red. The issue only appears when using the one with red color.

Here is the waveshare repo for various displays: https://github.com/waveshare/e-Paper/tree/master/RaspberryPi_JetsonNano/python/lib/waveshare_epd

The relevant imagered reference in the official example is the following, although this did not help me in any way

    # display image
    def display(self, imageblack, imagered):
        self.send_command(0x24)
        self.send_data2(imageblack)

        self.send_command(0x26)
        self.send_data2(imagered)

        self.ondisplay()

Eventually the following was the solution for me on a different project, based on the code provided by nerstak on his epaper-weather project I have added the redimage segments into it as it was originally designed for BW screen.

from PIL import Image

from lib_waveshare_epd import epd2in13b_V4

epd = epd2in13b_V4.EPD()

screenWidth = epd.height
#screenWidth = 250
screenHeight = epd.width
#screenHeight = 122

def clear_screen():
    """
    Clear the screen
    """
    #logging.info("Goto Sleep...")
    epd.init()
    epd.Clear()
    time.sleep(2)
    epd.sleep()
....
    #logging.info("init and Clear")
    #epd.init()
    #epd.Clear(0xFF)

def draw_image_on_hardware(img: Image):
    """
    Draw given image to hardware e-ink
    Does not close img
    :param img: Image
    """
    #img.show()
    epd.init()

    #black image
    img.save(os.path.join("/tmp", "image.png"))
....
    #blank redimage
    redimage = Image.new('1', (epd.height, epd.width), 255)  # 250*122

    #black image file
    screen_output_file = Image.open(os.path.join("/tmp", "image.png"))
    #epd.display(epd.getbuffer(screen_output_file))

    #first draw makes black image, second draw overlays red image (must to draw twice on BWR display), drawing the same image twice will result a red image
    epd.display(epd.getbuffer(screen_output_file), epd.getbuffer(redimage))

    #logging.info("Goto Sleep...")
    time.sleep(2)
    epd.sleep()