Skip to content

Feat/esp32 glasses - #7

Open
Re1veN7 wants to merge 28 commits into
mainfrom
feat/esp32-glasses
Open

Feat/esp32 glasses#7
Re1veN7 wants to merge 28 commits into
mainfrom
feat/esp32-glasses

Conversation

@Re1veN7

@Re1veN7 Re1veN7 commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

KRMeeag and others added 22 commits July 30, 2026 20:06
firmware/ was listed in .git/info/exclude, so nothing under it had ever
been committed — it was absent from main and every remote branch. That
exclude file is local to one clone and is never pushed, so the firmware
was invisible to git here while nobody else had any copy of it at all.

Drop the exclusion and commit the project. .pio/ and .vscode/ stay
ignored via the project's own .gitignore, so only sources, docs and the
wiring diagrams land.

Also add an env:motorlink so src/main.cpp actually builds. Every
build_src_filter starts with -<*> and names exactly one file, and none
of them named main.cpp — it compiled in zero environments and `pio run`
gave no hint of it. Verified: builds clean under -Wall, 20.4% flash.
Bring-up aid for the Pi <-> ESP32 UART: latch the first ACK ever seen
and print once, so a wiring or baud problem is distinguishable from a
board that is simply idle. Latched rather than per-packet, otherwise it
prints at frame rate.

_check_ack() moves into an ack_seen local. Same single call per
iteration as before — it just gets read twice now.
…O board configs

Adds a new PlatformIO project (esp32_haptic_feedback) driving three motors
off BMI160 IMU telemetry, with a MAC-mode incremental fade test and a
deployment UART/JSON mode. Also moves the shared `board` and port settings
out of `[env]` into each control-panel environment so `motorlink` can target
the XIAO ESP32-C3 independently, and switches the motor controller to a
dedicated HardwareSerial (UART1) instead of Serial2.
Adds sendImuTelemetry(), an outbound 0x02 packet type on the existing
PiSerial link (D6/D7) alongside the inbound motor-command protocol.
Reuses the state/raw_pitch/raw_yaw values the BMI160 block already
computes every 200ms tick, encoding them as start+type+state+pitch(2)
+yaw(2)+checksum. No ACK is expected back for this packet type.
Decodes the new inbound 0x02 packet off the existing PiSerial link.
Reuses _check_ack's single per-iteration port.read() rather than
adding a second reader: the same drained chunk is scanned for both
the ACK prefix (unchanged, all 12 existing tests still pass) and a
telemetry frame, with the decoded reading staged on the port object
for a new _take_imu_telemetry() to collect.

Signed pitch/yaw are decoded via struct.unpack(">h", ...) for correct
two's-complement handling. A partial frame that stalls mid-packet is
abandoned after 0.5s so it can't permanently desync later frames.

Latest reading lands on a new lock-guarded ImuTelemetry class,
mirroring SystemConfig's get/update/snapshot shape, exposed as
user_data.imu_telemetry. No downstream consumer is wired yet — that's
the separate turning-body task.
…extraction

Covers the v1 0x02 protocol logic that shipped without dedicated tests:
negative-value signed int16 decode (struct.unpack byte order pinned
explicitly), checksum rejection (dropped frame does not update
ImuTelemetry), a frame split across two reads, a stale partial frame
being abandoned rather than corrupting the next one, ACK and telemetry
both being detected from one shared drain, and ImuTelemetry's
thread-safety under concurrent update/snapshot.

Purely additive — 210 insertions, 0 deletions. All 41 pre-existing
tests pass unmodified; all 9 new tests pass. No bug found in the v1
logic.
Adds a temporary [BENCH MOTOR] print in handlePacket() so a received
0x01 motor-update packet's left/center/right duty is visible on the
ESP32's USB debug console, plus scripts/test_motor_packet.py to send
manual motor-update packets from the RPi5 side for bench verification
without needing the full depth-estimation pipeline running.
…o the ESP32

sv-main.sh predates the --serial-port flag and never passed it, so every
real run silently built motor packets and dropped them
("running without an ESP32"). The manual bench test worked because it
opens the port directly; the real pipeline never did.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants