SPLat Logo

# ConnectEvent(ev:EventHandler) hash function

NOTICE: We are updating our website. For product enquiries and orders please contact us directly.
NOTICE: SPLat Controls has moved. We are now at 1/85 Brunel Rd, Seaford, 3198. map

# ConnectEvent(ev:EventHandler) hash function

Valid for use with hash command: HMI

Implemented on the following platforms: HMi430, Android, Windows.

HMI430

The HMI430 does not have a concepts of connected or not connected. Instead the Connect event is used to signal two other status changes that are unique to the HMi430:

Screen press during power-up

The intention is for this to be used to force the controller into screen calibrate mode. If the screen module itself has had to be replaced, the touch function needs to be re-calibrated.

Change in backlight status

The Connect event gives you an opportunity to perform some external action, say turn on a room light.

HMI430 sample program

When the Connect event is triggered, there will be some additional bytes of data available that you can use to tell what triggered the event. The following code extracts that data and actions accordingly.

COMHMI            EQU   251                           ;"Port" number for the display
evConnected:
   LoadX          5                                   ;does the buffer hold a..
   aCOMRx_FindXInBuf COMHMI                           ; .. end of message (5)?
   GoIfXeq        255,Return                          ;jump if not

   aCOMRx_ReadOne COMHMI                              ;get the message id from the comms buffer
   Push
;Test what kind of event it was ...
   GoIfXeq        0,_UIProcessBacklight               ;jump if message is backlight message
   GoIfXeq        1,_UIPowerOnTouch                   ;jump if user has been touching the screen since power on
Return:
   Return

_UIProcessBacklight:
   aCOMRx_ReadOne COMHMI                              ;get the separator
   GoIfXne        2,Return                            ;abort if not separator
   aCOMRx_ReadOne COMHMI                              ;get the backlight state. TRUE = ON
   aCOMRx_ReadOne COMHMI                              ;get the terminator
   GoIfXne        5,Return                            ;abort if not terminator
....  insert your code to action backlight status change. X is TRUE if the light is on
   Return

_UIPowerOnTouch:
   aCOMRx_ReadOne COMHMI                              ;get the endhdr
   GoIfXne        5,Return                            ;abort if not endhdr
   SPxCmd0        0,10                                ;go perform cal, won't return until complete
   GoSub          UIsubScreenShowIdle                 ;redraw the idle screen
   Return

Android and Windows

This function specifies an Event handler that is to be called when the HMI reports it has become connected. The typical scenario is an Android device that is not normally connected to a SPLat controller. When the Android HMI app is first launched, the user has to enable Bluetooth, make sure it is paired with the Bluetooth on the SPLat, and select the SPLat Bluetooth to connect to. All this while the HMI in the Android is displaying a default screen. Once the Bluetooth connection is successfully established, the Android HMI app sends a special code to the SPLat. The ConnectEvent function detects this and does a GoSub to your Event handler. Your event handler then draws the initial screen applicable to your SPLat application.

The HMI function in SPLat/PC has a Connect button that generates the same code to the SPLat.