FrSkyRC / ETHOS-Feedback-Community

Feedback & suggestions are welcomed here for ETHOS by FrSky
192 stars 86 forks source link

lcd.invalidate bug #4789

Closed noamkrief closed 1 day ago

noamkrief commented 1 day ago

I'm refreshing the screen every 0.1 seconds only at 0,0,50,50

The text at 100,100 refreshes every second for some reason. It should stay the SAME forever. It should NEVER refresh.

local function create()

end

local tempclock1 = 0

local function paint(widget) lcd.drawText(0,0,os.clock()) lcd.drawText(100,100,os.clock())

end

local function wakeupnow(widget)

if os.clock() > tempclock1 + 0.1 then   
    tempclock1 = os.clock()
    lcd.invalidate(0,0,50,50)
end

end

local function init() system.registerWidget({key="noam1", name="noam1", create=create, paint=paint, wakeup=wakeupnow, title = false}) end

return {init=init}

strgaltdel commented 1 day ago

Hi,

When you call lcd.invalidate(0,0,50,50), you are updating an area that starts at 0,0 (top left) and extends to 50,50.

This means that:

lcd.drawText(100,100,os.clock())

is not updated by this lcd.invalidate.

(2) I would recommend checking how often wakeup is being called. Depending on the complexity of the model configuration, it might be more than every 0.1 seconds. In that case, your "resource saver" wouldn’t actually be one.

regards

bsongis-frsky commented 1 day ago

At each cycle the minimum rectangle is refreshed. Since you ask for a refresh of [0, 0, 50, 50] and the Time in the bottom status bar requests a refresh too, once per second, the rectangle which will be refreshed is big, as the 2 rectangles must be included inside, and they are at opposite corner.

strgaltdel commented 1 day ago

That's an interesting explanation of how lcd.invalidate works; I never could find functionality described en detail.

So,

image

Thanks for the hint!

noamkrief commented 20 hours ago

@bsongis-frsky Sorry to ask again. But when I change the refresh rate to 1 second: if os.clock() > tempclock1 + 1 then

Then everything seems to work like I would expect. lcd.drawText(100,100,os.clock()) NEVER changes. Not even once per second.

When I lcd.invalidate(0,0,50,50) I expect only the top left 50x50 box to be refreshed. Anything outside of that should NEVER change.