Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

NavBar Android app

NavBar is a windshield LED light bar that shows navigation guidance (turn direction, distance, lanes) as light. This repository is the Android companion app: it gets turn-by-turn data, shows it on screen together with a virtual LED bar, and sends light scenes to the NavBar device over Bluetooth Low Energy.

Status

Milestone State
M0 Scaffold done
M1 Core (model, protocol, scene planner/renderer) done
M2 Simulator + LED preview (demo without hardware) done
M3 BLE device link done
M4 Google Navigation SDK source removed again (Oct 2026): too heavy; Google Maps itself is the real source
M5 Maps notification source (experimental) done

One-time setup

You need a JDK 17 and the Android SDK. The easiest way is Android Studio, which brings both.

Option A: Android Studio (recommended)

  1. Install Android Studio (https://developer.android.com/studio) and run its setup wizard (it installs the Android SDK).
  2. File → Open… and pick this folder. Android Studio downloads Gradle and all libraries on the first sync (this takes a few minutes).
  3. If it asks for a JDK, choose a JDK 17 (Settings → Build, Execution, Deployment → Build Tools → Gradle → Gradle JDK).
  4. To run the app on your phone: enable Developer options and USB debugging on the phone (Settings → About phone → tap Build number 7 times, then Settings → System → Developer options), connect it by USB, accept the prompt on the phone, then press the green ▶ Run button. Without a phone you can create a virtual device in Device Manager.

Option B: command line only

  1. Install a JDK 17 (for example Eclipse Temurin) somewhere Gradle can find it, e.g. ~/.jdks/. gradle/gradle-daemon-jvm.properties tells Gradle to run with Java 17.
  2. Install the Android command-line tools (https://developer.android.com/studio#command-line-tools-only) to ~/Android/Sdk/cmdline-tools/latest, then:
    ~/Android/Sdk/cmdline-tools/latest/bin/sdkmanager --licenses
    ~/Android/Sdk/cmdline-tools/latest/bin/sdkmanager "platform-tools" "platforms;android-37.0"
  3. Create local.properties in this folder (it is git-ignored; never commit it):
    sdk.dir=/home/<you>/Android/Sdk

Everyday commands

./gradlew assembleDebug        # build the app (APK in app/build/outputs/apk/debug/)
./gradlew installDebug         # install on the connected phone (USB debugging on)
./gradlew test                 # JVM unit tests of all modules
./gradlew connectedAndroidTest # instrumented tests on a phone or emulator
./gradlew spotlessApply        # auto-format the code
./gradlew spotlessCheck lint   # style and Android lint

Before pushing: ./gradlew spotlessCheck lint test assembleDebug must pass (CI runs exactly this).

Module overview

Module Kind Content
app Android app UI (Compose), dependency injection (Hilt), pairing, foreground service
core:model pure Kotlin NavState, Step, Maneuver, Lane, …
core:protocol pure Kotlin BLE frame encoder/decoder, UUIDs
core:scene pure Kotlin Scene, ScenePlanner, SceneRenderer, SceneSender
ble Android library NavBarLink: real Bluetooth link (BleNavBarLink, Nordic BLE library) and FakeNavBarLink
nav:api pure Kotlin NavigationSource interface
nav:simulator Android library scripted scenarios
nav:notification Android library Google Maps notification source (experimental): parser, icon hashes, fixtures

"Pure Kotlin" modules have no Android dependencies; their tests run quickly on your computer.

Try it (no hardware needed)

  1. Install the app on a phone (./gradlew installDebug, or the ▶ button in Android Studio) and open NavBar.
  2. On the Drive tab, press Start simulation. The app "drives" the selected scenario:
    • the big arrow, distance, road name and lanes show the next maneuver;
    • the row of dots near the bottom is a virtual NavBar: it shows exactly what the real light bar would show, using the same rendering rules as the firmware.
  3. Settings → Navigation: pick another scenario or a recorded drive, change the speed, or use the time factor (up to 10×) to get to the interesting part faster. Speed and time factor can be changed while a simulation runs.
  4. Settings → Debug log lists every frame the app sent (hex bytes plus a decoded summary) and every STATUS reply. As long as no NavBar is paired, the frames go to a built-in fake device (FakeNavBarLink) that answers like the firmware.
  5. Settings → Device lets you pair a real NavBar (see below); Device details shows its status.

What you should see (details in docs/scene-design.md; "green" is the main colour, which you can change under Settings → Light):

Situation Virtual NavBar
Turn further away than the start distance (1 km) off
1000 m → 50 m before a turn green bar on the turn side, growing outwards; brighter below 300 m
Last 50 m before a turn (final part) the whole turn-side half green, plus three white comets running one after another over the whole bar towards the turn side
Lanes known, below 800 m one patch per lane with wide dark gaps: recommended lanes green, the others dim warm white
Straight ahead / destination ahead, last 50 m the green centre block pulses (low → bright, once per second)
Roundabout white dots in front of the driver, one per exit (3rd exit → 3 dots), plus green on the exit side (pulsing in the last 50 m); stays on until you have left the roundabout

| Rerouting / no GPS | whole bar slowly pulsing amber (yellow if amber is your main colour) | | Arrived | whole bar pulsing green (lime if green is your main colour) for 3 s, plus a white swoosh to the side if the destination is left or right, then off | | No maneuver within the start distance | the selected idle views take turns (next section) |

The start distance (1 km) and the final part (50 m) can be changed under Settings → Light. Under LED in front of the driver, move the slider until the LED that lights up on the bar sits straight in front of you; the roundabout dots are centred on it.

When no maneuver is shown (idle views)

While the next maneuver is further away than the start distance, the bar can show other things, chosen under Settings → When no maneuver is shown (each with a preview). They are white (warm white if white is your main colour), so they never look like guidance, and each has its own shape:

View On the bar
Route progress the whole bar is the route: driven part bright from the left, your current position at full brightness, the rest dim; slow traffic ahead yellow, jams amber (from Google Maps' traffic colours)
Next maneuver the middle half between two bright end caps: the distance left shrinks towards the turn side; two LEDs in the main colour beside it (left/right) or in its middle (straight) show where the maneuver goes
Music the same end caps as Next maneuver, filling from left to right as the track plays, the current position at full brightness; two dots outside both caps in a colour that is not your main colour (green, or amber if your main colour is green or lime) tell it apart (Spotify, YouTube Music, podcasts…; needs notification access)

With more than one selected, they take turns (Switch views every, default 10 s): one fades to dark, the next fades in. A maneuver within the start distance always takes over.

Breathe with the beat (off by default) makes the played part of the music view breathe with the music: the app finds the tempo and the beat in the bass of what the phone plays (like music visualisers do: bass onsets, tempo by autocorrelation, beat phase) and sends a slow pulse that the bar animates by itself, brightest on the beat. One breath spans a whole number of beats and lasts 1–2 s, because the bar never flashes faster than once a second; energetic music breathes deeper. It needs the microphone permission but only measures the spectrum of what the phone plays (Android's audio Visualizer); nothing is recorded. Settings shows "Beat found: … BPM" while it works. Bluetooth audio reaches the car speakers later than the phone measures it: if the light peaks before the beat, raise Sync delay (default 200 ms), if after, lower it. Some phones give no spectrum for some audio paths; the app then says so and keeps the bar steady. The simulator scenario Long motorway with traffic shows the idle views without driving.

Simulator scenarios

Scenarios are JSON files in nav/simulator/src/main/assets/scenarios, listed in file-name order. Six ship with the app: city left turn with 3 lanes, motorway exit with 4 lanes, roundabout exit 2, rerouting mid-route, arrival with the destination on the right, and a long motorway with traffic. To add one, copy a file, change id (must be unique) and the steps, and rebuild. The format:

{
  "id": "my-scenario",
  "name": "Shown in the picker",
  "description": "Optional longer text",
  "drivingSide": "RIGHT",
  "steps": [
    { "distanceM": 800, "maneuver": "LEFT", "roadName": "Hauptstraße",
      "lanes": [ { "directions": ["LEFT"], "recommended": true }, { "directions": ["STRAIGHT"] } ] },
    { "distanceM": 300, "maneuver": "DESTINATION" }
  ],
  "events": [ { "type": "NO_SIGNAL", "atM": 200, "durationS": 4 } ]
}
  • distanceM: metres from the previous maneuver (or the start) to this one.
  • maneuver: one of STRAIGHT, SLIGHT_LEFT, LEFT, SHARP_LEFT, UTURN_LEFT, KEEP_LEFT, RAMP_LEFT, MERGE_LEFT, FORK_LEFT (and the same with RIGHT), ROUNDABOUT_ENTER (with "roundaboutExit": 2), ROUNDABOUT_EXIT, DESTINATION, DESTINATION_LEFT, DESTINATION_RIGHT, FERRY, UNKNOWN.
  • lanes: left to right as the driver sees them; directions use the same names (STRAIGHT, LEFT, SLIGHT_RIGHT, …).
  • events: NO_SIGNAL (guidance kept, status "no signal") or REROUTE (guidance blank for durationS, then continues with newSteps). atM is measured from the start of the drive.

The unit tests check that every shipped scenario parses and plays through to arrival.

Recorded drives

Real Google Maps drives can be replayed like a scenario: Settings → Simulator → Recorded drives. The app plays the recorded Maps notifications through the same parser as on the road, with the timing of the real drive; the time factor becomes the playback speed. One recording ships with the app (nav/notification/src/main/assets/recordings, 10 Oct 2026, with the roundabout "dritte Ausfahrt"). Drives you record on the phone (Debug → Maps → record) show up there as well. To bundle one with the app, copy it from the phone and rebuild:

adb pull /sdcard/Android/data/de.navbar.app/files/recordings/<time>/notifications.jsonl \
  nav/notification/src/main/assets/recordings/<time>.jsonl

A recording is split into drives at each arrival.

Following Google Maps (experimental)

The app follows navigation in the normal Google Maps app by reading its navigation notification. It costs nothing, but it is unofficial (any Maps update can break it) and has no lane data.

Setup, once:

  1. Allow notifications for Google Maps (phone Settings → Apps → Maps → Notifications, at least "Navigation").
  2. NavBar → Settings → Navigation → Allow notification access → switch NavBar on. (NavBar only looks at Google Maps notifications and ignores everything else.)
  3. Pick Google Maps as source.

Use: just start navigation in Google Maps. With Start automatically with Google Maps (Settings tab, on by default) the light bar starts by itself, even with NavBar in the background, and stops 10 s after Maps ends navigation. Without auto-start, tap Start light bar on the Drive tab first. A session you start by hand is never stopped automatically. With a paired NavBar, the companion-device permission REQUEST_COMPANION_START_FOREGROUND_SERVICES_FROM_BACKGROUND lets the app start its foreground service from the background (no prompt; it only works while a NavBar is paired).

How it reads the notification (on Android 16+ Maps posts a "Live Update" progress notification):

  • distance from the status-bar chip text or the title ("70 m · Rechts abbiegen auf Hirbishofer Str.", German and English formats like 300 m, 1,2 km, 0.5 mi, 500 ft);
  • road name from the instruction text; remaining route distance from the notification's progress;
  • maneuver from the arrow icon. Google Maps contains its maneuver icons as drawables named maneuver_* (64 of them: turns, keep/fork, merge, ramps, U-turns, every roundabout variant, depart, destination). NavBar renders them from the installed Maps app on the phone (MapsIconCatalog; Android's public resources API, nothing is copied), hashes them, and matches the notification icon against that table. It rebuilds itself when Maps updates. The instruction text ("Rechts abbiegen", "2. Ausfahrt", …) is the fallback, otherwise UNKNOWN (neutral warm-white wedge).
  • in the last ~50 m Maps drops the distance; a maneuver without a distance therefore counts as 0 m, so the final sweep shows (except for the "Richtung … starten" step at the start).

Maneuver test

Settings → Maneuver test, or Debug log → Maps → Maneuver test: every distinct maneuver picture of Google Maps as a tile, a distance slider (0 m to one step beyond the start distance, with presets; 0 m = Maps' last metres without distance) and, for roundabouts, the exit number; for destination icons an Arrived toggle shows the arrival animation that follows. Each choice builds a Maps-style notification and runs it through the real parser and planner. The light pattern shows at the top and is sent to the paired NavBar over Bluetooth (or to the simulated device). Not available while a navigation session runs; leaving the screen clears the bar.

Recording drives and unknown icons

Settings → Debug log → Maps:

  • Start recording / Stop recording records every distinct Maps notification for as long as you like, plus each distinct icon as PNG, to /sdcard/Android/data/de.navbar.app/files/recordings/<time>/ (notifications.jsonl, icons/, and on stop fixtures.json in the test-fixture format).
  • Export last N writes the last 300 notifications to files/maps-captures.json.
  • Always on in the background: any icon the catalog does not recognise is saved once to files/unknown-icons/ (<hash>.png plus index.jsonl with the notification text). The line at the top shows how many.

Fetch everything with:

adb pull /sdcard/Android/data/de.navbar.app/files/

To add test fixtures, check the expected values in a fixtures.json, fix them where needed, and put the file into nav/notification/src/test/resources/fixtures.

Pairing a NavBar over Bluetooth

  1. Switch the NavBar on (new phones can pair during the first 2 minutes, or after a short button press).
  2. In the app: Settings → Device → Pair NavBar. Allow "Nearby devices" (Bluetooth) and notifications.
  3. Android's own device picker lists devices whose name starts with NavBar- and that offer the NavBar service. Pick yours; confirm the pairing prompt if Android shows one.
  4. Settings shows the link state; Device details shows live STATUS, the CONFIG editor (Save to device writes it) and test buttons (identify, sweeps, lane demo, clear). Test buttons are disabled while a navigation session runs.
  5. Start a simulation on the Drive tab: the frames now go over Bluetooth. A notification "Navigation light bar active" shows that a foreground service keeps the link alive with the screen off; it ends with the session.

What the link does: bond if needed ("Just Works", encrypted), request MTU 247 (fails with a clear error below 73), subscribe to STATUS, send a scene on every change (max. 10/s) plus a KEEPALIVE every second, and reconnect after a dropout with backoff 1, 2, 4, 8, 16, 30 s. The real link is only kept up while Settings is open, a session runs, or the NavBar is in range: from Android 12 the system wakes the app when the paired NavBar appears (e.g. when the car starts), so the bar is connected before you start navigating. Use simulated device sends frames to the built-in fake again without forgetting the pairing; Forget removes the pairing (remove the Bluetooth bond in the phone's Bluetooth settings too, if you want it gone completely).

No NavBar yet? Let your Linux PC pretend to be one

tools/navbar_emulator.py makes a Linux computer with Bluetooth (BlueZ 5.50+, python3-dbus, python3-gi; all preinstalled on Ubuntu desktop) advertise as NavBar-PC with the NavBar GATT service. It checks every frame like the firmware, honours ttl/keepalive, sends STATUS at 1 Hz, accepts CONFIG writes and draws the bar in the terminal in colour.

python3 tools/navbar_emulator.py              # like the device: encrypted, "Just Works" pairing
python3 tools/navbar_emulator.py --no-encryption
python3 tools/navbar_emulator.py --self-test  # decoder/renderer check, no Bluetooth needed

Then pair NavBar-PC in the app as above. Stop it with Ctrl+C. Notes:

  • Pairing with a PC also offers the PC as a media audio device. If the phone's sound comes out of the PC, turn off "Media audio" for the PC in the phone's Bluetooth settings.
  • The emulator always accepts pairing (the device only does so for 2 minutes after power-on).
  • Stopping and restarting the emulator is a good way to test reconnection.
  • Alternative: nRF Connect for Android on a second phone can emulate the service with the UUIDs from docs/protocol.md and shows every write as hex.

Testing without hardware

  • Day to day: the Simulator source plus the virtual NavBar and the Debug log.
  • Real Bluetooth: the PC emulator above.
  • Never test while driving.

Notes for the firmware

The protocol text leaves a few rendering details open. The app's SceneRenderer (core/scene) decides them as follows; the firmware should match:

  • Rounding: pixel = round(pos × (ledCount − 1) / 255) with halves rounding up; colour scaling rounds to nearest.
  • Soft edges halve the element's first and last pixel of its span (start and end) whenever they are lit.
  • SWEEP: head index (t mod T) × spanLength / T; the tail is round(span × param / 100) pixels including the head, fading linearly, and does not wrap around the start. Period 0 is treated as 1 (100 ms).
  • PULSE starts at its lowest level (0.5 − 0.5·cos); periods below 10 are treated as 10.
  • PROGRESS lights round(spanLength × param / 255) pixels from the start side.
  • OFF overwrites its span with black (no effect when additive).

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages