winstonma / RPi-MagicMirror-Waveshare

Script that show MagicMirror content on Waveshare E-Ink device
GNU Affero General Public License v3.0
5 stars 1 forks source link

epd.sleep() used? #5

Open Coernel82 opened 1 year ago

Coernel82 commented 1 year ago

Hi Winston, my display partially does not show clear black but a greyish fade. After some googling this problem is known and seems not to be solved by the community. However I found some information that the display has to be set to sleep mode.

So I added epd.sleep() in my setup and also epd.init() as you used that function in your code already. Waveshare documents def init(self) though. I am a noob - so not sure what to use.

while True:
        # Display the screenshot
        epd.init()  # wake up display
        img = Image.open(BytesIO(driver.get_screenshot_as_png()))
        epd.display(epd.getbuffer(img))
        epd.sleep() # and set it to sleep again
        sleep(refreshRate - time() % refreshRate)

I am not sure if this is correct however I did have a look at the Waveshare library for the 7.5" display and couldn't find a sleep command in the original library.

As documentated by waveshare you should use epd.sleep()

I can confirm that the code works and probably should be altered - at least to save power and probably safe the display from damage.

What do you think? Do you quickly want to add the two lines or would you like to have a pull request?

Coernel82 commented 1 year ago

One addition: The demo code for whatever reason does not create the greyish fade but crisp clear black and white images - and as I had a look into the code also uses epd.display(epd.getbuffer(img) so... I have no clue!

Coernel82 commented 1 year ago

Do you use the HAT on the Raspberry Pi or do you use direct wire connection? Someone wrote that the HAT is unreliable.

Coernel82 commented 1 year ago

I had a further look at the Waveshare library code and found self.send_command(0x07) # DEEP_SLEEP As it seems the deep sleep can be triggered by different ways and the direct command is the mentioned above. So from my understanding now epd.sleep() is not necessary in your code. As you have more understanding of programming I'd be happy if you could confirm that.

winstonma commented 1 year ago

haha I am no expert here. I just followed their demo, and took BenRoe's idea of using selenium's screenshot feature and put things altogether.

The reason I wrote this Python because it can get things done with 30 lines of code (out of this 30 lines of code it mainly comes from the sample code, I only wrote less than 10 lines of code). So I am no expert at all.

By the way I didn't get any of the greyish fade problem.

winstonma commented 1 year ago

Let me spend some time on testing the sleep command and get back to you later.

But in my case I am running partial refresh (again, steal the idea from Fast partial refresh on 4.2" E-paper display from Waveshare / Good Display). I think the sleep would slow down the refresh. But I would spend some time of adding sleep during the weekend.