The text of a manual · part 14 of 18
Qlarity-Based Terminal Programmer's Reference Manual: Chapter 4 Qlarity API Function Reference, pages 92 to 100
Pages 92 to 100 of 134, from Qlarity-Based Terminal Programmer's Reference Manual
The original document is the PDF (1.5 MB). This is its text as extracted, unedited; tables and drawings read best in the PDF, and each page heading opens it at that page.
Filed in the catalog under the QSI Corp QTERM-G70
Page 92
80
QSI Qlarity-based Terminal Programmer’s Reference
To check the attributes of the file, logically AND “{flags}” with the appropriate value, and check to see if it is equal to that flag (i.e., “{flags}” AND FILEINFO_ISOPEN == FILEINFO_ISOPEN).
Description:
Syntax:
This function opens a file for accessing the data and returns a file handle used to reference the file in other function calls. When opening, at least FILE_READ or FILE_ WRITE must be specified. If neither FILE_TEXT nor FILE_BINARY is specified, the access mode is determined as follows: if the file exists, it is opened in the same mode in which it was created; if the file does not exist, it is opened in text mode by default (as if FILE_TEXT were specified). Files opened in text mode do not support overwriting data in the file. There are a limited number of files that can be open at any one time (currently 7).
openfile(name[] as reference? to byte, -> flags as file_flags) returns filedesc
4.16.9 CloseFile
Parameters:
Syntax:
{name} A string containing the name (possibly including path) of the desired file.
closefile(fnum as filedesc)
If the path included in “{name}” begins with / or \, it starts with the root directory; otherwise it is relative to the current directory. 4.16.8 OpenFile
{flags} A combination of the following values (logically ANDed together): FILE_READ Open file for reading (if FILE_WRITE is not specified, FILE_NO_CREATE is automatic and FILE_APPEND cannot be specified). FILE_WRITE Open file for writing.
Parameters: {fnum} File handle returned from an OpenFile() call. Description: This function closes a file. The “{fnum}” file handle is invalid after a call to this function. 4.16.10 ReadFile Syntax: readfile(fnum as filedesc, var as -> reference to anytype)
FILE_TEXT Open file in text mode (FILE_BINARY may not be specified).
Parameters:
FILE_BINARY Open file in binary mode (FILE_TEXT may not be specified).
{var} Variable (of any type) to receive data read from the file.
FILE_NO_CREATE Do not create the file or destroy old file contents (it must exist). FILE_APPEND When opening a file for writing, do not destroy old file contents, and adjust file position to be at the end of the file.
{fnum} File handle of desired file.
Description: This function reads data from the specified file and stores the data in variable “{var}.” Data is read starting at the current position in the file. If the access mode of the file is binary, the number of bytes needed for “{var}” is read from the file and stored in “{var}.” For arrays in binary mode, the size of the array determines the number of items read from the file. In text mode, one line of data (bytes up to but not including the newline character 0x10) is read from the file and is converted to “{var}'s” data type, as with a call to the Val() API function. The resulting value is stored in “{var}.”
QSI Corporation Fax 801-466-8792 Web www.qsicorp.com Phone 801-466-8770
Page 93
QSI Qlarity-based Terminal Programmer’s Reference
4.16.11 WriteFile
81
Syntax:
1 is the end of the file.) For files in text mode, the position and offset refer to the line number in the file. For files in binary mode, these refer to the byte offset in the file.
writefile(fnum as filedesc, data as -> reference? to anytype)
4.16.13 GetFilePos
Parameters:
Syntax:
{fnum} File handle of the desired file.
getfilepos(fnum as filedesc) returns integer
Parameters: {data} A variable (of any type) containing data to write to the file.
{fnum} File handle of the desired file.
Description:
Description:
This function writes data to the specified file based on the file's access method. If the file is in binary mode, the data is written in bytes exactly as it is in “{data}.” In binary mode, bytes in the file are overwritten if the current file position is not at the end of the file. In text mode, the current file position must be at the end of the file. Also, the data is converted to a string (as with a call to the Str() API function), and the resulting string is written to the file followed by a newline character (0x10).
This function returns the current position in the file. For files in text mode, this refers to the line number of the current line in the file. For files in binary mode, the current position is a byte offset into the file.
4.16.12 SetFilePos
Parameters:
Syntax:
{fnum} File handle of the desired file.
setfilepos(fnum as filedesc, offset as -> integer, absolute as boolean)
Parameters: {fnum} File handle of the desired file. {offset} An integer containing the offset to be added to the current position (or the beginning of the file). {absolute} A flag determining the basis for the new position calculation. A value of “true” adds “{offset}” from the beginning of the file. A value of “false” adds “{offset}” to the current file position.
4.16.14 EndOfFile Syntax: endoffile(fnum as filedesc) returns boolean
Description: This function determines if the current position in the file is at the end of the file. A value of “true” is returned if this is the case, other “false” is returned. 4.16.15 EraseFileSpace Syntax: erasefilespace()
Description: This function unconditionally erases the entire file space (all files and directories). USE WITH CAUTION. 4.16.16 RenameFile
Description: This function sets the current read/write position for the specified file. To reset the position to the beginning of the file, use an offset of 0 and absolute as “true.” (An offset of -
Syntax: renamefile(name[] as reference? to byte, -> newname[] as reference? to byte)
QSI Corporation Fax 801-466-8792 Web www.qsicorp.com Phone 801-466-8770
Page 94
82
QSI Qlarity-based Terminal Programmer’s Reference
Parameters: {name} A string containing the old name (possibly including path) of the file to rename. {newname} A string containing the new name (possibly including path) to be used to refer to the file.
useful for debugging code. Note that in Layout View, Qlarity Foundry usually only executes handlers for the MSG_INIT and MSG_DRAW messages (as well as MSG_ERROR and user messages that originate in these messages), so any calls to Tool_Trace() must originate from handlers for these messages.
4.18 Miscellaneous Functions
Description:
4.18.1 SetGPIO
This function will rename a file that is contained in the flash file system.
Syntax:
4.17 Qlarity Foundry Functions These functions are only available in Qlarity Foundry, and calls to them should be enclosed in a “#if _TOOL/ #endif” directive to prevent their inclusion in the runtime application. 4.17.1 Tool_Persist setgpio(pins as unibyte, action as -> gpio_action)
Parameters: {pins} A value of type unibyte indicating which outputs to set. The “gpio_pin” type has been created to simplify use of this API. Legal values are PIN0, PIN1, PIN2, etc. Multiple values may be OR'ed together to select any combination of output pins.
Syntax: tool_persist(x as reference to anytype)
Parameters: {x} The name of a variable modified in a tool message handler. Description: This function informs Qlarity Foundry that an object property has been modified in a tool message handler. Qlarity Foundry must be informed of the change in order to update the application properly. Only call this if you want a value permanently saved. See section 3.7, “Tool Messages” for more details. 4.17.2 Tool_Trace Syntax: tool_trace(str as string)
{action} A value of type “gpio_action” (see below) indicating how the outputs should be set. Description: This function sets the output state of one or more GPIO pins. The pins must be set to outputs using the SetGPIODirection API function before this function can be used. The function sets the outputs on the pins selected by “{pins}” according to the desired “{action}.” Legal values for “{action}” include: GPIO_SET Set the outputs (logic HIGH) on the selected pins. GPIO_CLEAR Clear the outputs (logic LOW) on the selected pins. GPIO_TOGGLE Toggle the outputs on the selected pins.
Parameters: {str} A message to display in Qlarity Foundry.
4.18.2 ReadGPIO Syntax:
Description:
readgpio(pins as unibyte) returns gpio-pin
This function causes Qlarity Foundry to display the message contained in “{str}” when the function is called. It is
QSI Corporation Fax 801-466-8792 Web www.qsicorp.com Phone 801-466-8770
Page 95
QSI Qlarity-based Terminal Programmer’s Reference
83
Parameters:
Description:
{pins} A value of type unibyte indicating which inputs to read. The “gpio-pin” type has been created to simplify use of this API. Legal values are PIN0, PIN1, PIN2, etc. Multiple values may be OR'ed together to select any combination of input pins.
This function returns the version of the system software (firmware) currently programmed into the terminal. 4.18.5 GetHardwareInfo Syntax: gethardwareinfo(req as hwinfo) returns -> byte[]
Description: This function reads the input state of one or more GPIO pins. (Pins may be set to inputs using the SetGPIODirection API function). The function reads the inputs on the pins selected by “{pins}” and returns a unibyte containing the read values. The return value must be AND'ed with the appropriate “gpio_pin” to determine the value on that pin. A non-zero result indicates that the input is set (logic HIGH), while a zero result indicates that the input is clear (logic LOW). 4.18.3 SetGPIODirection Syntax: setgpiodirection(pins as unibyte, input -> as boolean)
Parameters: {pins} A value of type unibyte indicating which gpio pins to set to the desired direction. The “gpio-pin” type has been created to simplify use of this API. Legal values are PIN0, PIN1, PIN2, etc. Multiple values may be OR'ed together to select any combination of pins. {input} A boolean flag that should be set to TRUE if the desired direction is input, and FALSE if the desired direction is output. Description: This function sets the input/output direction of one or more GPIO pins. The function sets the pins selected by “{pins}” to inputs if “{input}” is TRUE, otherwise the pins are set to outputs. 4.18.4 GetVersion Syntax: getversion() returns float
Parameters: {req} A value of type “hwinfo” (see below) indicating the desired hardware information. Description: This function returns information about the terminal hardware. It returns a byte array containing the requested information. The returned information is determined by the “{req}” argument. This argument is of type “hwinfo,” which is an enumerated type with the following legal values: HW_ETHERNET Request information on the Ethernet interface. The returned byte array contains two bytes. The first byte is set to 1 if the Ethernet interface is present, otherwise it is set to 0. The second byte is set to 1 if the Ethernet link is currently active, otherwise it is set to 0. HW_TOUCH Request information on the touch screen. The returned byte array contains one byte, which is set to 1 if a touch screen is present, otherwise it is cleared to 0. HW_KEYPAD Request information on the keypad. The function returns a byte array of variable length. The first byte is set to 1 if a keypad is present, otherwise it is cleared to 0 (and the length of the returned byte array is 1). If a keypad is present, the remaining bytes in the array contain all possible keycodes for the keypad. The keycodes must by logically OR’ed with 0x8000 to obtain the actual keycodes that will be received by the application via keypad messages. HW_KEYBOARD Request information on the keyboard. The returned byte array contains one byte, which is set to 1 if a keyboard is present, otherwise it is cleared to 0.
QSI Corporation Fax 801-466-8792 Web www.qsicorp.com Phone 801-466-8770
Page 96
84
QSI Qlarity-based Terminal Programmer’s Reference
HW_TEMPCONTROL Request information on the temperature compensation controller. The returned byte array contains one byte, which is set to 1 if a temperature compensation controller is present, otherwise it is cleared to 0. HW_CLOCK Request information on the real time clock. The returned byte array contains one byte, which is set to 1 if a battery-backed real time clock is present, otherwise it is cleared to 0. HW_DISPLAY Request information on the display. The returned byte array combines four bytes with the display pixel width stored in the first two bytes (MSB first), and the display pixel height stored in the last two bytes (MSB first). Following the four bytes are three bytes indicating more about the type of display in the following order: color, tft, and transflective. A value of 0 for any of those three fields indicates that the display does not have that property. HW_DEFAULTAPP Request information on whether a default application is available in the unit. The returned byte array contains one byte, which is set to 1 if a default application is present, otherwise it is cleared to 0. HW_MACADDRESS Request information on what the Ethernet address of the unit is. The returned byte array contains a six byte Ethernet address. HW_AUDIOCODEC Request information on the audio capabilities of the terminal. The returned byte array contains one byte, which is set to 1 if an audio decoder is present, otherwise it is cleared to 0. HW_GPIO Request information on the general purpose digital input/output (GPIO) capabilities of the terminal. The returned byte array contains one byte, which is set to 1 if GPIO is present, otherwise it is cleared to 0. HW_CPU Request information on the type of CPU present in the unit, and its execution frequency. The returned byte array contains the text name of the CPU, a '/' character, and some text indicating the instruction execution frequency in Hertz. HW_COMLIST Request information on which communications ports are present. The returned byte array will contain a 1 in every location that a com exists (COM1 would correlate with the 0-th element in the array). The size of the array will depend on how many serial ports are installed. Serial ports do not exist if there is no corresponding element in the array. HW_MEMORY Request statistics on unit memory. The first four elements of this byte array indicate the total amount of RAM that the unit has (MSB). The next four elements indicate the total amount of flash memory available (MSB). The last four elements indicate an estimate of the current amount of RAM the unit still has available (MSB). 4.18.6 SetContrast Syntax: setcontrast(direction as contrast_adjust)
Parameters: {direction} A value of type “contrast_adjust” (see below) that determines how to adjust the contrast. Description: This function adjusts the contrast of the display at runtime (i.e., not with Power On Setup). The adjustment is temporary and is forgotten when power is removed from the terminal. Permanent changes to the contrast setting must be made with the Power On Setup utility or the SetSystemSetting() API function. The SetContrast() function takes an argument of type “contrast_adjust,” which is a defined type with the following legal values: CONTRAST_LIGHTER Adjust the contrast one step lighter. CONTRAST_DARKER Adjust the contrast one step darker.
QSI Corporation Fax 801-466-8792 Web www.qsicorp.com Phone 801-466-8770
Page 97
QSI Qlarity-based Terminal Programmer’s Reference
4.18.7 SetBacklight
85 should be made with the Power On Setup facility or the SetSystemSetting() API function.
Syntax: setbacklight({command} as backlight_adjust)
4.18.9 SetLED
Parameters:
Syntax:
{command} A value of type “backlight_adjust” (see below) that determines how to adjust the backlight setting.
setled(cmd as ledcmd, lednum as integer)
Description: This function adjusts the backlight setting of the display at runtime (i.e., not with Power On Setup). The adjustment is temporary and is forgotten when power is removed from the terminal. Permanent changes to the backlight setting should be made with the Power On Setup facility or the SetSystemSetting() API function. The SetBacklight() function takes an argument of type “backlight_adjust,” which is a defined type with the following legal values: BACKLIGHT_ON Turn backlight on (set to previous “on” setting). BACKLIGHT_OFF Turn backlight off (power saving mode). BACKLIGHT_LIGHTER Adjust the backlight one step lighter.
Parameters: {cmd} A value of type “led_cmd” (see below) that determines how the LED setting is adjusted. {lednum} An integer indicating which LED is adjusted. Description: This function changes the state (on or off) of one of the keypad LEDs. The “{cmd}” parameter of type “led_cmd” is a defined type with the following legal values: LED_ON Turn on the specified LED. LED_OFF Turn off the specified LED. LED_TOGGLE Toggle the state of the specified LED. 4.18.10 GetTime
BACKLIGHT_DARKER Adjust the backlight one step darker. 4.18.8 EnableKeypadBacklight Syntax: enablekeypadbacklight(enable as boolean)
Parameters: {enable} A boolean value that sets the state of the keypad backlight. A setting of TRUE turns on the backlight, while a setting of FALSE turns it off. Description: The EnableKeypadBacklight function sets the current state of the keypad backlight (if one is available). The setting is temporary and is forgotten when power is removed from the terminal. Permanent changes to the keypad backlight setting
Syntax: gettime(day as reference to integer, -> month as reference to integer, dig2year -> as reference to integer, dotw as reference -> to weekday, hour as reference to integer, -> minute as reference to integer, second as -> reference to integer)
Parameters: {day} An integer to receive the current day of the month. {month} An integer to receive the current month. {dig2year} An integer to receive the last two digits of the current year.
QSI Corporation Fax 801-466-8792 Web www.qsicorp.com Phone 801-466-8770
Page 98
86
QSI Qlarity-based Terminal Programmer’s Reference
{dotw} A variable of type “weekday” (see below) to receive the current day of the week. {hour} An integer to receive the current hour (military time). {minute} An integer to receive the current minute.
{hour} An integer indicating the current hour (military time). {minute} An integer indicating the current minute. {second} An integer indicating the current second. Description:
{second} An integer to receive the current second. Description:
This function sets the current time which is maintained by the real time clock hardware. The variable “{dotw}” is of type “weekday,” which is a defined type with the following (self-explanatory) legal values:
This function returns the current time as maintained by the real time clock hardware.
SUNDAY MONDAY TUESDAY WEDNESDAY THURSDAY FRIDAY SATURDAY
The variable “{dotw}” is of type “weekday,” which is a defined type with the follow (self-explanatory) legal values: SUNDAY MONDAY TUESDAY WEDNESDAY THURSDAY FRIDAY SATURDAY 4.18.11 SetTime Syntax: settime(day as integer, month as integer, -> dig2year as integer, dotw as weekday, hour-> as integer, minute as integer, second as -> integer)
Parameters:
4.18.12 GetTemperature Syntax: gettemperature() returns integer
Description: This function returns the current temperature (degrees Celsius) inside the terminal case. The Qlarity-based hardware includes a temperature sensor that is used to implement temperature compensation of display contrast. The sensor is accurate to approximately ±2° C, and is calibrated by a setting in the Power On Setup utility. 4.18.13 TypeOf
{day} An integer indicating the current day of the month.
Syntax:
{month} An integer indicating the current month.
typeof(unique as reference to integer, -> obj as objref, {name}[] as reference? to -> byte) returns typeval
{dig2year} An integer indicating the last two digits of the current year.
Parameters:
{dotw} A variable of type “weekday” (see below) indicating the current day of the week.
{unique} An integer to receive a type identifier if the property or variable to be typed is user-defined. Built-in types cause 0 to be stored in this parameter.
QSI Corporation Fax 801-466-8792 Web www.qsicorp.com Phone 801-466-8770
Page 99
QSI Qlarity-based Terminal Programmer’s Reference
{objref} Objref of the object (default for global) whose property type will be returned. {name} Name of the property/variable whose type will be returned. Description: This function determines the type of an object property or variable. The returned value is of type “TYPEVAL” with legal values as shown below. Value
87
Description: This function modifies most of the hardware terminal settings for the Qlarity-based terminal. These settings can also be saved in the non-volatile flash memory of the terminal, making the settings effective across power cycles. When writing changes that are to be saved to the flash, settings are first written to a pending save area. The pending changes are only saved to the flash when this function is called with the command SYS_SAVE. The “{action}” argument is of type SYSCMD_ACTION and can take the following values:
Type
INTEGER_TYPE
Integer
FLOAT_TYPE
Floating Point
BOOLEAN_TYPE
Boolean
BYTE_TYPE
Byte
UNIBYTE_TYPE
Unibyte
ARRAY_TYPE
Array
OBJREF_TYPE
Object Reference
If the object property or variable is a user-defined type, a unique, non-zero value corresponding to the type will be stored in “{unique}.” 4.18.14 SetSystemSetting Syntax: setsystemsetting({cmd} as syscmd, -> newvalue as anytype, action as -> syscmd_action)
Parameters: {cmd} A value of type “syscmd” (see below) that determines what terminal control setting will be modified. {newvalue} The new value for the selected terminal control setting. This value expects an integer if not otherwise noted in the description of the “syscmd.” {action} A value of type “syscmd_action” (see below) that determines the time at which the new settings take effect.
SYSACT_DONOW The new setting will take effect immediately but not persist after the terminal power is cycled. A value set using this action will not be saved when this function is called with the SYS_SAVE command. SYSACT_ONBOOT The new setting will not take effect immediately but should take effect after the terminal power is cycled. This value is placed into a list of pending changes that is saved to the non-volatile flash memory when this function is called with the SYS_SAVE command. SYSACT_ALWAYS The new setting will take effect immediately and after the terminal power is cycled. The current setting is changed and this value is also placed into a list of pending changes that is saved to the non-volatile flash memory when this function is called with the SYS_SAVE command. The “{cmd}” argument specifies which setting will be modified. It is of type “syscmd,” which is an enumerated type with the following legal values: SYS_CONTRAST Sets the display contrast using a scale from 0 to 255, with 255 the brightest. The value -1 may also be passed in to cause the current contrast value to be used. Note that incrementing by one in the scale will not necessarily change the contrast value, and values returned by GetSystemSetting() may not match what was passed into SetSystemSetting()! To change the contrast by one contrast increment, use the SetContrast() function and then pass in -1 for the contrast setting in this function to save to the flash.
QSI Corporation Fax 801-466-8792 Web www.qsicorp.com Phone 801-466-8770
Page 100
88
QSI Qlarity-based Terminal Programmer’s Reference
SYS_BACKLIGHT Sets the display backlight using a scale from 0 to 255, with 255 the brightest. The value -1 may also be passed in to cause the current backlight value to be used. Note that incrementing by one in the scale will not necessarily change the backlight value, and values returned by GetSystemSetting() may not match what was passed into SetSystemSetting()! To change the backlight by one backlight increment, use the SetBacklight() function and then pass in -1 for the backlight setting in this function to save to the flash. SYS_VOLUME For units that have an audio decoder, this sets the unit volume using a scale from 0 to 255, with 255 the loudest. The value -1 may also be passed in to cause the current volume to be used. Note that incrementing by one in the scale will not necessarily change the volume, and values returned by GetSystemSetting() may not match what was passed into SetSystemSetting()! To change the volume by one volume increment, use the SetVolume() function and then pass in -1 for the volume setting in this function to save to the flash. SYS_NOTEAMPLITUDE For units that have an audio decoder, this sets the amplitude of the generated note waveforms using a scale from 0 to 255, with 255 the loudest. SYS_MODE Change the current terminal mode (development mode on, development mode off, and default application). In this case, “{newvalue}” is of type “syscmd_mode,” which is an enumerated type with the following legal values: MODE_DEVELOFF MODE_DEVELON MODE_DEFAULTAPP If the terminal does not have a default application, selecting MODE_DEFAULTAPP will be the same as MODE_DEVELOFF. As there is no “current” value for this setting, using SYSACT_ DONOW will not do anything, and using SYSACT_ ALWAYS will only set the pending save setting. SYS_ORIENT Change the display orientation (portrait or landscape). In this case, “{newvalue}” is of type “syscmd_orient,” which is an enumerated type with four legal values:
ORIENT_PORTRAIT ORIENT_LANDSCAPE ORIENT_PORTRAIT2 ORIENT_LANDSCAPE2 SYS_KBDRPTDELAY For systems with a keyboard interface, change the keyboard repeat delay, which is the amount of time after the key is pressed before the first repeat character is generated. In this case, “{newvalue}” is of type “syscmd_kbdrptdelay,” which is an enumerated type with the following legal values: KBDRPTDELAY_250 (Delay = 250 ms) KBDRPTDELAY_500 (Delay = 500 ms) KBDRPTDELAY_750 (Delay = 750 ms) KBDRPTDELAY_1000 (Delay = 1000 ms) SYS_KBDRPTRATE For systems with a keyboard interface, change the keyboard repeat rate, which is the number of characters generated per second after repeat begins. In this case, “{newvalue}” is of type “syscmd_kbdrptrate,” which is an enumerated type with the following legal values: KBDRPTRATE_30_0 KBDRPTRATE_26_7 KBDRPTRATE_24_0 KBDRPTRATE_21_8 KBDRPTRATE_20_0 KBDRPTRATE_18_5 KBDRPTRATE_17_1 KBDRPTRATE_16_0 KBDRPTRATE_15_0 KBDRPTRATE_13_3 KBDRPTRATE_12_0 KBDRPTRATE_10_9 KBDRPTRATE_10_0 KBDRPTRATE_9_2 KBDRPTRATE_8_5 KBDRPTRATE_8_0 KBDRPTRATE_7_5 KBDRPTRATE_6_7 KBDRPTRATE_6_0 KBDRPTRATE_5_5 KBDRPTRATE_5_0 KBDRPTRATE_4_6 KBDRPTRATE_4_3 KBDRPTRATE_4_0 KBDRPTRATE_3_7 KBDRPTRATE_3_3
(30.0 cps) (26.7 cps) (24.0 cps) (21.8 cps) (20.0 cps) (18.5 cps) (17.1 cps) (16.0 cps) (15.0 cps) (13.3 cps) (12.0 cps) (10.9 cps) (10.0 cps) (9.2 cps) (8.5cps) (8.0cps) (7.5cps) (6.7cps) (6.0 cps) (5.5 cps) (5.0 cps) (4.6 cps) (4.3 cps) (4.0 cps) (3.7 cps) (3.3 cps)
QSI Corporation Fax 801-466-8792 Web www.qsicorp.com Phone 801-466-8770