Files
wadamesh/variants/tdisplay_p4/P4Audio.h
T
Kaj SchittecatandClaude Opus 4.8 2353c56adc p4: T-Display P4 port — web VNC/remote, time-sync hardening, brightness + sound
LilyGo T-Display P4 (ESP32-P4 + factory ESP-AT C6) reaches POC: LoRa mesh, Wi-Fi
companion (TCP:5000), GPS, SD, battery gauge, chat persistence, and now:

- Web VNC/REMOTE/terminal via a first-byte router on the single ESP-AT listener
  (HTTP verbs -> WS server, '<' frames -> phone companion; both live at once).
  C6Server gains a _begun gate so never-listening instances stay inert.
- VNC freeze fixed: bounded one-CIPSEND-chunk drains under the WS client mutex
  (a whole-band blocking write starved the main loop), fast-drop of stalled
  mirror clients, SEND-OK wait 8s->4s.
- Wi-Fi robustness: CWJAP? miss-streak tolerance, CIPSERVER liveness verify +
  re-arm (a re-association silently killed the listener until reboot).
- Time sync: HTTP-Date fallback when SNTP is blocked; ClockFloorRTC gains a
  MAX_PLAUSIBLE_EPOCH guard (all boards) after a garbage-future hardware RTC
  read (2043) latched the ratchet.
- Brightness: RM69A10 DCS 0x51 driven live (CC slider + persisted pref).
- Sound: ES8311 + NS4150B notification chimes (P4Audio, esp-bsp-derived
  register sequence on Wire1), full HAS_UI_SOUND surface + CC Screen/Sound
  sliders; ccVolumeReleaseCb's hardcoded tanBeep -> uiSoundPreview.
- tdisplay_p4/: IDF project (build.sh, c6_at AT-over-SDIO driver, sdkconfigs,
  fetch-deps.sh vendoring, .gitignore for local payloads).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-15 19:13:23 +02:00

15 lines
756 B
C

// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
// T-Display P4 speaker path: ES8311 codec (I²C_2, 0x18) + NS4150B class-D amp (always
// enabled in hardware — LilyGo routes no control pin) fed by I2S MCLK=13 BCLK=12 WS=9
// DOUT=10. Fixed 16 kHz / 16-bit stereo — plenty for notification chimes, tiny buffers.
// All calls are safe from any task; init is lazy on first use (~ms, I²C + I2S bring-up).
#include <stdint.h>
// Bring the codec + I2S up (idempotent). Returns false if the codec never answered.
bool p4AudioReady();
// Blocking sine tone: `amplitude` is the 16-bit peak (0..~30000; the UI uses pct*130).
// No-op (fast) when amplitude <= 0 or the codec is absent.
void p4AudioTone(int freq_hz, int duration_ms, int amplitude);