<div align="center">

# 🧭 BLE HUD Navigation — LilyGO T-Display-S3

### A pocket-sized Bluetooth Heads-Up Display that mirrors your phone's turn-by-turn navigation — directions, distance, speed and speed limits — onto a crisp ESP32-S3 screen on your dashboard.

[![Platform](https://img.shields.io/badge/MCU-ESP32--S3-E7352C?logo=espressif&logoColor=white)](https://www.espressif.com/en/products/socs/esp32-s3)
[![Board](https://img.shields.io/badge/board-LilyGO%20T--Display--S3-00979D)](https://github.com/Xinyuan-LilyGO/T-Display-S3)
[![Framework](https://img.shields.io/badge/framework-Arduino-00878F?logo=arduino&logoColor=white)](https://www.arduino.cc/)
[![Connectivity](https://img.shields.io/badge/BLE-Bluetooth%20Low%20Energy-0082FC?logo=bluetooth&logoColor=white)](#-ble-communication-protocol)
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)

![Device Preview](image/gif.gif)

</div>

---

## 🚀 Overview

**BLE HUD** turns a [LilyGO T-Display-S3](https://github.com/Xinyuan-LilyGO/T-Display-S3) into a wireless **Heads-Up Display** for car navigation. It connects over **Bluetooth Low Energy** to a navigation app on your phone and shows the next maneuver in large, glanceable graphics right in your line of sight — no need to look down at your phone while driving.

It's cheap (~€15 board), runs on a single ESP32-S3, and needs no internet of its own — all the routing happens on your phone.

> This project is adapted for the LilyGO T-Display-S3 and builds on the original
> [BLE-HUD-navigation-ESP32](https://github.com/alexanderlavrushko/BLE-HUD-navigation-ESP32)
> by [Alexander Lavrushko](https://github.com/alexanderlavrushko).

<div align="center">
<img src="image/image1.jpg" alt="The HUD running next to a phone in Sygic navigation" width="640">
<br><em>The HUD (right) mirroring the next turn, distance and speed limit from the phone (left).</em>
</div>

---

## ✨ Features

- 🧭 **Turn-by-turn directions** — large arrow icons for every maneuver
- 📏 **Distance to next turn** — live countdown to the upcoming maneuver
- 🚦 **Speed & speed-limit display** — current speed and the active limit
- 🛣️ **Lane guidance** — lane-assist graphics for complex junctions
- 🔌 **Connection-aware states** — startup, disconnected, no route, navigating, recalculating
- 🎬 **Startup animation** — clean boot splash with progress bar
- 🔋 **Battery voltage monitoring** — optional, for portable/battery builds
- 😴 **Deep sleep** — button-triggered low-power mode to save energy
- 📱 **Works with Sygic GPS** (iOS) over standard BLE GATT

---

## 🛠 Hardware

| Component | Details |
|-----------|---------|
| Board | **LilyGO T-Display-S3** (ESP32-S3) |
| Display | Integrated **1.9" ST7789**, 320×170, full colour |
| Connectivity | Bluetooth Low Energy (built into the ESP32-S3) |
| Power | USB-C, or a Li-Po battery on the onboard connector |
| Optional | Voltage divider for battery-level monitoring |

### 🛒 Where to buy the board

- [AliExpress (affiliate link)](https://s.click.aliexpress.com/e/_EIARYJM)
- [Alibaba (affiliate link)](https://www.alibaba.com/x/AzeWnt?ck=pdp)

### 🔘 Buttons

| Button | GPIO | Action |
|--------|------|--------|
| Left | IO0 | Long press → enter **deep sleep** (press again to wake) |
| Right | IO35 | Toggle **battery voltage** display |

---

## 📲 Phone app — Sygic GPS (iOS)

The HUD currently receives data from **Sygic GPS Navigation & Maps**:
[Download on the App Store](https://apps.apple.com/us/app/sygic-gps-navigation-maps/id585193266).

### Enable the hidden BLE HUD feature

1. Open Sygic → **Menu → Settings → Info → About**
2. **Tap 3 times** on any item to unlock the hidden menu
3. Go to **About → BLE HUD → Start**
4. Grant Bluetooth permission

The app will then find and connect to the ESP32 automatically.

---

## 🔧 Build & flash

### Prerequisites

- [Arduino IDE](https://www.arduino.cc/en/software) with **ESP32 board support** ([install guide](https://docs.espressif.com/projects/arduino-esp32/en/latest/installing.html))
- This repository (clone it or download the `src/` folder)

### Required libraries

| Library | Where to get it |
|---------|-----------------|
| `TFT_eSPI` | Library Manager — **must be configured for the T-Display-S3** (see below) |
| `Button2` | Library Manager |
| `BLEDevice` / `BLEServer` / `BLEUtils` / `BLE2902` | Bundled with the ESP32 Arduino core |

### Configure TFT_eSPI for the T-Display-S3

Use the display config from the official LilyGO repo:
[Xinyuan-LilyGO/T-Display-S3](https://github.com/Xinyuan-LilyGO/T-Display-S3).
Apply `User_Setups/SetupXX_TDisplay_S3.h` (or edit `User_Setup.h`) so `TFT_eSPI`
targets the onboard ST7789. **This is the #1 cause of a blank/garbled screen.**

### Flash

1. Board: **`ESP32S3 Dev Module`** (or `LilyGo T-Display-S3`)
2. Select the correct USB port
3. Open `src/BLEHUDNaviESP32TDislpays3.ino` and **Upload**

> 💡 If the board isn't detected, hold **BOOT** while plugging in the USB-C cable to force download mode.

---

## 📡 BLE communication protocol

The ESP32 advertises a GATT service and expects navigation packets in this format:

```
[1, <speed>, <direction>, <message>]
```

| Field | Type | Description |
|-------|------|-------------|
| `speed` | uint8 | Current speed (0–255 km/h) |
| `direction` | enum | Maneuver type — see [`src/DataConstants.h`](src/DataConstants.h) |
| `message` | string | Null-terminated street/instruction text |

| GATT | UUID |
|------|------|
| Service | `DD3F0AD1-6239-4E1F-81F1-91F6C9F01D86` |
| Indicate (notify) | `DD3F0AD2-6239-4E1F-81F1-91F6C9F01D86` |
| Write | `DD3F0AD3-6239-4E1F-81F1-91F6C9F01D86` |

---

## 💻 Usage

1. Power on the device — it shows the startup animation, then "waiting for connection".
2. Start navigation in Sygic and enable the **BLE HUD** feature (steps above).
3. Once connected, the HUD shows the next direction, distance, speed and speed limit automatically.
4. Long-press the left button to put the device into **deep sleep**.

---

## 🗂️ Project structure

```
.
├── src/
│   ├── BLEHUDNaviESP32TDislpays3.ino   # Main sketch (BLE server, display state machine)
│   ├── DataConstants.h                 # Direction enums & shared constants
│   ├── ImagesDirections.h              # Turn-arrow bitmaps
│   ├── ImagesLanes.h                   # Lane-assist bitmaps
│   ├── ImagesOther.h                   # UI/status bitmaps
│   └── VoltageMeasurement.h            # Optional battery-voltage helper
├── image/                              # Demo GIF & photos
└── README.md
```

---

## 🧯 Troubleshooting

| Symptom | Fix |
|---------|-----|
| Blank or garbled screen | `TFT_eSPI` not configured for the T-Display-S3 — apply the LilyGO setup file |
| Board not detected | Hold **BOOT** while connecting USB-C to enter download mode |
| Phone won't connect | Re-enable the hidden **BLE HUD** menu in Sygic and toggle Bluetooth |
| Compile error on BLE headers | Make sure the **ESP32 Arduino core** is installed and selected |

---

## 🔮 Roadmap ideas

- [ ] Android navigation app support
- [ ] Configurable units (km/h ↔ mph)
- [ ] Adjustable brightness / auto-dimming
- [ ] 3D-printed dashboard mount

---

## 🙌 Acknowledgements

- [Alexander Lavrushko](https://github.com/alexanderlavrushko) — the original [BLE-HUD-navigation-ESP32](https://github.com/alexanderlavrushko/BLE-HUD-navigation-ESP32) codebase this project is based on.
- [Xinyuan-LilyGO](https://github.com/Xinyuan-LilyGO/T-Display-S3) — T-Display-S3 hardware & display configuration.

If this project is useful to you, please consider giving it a ⭐ — it really helps others find it!

---

## 📜 License

Released under the [MIT License](LICENSE).
