NOTICE: The Processors Wiki will End-of-Life in December of 2020. It is recommended to download any files or other content you may need that are hosted on The site is now set to read only.

Data Formatting and Transformation

From Texas Instruments Wiki
Jump to: navigation, search

Processing Data going to widget (incoming) and leaving the widget (outgoing)

Pre processing functions may be used to transform data that is going to be displayed in the widget or leaving the widget before it is sent to the target. The most common use of pre processing functions is to control the format of displayed data. These functions need to be created in JavaScript and can be added to app.js file as it is automatically loaded by GUI Composer application. A good resource for syntax and available functions in javascript is at


1. Create an application, add a widget and specify a variable in its value binding. Then click on "..." button beside a binding that you specified. This opens a new dialog allowing you to format the value of a variable before it is displayed in the widget. It also contains edit boxes to specify javascript functions that will be called. PreProcessingFunction will be called when data is sent from the target to the widget allowing you to control how data is displayed. PostProcessing function will be called in reverse direction, when a user modifies widgets value and it is being sent to the target. 

2. The easiest way to enter the logic of pre/post processing functions is to click on Edit button in the dialog where pre/post processing function name is specified. GUI Composer designer will then open app.js file and create a prototype function where you need to fill in the processing logic. 

E.g. data formatting
function ToQ24_RoundTo2Decimals(oldValue) {
   var toQ24 = oldValue/(Math.pow(2,24));
   var result = new Number(Math.round(toQ24 * 100)/100);
   var s = result.toString();
   return (s)

function FromQ24(oldValue) {
   var result = Math.round(oldValue*(Math.pow(2,24)));
   return ( result )

This contains a sample application that is based on example that is part of GUI Composer Runtime which includes an example of preprocessing functions.