SETUP(System)
Description
Set up the system. These parameters can be set at initialisation or at any time during operation by specifying the parameter to be changed. Example: SETUP( SYSTEM ){ bled=50; }. To change a setting use a dot operator as follows: LOAD( SYSTEM.bled, 50 );
Syntax/Parameters
Setup(System)
{
...
}
Options
startup = all;    display messages and progress bar at start up using startup=all or none or bar.
bled = 100;       set backlight to OFF=0 or ON=100 (1-99 brightness levels available v4 PCB, v32 firmware)
wdog = 1000;    set the watchdog time out period in milliseconds.
rotate = 0;        set the rotation of the screen with respect to PCB. This is stored in EEPROM for use with boot messages.(0, 90, 180 or 270)
test = hide/showTouchAreas;    hide or show touch areas during product development
angles = degrees;    select degrees or radians for calc functions
encode = s, w, m;    menu text strings can contain single byte ASCII (s), 2 bytes for UNIcode (w) or multibyte for UTF8 (m)
calibrate = y;    initialise the internal touch screen calibration screen. This automatically returns to the previous page on completion. If it is necessary to abort then send SETUP( SYSTEM ) {calibrate=n;}
clkfreq = 92000000;    Main external bus clock is changeable in 2MHz steps from 80MHz to 92MHz (default).
ignore = allErrors;    Ignores all errors and continues execution (only recommended in test as can cause undesired results - error messages are still sent from a serial port set to debug, ie rxi=d;).
= invalidJpg; Ignores errors for unsupported JPG formats (eg progressive) and the image is skipped
= imageTooBig; Ignores errors when there's not enough memory to load image and the image is skipped

System Version
The software and hardware versions can be read to a serial port or text variable.
   LOAD( RS2, VERS_IBOOT ); returns NAND bootloader version
   LOAD( RS2, VERS_ILOADER ); returns main loader version
   LOAD( RS2, VERS_IAPP ); returns main application version
   LOAD( RS2, VERS_IMODULE ); returns module name and version

Startup Information - v42.00
Displaying of messages and progress at start up now configurable using SETUP(SYSTEM){startup=all|none|bar;}
Word 'DEMO' changed to 'PROTO' in version message as this software is still not formally released.

Touch Calibration - v47.24
Create your own calibration screen and store parameters in host.

Touch Calibration points can now be set in system setup with user parameters.
> To use:
   SETUP(system)
   {
   tch_loc_tlx = num; // Top Left Touch Point Location X
   tch_loc_tly = num; // Top Left Touch Point Location Y
   tch_val_tlx = num; // Top Left Touch Value X
   tch_val_tly = num; // Top Left Touch Value Y
   tch_loc_trx = num; // Top Right Touch Point Location X
   tch_loc_try = num; // Top Right Touch Point Location Y
   tch_val_trx = num; // Top Right Touch Value X
   tch_val_try = num; // Top Right Touch Value Y
   tch_loc_brx = num; // Bot Right Touch Point Location X
   tch_loc_bry = num; // Bot Right Touch Point Location Y
   tch_val_brx = num; // Bot Right Touch Value X
   tch_val_bry = num; // Bot Right Touch Value Y
   tch_loc_blx = num; // Bot Left Touch Point Location X
   tch_loc_bly = num; // Bot Left Touch Point Location Y
   tch_val_blx = num; // Bot Left Touch Value X
   tch_val_bly = num; // Bot Left Touch Value Y
   }
> also supports load(system.tch_loc_tlx,num); etc..

Touch Calibration points can also be read
> load(num,tch_loc_tlx); etc.. <- note "system." not used here

The actual touch values are obtained by using TOUCHX and TOUCHY built in variables.

Error Message Suppression - v49.00
Error messages can be ignored/suppressed for certain situations.
    SETUP( system )
   {
   ignore=imageTooBig; // Ignores errors when there's not enough memory to load image and the image is skipped
   ignore=invalidJpg; // Ignores errors for unsupported JPG formats (eg progressive) and the image is skipped
   ignore=allErrors; // Ignores all errors and continues execution (only recommended in test as can cause undesired results).
   //No messages are displayed on the screen, though they are transmitted on a serial port set to debug.
   }

Memory Usage Output - v49.00
A run-time memory allocation can be output of the diagnostic serial port by setting SETUP(system){test=showMemoryUse;}.

Note, that the transmit buffer should be at least 32KB otherwise transmit data may be lost.
The top location of RAM is 0x23FFFFFF.

Test Flags - v49.04
SETUP(SYSTEM){test=showLoadInfo;} displays loading file / line information on start screen

System Errors - v49.19
All system errors now allocated a fixed error number, which is displayed on the System Error Screen.
Details of the last error can be found from the built-in entities:
   SYSERRNUM (S32) Error number
   SYSERRSRC (TXT64) Source of error (menu file name or port name)
   SYSERRPOS (S32) Error line number in source file (if applicable)
   SYSERRMSG (TXT128) Error message for given error number
The variables maintain the last error information.

An error function can be specified which is called when a system error occurs:
   SETUP(SYSTEM) { errFunc=funcName; }

The system error will appear on the screen then the function will be called. The error screen is then cleared by tapping the touch screen. The error function should be kept simple, as functionality is restricted, such as enabling USB port to allow updates.

If SETUP(SYSTEM) { ignore=allErrors; } is set then just the error function is called, no error screen is displayed and no touch is required.
All errors are always sent to a port set to debug (rxi=d;) independent of the ignore or errFunc settings.

Error information can be found on the website click here

Screen Rotation - v49.25
Screen rotations of 0, 90, 180 and 270 degrees fully supported.

Use, for example, SETUP(SYSTEM){rotate=90;} at start of tuXXXa.mnu file. The value is stored in EEPROM and used to orientate boot messages etc on next boot.
Also boot startup messages centralised and rotated.
nandboot.bin V00.27
iuloader.bin V00.38

Touch Screen Calibration - Manual Save & Status - v49.37
* Added option to save manual touch calibration figures to EEPROM, either
SETUP(SYSTEM)
{
tch_val_tlx = 123;
...
tch_val_bly = 345;
touchSave = eeprom; // or "none" for no storage
}
or,
LOAD(SYSTEM.touchSave,eeprom);
* Added system parameter calFunc which is called when calibration is started and finished. Reading TCH_CAL value will indicate what stage the calibration is at.
SETUP(SYSTEM){calFunc=myFunc;}
FUNC(myFunc){LOAD(RS2,TCH_CAL);}
LOAD(SYSTEM.calibrate,y);
> myFunc will run when calibration page is shown - TCH_CAL value = 255 (calibrating)
> myFunc will run when calibration finished and previous page shown - TCH_CAL value = 1 (done)
> TCH_CAL value = 0 when touch is not calibrated.
* Added additional retry mechanisms for saving/retrieving values from EEPROM.


Storage of cal figures, screen rotate, and start up text in file: tu480a.cfg - v49.47
* To use the NAND config file for settings, add useCfg=y; to system setup,

SETUP(SYSTEM)
{
useCfg=y;
}

* File is named tuXXXa.cfg, where XXX is module size 320, 480, 640, 800. The file is stored in NAND in the "LIB" area.
* Typical Config File contents (note parameter values are all numeric within the file):

usecfg=1; // Use config file: 0=no, 1=yes
sbled=100; // Start-up back light level: 0 to 100
wdog=-1; // Watchdog: -1 unset, 0 off, 1-16000 time ms
rotate=0; // Screen rotate: 0, 90, 180, 270
startup=3; // Start-up: 0=none, 1=text, 2=bar, 3=text+bar
tch_loc_tlx=19; // Touch - TL x location
tch_loc_tly=19; // Touch - TL y location
tch_loc_trx=459; // Touch - TR x location
tch_loc_try=19; // Touch - TR y location
tch_loc_brx=459; // Touch - BR x location
tch_loc_bry=251; // Touch - BR y location
tch_loc_blx=19; // Touch - BL x location
tch_loc_bly=251; // Touch - BL y location
tch_val_tlx=87; // Touch - TL x value
tch_val_tly=912; // Touch - TL y value
tch_val_trx=928; // Touch - TR x value
tch_val_try=905; // Touch - TR y value
tch_val_brx=912; // Touch - BR x value
tch_val_bry=131; // Touch - BR y value
tch_val_blx=84; // Touch - BL x value
tch_val_bly=132; // Touch - BL y value

* Changes made by SETUP(SYSTEM){} and LOAD(SYSTEM.param,val); will modify the file.
* Following touch screen calibration, the calibration parameters will be stored to the config file.
* The new file is compared with the file stored in NAND and only overwritten if different to save NAND write cycles.
* When a RESET(NAND); or RESET(NANDLIB); is issued, the config file is preserved by reading file into memory, erasing NAND,
writing the config file back to NAND.
* A RESET(FACTORY); will erase the config file.
* Parameters are read from EEPROM initially and then overwritten by parameters from the config file.
* If an EEPROM is not fitted, then useCfg will default to y.

Start-up backlight level ''sbled'' - v49.47
* A start-up backlight can be specified.

SETUP(SYSTEM)
{
sbled = 100; // Values 0 to 100
}

* This value is used as the default level rather than the current 100% value.
* Value is also stored in EEPROM and used for boot-up screens.

New boot code created:
nandboot.bin V00.31
iuloader.bin V00.43
 
Example
 SETUP( SYSTEM )
 {
   bled=100;
   wdog=100;
   rotate=0;
   calibrate=n;
   test=showTouchAreas;
   angles=degrees;
   startup=all;
   encode=s;
   clkfreq=92000000;
 }