Files
Dejvino 1dcc87d8d4 Fix trackball click: I2S MCLK was claiming GPIO0; emulator pin-ownership parity
Root cause (on device): sound_engine zero-initialized i2s_pin_config_t,
leaving mck_io_num == 0. i2s_set_pin() then claimed GPIO0 — an
MCLK-capable pin on the S3 and the trackball centre / BOOT line — as
its MCLK output. Verified on device with a diagnostic build: pin0 read
LOW at idle, exactly one latched FALLING edge, clicks never registered.

- sound_engine: set pins.mck_io_num = I2S_PIN_NO_CHANGE explicitly.
- NetDeck: register the trackball click on release with contact-bounce
  collapse (the proven CrtTerminal pattern); pollTouch re-arms when
  isPressed() stays true but getPoint() reports no points (stuck GT911
  IRQ on some units).
- Emulator parity (so this class of bug dies before flashing):
  GPIO-matrix pin-ownership model in the shim — i2s_set_pin() claims
  its pins, claimed pins are dead inputs (digitalRead LOW, no edges,
  loud WARNING on claim/ISR collisions); host pin writes go through
  emu::setPin/togglePin with an edge-accurate ISR latch (a full
  press+release pulse between dispatches no longer gets swallowed);
  E2E inits SDL_INIT_AUDIO so the I2S path actually runs there.
  Regression coverage: e2e/trackball_click (fails on the old engine),
  unit/shim_claimed_pin_is_dead_input,
  unit/shim_edge_survives_same_dispatch_pulse.
- Makefile: firmware step follows the sketch move (root platformio.ini,
  src_dir = src/netdeck).
- HW.md: new notes file for emulator-vs-hardware quirks and the
  on-device debugging recipe.

On-device verified: clicks register in both views (beacon drops, node
routing). Fast layer 23 unit + 7 integration green. Note: e2e
boot_and_controls + network_journey failures are pre-existing at HEAD
(reproduced on a clean stash before this change).
2026-11-15 10:24:30 +01:00

39 lines
1022 B
C++

/**
* @file shim_globals.cpp
* @brief Definitions of the shim globals that src/main.cpp normally owns.
*
* Both test binaries (NetDeck-tests, NetDeck-e2e) link this instead of
* main.cpp, so they get the shim environment without the SDL window/event
* host loop. The sketch itself is included by each test's own TU (single-TU
* inclusion, same trick main.cpp uses).
*/
#include "Arduino.h"
#include "TFT_eSPI.h"
#include "Wire.h"
#include "SPI.h"
namespace emu {
uint8_t pinLevels[64];
const char *pinDrivenBy[64];
std::deque<PinEdge> pinEdges;
bool touchDown = false;
int touchX = 0, touchY = 0;
std::deque<uint8_t> keyboard;
bool quitRequested = false;
} // namespace emu
namespace emuGfx {
uint32_t fb[320 * 240];
SDL_Texture *tex = nullptr;
bool dirty = true;
} // namespace emuGfx
SerialSim Serial;
TwoWire Wire;
SPIClass SPI;
const FreeFontStub FreeSansBold24pt7b {0};
const FreeFontStub FreeSansBold18pt7b {0};
const FreeFontStub FreeSansOblique12pt7b {0};
const FreeFontStub FreeSans12pt7b {0};