SPLat Logo

HMI - Simple Example

NOTICE: SPLat Controls has moved. We are now at 1/85 Brunel Rd, Seaford, 3198. map

HMI - Simple Example

As with most things in life, getting started can be a little tough.  So here's a very simple HMI example that:

 


HUEkViolet #EQU 'FF8F00FF ;create a named colour
bValue defBYTE ;make a variable to hold a counter

;draw some text and a button
#HMI Print( "Hello\nWorld!" )
#HMI ButtonEvent2( x:c-4, y:-3, w:20%, h:3, m:"r20", t:"Press\nMe!", rb:HUEkViolet, ev:subCount )

;start multitasking (required for button events)
RunTasksForever

;this subroutine is called when the button is pressed or held
subCount:
IncM bValue ;increment the counter
#HMI SetCursor( x:0, y:c ) ;display the..
#HMI Print( b(*bValue,f) ) ;..new value
Return ;finished handling the button

 This is a fully working example.

Any text that starts on the first column is a label and everything that doesn't start on the first column is an instruction or directive.  In this example, the labels are:

bValue
subCount

As bValue is assigned to a defBYTE it becomes a label for a RAM byte address.  All the other labels are assigned program addresses.  A terminating colon ":" is optional.

Be aware you must use MultiTrack multi-tasking otherwise your button subroutine won't be called.

Remember to "Return" from the button subroutine.

It's good programming practice to only draw to the screen from one task.  Drawing from a button subroutine is ok, but best keep it simple & quick.

For the more adventurous

The full source code for the demo program that ships with the HMI430 is also available:

Download hmi430demo.zip