Report Bugs Here

Moderator: Mmiscool

User avatar
By PhilTilson
#66473 I am posting this in both General and Bugs as I'm not sure it IS a bug and want to have the widest audience!

A while ago I posted in Projects some software for a 'wake-up light' that uses RGB LEDs. This seemed to have been working fine, but recently had crashed every time it started up, sometimes doing multiple crashes which were difficult to interrupt!

Having done some debugging, the problem seems to be with CSSID. I establish some buttons for controlling the light with lines like this:

Code: Select allbutton "Morning", [dayon]
btnday = htmlid()
cssid btnday, "background-color: lightgray; left: 130px;"

Later in the program, if the button is clicked, I call the routine:

Code: Select all[dayon]
io(pwo,rr,daylevel)
io(pwo,gg,daylevel)
io(pwo,bb,daylevel)
cssid btnday, "background-color: aqua;"
serialprintln dtg$ & "  Day_on: " & daylevel
wait

in order to change the button colour to indicate that the day lights are on. This works. Later, to turn them off, I use:

Code: Select all[alloff]
day_inc_active = 0
inclevel = 0
night_active = 0
io(pwo,rr,0)
io(pwo,gg,0)
io(pwo,bb,0)
cssid btnday, "background-color: lightgray;"
cssid btnnight, "background-color: lightgray;"
serialprintln dtg$ & "  All Off"
wait

This seems to work the first time, but subsequent calls cause a crash and memory dump. Once rebooted, I try again and the same thing happens.

If I remove the CSSID calls, the system is rock solid.

Surely I should be able to save the values obtained from HTMLID() in a variable and then use it subsequently for CSSID? It seems to work fine most of the time, but not here!

If anyone wants the full code to try running it to see if you get the same problem, let me know and I'll post it.

Phil
User avatar
By mariolatronico
#66597 HI,
The following lines eat memory each time they are run:
cssid btnday, "background-color: aqua;"
cssid btnday, "background-color: lightgray;"
cssid btnnight, "background-color: lightgray;"
please, see: http://www.esp8266.com/viewtopic.php?f=42&t=13024
Electoguard's Memory Gauge is very useful for studying the event.
Try erasing and redrawing the graphical interface instead of change it.
regards
User avatar
By Mmiscool
#66714 This problem occurs because the CSS is constantly added to the bottom of the HTML buffer internally.

The only sure fire way to prevent this kind of problem is to redraw the gui and change the colors of an item only once.