CYD LeetCode daily
~/personal/experiments/cyd/Leetcode/Leetcode.ino. Pulls LeetCode’s daily
question and scrolls it on the CYD.
How it works
Section titled “How it works”- Fetch:
POST https://leetcode.com/graphql, queryquestionOfToday { activeDailyCodingChallengeQuestion }→ title, frontend id, difficulty, HTML body. No auth needed. - Sanitize:
sanitizeHtml()strips tags; the body arrives as HTML. - Render: TFT_eSPI,
setRotation(0)(portrait). Text is pre-wrapped intowrappedLines, drawn a window at a time. - Scroll: auto-advances one line per second, wraps at the end.
- Touch: any touch toggles auto-scroll on/off. 300 ms debounce, no coordinate regions — the whole screen is the button.
- Refresh: hourly (
fetchInterval = 3600000).
Wiring
Section titled “Wiring”Touch is XPT2046 on its own SPI bus, separate from the display:
IRQ 36, MOSI 32, MISO 39, CLK 25, CS 33. Display pins come from TFT_eSPI’s
config, not this sketch — a wrong User_Setup.h is the usual cause of a white
or mirrored screen. TouchTest/ in the same folder isolates the touch side.
Gotchas
Section titled “Gotchas”- WiFi is a hardcoded array of SSID/password structs, tried in order with a 10 s timeout each. Adding a network means reflashing.
DynamicJsonDocument(8192)— a long question body will silently truncate. Failures show asJSON Error/API Erroron screen; check serial for more.leetcode.txtalongside is an older copy of the sketch, not a data file. The two have diverged;.inois the real one.