Support every datasheet command and map text to the CG-ROM fonts

- Brightness, blink, screen on/off, annunciators, cursor control, display
  modes, user-defined characters, code table, international charset,
  peripheral select, self-test, raw writes and reinit
- UTF-8 text is encoded with the selected code table (tables generated
  from Python codecs by tools/gen_charmaps.py), falling back to
  accent-stripping
- Settings survive reinit and the self-test
- Example gains brightness select and display switch, and uses the git
  source on mangavalk.com

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mangavalkandClaude Opus 5.5 committed 2026-10-31 17:55:36 +01:00
1 parent 3fcd15ad86
commit 95686a3608
8 files changed
+1322 -148

No files matched your search

+34 -19
View File
@@ -1,22 +1,27 @@
# CLAUDE.md
ESPHome external component for a Samsung 20L203 2×20 serial VFD (RS-232
input, 9600 8N1, write-only). It is consumed from git by an ESPHome server through
`external_components: source: github://...`, so the layout must stay
input, write-only, factory default 9600 8N1). An ESPHome server consumes it
from git (`https://mangavalk.com/mangavalk/esphome-samsung-vfd`, a self-hosted
server, so `type: git` with a URL, not `github://`). The layout must stay
`components/samsung_vfd/` at the repo root.
## Layout
- `components/samsung_vfd/__init__.py`: config schema, codegen and the action
registrations (`print`, `printf`, `clear`, `home`).
- `components/samsung_vfd/samsung_vfd.h`: the class, the control-byte constants
and the templated action classes.
- `components/samsung_vfd/__init__.py`: the config schema (size, brightness,
code table, international charset, user characters), codegen and every
`samsung_vfd.*` action registration.
- `components/samsung_vfd/samsung_vfd.h`: the protocol constants, enums, the
class and the templated action classes.
- `components/samsung_vfd/samsung_vfd.cpp`: the shadow buffer, word wrap,
UTF-8 → single-byte sanitising and `flush_()`.
UTF-8 → display byte encoding, settings re-apply and the raw commands.
- `components/samsung_vfd/charmaps.h`: **generated** by
`python tools/gen_charmaps.py`; don't edit it by hand.
- `docs/20L203DA12-datasheet.pdf`: the command set (section 5.4), jumpers,
wiring and the character tables. Check it before adding protocol features.
wiring and the CG-ROM tables (section 6). Check it before changing the
protocol.
- `examples/samsung-vfd.yaml`: the full reference device config. It pulls the
component from GitHub; for local work, switch to the commented
component from git; for local work, switch to the commented
`type: local, path: ../components` source.
## Design rules
@@ -25,17 +30,26 @@ input, 9600 8N1, write-only). It is consumed from git by an ESPHome server throu
Every change goes through `flush_()`. It rebuilds the payload, returns early
if the payload equals `last_payload_`, and otherwise sends `0B` (home) plus
the payload. Don't clear before redrawing: that causes flicker.
- Anything that changes the display out of band (clear, init) must reset
`last_payload_` so the next flush retransmits.
- Anything that changes the screen out of band (clear, init, raw writes, CAN,
user-character changes, the self-test) must call `invalidate_()` so the next
flush retransmits.
- Settings (brightness, blink/on, annunciators, code table, charset, user
characters, mode) are stored in members and re-sent by `apply_settings_()`
after `ESC @` (`reinit()`) and after the self-test. A new setting must be
added there too.
- Text sent to the display is one byte per character; always pass it through
`sanitize_()`.
- Keep the protocol constants in `samsung_vfd.h`. The display boots in
overwrite mode: the cursor wraps from the end of line 1 to line 2 and from
the end of line 2 back home, and nothing scrolls. A full-screen redraw is
therefore `0B` plus `rows × cols` characters.
`encode()`, which uses the current code table, then strips accents, then
falls back to `?`.
- The display boots in overwrite mode: the cursor wraps from the end of line 1
to line 2 and from the end of line 2 back home, and nothing scrolls. The
buffered text API depends on this; the scroll modes are only for raw writes.
- The RXD input is RS-232. The reference build uses a MAX3232 (no inversion
in config); a directly wired ESP32 pin needs `inverted: true` on the UART TX
pin.
pin. Baud rate and parity come from the board's jumpers, so they are not
validated by the component.
- User characters: up to 4, codes 0x20–0x7E. Each is 5 column bytes, bit 6 =
top row. `pattern_to_columns()` must turn the datasheet's `$` example into
`12 2A 7F 2A 24`.
## Checking changes
@@ -49,8 +63,9 @@ esphome config samsung-vfd.yaml # schema check
esphome compile samsung-vfd.yaml # full C++ build
```
`secrets.yaml` is gitignored. Copy `examples/secrets.yaml.example` to
`examples/secrets.yaml` to compile.
On Windows, run the compile from PowerShell or cmd, not Git Bash: the ESP-IDF
installer refuses MSYS shells. `secrets.yaml` is gitignored. Copy
`examples/secrets.yaml.example` to `examples/secrets.yaml` to compile.
Follow ESPHome C++ style: `this->` on members, a trailing `_` on protected
members, and the `esphome::samsung_vfd` namespace.