# HBar()
| Valid For | #HMI |
|---|---|
| Applies To | HMI430 |
This instruction draws an horizontal bar.
Function Prototype
HBar(
x:LeftPosition,
y:BaselinePosition
w:Width
h:Height
v:NormalisedBarValue )
| Parameter | Option | Description |
|---|---|---|
| x | mandatory | Left-most position of the HBar within the current bounding box. Any of the positioning methods may be used. |
| y | mandatory | Text baseline position of the HBar within the current bounding box. Any of the positioning methods may be used. |
| w | mandatory | Total width of the HBar (the HBar background will fill this width) |
| h | mandatory | Height of the HBar |
| v | mandatory | Value of the HBar (0.0 means no bar, 0.5 means 50%, 1.0 means 100%) |
Description
Use this instruction to draw an analogue style horizontal bar, useful for displaying analogue readings as a bar rather (or as well as) a number. Both the background and foreground colour of the bar may be specified using the current colours as set by #HMI SetColours(). It’s quite common to use green/yellow/red for good/warning/bad.
If using character positioning, the bar will use the size of the current font.
You can display a value in an HBar() by using the nothing colour as the text background.
Examples
This example draws a bar that’s as wide as the screen and whose bar is at 50% (the value is taken from W). It then draw the value “50%” centered in the HBar
#HMI SetFont( f:"sysdefault.fon" )
#HMI SetColours( f:HUEkGreen, b:HUEkMedGrey ) ;green HBar, gray background
fLoadW 0.5 ;a value to chart
#HMI HBar( x:0, y:0, w:100%, h:1, v:f(=w) ) ;hbar @ full width
;HBar is done, but for bonus points we'll display the value as text in it...
#HMI SetColours( f:HUEkWhite, b:HUEkNothing ) ;white text, don't erase the HBar behind the text
#HMI SetCursor( x:0, y:0 )
fLoadQ 100.0 ;convert to a..
fMul ;..percentage
#HMI Print( "\C", f(=w,3,0), "%" ) ;display centered in the HBAR
Where:
- The colours have been equated as:
HUEkGreen #EQU ‘FF00C000
HUEkMedGray #EQU ‘FF808080
HUEkWhite #EQU ‘FFFFFFFF
HUEkNothing #EQU ‘00010101