pimoroni / breakout-garden

Documentation, software, and examples for the Breakout Garden ecosystem.
https://shop.pimoroni.com/products/breakout-garden-hat
MIT License
70 stars 13 forks source link

Icons in the weather example causing `UnicodeDecodeError` #23

Closed abhijitvalluri closed 3 years ago

abhijitvalluri commented 4 years ago

I am getting the following error when running the weather example. I did not modify any code in the examples. I am running this on a raspberry pi zero w.

Traceback (most recent call last):
  File "./weather.py", line 104, in <module>
    icon_image = Image.open(f)
  File "/usr/local/lib/python3.7/dist-packages/PIL/Image.py", line 2779, in open
    prefix = fp.read(16)
  File "/usr/lib/python3.7/codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x89 in position 0: invalid start byte

My system configuration (output of uname -a) is:

Linux raspberrypi 4.19.66+ #1253 Thu Aug 15 11:37:30 BST 2019 armv6l GNU/Linux

What am I doing wrong and how can I fix it? Currently I commented out all the code for processing the icons.

Gadgetoid commented 4 years ago

This looks like a classic missing of the subtle differences between Python 2.x and Python 3.x. I've pushed a fix that avoids the use of file open, since PIL will natively take a filename.

abhijitvalluri commented 4 years ago

Thanks! I will try it again later today! 😃 Also, an unrelated question but about the 1.12" OLED screen. Will it cause burn in if I continuously display the weather status, like 24x7? OLEDs typically experience burn in, so I am thinking if it does I should do something to mitigate it.

chad-ermacora commented 4 years ago

Thanks! I will try it again later today! Also, an unrelated question but about the 1.12" OLED screen. Will it cause burn in if I continuously display the weather status, like 24x7? OLEDs typically experience burn in, so I am thinking if it does I should do something to mitigate it.

From my understandings, OLED's are fairly susceptible to burn-in. I created a python3 thread that auto turns off this display after 30 seconds of showing whatever it shows. You could probably adapt the code to your needs.

https://github.com/chad-ermacora/sensor-rp/blob/master/sensor_modules/pimoroni_1_12_mono_oled.py

Gadgetoid commented 4 years ago

The OLED question is a good one- actually- perhaps we should set one up 24/7 and see if we can burn it in.

I think OLED burn-in problems are possibly slightly overstated and may be users mistaking image retention for burn-in, but they are certainly not non-existent. OLEDs pretty much made their debut in small devices displaying basically the same thing all the time- albeit I bet they turned off after a short period to conserve power anyway!

abhijitvalluri commented 4 years ago

Thanks @chad-ermacora, I will take a look and make use of that code in my project. @Gadgetoid, I will be interested in the results of such a test if you do one!

Also, I tested the updated code and I can confirm that it works fine now! Thanks for the help!