Jump to content




Reactor Controlling Program


  • You cannot reply to this topic
4 replies to this topic

#1 The_Cat

  • Members
  • 119 posts

Posted 20 June 2015 - 03:32 PM

Hey Guys,

So I am making this program which lets me control and see different things using the touch screen monitor.

The problem which I am having is that the screen flashes (I think its because of the loop updating the writing of the buttons or what not) so I tried adding a timer event within the loop but had no luck as it seems to somewhat ignore the timer i.e. doesn't stop everything keeps flashing the display.

Here is my code (Reactor is connected via wired modem):

Spoiler


#2 TheOddByte

    Lazy Coder

  • Members
  • 1,607 posts
  • LocationSweden

Posted 20 June 2015 - 03:55 PM

You mean that it's flickering? That often happens when you clear the screen and redraw a lot of stuff all the time, there are different ways to fix this, but the most ideal way todo it is to use a buffer, which prevents the screen from flickering.
You can find a buffer in the APIs section, here's one

Another way you could fix this would be to not redraw as often, use a variable or something that redraws every 100th time or something.
local var = 0
while true do
    var = var + 1
    if var >= 100 then
        var = 0
        redraw()
    end
end
This is not a really good solution IMO, but it may work in your situation, depending on how fast you go through the loop.
Because if for example you go through the loop 100 times in one second, then this would only redraw one time each second, instead of 100 times :P

#3 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 20 June 2015 - 04:02 PM

Well, no, the problem is that the screen is getting cleared, and then appears to sleep for a second, and then updated values are fetched while things are being written to the screen. This should just require a re-ordering of the existing code, it won't require buffering or any other complex solutions. Simply fetch new data, and only then clear the screen and immediately re-write the new data.

#4 TheOddByte

    Lazy Coder

  • Members
  • 1,607 posts
  • LocationSweden

Posted 20 June 2015 - 05:20 PM

View PostLyqyd, on 20 June 2015 - 04:02 PM, said:

Well, no, the problem is that the screen is getting cleared, and then appears to sleep for a second, and then updated values are fetched while things are being written to the screen. This should just require a re-ordering of the existing code, it won't require buffering or any other complex solutions. Simply fetch new data, and only then clear the screen and immediately re-write the new data.
Ooops, my mistake, thought it was because of excessive drawing.
With the information Lyqyd gave you, you simply have to move "m.clear()" before you draw.

#5 The_Cat

  • Members
  • 119 posts

Posted 21 June 2015 - 10:42 AM

Quote

Ooops, my mistake, thought it was because of excessive drawing.
With the information Lyqyd gave you, you simply have to move "m.clear()" before you draw.

Works now!
Thanks Lyqyd and OddByte :)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users