Table of Contents
gc_simple_json
Example Summary
This example demonstrates basic usage of how to send data using JSON formatted strings. In addition, it showcases how to connect target objects with GUI widgets. For details about the architecture of the example or about implementation, please view the User’s Guide.
Example Usage
Please read the Quick Start Guide on how to flash your LaunchPad with the code example, and how to import the provided GUI zip into GUI Composer.
- This example uses the MSP430_SimpleGUI_JSON.zip GUI. This can be found:
- In this package in
<MSP430WARE_INSTALL_DIR>/GUI_Composer/GUI - Online on the TI Gallery
- In this package in
Run the example and the GUI.
The demo should start running with the following functionality:
“Counters” plot shows an 8-bit, 16-bits and 32-bits counters
- The 8-bit counter corresponds to variable u8Counter and it’s bound to JSON token “c1”. It increments by 50 when switch S1 is pressed.
- The 16-bit counter corresponds to variable u16Counter and it’s bound to JSON token “c2”. It increments by 5,000 when switch S2 is pressed.
- The 32-bit counter corresponds to variable u32Counter and it’s bound to JSON token “c3”. It increments by 10,000 periodically on TB0 interrupt
The gauge shows a floating point number, which in this case is sent as fractional (QMath/IQMath)
- The counter corresponds to variable qCounter and it’s bound to JSON token “c4”. It increments by qIncrement on TB0 interrupt and only when bEnableSwitch==true.
The increment for the gauge is set by the horizontal slider
- The increments corresponds to variable qIncrement and it’s bound to JSON token “u16Data”. The value is sent by the GUI to the device when the slider changes.
The “Enable Float” switch enables incrementing the gauge increments
- The switch corresponds to variable bEnableSwitch and it’s bound to JSON token “bEnable”. The switch is sent by the GUI to the device when the value changes.
Notes:
- This example does not implement push-button debounce, so you might see multiple increments when pressing the button.
- The increments (50, 5000, 10000) are only meant to show the difference between variable type sizes.
- The example is sending ALL variables every time it wakes up due to button press or timer interrupt.
- It’s recommended to keep the JSON tokens short, especially when sending them often. Longer tokens will result in longer transmission times.
Additional Information
For more information on modifying the GUI and serial communication, please view the GUI Composer User’s Guide.