Commit Graph
183 Commits
Author SHA1 Message Date
Dejvino 315cdbd177 Learn the populated microphone slots and DMA packing at runtime 2026-11-12 14:54:47 +01:00
Dejvino 129c670ff4 Drop mic gain out of saturation and soften the noise gate
The hardware log showed the live mic slots sitting at ~0.6 RMS in
ambient noise. At 37.5 dB the ES7210 was clipping, so the noise floor
slowly climbed to the saturated level and the gate never fired again:
the blip appeared once and then vanished forever.

Use 18 dB analog gain so ambient levels have headroom, lower the gate
to 1.5x the floor so real sounds stand out, and widen the loudness
window to -50..-6 dBFS. The debug line now also prints the
floor-relative signal levels.
2026-11-12 14:33:01 +01:00
Dejvino 72f80bfdd8 Make microphone slot discovery self-healing
The ES7210 power-up transient is loud enough to look like the first
sound. It placed one centred blip right after init and then pinned the
mic pair to whichever slots were loudest at that instant. If that was
the wrong pair, later claps were ignored forever.

Ignore the first 800 ms after starting the codec, and re-evaluate the
mic pair on every clear sound instead of locking once. The pair only
changes after repeating for a few blocks, or immediately when the
current pair is silent while another one is loud. Also enable the
per-second rms/pair debug line so the slot mapping can be verified on
hardware.
2026-11-12 14:10:17 +01:00
Dejvino b8de153e5a Fix microphone stereo detection on the T-Deck Plus
I2S_CHANNEL_FMT_ALL_LEFT copies a single channel into every slot, so
both microphones read the same signal and the balance stayed at zero.
Use I2S_CHANNEL_FMT_MULTIPLE (the real TDM mode) instead.

The board only fits two of the four ES7210 mic footprints, but the
schematic carries all four. Rather than hardcode MIC1/MIC3, the detector
now measures the TDM slots and locks onto the two that carry signal,
treating the lower slot as the left microphone. Equal maximum gain is
applied to all inputs so the pair amplifies consistently.

Also widen the balance range (claps produce only a few dB of difference
between the closely spaced mics) and recalibrate loudness to the dBFS
range seen with 37.5 dB analog gain.
2026-11-12 14:04:31 +01:00
Dejvino 2ba92a65d1 Drive radar blips from the T-Deck Plus dual microphones
Add a SoundDetector that reads the ES7210 as a 4-slot TDM stream
(slot 0 = MIC1/left, slot 2 = MIC3/right), tracks a per-channel RMS
envelope with an adaptive noise floor, and publishes a stereo balance
plus a dB-mapped loudness.

The radar sketch now slides a single reused blip left/right from the
balance and moves it nearer as the loudness rises, instead of firing a
hardcoded demo blip. The device's own ping/click mutes the detector for
200 ms so it cannot hear itself.

The trackball stays detached: GPIO0 is unavailable while the ES7210
microphones are running.
2026-11-12 08:20:38 +01:00
Dejvino 7dfdc06e6f Add NoiseSensor radar example and fix short sound playback
The sound task used to zero the I2S TX DMA ring as soon as the event
queue drained. i2s_write() only queues samples, so anything shorter than
the ~64 ms ring was erased before it reached the speaker. Enable
tx_desc_auto_clear instead, which clears each descriptor after the DMA
has actually transmitted it.

Also add the NoiseSensor radar example and point the default PlatformIO
environment at it.
2026-11-12 08:14:19 +01:00
Dejvino 951c56168c CRT Terminal app 2026-11-11 22:03:40 +01:00
Dejvino 1ef22cc832 Trackball: ISR edge capture + momentum model; extract difficulty tunables
- Trackball edges are counted by IRAM_ATTR ISRs (4 quadrant pins + BOOT
  click), so nothing is lost while loop() stalls in long TFT draws.
  The old ~1 ms polling hot path is gone.
- Debounce is handled by the momentum model itself: edge counts are
  impulses on a heavy ball, friction bleeds velocity off each frame.
  Contact bounce decays into a sub-pixel nudge and never reverses
  motion, so no time-gate is needed. Slow rolls glide in 1-px steps
  via sub-pixel accumulators; hard flicks stay capped.
- Per-platform sensitivity: device gets 4x impulse per edge (its real
  pulse rate is far lower than the emulator's synthetic streams) plus
  lower friction; selected via the shim's EMULATOR define.
- Emulator shim: attachInterrupt/detachInterrupt emulation; handlers
  are dispatched from the host loop when pin levels change.
- MissileCommand: extract arcade difficulty scaling into a tunables
  block (wave quota, bomb speed, spawn pacing, smart-bomb chance,
  craft speeds/drop rates, scoring, score multiplier, bonus-city
  interval, mercy rules). Formulas unchanged, only symboled.
2026-11-11 07:32:12 +01:00
Dejvino 798f8600a0 Boot: input grace period; persist high score + volume via NVS
- Ignore all input for ~1.2 s after power-up/reset (INPUT_GRACE_MS):
  the keyboard controller can emit stale bytes and pins can float,
  which used to start a game right after a restart.
- High score + volume survive power cycles: Preferences (NVS, 'mc'
  namespace) loaded in setup(), saved on game over and on every
  volume key (U/V/M). arduino-esp32 commits NVS in end(), so
  savePrefs() does putUInt x2 + end() + begin() reopen.
- SoundEngine::setVolume() restores a saved level (0 = stay muted,
  lastVol_ keeps unmute working).
- Emulator: file-backed Preferences shim (mc-prefs.cfg, gitignored)
  so persistence is testable on the desktop.
2026-11-11 07:05:59 +01:00
Dejvino a5921032d7 Trackball: poll every iteration, count all pulses, accelerate
The crosshair crawled one 14px segment per tick because the ball pins
were sampled only once per game frame (33 ms) and just compared to the
previous level: a fast roll completed whole pulse cycles between reads,
so most edges were dropped and at most one step per frame was applied.

Now pollTrackball() runs in the loop() hot path (~1 ms apart) and counts
every edge into per-direction accumulators; applyTrackball() consumes
them once per frame, moving the cross steps * CROSS_STEP and capping at
CROSS_MAX_STEP (48 px/frame) — slow roll = fine steps, hard flick =
the cursor flies across the screen, arcade-style. Accumulation is
disabled outside PLAYING/BANNER and the first read is primed so the
power-up pin levels don't count as steps.

Emulator: mouse wheel now simulates ball pulses (6 edges per notch,
drained one toggle per iteration) for desktop testing.
2026-11-11 06:25:06 +01:00
Dejvino 0f85c75331 Missile Command: arcade rules, crafts, trail system v2, emulator wave skip
Game (examples/MissileCommand):
- Trails rewritten as an analytic flight path (pos is a pure function of
  distance travelled): paint and erase replay the exact same pixels, so
  blinking trails leave zero residue. Smart bombs wiggle (S-curves) with
  deterministic paths; erase band widened to a symmetric 7px so the ±1px
  Bresenham slope jitter between paint/erase endpoints can never leak
  paint ink (verified zero strays across dense frame captures).
- 2600 look: bright steady missile head dot with a flashing trail
  (shared blink phase), trails vanish on death/impact; AA rockets stay
  moving dots.
- Arcade rules: bomber planes (100x mult) and satellites (250x mult)
  cross the sky dropping bombs; max 3 city kills per wave; bonus cities
  at every 10k kept in reserve and deployed between waves; battery
  silos rebuilt and replenished at each wave start (they no longer stay
  dead across levels); center battery fires fast rockets, sides slow.
- Wave-start attack alarm (four falling tones, once); volume U/V/M with
  OSD; sound task zeroes the I2S DMA ring when the queue drains so a
  finished sound's tail no longer loops forever.

Emulator:
- --wave N flag to skip straight to a wave for quick testing
- --dump-interval N rolling frame captures (seq%05d.bmp)
- shim: uxQueueMessagesWaiting added
2026-11-10 23:42:01 +01:00
Dejvino 45ffa87425 Trails: match erase width to draw width, bright flashing missile head
- Enemy missile trails now drawn 3px thick via drawThickLine() with a
  bright head dot (white) that flashes against the trail color every
  couple of frames, like the Atari 2600
- eraseBombTrail() uses a thicker erase band than the draw (5px, 7px for
  wigging smart bombs) plus a 2px tip circle, so no trail residue is
  left behind when a missile dies or impacts
2026-11-10 22:11:33 +01:00
Dejvino d4e6b4e6be Add Missile Command game for T-Deck + desktop emulator
Game (examples/MissileCommand):
- Classic Missile Command: 6 cities, 3 batteries x 10 missiles,
  escalating waves, smart bombs, score multiplier, session high score
- Trackball aims, press/tap fires, keyboard A/S/D selects battery,
  screen tap aims+fires
- Rendering: incremental TFT_eSPI drawing (persistent enemy trails that
  vanish on death, no AA-rocket trails, explosion circles that repair
  terrain, ghost-free crosshair)
- Sound (sound_engine.cpp): non-blocking I2S task on core 0; wave-start
  alarm of four falling tones (like the original), sweeps/noise effects,
  U/V/M keyboard volume control with OSD, master volume scaling

Emulator (emulator/):
- SDL2 host that compiles the unmodified sketch against shim headers
  (Arduino, TFT_eSPI->framebuffer, GT911 touch, I2C keyboard, I2S->SDL
  audio); arrow keys emulate the trackball, --autoplay/--frames/--dump
  flags for headless smoke tests
2026-11-10 22:06:41 +01:00
lewisxhe 9aac147a31 Update factory firmware 2026-11-03 17:25:43 +08:00
lewisxhe 173cea69e3 Update factory firmware 2026-11-03 09:19:29 +08:00
lewisxhe 2027dee791 Update firmware page 2026-10-27 09:46:25 +08:00
lewisxhe 1dddf6e0d3 Update README 2026-09-29 14:41:24 +08:00
lewisxhe 980269291b Update factory 2026-09-08 11:03:10 +08:00
lewisxhe d0d202b456 Update README 2026-09-03 11:09:09 +08:00
lewisxhe 274ddaa0d0 fix arduino ide build error 2026-07-21 15:23:30 +08:00
lewisxhe 5939aca72e fix factory gps bug 2026-05-15 10:46:26 +08:00
lewisxhe 7fd1056431 Add grove model 2026-05-11 14:27:27 +08:00
lewisxhe 651631d789 Update README 2025-12-24 08:57:26 +08:00
lewisxhe 4087b04e3f Update README 2025-12-22 16:41:38 +08:00
lewisxhe 366af63a2b Update README 2025-12-22 16:30:43 +08:00
lewisxhe 306c6cb83b Update fw 2025-11-13 09:55:11 +08:00
lewisxhe 1030f90e1d Added fw 2025-11-12 14:53:56 +08:00
lewisxhe ac871c78be Update Meshtastic firmware 2025-10-28 09:28:00 +08:00
lewisxhe b83fa31a73 Update README 2025-10-21 10:13:47 +08:00
lewisxhe 13d822798b Added ant datasheet 2025-10-07 13:40:14 +08:00
lewisxhe e041323369 Added i2s tone https://github.com/Xinyuan-LilyGO/T-Deck/issues/99#issuecomment-3329099006 2025-09-25 08:54:23 +08:00
lewisxhe ba3855440b Added gps sch https://github.com/Xinyuan-LilyGO/T-Deck/issues/98 2025-08-05 11:22:09 +08:00
lewisxhe bd6fbc4a0b Update README 2025-06-20 14:24:19 +08:00
lewisxhe e2aeb7e8ac Update firmware 2025-06-20 14:20:19 +08:00
lewisxhe c1982c983c Factory example add keyboard set brightness method 2025-06-20 14:19:56 +08:00
lewisxhe 12f12f8cd6 ESP32C3 Keyboard firmware add revision notes 2025-06-20 14:19:20 +08:00
lewisxhe a107982e04 Factory example recording GPS completion takes time 2025-06-20 10:10:54 +08:00
lewisxhe a84522e8c4 Update READMEhttps://github.com/Xinyuan-LilyGO/T-Deck/issues/90#issuecomment-2980116659 2025-06-18 08:51:29 +08:00
lewisxhe ec2dfd955d Update README https://github.com/Xinyuan-LilyGO/T-Deck/issues/88 2025-06-16 16:04:16 +08:00
Lewis HeandGitHub ef0868fc71 Merge pull request #87 from kilrah/keyboard_raw
Add new commands to allow reading raw key states
2025-06-12 17:13:55 +08:00
Kilrah 1eb6fb0ebd Add new commands to allow reading raw key states 2025-06-11 21:58:37 +02:00
lewisxhe 2ef9f07627 Update README 2025-06-06 17:18:11 +08:00
lewisxhe 975e485d32 Added mesh fw v2.6.11 fixed touch 2025-06-06 17:11:21 +08:00
lewisxhe faf8dd034a Added mesh-ui v2.6.8 2025-05-12 14:29:22 +08:00
lewisxhe babfe1972c Fixed typo https://github.com/Xinyuan-LilyGO/T-Deck/issues/81 2025-04-07 09:59:43 +08:00
lewisxhe 9e68cc8206 Update README 2025-04-01 16:30:03 +08:00
lewisxhe 65c60427fa Update README 2025-03-31 17:16:54 +08:00
lewisxhe abdd781f32 Merge branch 'master' of https://github.com/Xinyuan-LilyGO/T-Deck 2025-03-31 16:09:29 +08:00
lewisxhe 46a8b8767f Added T-Deck mesh device-ui fw 2025-03-31 16:09:26 +08:00
Lewis HeandGitHub 879de3b205 Merge pull request #77 from hreikin/patch-1
Fix ledc error reported over serial on boot.
2025-03-17 09:54:40 +08:00