SPLat Logo

ui_utils.spt

NOTICE: Our web site is being updated, but is currently experiencing extreme slowness due to host issues. Please contact us directly.
NOTICE: SPLat Controls has moved. We are now at 1/85 Brunel Rd, Seaford, 3198. map

ui_utils.spt

The ui_utils.spt file contains a collection of useful subroutines relating to the HMI430.

Download ui_utils.spt

You'll also need the utils.spt file

Download utils.spt

 

UIsubInitialise

This subroutine should be called once at power on.  It will register the ConnectEvent handler.

UIsubGetButton

This is probably the most important subroutine.  It should be just once within a button even subroutine.  It will return a bunch of information about the button press:

Calling this function is optional.  If your button subroutine only responds to one specific button and only when the button is pressed, then you don't need UIsubGetButton.

However, if you are performing number entry, then each number on your keypad can be given an ID 0 thru 9.  All these buttons can call the same subroutine as it will call UIsubGetButton to get the ID of the button.

Perhaps you are controlling a water pump.  On your LCD you may have a picture of the tank.  In fact, the tank is a button, pressing it halfway up can set the new fill level to 50%.  Call UIsubGetButton to determine where the user pressed the tank.

Callbacks

ui_utils.spt expects your application will have the following subroutines.  If you don't need them, then simply have them as stub routines, eg:

UIsubBacklightEvent:
Return

UIsubRedrawAfterCal:
Return

 

UIsubBacklightEvent

This routine will be called whenever the backlight changes state, eg from high to medium, or medium to off, or off to high.  The parameters passed to this routine are:

 

UIsubRedrawAfterCal

If you press on the LCD when turning it on and keep it pressed for a few more seconds, the controller will automatically start the touch screen calibration function.  Once you have finished calibrating the touch screen, this routine will be called, allowing you to redraw your UI.

Example

Here's an example using the ui_utils.spt module:

   <POWER ON>
...
GoSub UIsubInitialise ;place this at the start of your code
...
...

UIsubBacklightEvent:
LoadX UIBLkHigh ;is the backlight..
Compare ;..at the high level? 0 = yes, otherwise no
Output oSwDisplayLED ;light the display button if backlight is medium or off
Return

UIsubRedrawAfterCal:
;(your code to redraw your screen)
Return


   #Include File( "ui_utils.spt" )              ;place this somewhere near the end of your code (or use a build script)

Note this function differs from its cousin in the Android world in that the "Connect" event is never sent (there's no point, the touch screen is always connected).