-->
Page 1 of 3

oled.print bug?

PostPosted: Fri Mar 02, 2018 5:35 pm
by Al McDivitt
Hi all
Might be me?
ESP Basic 3.0.Alpha 69
Temp,Hum don't print on oled display but show on textbox
new to ESPBasic any help would be great
Thanks in advance
Cheer's
Al McDivitt

My Code (Wemos D1 Mini Pro)

memclear
cls
oled.cls()
PinDHT = 2
DHT.SETUP(11, PinDHT)

i2c.setup(4,5)
timer 1000, [branch] ' ## Time for auto refresh variables ##

oled.print("Current Temperature", 10,1)
oled.print(Temp, 10,10) ' *** Temp not showing on OLED
oled.print("Current Humidity", 10,18)
oled.print(Hum, 10,28) '** Hum not showing on OLED
oled.print("Your IP is:", 10,36)
oled.print(ip(), 30,48)


textbox Temp ' *** Temp IS showing in textbox
Wait


[TestExit]
timer 0
end

[branch]
gosub [readdata]
wait

[readdata]

Temp = DHT.TEMP() 'Current Temperature
Hum = DHT.HUM() 'Current Humidity

Re: oled.print bug?

PostPosted: Fri Mar 02, 2018 11:11 pm
by Mmiscool
Convert the number to a string using the str() function.
oled.print(str(Temp), 10,10)


https://docs.google.com/document/d/1EiY ... 20ztyx3ev3

Re: oled.print bug?

PostPosted: Sat Mar 03, 2018 1:35 am
by Al McDivitt
Mmiscool wrote:Convert the number to a string using the str() function.
oled.print(str(Temp), 10,10)

Thanks but tried that get nan displayed


https://docs.google.com/document/d/1EiY ... 20ztyx3ev3

Re: oled.print bug?

PostPosted: Sat Mar 03, 2018 1:44 am
by Mmiscool
At the top of your code set Temp = 0

When you create the text box with a variable that is not initialised it creates the variable as a string by default and not a number.