# FreezeScreen()
| Valid For | #HMI |
|---|---|
| Applies To | HMI430 |
This function is used to prevent screen flicker during long drawing operations.
Function Prototype
# FreezeScreen(
0|1 )
| Parameter | Option | Description |
|---|---|---|
| 0 or 1 | mandatory | 1 means freeze the screen. 0 means unfreeze the screen. |
Description
This function is used when your application is updating items or values on the screen and you can see a visible flicker. By calling FreezeScreen( 1 ), you can draw to the screen without the user seeing it. Only when you finally call FreezeScreen( 0 ) will all your drawing actions be instantly sent to the screen.
This isn’t magical – all that’s happening is your drawing is being done into a background buffer. When you unfreeze, that buffer is dumped onto the screen very rapidly, pretty much “in the blink of an eye” fast.
Take care not to freeze for too long as buttons still work while the screen is frozen. This means the user may be pressing old buttons that are still visible but have since been replaced with new buttons they can’t see. So if an old buttons says “Exit” but a new one in the same position has been drawn while the screen is frozen says “LaunchMissiles”, then the user will see “Exit” but pressing it will actually launch the missile. Oh dear…
Be careful to always unfreeze – otherwise your screen will never update.
Example
We tend to not use FreezeScreen() when drawing a new screen, as seeing items rapidly appear on the screen tends to keep the user entertained. It’s better then having them look at a blank screen while it’s loading everything up in the background.
However, here’s a perfect example of when FreezeScreen() should be used.
#HMI FreezeScreen( 1 )
#HMI SetColours( f:HUEkBlack )
#HMI SetFont( "propnormalbold.fon" )
#HMI SetBounds( x:328px, b:152px, w:88px, h:1 ) ;note "b:152px" to use baseline positioning and "h:1" meaning 1 line high
#HMI Cls()
GoSub subReadPressure ;some subroutine that will return the pressure in W
fGoIfNeg _DispPressErr
#HMI Print( "\C", f(=w,5,1) ) ;print centered
Goto _EndDispPress
_DispPressErr
#HMI Print( "\CERROR" )
_EndDispPress
#HMI SetBounds()
#HMI FreezeScreen( 0 )
In this example either a pressure value or “ERROR” is being displayed. Functions Bounds() and Cls() are being used to ensure the old pressure reading is erased before the new one is printed. It is quite common for a screen update to occur in-between the Cls() and the Print(), meaning the user will see a “flicker” (a brief moment when no value is displayed). So here, FreezeScreen() is employed to ensure the pressure reading does not flicker.