Turn LCD off until a key is pressed

Just starting out? Need help? Post your questions and find answers here.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

> The delay should be raised to at least 20-100 in my opinion,
> this makes the program lighter on the CPU

Nah, 1 is fine. Remember, 1 isn't always going to be exactly 1 ms, it's going
to be whatever the CPU needs at that time. I've done tests using 1, 50 and
100 ms and there was no difference in CPU load at all, and the 50 and 100
settings just made my app less responsive due to the extra forced sleeping.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Henrik
Enthusiast
Enthusiast
Posts: 404
Joined: Sat Apr 26, 2003 5:08 pm
Location: Denmark

Post by Henrik »

PB wrote:> The delay should be raised to at least 20-100 in my opinion,
> this makes the program lighter on the CPU

Nah, 1 is fine. Remember, 1 isn't always going to be exactly 1 ms, it's going
to be whatever the CPU needs at that time. I've done tests using 1, 50 and
100 ms and there was no difference in CPU load at all, and the 50 and 100
settings just made my app less responsive due to the extra forced sleeping.
@PB
Well i tend to believe you'r right here again when i think about it, because at least some of the times were i was forced to use heigher delay was because i wanted to make sure that something else was finish with watever it was doing.
So you might be right again, delay(1) maybe enough. :)

Regards Henrik
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

> some of the times were i was forced to use heigher delay was because
> i wanted to make sure that something else was finish

Yes, if you're waiting for something then of course a longer Delay is needed;
but for a tight loop like this, then 1 ms is way more than enough. Besides, if
you're waiting for something then you should still do a 1 ms delay and just
constantly check for the condition of the other thing in that 1 ms loop.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Post Reply