TrackFace1ο
Overviewο
The TrackFace1 widget is a custom container component for TouchGFX designed to display fitness tracking data in a watch-face style layout. It presents three key metrics - pace, distance, and elapsed time - in a vertically stacked arrangement with clear labels and separators, optimized for wearable device interfaces.
Purposeο
The primary purpose of the TrackFace1 widget is to provide a comprehensive, at-a-glance view of running or walking activity metrics in embedded fitness applications. It displays pace (time per unit distance), distance traveled, and elapsed time, with support for both metric and imperial units, making it ideal for sports watches, fitness trackers, and activity monitoring screens.
Componentsο
The widget consists of the following visual components arranged in a 240x240 pixel layout:
Pace Section (top):
paceText: Label displaying βPaceβpaceValue: Displays pace in MM:SS format (minutes:seconds per unit)
Distance Section (middle):
distanceText: Label displaying βDistanceβdistanceValue: Numeric distance valuedistanceUnits: Unit indicator (βkmβ or βmi.β)
Timer Section (bottom):
timerText: Label displaying βTimerβtimerValue: Elapsed time in H:MM:SS format
Separators:
line1: Horizontal line above distance sectionline2: Horizontal line above timer section
All text elements use gray color (#C0C0C0) with Poppins fonts in various weights and sizes for optimal readability.
Functionalityο
The widgetβs core functionality centers on data display and unit management:
Pace Display: Accepts pace as seconds per kilometer, automatically converts to MM:SS format (e.g., 387 seconds = β6:27β)
Distance Display: Accepts distance in meters, converts and displays in kilometers or miles with appropriate precision (1-2 decimal places)
Timer Display: Accepts elapsed time in seconds, formats as H:MM:SS (e.g., β0:05:49β)
Unit System Support: Automatic conversion between metric (km) and imperial (mi.) units
GPS Fix Handling: Shows βββ placeholders when GPS signal is unavailable or data is invalid
Automatic Formatting: Intelligent precision adjustment for distance values based on magnitude
The widget automatically invalidates and redraws text areas when data changes, ensuring immediate visual updates.
Usage in TouchGFX Designerο
Import the Custom Container Package:
Open TouchGFX Designer
Go to
Custom ContainersβImportSelect the TrackFace1 package file (manifest.xml)
Add to Screen:
Drag the TrackFace1 custom container from the Custom Containers panel onto your screen
Position as needed (recommended 240x240 size for optimal layout)
Configure Properties:
The widget has no configurable properties in Designer beyond standard container properties
All data and unit settings are controlled programmatically
Usage in C++ Codeο
Include the Header:
#include <gui/containers/TrackFace1.hpp>
Declare in View: In your View class (e.g.,
MainView.hpp):TrackFace1 trackFace;
Initialize in Constructor/Setup:
add(trackFace); trackFace.setPosition(x, y, 240, 240);
Update Data:
// Set pace (seconds per kilometer) trackFace.setPace(387.0f, false, true); // 6:27 min/km, metric, GPS fix OK // Set distance (meters) trackFace.setDistance(5000.0f, false, true); // 5.00 km, metric, GPS fix OK // Set timer (seconds) trackFace.setTimer(349); // 0:05:49
Handle Unit System:
// Imperial units example trackFace.setPace(623.0f, true, true); // 10:23 min/mi (equivalent to 6:27 min/km) trackFace.setDistance(3218.0f, true, true); // 2.00 mi
GPS Fix Handling:
// No GPS fix - shows "---" trackFace.setPace(0.0f, false, false); trackFace.setDistance(0.0f, false, false);
Files Includedο
manifest.xml: Package manifestcontent/CustomContainerExport.touchgfx: Designer export definitioncontent/CustomContainerManifest.xml: Container manifestcontent/texts.xml: Text database with labels and templatesfiles/gui/include/gui/containers/TrackFace1.hpp: Header filefiles/gui/src/containers/TrackFace1.cpp: Implementation filefiles/assets/fonts/: 4 Poppins font variants (Italic, Medium, Regular, SemiBold)
Dependenciesο
TouchGFX Framework (minimum version 4.26.0)
App::Utils utility functions for unit conversions and time formatting
Standard TouchGFX container and text components