To connect a Garmin watch with LED lights on a running shirt, we’ll need to use Garmin’s Connect IQ SDK for the watch side and a microcontroller with Bluetooth Low Energy (BLE) capability for the shirt side. Here’s a high-level overview of how we can achieve this:
1. Garmin Watch App: We’ll create a Connect IQ app that reads pace data and transmits it via BLE.
2. Microcontroller: We’ll use an Arduino or similar microcontroller with BLE capability to receive data from the watch and control the LED lights.
3. LED Display: We’ll use addressable LED strips to display the pace.
Let’s break this down into steps:
1. Garmin Watch App (Connect IQ):
using Toybox.Application;
using Toybox.WatchUi;
using Toybox.System;
using Toybox.ActivityMonitor;
using Toybox.BluetoothLowEnergy as Ble;
class PaceTransmitterApp extends Application.AppBase {
private var bleChannel;
function initialize() {
AppBase.initialize();
}
function onStart(state) {
// Initialize BLE
bleChannel = new Ble.GenericChannel(
“7E98”, // Custom service UUID
“7E99” // Custom characteristic UUID
);
Ble.registerProfile(bleChannel);
}
function onStop(state) {
Ble.unregisterProfile(bleChannel);
}
function getInitialView() {
return [new PaceView()];
}
function transmitPace() {
var info = ActivityMonitor.getInfo();
var pace = info.currentPace;
if (pace != null) {
var paceBytes = pace.format(“%d”);
bleChannel.transmit(paceBytes);
}
}
}
class PaceView extends WatchUi.View {
function initialize() {
View.initialize();
}
function onUpdate(dc) {
// Update view and transmit pace every second
(new PaceTransmitterApp()).transmitPace();
}
}
2. Microcontroller (Arduino) Code:
“`cpp
#include <ArduinoBLE.h>
#include <Adafruit_NeoPixel.h>
#define LED_PIN 6
#define LED_COUNT 60
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
BLEService paceService(“7E98”);
BLEIntCharacteristic paceCharacteristic(“7E99”, BLERead | BLENotify);
int currentPace = 0;
void setup() {
Serial.begin(9600);
while (!Serial);
if (!BLE.begin()) {
Serial.println(“BLE failed to start!”);
while (1);
}
BLE.setLocalName(“LED Running Shirt”);
BLE.setAdvertisedService(paceService);
paceService.addCharacteristic(paceCharacteristic);
BLE.addService(paceService);
BLE.advertise();
Serial.println(“Bluetooth device active, waiting for connections…”);
strip.begin();
strip.show(); // Initialize all pixels to ‘off’
}
void loop() {
BLEDevice central = BLE.central();
if (central) {
Serial.print(“Connected to central: “);
Serial.println(central.address());
while (central.connected()) {
if (paceCharacteristic.written()) {
currentPace = paceCharacteristic.value();
updateLEDs(currentPace);
}
}
Serial.print(“Disconnected from central: “);
Serial.println(central.address());
}
}
void updateLEDs(int pace) {
// Convert pace (seconds per km) to minutes:seconds format
int minutes = pace / 60;
int seconds = pace % 60;
// Clear previous display
strip.clear();
// Display minutes (red)
displayNumber(0, minutes, strip.Color(255, 0, 0));
// Display colon (white)
strip.setPixelColor(20, strip.Color(255, 255, 255));
strip.setPixelColor(21, strip.Color(255, 255, 255));
// Display seconds (green)
displayNumber(25, seconds, strip.Color(0, 255, 0));
strip.show();
}
void displayNumber(int startPixel, int number, uint32_t color) {
// Implement logic to display numbers using LED segments
// This is a simplified version and would need to be expanded for a full implementation
for (int i = 0; i < 20; i++) {
strip.setPixelColor(startPixel + i, color);
}
}
“`
Now, let’s update our React component to simulate this setup:
“`typescriptreact project=”LED Running Shirt” file=”led-running-shirt.tsx”
…
“`
This updated component simulates the connection between a Garmin watch and the LED running shirt:
1. We’ve added a “Connect Watch” button to simulate the Bluetooth connection process.
2. The pace is only updated when both the watch is connected and the run has started.
3. The pace is displayed in minutes:seconds format, simulating how it would appear on the LED display.
4. We’ve removed the distance/pace toggle to focus on the pace display, as per the original Garmin watch integration request.
In a real-world implementation:
1. The Garmin watch would run the Connect IQ app we outlined earlier, continuously broadcasting the current pace via BLE.
2. The Arduino (or similar microcontroller) in the shirt would receive this data and update the LED display accordingly.
3. You’d need to design a flexible, washable PCB to integrate the microcontroller and LEDs into the shirt fabric.
4. Power management would be crucial – you might use a small, rechargeable LiPo battery.
5. The LED display would need to be bright enough to be visible in daylight but not so bright as to be distracting at night.
This setup provides a basic framework for creating a running shirt with LED lights that display real-time pace data from a Garmin watch. The actual implementation would require careful hardware design and more robust software to handle real-world conditions and edge cases.