Commit Graph
76 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 980269291b Update factory 2026-09-08 11:03:10 +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 e041323369 Added i2s tone https://github.com/Xinyuan-LilyGO/T-Deck/issues/99#issuecomment-3329099006 2025-09-25 08:54:23 +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
Kilrah 1eb6fb0ebd Add new commands to allow reading raw key states 2025-06-11 21:58:37 +02:00
lewisxhe babfe1972c Fixed typo https://github.com/Xinyuan-LilyGO/T-Deck/issues/81 2025-04-07 09:59:43 +08:00
Michael HaslamandGitHub 11d463ceda Fix ledc error reported over serial on boot. 2025-03-16 00:10:11 +00:00
lewisxhe a120b94749 Fixed GPS Checksum 2025-02-22 15:40:19 +08:00
lewisxhe 057ad4480a Update example 2025-02-06 14:30:47 +08:00
lewisxhe 1faddb5d24 Fixed examples https://github.com/Xinyuan-LilyGO/T-Deck/issues/72 2025-01-20 11:31:13 +08:00
lewisxhe 94e88996b4 Update T-Deck keyboard example 2024-12-25 09:24:52 +08:00
lewisxhe 9d15775e79 Added keyboard backlight control function 2024-12-25 09:24:29 +08:00
lewisxhe 9ce2f1e215 Fixed SYM function https://github.com/Xinyuan-LilyGO/T-Deck/issues/70 2024-12-24 17:37:35 +08:00
lewisxhe ed76f64db5 Fixed the stuck boot screen caused by lack of LoRa 2024-12-20 11:09:44 +08:00
lewisxhe 5d21e58792 Fix typos and the backlight function key sends the character 'b' https://github.com/Xinyuan-LilyGO/T-Deck/issues/69 2024-12-18 09:11:31 +08:00
lewisxhe 7aa23db023 Added play mp3 examples https://github.com/Xinyuan-LilyGO/T-Deck/issues/63 2024-11-14 09:48:06 +08:00
lewisxhe c80bec1703 Add a simple example https://github.com/Xinyuan-LilyGO/T-Deck/issues/59 2024-10-24 15:18:53 +08:00
lewisxhe fb836ad925 Added SD example 2024-10-23 12:03:43 +08:00
lewisxhe 87a9c3ed41 Remove touch interrupt control. 2024-10-21 14:06:33 +08:00
lewisxhe 648bb8d0cd Added GPS Model info 2024-10-04 16:41:40 +08:00
Lewis HeandGitHub f85192ad49 Merge pull request #48 from hpsaturn/av/wifi_env_variables
Added alternative to set WiFi params via environment variables
2024-09-24 09:26:08 +08:00
Hpsaturn fae86efeec added alternative to set wifi params via env variables 2024-09-23 21:47:40 +02:00
lewisxhe 9ddebdf855 Fix example note 2024-09-23 09:21:13 +08:00
lewisxhe b6f0e57fc9 Update UnitTest example 2024-09-20 11:32:56 +08:00
lewisxhe 3fc6fd074b Update microphone example 2024-09-19 14:42:06 +08:00
lewisxhe 9394aa309b Added LoRaWan examples 2024-09-19 14:33:32 +08:00
lewisxhe 210367a171 Added missing header 2024-09-19 10:39:14 +08:00
lewisxhe 993ee80cab Fix Arduino IDE compilation 2024-09-18 14:05:14 +08:00
lewisxhe 83ecab13fa Update GPS example 2024-09-13 14:27:20 +08:00
lewisxhe 316d96d2b4 Update example 2024-09-13 11:41:01 +08:00
lewisxhe 6fd894ba47 Update examples 2024-09-13 11:40:37 +08:00
lewisxhe 12f68646e8 lvgl_example Touch interrupt method https://github.com/Xinyuan-LilyGO/T-Deck/issues/42 2024-09-04 09:33:21 +08:00
lewisxhe f979f22318 Added lvgl example 2024-09-02 11:39:46 +08:00
lewisxhe 36dbd54f45 Update GPS example 2024-09-02 09:26:56 +08:00