Public Access
Rewrite Nano serial parser as line based, fix protocol bugs
- Commands run on '\n' instead of busy-waiting for a byte count, which fixes s/F/T waiting for the next command and P drawing 0xFF garbage - Invalid bitmaps no longer leak their data as commands; bitmap data is streamed so full-screen bitmaps still fit - Store flip time as uint16 with magic marker, validate 50-2000 us - Overflow-safe millis() handling for the periodic refresh - Run the full refresh only after D or when serial is idle, so incoming data is not lost while the redraw blocks - Put the boot refresh measurement behind MEASURE_REFRESH - Fix DEBUG hex output and use F() strings to save RAM - Driver: direct mode now updates the old buffer instead of re-setting the new one Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
459937352a
commit
f1dbc35ebd
4 files changed
+328
-231
No files matched your search
+27
-10
@@ -8,18 +8,33 @@ logic.
|
||||
|
||||
## Behaviour
|
||||
|
||||
- **Boot:** the Nano flips the whole display on and then off, then prints the time a full
|
||||
redraw took.
|
||||
- **Boot:** the Nano loads the flip time from EEPROM and flips the whole display on and
|
||||
then off.
|
||||
- **`display()`:** compares the new buffer with the last one that was shown and strobes
|
||||
only the dots that changed.
|
||||
- **Every 2 minutes** (`REFRESH_TIME`) it forces a full redraw to fix dots that got stuck.
|
||||
- **Flip pulse length** (µs) is set with the `T` command and stored in EEPROM, so it is
|
||||
kept after a reboot.
|
||||
- **Every 2 minutes** (`REFRESH_TIME`) it does a full redraw to fix dots that got stuck.
|
||||
A full redraw blocks for about half a second, which is long enough to overflow the
|
||||
64-byte serial buffer. So it only runs right after a `D` (the end of a frame, when the
|
||||
ESP is quiet) or when no serial data has arrived for 2 seconds.
|
||||
- **Flip pulse length** (µs, 50–2000) is set with the `T` command and stored in EEPROM,
|
||||
so it is kept after a reboot. The default is 200 µs.
|
||||
|
||||
### Debug options
|
||||
|
||||
Uncomment these at the top of `main.cpp`:
|
||||
|
||||
| Define | Effect |
|
||||
|--------|--------|
|
||||
| `DEBUG` | Print unknown command bytes on the serial port |
|
||||
| `MEASURE_REFRESH` | At boot, time a full redraw and print the duration in ms |
|
||||
|
||||
## Serial protocol
|
||||
|
||||
Each command is one ASCII line. Coordinates are 2-digit **hex**. Color is `0` (black) or
|
||||
`1` (yellow). The ESP32 driver (`ESPSERIAL`) only uses `s`, `S`, `F`, `D` and `T`.
|
||||
Each command is one ASCII line that **ends with `\n`** (`\r` is ignored). The Nano
|
||||
collects a whole line before it runs the command. If a line is broken or unknown, it is
|
||||
skipped and the next line starts clean. Coordinates are 2-digit **hex**. Color is `0`
|
||||
(black) or `1` (yellow). The ESP32 driver (`ESPSERIAL`) only uses `s`, `S`, `F`, `D` and
|
||||
`T`.
|
||||
|
||||
| Cmd | Format | Meaning |
|
||||
|-----|--------|---------|
|
||||
@@ -27,10 +42,12 @@ Each command is one ASCII line. Coordinates are 2-digit **hex**. Color is `0` (b
|
||||
| `S` | `SXXYYc` | Set pixel and flip it right away (direct mode) |
|
||||
| `F` | `Fc` | Fill the whole buffer |
|
||||
| `D` | `D` | Push the buffer to the display (changed dots only) |
|
||||
| `P` | `PXXYYcsTEXT` | Print text at (XX,YY), color `c`, size `s`. `\n` in TEXT starts a new line. |
|
||||
| `B` | `BXXYYWWHHcHEX...` | Draw a bitmap. WW must be a multiple of 4. Pixel data is one hex digit per 4 pixels. |
|
||||
| `P` | `PXXYYcsTEXT` | Print text at (XX,YY), color `c`, size `s`. A literal `\n` (backslash, n) in TEXT starts a new line. The whole line can be at most 64 characters. |
|
||||
| `B` | `BXXYYWWHHcHEX...` | Draw a bitmap. WW must be a multiple of 4. Pixel data is one hex digit per 4 pixels, row by row. The data is drawn while it arrives, so it is not limited to 64 characters. |
|
||||
| `R` | `R` | Print the buffer as ASCII art on the serial port |
|
||||
| `T` | `Tnnn` | Set the flip pulse length in µs (decimal), stored in EEPROM |
|
||||
| `T` | `Tnnn` | Set the flip pulse length in µs (decimal, 50–2000), stored in EEPROM |
|
||||
|
||||
Invalid commands get a reply that starts with `ERR:` on the Nano's TX pin.
|
||||
|
||||
Example (what the ESP32 sends for one pixel and a refresh):
|
||||
|
||||
|
||||
Reference in new issue
Block a user