HelloWorld - Introduction to UNA App Architecture๏
Welcome to the UNA SDK tutorial series! HelloWorld is your first step in learning to build applications for the UNA Watch platform. This tutorial focuses on the fundamental app architecture - how service and GUI components communicate - without the complexity of sensors or data logging.
What Youโll Learn๏
How to set up your development environment for UNA apps
The basic structure of a UNA Watch application
How service and GUI layers communicate
How to build and run apps on simulator and hardware
Understanding the UNA app framework fundamentals
Getting Started๏
Prerequisites๏
Before building HelloWorld, you need to set up the UNA SDK environment. Follow the toolchain setup for complete installation instructions, including:
UNA SDK cloned with submodules (
git clone --recursive)ST ARM GCC Toolchain (from STM32CubeIDE/CubeCLT, not system GCC)
CMake 3.21+ and make
Python 3 with pip packages installed
Minimum requirements for HelloWorld:
UNA_SDKenvironment variable pointing to SDK rootARM GCC toolchain in PATH
CMake and build tools
For GUI development/modification:
TouchGFX Designer installed (see toolchain setup)
Building and Running HelloWorld๏
Verify your environment setup (see toolchain setup for details):
echo $UNA_SDK # Should point to SDK root. # Note for backward compatibility with linux path notation it uses '/' which arm-none-eabi-gcc # Should find ST toolchain which cmake # Should find CMake
Navigate to the HelloWorld directory:
cd $UNA_SDK/Docs/Tutorials/HelloWorld
Build the application:
mkdir build && cd build cmake -G "Unix Makefiles" ../Software/Apps/HelloWorld-CMake make
The app will start and show a basic GUI demonstrating the UNA app framework. This HelloWorld focuses on the core architecture - the service-GUI communication pattern that all UNA apps use.
Running on Simulator๏
To test the app on the simulator (Windows only):
Open
HelloWorld.touchgfxin TouchGFX Designer and click Generate Code (F4) (do this once).Navigate to
HelloWorld\Software\Apps\TouchGFX-GUI\simulator\msvsOpen
Application.vcxprojin Visual StudioPress F5 to start debugging and run the simulator
The simulator will display the HelloWorld GUI. Since HelloWorld has minimal interactive elements, it primarily demonstrates the app startup and basic framework.
For detailed simulator setup and features, see Simulator.
Working with TouchGFX GUI (Optional)๏
If you want to explore or modify the GUI design:
Install TouchGFX Designer (see toolchain setup for installation)
Open the TouchGFX project:
HelloWorld.touchgfx
Make design changes in TouchGFX Designer (add/modify screens, widgets, interactions)
Generate code after making changes:
Click โGenerate Codeโ button in TouchGFX Designer, OR
Rebuild the app to include your GUI changes:
cmake -G "Unix Makefiles" /path/to/HelloWorld-CMake # If artifacts has been changed make
Note: HelloWorld has a minimal GUI. For learning GUI development, study the more complex examples like Cycling or HRMonitor apps, or see the toolchain setup.
HelloWorld App Overview๏
HelloWorld demonstrates the essential UNA app architecture:
The Service Layer (Backend)๏
Runs as the main application thread
Handles sensor connections and data processing
Manages app lifecycle (start/stop)
Communicates with the GUI through messages
The GUI Layer (Frontend)๏
Built with TouchGFX framework. For detailed information about the TouchGFX port implementation, see TouchGFX Port Architecture
Displays information to the user
Receives updates from the service
Handles user interactions
Communication Between Layers๏
Uses the UNA kernel messaging system
Service sends data to GUI via custom messages
GUI can send commands back to service
Understanding the Commented Code๏
HelloWorld includes commented-out implementations of common UNA app features. These serve as reference examples for future tutorials:
Heart Rate Sensor Integration: Complete sensor connection, data parsing, and real-time GUI updates
FIT File Logging: Activity data recording with session summaries
Custom Messaging: Service-to-GUI communication patterns
Note: The next tutorial will walk through enabling heart rate monitoring step-by-step. For now, focus on understanding the basic app structure and messaging framework.
Understanding UNA App Communication๏
HelloWorld demonstrates the two main ways UNA apps communicate between service and GUI:
SDK Custom Messages (Service โ GUI)๏
Used for real-time data updates. The service creates messages using SDK::make_msg<>() and sends them via the kernel. The GUI receives them in Model::customMessageHandler().
AppTypes Events (GUI โ Service)๏
Used for commands and configuration. The GUI sends events through the IGuiBackend interface, which the service implements to receive commands.
These patterns form the foundation of all UNA app communication. Future tutorials will show how to implement specific features using these systems.
Common Patterns and Best Practices๏
Sensor Integration๏
Always check
matchesDriver(handle)before processing sensor dataValidate data with
isDataValid()before usingHandle sensor timeouts and disconnections gracefully
Message Design๏
Use unique message type IDs (increment from 0x00000001)
Keep messages small and focused on single purposes
Use descriptive names for message types and fields
GUI Updates๏
Only update GUI when necessary to avoid performance issues
Use appropriate data types (float for measurements, int for counts)
Handle invalid/missing data gracefully
File Operations๏
Use the kernelโs filesystem interface (
mKernel.fs)Handle file I/O errors appropriately
FIT files are Garminโs standard format for activity data
Next Steps๏
Get HelloWorld running - Follow the build steps above and confirm the app launches
Explore the code structure - Look at Service.cpp and Model.cpp to understand the messaging flow
Check the commented examples - Review the commented HR and FIT code to see whatโs available
Continue to the next tutorial - Learn how to enable heart rate monitoring and data logging
Study other example apps - Look at Alarm or Cycling apps for different patterns
Troubleshooting๏
Build Issues๏
Ensure all SDK paths are correctly configured
Check that TouchGFX is properly installed
Verify CMake finds all required dependencies
Runtime Issues๏
Check log output for error messages
Verify sensor connections on real hardware
Use the simulator for initial testing
Common Mistakes๏
Forgetting to uncomment all related code sections
Using duplicate message type IDs
Not handling message memory management properly
Remember: Every complex app started as a simple HelloWorld. Take it step by step, and youโll be building amazing UNA Watch applications in no time!