SimpleHMI low level message codes
This section describes the low level serial command/message codes that flow between a SimpleHMI device and the host. Typically the SimpleHMI device is an Android phone, and the host is a SPLat controller. If you are programming a SPLat you will be using the HMI
or HMI_Log
hash commands and various hash functions, so all that follows is taken care of under the hood (no need to read on unless you are making SimpleHMI support for a host other than SPLat.).
See also: SimpleHMI tutorial, HMI
hash command, HMI_Log
hash command
General message format to SimpleHMI
All commands (a.k.a. messages, packets, datagrams) to the SimpleHMI consist of a header, a body and a terminator.
The header starts with a '01
character (this is the traditional SPLat notation for hex) followed by a command character. Command characters have been arbitrarily assigned from the visible (printing) characters, but could in future be any codes greater than '1F
(invisible codes are reserved for other uses). Thus the header is always two characters.
The body consists of 0 or more arguments. Arguments are always ASCII (visible) characters, so for example the number 23 will be an ASCII 2 ('32
) followed by ASCII 3 ('33
). The arguments list is terminated in '03
. If there is more than 1 argument they are separated by '02
characters.
The following table summarises the complete repertoire of commands to the SimpleHMI. In this table the vertical bar (pipe) character | indicates a '02
argument separator. The '01
that starts every command, and the '03
that ends every command, are not shown.
Messages to SimpleHMI
Name | Cmd | Arguments (Body) | Description |
---|---|---|---|
|
|
Text | Any following text up to the '03 terminator, is displayed at the current cursor position. No wrapping! |
|
|
None | |
|
|
Text | The text is added to the accumulating record for the currently selected log file. |
|
|
None | The current system time in the SimpleHMI device is added to the accumulating record for the currently selected log file. |
|
|
None | The current system time in the SimpleHMI device is added to the accumulating record for the currently selected log file. |
|
|
ądRow | ądCol | Move the text cursor relative to its current position. If an argument is empty it is unchanged. Row and column delta specifiers can be any of those defined under the |
|
|
Row | Col | Move the text cursor to a new absolute position. If an argument is empty it is unchanged. Row and column specifiers can be any of those defined under the |
|
|
None | Push foreground and background colours onto the colour stack. |
|
|
None | Pop the most recently pushed colours off the colour stack and set both foreground and background colours to the retrieved values.. |
|
|
None | Pop the most recently pushed colours off the colour stack and set the foreground colours to the retrieved value. The background colour is not affected. |
|
|
None | Pop the most recently pushed colours off the colour stack and set the background colours to the retrieved value. The foreground colour is not affected. |
|
|
R | G | B values, each 0-255 | Foreground colour for future text and possibly other items |
|
|
R | G | B values, each 0-255 | Background colour for future text and possibly other items, and Cls |
|
|
Btn | Row | Col | Height | Width | Text | Mode | ClickCode | Set button parameters. Coordinates in character pitch. Mode:In early versions this parameter was called Visible, and simply controlled visibility of the button. It now contains mode control in addition to visibility information. The coding is described in the Note: There could be some confusion between the |
|
|
Row | Col | Height | Width | Var | Draw a filled rectangle in the position and size given using Requires |
|
|
None | Clear the text, set cursor to 1,1, colour screen with the current background colour. |
|
|
None | Reset the HMI to initial conditions |
|
|
Prompt | Min | Max | EventCode | Prompt user to input an integer number. Force min/max limits, return the resultant string preceded by |
|
|
None | Hides all the buttons and resets their parameters. |
|
V | Character_Widths | EventCode | Sets the number of characters across the screen |
|
|
None | Displays horizontal and vertical character pitch rulers. Only shows positions that are fully accessible. For example, if the selected ScreenWidthEvent value results in a character size that would fit 23.9 times into the actual screen height, the vertical ruler will contain rows zero through 22. |
|
8-bit mask as hex number | Bit 7 Enables the Terminal tab so the terminal function can be used. | |
|
Y | BaseName | Mode | |
|
|
BaseName | Signals that a new file is to be created on the next |
|
o | EventCode | (Android only) . Displays the colour wheel graphic. See below for what gets sent back to the host. |
|
p | Text | Language | Country | ClearQueue | Speaks aloud a given text, with language and country settings. For more details of parameters see |
|
|
Text | Speaks aloud a given text, with no other parameters. Intended for speaking numbers from SPLat. With other hosts may be used as a simplified |
|
|
Text | Not used in Android. Any following text up to the '03 terminator, is appended to the trace window. It can optionally be written to a disk file. |
Messages from SimpleHMI back to the host
- In the
ButtonParams
command, the last argument is called ClickCode. This defines the code that will be sent back to the host when an Enduser clicks the button. TheClickCode
can be any sequence of character codes greater than'1F
('1F
and below are reserved). When a button is pressed itsClickCode
will be sent to the host followed by a'04
. - In the
IntInput
command, the last argument is called EventCode. When the enduser completes entering the requested data, a message is sent back to the host in the following form:EventCode, '05, User_Response, '04
The
EventCode
can be any sequence of character codes greater than'1F
('1F
and below are reserved). The'05
is provided by SimpleHMI, and terminates the header.User_Response
is whatever ASCII input the user provided. The'04
is the message terminator. IfUser_Response
is empty (the'04
follows immediately after the'05
), it means the user cancelled the operation without entering any data. - The ColourWheel command generates a stream of messages as the Enduser moves a finger across the graphic. Each message consists of:
EventCode, '05, RedVal, GreenVal, BlueVal, '04
There are spaces after
RedVal
andGreenVal
.to separate the colour values. Colour values are in the range 0 to 255. - Other commands can result in an
EventCode
being sent back to the host. TheEventCode
can be any sequence of character codes greater than'1F
('1F
and below are reserved) and will be returned by the SimpleHMI in the form:
EventCode, '05, '04
- When the SimpleHMI app in an Android device successfully makes a Bluetooth connection, it sends out a
ConnectedEvent
message. This consists of the character pair'06 '04
.
These formats have been designed to work with SPLat instructions ComRx_FindXInBuf
and ComRx_StrFind
. ComRx_FindXInBuf
will tell you if there is a '04
message terminator in the buffer. If every ClickCode
and EventCode
has been made unique, it is a simple matter to use ComRx_StrFind
with suitable tables in NVEM0 to identify the actual event.
On other host platforms, for example a C-programmed controller, the event codes could be used to index a table of callback addresses.
Default button codes
Normally the host will tell the SimpleHMI client what click codes to send back when buttons are clicked. There are however defaults for the buttons that display as F1 through F8 on the default screen. These codes are ASCII "1" through ASCII "8" (the same as hex '31 through '38). When a button is click the code will be send followed by the '04 terminator. These codes have been designed to work with even the most simplistic of hobby grade hosts that achieve serial input by bit-banging, and block all other activity while doing so.