adafruit / Adafruit_CircuitPython_framebuf

CircuitPython framebuf module, based on the Python framebuf module
MIT License
39 stars 36 forks source link

Strange characters displaying on OLED (rfm69_check.py) #15

Closed rahulgkatre closed 5 years ago

rahulgkatre commented 5 years ago

img_9570

I tried running rfm69_check.py from the RFM69 Raspberry Pi Setup tutorial (https://learn.adafruit.com/adafruit-radio-bonnets/rfm69-raspberry-pi-setup). The text should be reading: RFM69: Detected as shown in the tutorial.

Initially I ran into the issue where the font5x8.bin file was missing. To download it to the Pi, I ran

curl -o font5x8.bin https://github.com/adafruit/Adafruit_CircuitPython_framebuf/blob/master/examples/font5x8.bin

The rfm69_check.py would run properly (the buttons work, as they display some sort of text in the correct position when pressed), but none of the characters are correct. I am running on a Raspberry Pi B+ with the latest version of Raspbian. This is the 915MHz Non-LoRa version of the bonnet.

Edit: Additionally, my use case for the OLED is just to show the IP address of the Pi when it is connected to any sort of network.

brentru commented 5 years ago

The URL for CURL should be: https://github.com/adafruit/Adafruit_CircuitPython_framebuf/blob/master/examples/font5x8.bin?raw=true

I just updated the guide to include this url.

rahulgkatre commented 5 years ago

Ok, I ran the same line but with the URL you gave, and this is what I got:

Traceback (most recent call last):
  File "rfm69_check.py", line 55, in <module>
    display.text('RFM69: Detected', 0, 0, 1)
  File "/home/pi/.local/lib/python3.5/site-packages/adafruit_framebuf.py", line 291, in text
    y, self, color)
  File "/home/pi/.local/lib/python3.5/site-packages/adafruit_framebuf.py", line 366, in draw_char
    line = struct.unpack('B', self._font.read(1))[0]
struct.error: unpack requires a bytes object of length 1

The commands I ran:

rm font5x8.bin
curl -o font5x8.bin https://github.com/adafruit/Adafruit_CircuitPython_framebuf/blob/master/examples/font5x8.bin?raw=true
python3 rfm69_check.py

Running ls shows this:

blinkatest.py  font5x8.bin  rfm69_check.py

I also recreated the Python file just in case there was an issue when I copy/pasted it, but that didn't change anything. I did this:

rm rfm69_check.py
sudo nano rfm69_check.py
rahulgkatre commented 5 years ago

Update: I got it to work. I reinstalled all the pip3 libraries and then I ran this line to download font5x8.bin:

wget -O font5x8.bin https://github.com/adafruit/Adafruit_CircuitPython_framebuf/blob/master/examples/font5x8.bin?raw=true
brentru commented 5 years ago

@rahulkatre-projects Great to hear - I updated the guide to add the wget command you had success with. After you installed the libraries, did you try the CURL command you originally tried (curl -o font5x8.bin https://github.com/adafruit/Adafruit_CircuitPython_framebuf/blob/master/examples/font5x8.bin?raw=true)?

rahulgkatre commented 5 years ago

I'll try removing the file and re-downloading it with CURL. I might have entered the command wrong in the first place (I didn't have curl -O at the beginning, just curl) so that may have been the cause of my issues. The file did download correctly, which was the confusing part.

Update: I don't think it seems to be working correctly. I tried curl -OL font5x8.bin [url] and curl -O font5x8.bin [url] ([url] is the raw=true link), but both of those didn't download or run the Python file correctly.

I'm really not a whiz with the command line, but curl was giving multiple issues while testing this. I think it's better to just use wget, as it's much more straightforward in my opinion.