Functions and Calculations
The EA uniTFTs-Series can process small mathematical functions internally at runtime. In addition, with logical operators and options, they offer the possibility to make decisions, similar to an if-statement. In order to be able to evaluate user inputs or optimize the screen layout, calculation commands are also available that can work with object properties, such as bar graph value, last touch position or object width and position. Most functions are available as both integer and floating-point calculations. Care must be taken to stay in the respective number range, or to convert with the cast operator (float or int). The module works with little-endian (Intel-format), that means the least significant byte is transferred first. Attention: Calculations need to be run inside brackets (...). See command syntax for further details. |
signed Integer (32 Bit) |
Float IEEE 754 (32-Bit) |
Mathematical functions
Arithmetical functions |
+, -, * , /, () |
● |
● |
Absolute value |x| |
● |
● |
|
Sign of x (-1, 0, 1): x<0, x==0, x>0 |
● |
● |
|
Modulo x%y |
● |
● |
|
Power x^y |
● |
● |
|
Root |
● |
||
n-th root (from V1.1) |
sqrt(var,n) |
● |
|
Truncate decimal points |
● |
||
Round decimal points |
● |
||
Logarithm (base n) (from V1.1) |
log(var,n) |
||
Logarithm (base 10) |
● |
||
Natural logarithm (ln, Basis e) |
● |
||
Exponential function base e |
● |
||
Degrees to rad |
● |
||
Rad to degrees |
● |
||
Sine |
● |
||
Cosine |
● |
||
Tangent |
● |
||
Arcsine |
● |
||
Arc cosine |
● |
||
Arctangent |
● |
||
Arctangent, right quadrant |
atan(y,x) |
● |
|
Minimum |
● |
● |
|
Maximum |
● |
● |
|
Average |
● |
● |
|
Random value sv <= x <= ev (max 65535) |
● |
● |
|
Random value 0 <=x <= ev (max 65535) |
rand(ev) |
● |
● |
Random value 0<= x<=1000 |
rand() |
● |
● |
Register increment / decrement
pre-/post- increment |
++Rx, Rx++ |
● |
● |
pre-/post- decrement |
--Rx, Rx-- |
● |
● |
Cast Integer ↔ Float
Integer calculation, return Float |
● |
||
Float calculation, return Integer |
● |
Bit Operating
Low Byte |
● |
||
High Byte |
● |
||
Low Word |
● |
||
High Word |
● |
||
Low Byte from High Word |
● |
||
High Byte from High Word |
● |
||
AND |
& |
● |
|
OR |
| |
● |
|
NOT |
~ |
● |
|
XOR |
^ |
● |
|
Shift left / right |
<<, >> |
● |
|
Set bit (Bit-Nr. 0..31) |
● |
||
Clear bit(Bit-Nr. 0..31) |
● |
||
Exor bit (Bit-Nr. 0..31) |
● |
||
Test bit (Bit-Nr. 0..31) returns true or false |
● |
Logical Operators
AND |
&& |
● |
● |
OR |
|| |
● |
● |
NOT |
! |
● |
● |
Equal, not equal |
==, != |
● |
● |
Less, less than or equal |
<, <= |
● |
● |
Greater,Greater than or equal |
>, >= |
● |
● |
Decision
If-Then-Else-function |
● |
● |
|
Value between L1 and L2 (including limits) (from V1.1) |
insideE(value,L1,L2) |
● |
● |
Value between L1 and L2 (excluding limits) (from V1.1) |
insideU(value;L1,L2) |
● |
● |
Object commands
Width (without transform) |
● |
● |
|
Height (without transform) |
● |
● |
|
Width of the child (from V1.3) |
objW(id, Child-ID) |
● |
● |
Height of the child (from V1.3) |
objH(id, Child-ID) |
● |
● |
Position X (actual anchor, for groups: relative to parent object) |
● |
● |
|
Position Y (actual anchor, for groups: relative to parent object) |
● |
● |
|
Screen-Position X (given anchor, also for groups: Screen coordinates) |
objX(id, anchor) |
● |
● |
Screen-Position Y (given anchor, also for groups: Screen coordinates) |
objY(id, anchor) |
● |
● |
Screen position X of the child (specified anchor, also for groups: screen coordinates) (from V1.3) |
objX(id, anchor, Child-ID) |
● |
● |
Screen position Y of the child (specified anchor, also for groups: screen coordinates) (from V1.3) |
objY(id, anchor, Child-ID) |
● |
● |
Scaled width |
● |
● |
|
Scaled height |
● |
● |
|
Shear X |
● |
● |
|
Shear Y |
● |
● |
|
Rotation |
● |
● |
|
Opacity |
● |
● |
|
Layer |
● |
● |
|
Get Obj-ID by Group-ID or screenwide (id=0) and layer (from V1.2) |
● |
● |
|
Read actual used style |
● |
● |
|
Read active anchor |
● |
● |
|
Object exists? |
● |
● |
|
Object visible? (from V1.1) |
● |
● |
|
Get Obj-ID from screen-coordinates. |
● |
● |
|
Get Obj-ID from screen-coordinates. If onlyrect is true, then fast calculation is done and only the object's rectangular size is checked (transparencies are ignored) (from V1.4) |
objXY(x,y,onlyrect) |
● |
● |
Object commands Menu
Get last valid menu item |
● |
● |
|
Get active shown menu item (0=closed) |
● |
● |
|
Check state of item (1=checked, 0=unchecked) |
● |
● |
|
Get enable state (1=enabled, 0=disabled) |
● |
● |
Object commands ComboBox
Get last valid item |
● |
● |
|
Get active shown item (0=closed, -1=no item visible) |
● |
● |
|
Get enable state (1=enabled, 0=disabled) |
● |
● |
Object commands SpinBox
Get last valid items |
● |
● |
|
Get last valid item of box no in spinbox group |
objBL(id, boxnr) |
● |
● |
Get active shown items |
● |
● |
|
Get active shown item of box no in spinbox group |
objBV(id, boxnr) |
● |
● |
Get enable state (1=enabled, 0=disabled) |
● |
● |
Get last valid item (from V1.2) |
● |
● |
|
Get active shown item (from V1.2) |
● |
● |
|
Get enable state (1=enabled, 0=disabled) (from V1.2) |
● |
● |
|
Get PictureBox/Animated picture item size (from V1.5) |
objPA(id) |
● |
● |
Object commands StringBox
Visible lines |
● |
● |
|
Number of paragraphs (= number of lines without AutoWrap) |
● |
● |
|
Number of lines (after AutoWrap) |
● |
● |
|
Number of strings (after AutoWrap) |
objTN(id, Absatz nr) |
● |
● |
Visible top line |
● |
● |
|
String line start (after AutoWrap) |
objTL(id, Absatz nr) |
● |
● |
Paragraph from line number |
● |
● |
Object properties
Object properties Bargraph/Instrument
Current value |
● |
● |
|
Value drawn on the screen (not necessarily the same for animations as objIV (id)) |
● |
● |
|
EndValue |
● |
● |
|
StartValue |
● |
● |
Object properties paths
Length |
● |
● |
|
X-Coordinate of a path with distance |
● |
● |
|
Y-Coordinate of a path with distance |
● |
● |
|
Tangent angle of a point on a path |
● |
● |
Touch functions
Touch button/switch state =1 unpressed =2 pressed |
● |
● |
|
Radio-group: Active switch (id) |
● |
● |
|
Last used touch button |
● |
● |
|
Letzter Keyboard code |
● |
● |
|
Last entered keyboard code) |
● |
● |
|
Last touch position X (Down- or Drag-Event) |
● |
● |
|
Last touch position Y (Down- or Drag-Event) |
● |
● |
|
Touch position X of touch point number no (Down- or Drag-Event)) |
touchX(nr) |
● |
● |
Touch position X of touch point number no (Down- or Drag-Event) |
touchY(nr) |
● |
● |
Decomposition of input elements (Menu)
Get root from item |
● |
● |
|
Get menu from item |
● |
● |
|
Get sub-menu from item |
● |
● |
|
Make item from root, menu, sub-menu |
● |
● |
Decomposition of input elements (SpinBox)
Entry box 1 (8 Bit value) |
● |
||
Entry box 2 (8 Bit value) |
● |
||
Entry box 3 (8 Bit value) |
● |
||
Entry box 4 (8 Bit value) |
● |
||
Make item from individual spinbox values ((e4<<24) | (e3<<16) | (e2<<8) | e1) |
● |
||
Item from decimal number (only for spinbox with numeric entries 0-9) (from V1.3) |
spinD(Number, Decimal places) |
● |
Diagram (from V1.1)
Chart window changed since last touch event 0=no change 1=shift in x-direction 2=shift in y-direction 3=Zoom in x direction 4=Zoom in y direction |
diaWC(id) |
● |
● |
Automatic scrolling (0=off, 1=on) |
diaWS(id) |
● |
● |
x-offset of the diagram (active area) |
diaWX(id) |
● |
● |
y-offset of the diagram (active area) |
diaWY(id) |
● |
● |
Total width (active area) |
diaWW(id) |
● |
● |
Total height (active area) |
diaWH(id) |
● |
● |
Segment length x-direction |
diaPX(id) |
● |
● |
Segment length y-direction |
diaPY(id) |
● |
● |
Shift in x-direction |
diaMX(id) |
● |
● |
Shift in y-direction |
diaMY(id) |
● |
● |
Zoom in x-direction |
diaZX(id) |
● |
● |
Zoom in y-direction |
diaZY(id) |
● |
● |
Start value of the axis |
diaAS(id,axis-No.) |
● |
● |
Current start value of the axis |
diaAA(id,Achsen-No.) |
● |
● |
Current value of the axis from coordinates |
diaAV(id, axis-No.,x,y) |
● |
● |
Current axis interval |
diaAP(id,axis-No.) |
● |
● |
1/100 Time value of coordinate (only time format of x-axis) |
diaAT(id,axis-No.,x) |
● |
● |
Nearest line number |
diaLN(id,x,y) |
● |
● |
Nearest line number (limited to a maximum distance) |
diaLN(id,x,y,max. distance) |
● |
● |
Nearest Array Index |
diaLI(id,line-Nr.,x,y) |
● |
● |
Nearest Array Index (limited to a maximum distance) |
diaLI(id,line-Nr.,x,y,max. distance) |
● |
● |
First visible array index of the x-axis |
diaLF(id,line-No.) |
● |
● |
Last visible array index of the x-axis |
diaLL(id,line-No.) |
● |
● |
x-coordinate of line index (relative to active area) |
diaIX(id,line-No.,index) |
● |
● |
y-coordinate of line index (relative to active area) |
diaIY(id,line-No,index) |
● |
● |
x-coordinate of line index (absolute) |
diaSX(id,line-No.,index) |
● |
● |
y-coordinate of line index (absolute) |
diaSY(id,line-No.,index |
● |
● |
x-value of line index |
diaVX(id,line-No.,index) |
● |
● |
y-value of line index |
diaVY(id,line-No.,index) |
● |
● |
1/100s Time Value of line index (only time format of x-axis) |
diaVT(id,line-No.,index) |
● |
● |
I/O Ports
Analogue input
RS232 Master interface
I²C Master Interface
Timer
Time functions/ RTC
Time and date are calculated by the module internally in seconds with epoch = 1.1.2000 at 00:00:00 o'clock with SINT32 (= datetime-value). Thus, the maximum period used by the module is from 1932 - 2067. The base date can be changed with the #WDY command. To calculate time periods, it's always necessary to convert the time/date to seconds first, then carry out the calculation. The result can then be converted back again to minutes, hours, day, month and year. |
Convert current date into datetime-value |
● |
||
Convert number of days into seconds |
date(D) |
● |
|
Convert day + month + year (1932 - 2067) into datetime-value |
date(D,M,Y) |
● |
|
Convert actual time into seconds (starting with 0:00:00) |
● |
||
Convert number of hours into seconds (? h·3600) |
time(h) |
● |
|
Convert hours and minutes into seconds (? h·3600 + m·60) |
time(h, m) |
● |
|
Hour, minutes and seconds into seconds (? h·3600 + m·60 + s)+ s) |
time(h, m, s) |
● |
|
Convert current date and time into datetime-value |
● |
||
Hour+min+sec+day+month+year into datetime-value |
datetime(h,m,s,D,M,Y) |
● |
|
Actual year |
● |
||
Calculate year from datetime-value |
year(a) |
● |
|
Actual month |
● |
||
Calculate month from datetime-value |
month(a) |
● |
|
Actual day |
● |
||
Calculate day from datetime-value |
day(a) |
● |
|
Actual week day (0-6=Sunday..Saturday) |
● |
||
Calculate week day from datetime-value |
weekday(a) |
● |
|
Actual hour |
● |
||
Calculate hour from datetime-value |
hour(a) |
● |
|
Actual minute |
● |
||
Calculate minute from datetime-value |
minute(a) |
● |
|
Actual second |
● |
||
Calculate seconds from datetime-value |
second(a) |
● |
String register functions
Length of string (Register no) |
● |
||
ASCII-Code from string position |
● |
||
Unicode-Code from string position |
● |
||
Convert numerical string to SINT32 or float. |
● |
● |
|
Comparison of two string registers =0 both strings are the same >0 first unequal character in n1 is greater then the one in n2 <0 first unequal character in n1 is smaller then the one in n2 |
● |
||
Compare the first len characters of two strings |
strC(n1, n2, len) |
● |
|
Compare len characters of two strings, starting with offset (from V1.1) |
strC(n1, n2, len, offset) |
● |
|
Compare len characters of two strings, starting on different offsets (from V1.1) |
strC(n1, n2, len, offset1, offset2) |
● |
|
Search for code in string from left =-1 not found >=0 Offset of the first code found |
● |
||
Search for code in string from left starting with offset (from V1.1) |
strFL(nr, code, offset) |
● |
|
Search for code in string from right |
● |
||
Search for code in string from right starting with offset (from V1.1) |
strFR(nr, code, offset) |
● |
|
Search for string from another register (n2) in string (n1) |
● |
||
Search for string from another register (n2) in string (n1) from offset. (from V1.1) |
strFS(n1, n2, offset) |
● |
|
Check if code is a character |
● |
||
Check if code is digit or character ist |
● |
||
Check if code is a small letter |
● |
||
Check if code is a big letter |
● |
||
Check if code is whitespace |
● |
||
Check if code is a digit |
● |
||
Check if code is a hexadecimal number |
● |
||
Check if code is a binary number |
● |
Regular expressions (from V1.2)
For all commands concerning the RegEx the result is also saved in ten special RegExp-Registers with direct access, through X? (all X0,container X1..X9, see command syntax).
Find RegEx in StringRegister; return first index found in string(-1 not found) |
● |
||
Find RegEx in StringRegister begin search from offset |
strXF(RegExp, String, offset) |
● |
|
RegEx search from StringRegister n1 to n2; return String-ID first match (-1 not found) |
● |
||
RegEx search from StringRegister n1 to n2 begin search from offset |
strXS(RegExp, String-ID n1, String-ID n2, offset) |
● |
|
RegEx in StringArray[index]; return first index found in specified string (-1 not found) |
● |
||
RegEx in StringArray[index] begin search from offset |
strXI(RegExp, Array-ID, index, offset) |
● |
|
RegEx search in StringArray from start-index (si) to end of array; return array index (-1 not found) |
● |
||
RegEx search in StringArray from start-index (si) to end-index (ei) |
strXA(RegExp, Array-ID, si, ei) |
● |
|
RegEx search in StringArray from start-index (si) to end-index (ei), begin search from offset |
strXA(RegExp, Array-ID, si, ei, offset) |
● |
|
Get last RegEx search container string length (0=complete, container 1..9) |
● |
||
Get last RegEx Search container start offset |
● |
Observed Register functions (from V1.5)
Register change flag: true if observed Register nr has changed |
cfoR(nr) |
● |
|
StringRegister change flag: true if observed StringRegister nr has changed |
cfoS(nr) |
● |
|
Array change flag: true if observed Array nr has changed |
cfoA(nr) |
● |
|
Next changed Register Id: returns Id of next changed Register (-1 if no changed) |
cfoRN() |
● |
|
Next changed StringRegister Id: returns Id of next changed StringRegister (-1 if no changed) |
cfoSN() |
● |
|
Next changed Array Id: returns Id of next changed Array (-1 if no changed) |
cfoAN() |
● |
|
Next changed Register Id: returns Id of next changed Register starting at Id startnr |
cfoRN(startnr) |
● |
|
Next changed StringRegister Id: returns Id of next changed StringRegister starting at Id startnr |
cfoSN(startnr) |
● |
|
Next changed Array Id: returns Id of next changed Array starting at Id startnr |
cfoAN(startnr) |
● |
Array functions
Get max. elements for a new array (from V1.4) |
● |
● |
|
Get max. elements for a new string array with stringlength strlen (from V1.6) |
arE(-1, strlen) |
● |
● |
Get array element count (0 = not exist) (from V1.4) |
arE(id) |
● |
● |
Get array value (from V1.4) |
● |
● |
|
Get unicode value from string array from offset (from V1.6) |
arV(id, index, offset) |
● |
● |
Get next array value from read index and increment read index (from V1.4) |
arV(id) |
● |
● |
Get array read index (from V1.4) |
● |
● |
|
Get array write index (from V1.4) |
● |
● |
|
Highest used write pointer index (from V1.5) |
arW(id,1) |
● |
● |
First Array Index (for Autowrap, otherwise 0) (from V1.5) |
arF(id) |
● |
● |
Last array index (for autowrap, otherwise arW(id,1)) (from V1.5) |
arL(id) |
● |
● |
Number of used array entries (from V1.5) |
arU(id) |
● |
● |
Minimum of all array elements (from V1.5) |
arMIN(id) |
● |
● |
Maximum of all array elements (from V1.5) |
arMAX(id) |
● |
● |
Sum of all array elements (from V1.5) |
arSUM(id) |
● |
● |
Average value of all array elements (from V1.5) |
arAVG(id) |
● |
● |
Minimum of all array elements from range (from V1.5) |
arMIN(id,Start,Ende) |
● |
● |
Maximum aller Array Elemente aus Bereich (ab V1.5) |
arMAX(id,Start,Ende) |
● |
● |
Sum of all array elements from range (from V1.5) |
arSUM(id,Start,Ende) |
● |
● |
Average value from range (from V1.5) |
arAVG(id,Start,Ende) |
● |
● |
Color commands
Get red channel from a 24 bit RGB value |
● |
||
Get green channel from a 24 bit RGB value |
● |
||
Get blue channel from a 24 bit RGB value |
● |
||
Combine 3 single color channels to one 24 bit RGB value |
● |
||
Read 24 bit RGB value from a color ramp |
● |
||
Read opacity value from a color ramp |
● |
||
Read 24 bit RGB value from a display-pixel (from V1.4) |
● |
||
Read 16 bit RGB (RGB565) value from a display-pixel (from V1.5) |
tftRGB(x,y,1) |
● |
SD-Card (File and directory commands)
File exists? (<Path/filename> in string register no) |
● |
||
File size? (<Path/filename> in string register no)) |
● |
||
File attribute? (<Path/filename> in string register no) |
● |
||
Get fat-time of file (<Path/filename> in string register no)) |
● |
||
Get fat-date of file (<Path/filename> in string register no) |
● |
||
Convert datetime-value to fat-time |
● |
||
Convert datetime-value to fat-date |
● |
||
Convert fat-time and date to datetime-value |
● |
||
Calculate file crc, compare with FAT crc (from file in string register no), return true or false (#FFS) |
● |
||
Get stored file crc (from file in string register no), return CRC16. (#FFS) |
fileC(no,1) |
● |
|
Calculate file crc (from file in string register no), return CRC16 (#FFS) |
fileC(no,2) |
● |
|
Get actual read-pointer position (#FRO) (from V1.1) |
● |
||
Get actual read-pointer position calculated from file end (=negativ) (from V1.1) |
fposR(-1) |
● |
|
Get actual file size of opened read file (from V1.4) |
fposR(1) |
● |
|
Get actual write-pointer position (#FWO) (from V1.1) |
● |
||
Get actual write-pointer position calculated from file end (=negativ) (from V1.1) |
fposW(-1) |
● |
|
Get actual file size of opened write file (from V1.4) |
fposW(1) |
● |
|
Get actual maximum file size (from V1.4) |
fposW(2) |
● |
|
Get maximum file size of file from string register no (from V1.4) |
● |
||
Get storage total size (from V1.4) |
● |
||
Get storage free size (from V1.4) |
● |
||
Get object RAM total size (from V1.4) |
● |
||
Get object RAM free size (from V1.4) |
● |
||
Get object RaM max block size(from V1.4) |
● |
Module commands
Firmware version (from V1.1) |
● |
||
Last frame rate (fps) |
● |
● |
|
Get touch type (=0 no, =1 resistive, =2 PCAP)) |
● |
● |
|
Screen width (#XCV) |
● |
● |
|
Screen Height (#XCV) |
● |
● |
|
Screen width of hardware, not depending on (#XCV) |
scrW(1) |
● |
● |
Screen height of hardware, not depending on (#XCV) |
scrH(1) |
● |
● |
Video Width |
● |
● |
|
Video Height |
● |
● |
|
Number of video objects |
● |
● |
|
Get actual backlight brightness |
● |
● |
|
Get backlight autostate brightness (state=0..2 )) |
ledB(status) |
● |
● |
Get backlight autostate status |
● |
● |
|
Errorstring available? |
● |
● |
|
Errorstring available? copy Errorstring to Stringregister nr (#VSL) |
error(nr) |
● |
● |
Errorstring available? copy Errorstring to Stringreg nr and clear Errorstring |
error(nr,1) |
● |
● |
Priority list of all operators
12 |
() |
Parentheses / function call (highest priority)) |
11 |
++ |
Register increment |
- - |
Register decrement |
|
+ |
Sign |
|
- |
Sign |
|
! |
Logical NOT |
|
~ |
Bitwise NOT |
|
10 |
* |
Multiplication |
/ |
Division |
|
9 |
+ |
Addition |
- |
Subtraction |
|
8 |
<< |
Shift left |
>> |
Shift right |
|
7 |
< |
Less than |
<= |
Less than or equal |
|
> |
Greater than |
|
>= |
Greater than or equal |
|
6 |
== |
Equal |
!= |
Unequal |
|
5 |
& |
Bitwise AND |
4 |
^ |
Bitwise XOR |
3 |
| |
Bitwise OR |
2 |
&& |
Logical AND |
1 |
|| |
Logical OR (lowest priority)) |