Shaurya
Posts: 15
Joined: Sat Mar 02, 2019 7:37 am

Getting unexpected error while using oled...

Thu Jul 25, 2019 4:59 pm

I am having some veeeery basic but frustrating errors while displaying text on an Oled screen.

Code: Select all

count = 1
disp.clear()
disp.display()
draw.text((30, top+20), count, font=font, fill=255)
#there is more code to control the oled, but this is where I am getting the error. 
The oled cannot display count. It says something about 'int' values…

I am using Adafruit's SSD1306 library...
Thank you!

ghp
Posts: 1418
Joined: Wed Jun 12, 2013 12:41 pm
Location: Stuttgart Germany
Contact: Website

Re: Getting unexpected error while using oled...

Thu Jul 25, 2019 7:11 pm

You do not give too much information. What is the exact error message, where are the variables defined you are using.
What did you already do to correct the problem? Are there other places where it works?
For the library, there is example code, e.g. https://github.com/adafruit/Adafruit_Py ... s/stats.py

hippy
Posts: 6069
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Getting unexpected error while using oled...

Thu Jul 25, 2019 8:01 pm

Shaurya wrote:
Thu Jul 25, 2019 4:59 pm

Code: Select all

count = 1
disp.clear()
disp.display()
draw.text((30, top+20), count, font=font, fill=255)
The oled cannot display count. It says something about 'int' values…
It really does help to post the exact error message.
From that Python code I see ...

draw.text((x, top), "IP: " + str(IP), font=font, fill=255)

So I would guess from that second parameter, "IP:"+str(IP), it needs to be a string and your count parameter, having been set to 1, is an integer. Hence the error.

Try -

draw.text((30, top+20), str(count), font=font, fill=255)

Return to “Python”