Page 1 of 1

Getting unexpected error while using oled...

Posted: Thu Jul 25, 2019 4:59 pm
by Shaurya
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!

Re: Getting unexpected error while using oled...

Posted: Thu Jul 25, 2019 7:11 pm
by ghp
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

Re: Getting unexpected error while using oled...

Posted: Thu Jul 25, 2019 8:01 pm
by hippy
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)