All five display series; exact component colours; Editor's literal rule for format 4

- 15 more models (Discovery, Enhanced, Edge, NX8048P043): ids and series bytes 1/6/100 from the
  Editor; native orientation per series; Discovery/Enhanced/Edge use the Basic templates
- per series picture format and storage direction: Enhanced like Basic, Edge format 4,
  Discovery format 3 (20 zero bytes + raw RGB565) always stored row by row; fonts likewise
- component colours are scaled (v*255//31) on every series -- exact against the canvas with zero
  tolerance; format-0 pictures stay bit-replicated
- format-4 encoder: literal pixels when the next 8 runs cover <= 10 pixels (7+ runs), 8 pixels at
  a time -- reproduces the Editor on 12 designed patterns plus the 28 earlier samples

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mangavalkandClaude Opus 5.5 committed 2026-11-16 14:35:50 +01:00
1 parent 922ca21f0f
commit ec35ceb615
9 files changed
+145 -62

No files matched your search

+4 -5
View File
@@ -16,7 +16,7 @@ byte for byte, or a file written by nxhmi was opened in the Editor and showed th
| Pictures | **complete**: format 0 (Basic) and format 4 (Intelligent, with alpha; run-length or JPEG for quality < 100), all display directions |
| Fonts | **complete**: single- and multi-byte encodings (GB2312, Big5, Shift-JIS, KS C 5601, UTF-8), black/white and the anti-aliasing flag, overhanging glyphs, all display directions; generation from TrueType for all of them |
| Rendering pages like the Editor | **pixel-identical** for every Basic component and 9 of 11 Intelligent-only ones; ComboBox and Switch approximate at anti-aliased edges |
| New projects from scratch | `project.new_project(model)` for 12 Basic/Intelligent models; the generated demo is byte-identical to the Editor's re-save |
| New projects from scratch | `project.new_project(model)` for all 27 models of the 5 series; the generated demo is byte-identical to the Editor's re-save |
| Compiling `.tft` firmware | **research only** -- not possible yet |
## How the percentages in the README are counted
@@ -93,7 +93,6 @@ byte for byte, or a file written by nxhmi was opened in the Editor and showed th
### `.HMI` side
| Item | Notes |
|---|---|
| Other display series | Discovery / Enhanced / Edge not sampled; only Basic + Intelligent templates |
| Display direction | byte 12 decoded and written (`new_project(portrait=...)`); picture order verified for all four (format 4); font glyph order verified for 0° and 90° |
| Some header fields | main.HMI bytes 8, 13, 36, 0x41; page header 21/23; entry bytes 25-27 |
| Font name shown in the Editor's Fonts panel | cosmetic, generated fonts show an odd label |
@@ -118,6 +117,6 @@ byte for byte, or a file written by nxhmi was opened in the Editor and showed th
| Licensing | every `.tft` embeds Nextion's firmware files; the repo must never ship them -- a builder would read them from the user's own Editor installation |
## Suggested next steps
1. Intelligent picture format 4 (needed for Intelligent displays).
2. `.tft`: try the remaining trailer-checksum ideas listed in NOTES.md; then the compiled page format.
3. Sample the other display series to confirm templates and picture order.
1. `.tft`: try the remaining trailer-checksum ideas listed in NOTES.md; then the compiled page format.
2. The anti-aliasing routine of Intelligent rounded shapes (switch knob/track, ComboBox).
3. Picture quality < 100 on Edge (JPEG variant) -- not tried.
+19 -4
View File
@@ -61,7 +61,7 @@ primary table from the backup, among other things) -- never reuse a test file af
| 8 | 1 | 1 (**OPEN**) |
| 9 | 1 | 0x41 in a 2019 file, 0x44 after saving with Editor 1.68 (Editor/format revision?) |
| 10 | 1 | 0x21 |
| 11 | 1 | display series: 0 = Basic (T), 3 = Intelligent (P); others **OPEN** |
| 11 | 1 | display series: 0 = Basic (T), 1 = Enhanced (K), 3 = Intelligent (P), 6 = Edge (E), 100 = Discovery (F) |
| 12 | 1 | display direction in 90° steps (Setting > Display: 0 = 0°, 1 = 90°, 2 = 180°, 3 = 270°). Basic panels are portrait at 0°, so a 480×320 Basic project has 1; Intelligent panels are landscape at 0°. Page sizes follow (the Editor shows a 480×272 Intelligent project with 1 as 272×480). An unsupported value made the Editor fail to load ("'null' is not a supported encoding name") |
| 13 | 1 | character encoding (Setting > Display): 1 ascii, 2 gb2312, 3 iso-8859-1, 4-11 iso-8859-2..9, 12 iso-8859-13, 13 iso-8859-15, 14 iso-8859-11, 15 ks_c_5601-1987, 16 big5, 17-20 windows-1255..1258, 21 windows-874, 22 koi8-r, 23 shift-jis, 24 utf-8 (all measured; `models.ENCODINGS`) |
| 14 | 1 | 0x4F |
@@ -196,7 +196,7 @@ PNG that was imported):
| Offset | Size | Field |
|---|---|---|
| 0 | 4 | `0B 64 01 <format>` -- 0 = raw RGB565 (Basic series), 4 = compressed (Intelligent, **OPEN**) |
| 0 | 4 | `0A+direction, quality, 01, <format>` -- 0 = raw RGB565 (Basic, Enhanced), 3 = raw with a 20-byte zero header (Discovery), 4 = run-length or JPEG (Intelligent, Edge) |
| 8 | 4 | data offset = 24 |
| 12 | 2+2 | width, height |
| 16 | 4 | data length (format 0: w × h × 2) |
@@ -206,6 +206,19 @@ panel's native scan order -- column by column, each column bottom-to-top:
`offset = 2 * (x * height + (height - 1 - y))`. Verified pixel-exact (480×320 and 64×64, Editor
output byte-identical to ours). The order follows the display direction, see format 4.
Per series (measured by letting Editor 1.68 convert our pictures/fonts in each series):
| Series | Picture format | Stored direction (pictures and fonts) | Font glyph data |
|---|---|---|---|
| Basic, Enhanced | 0 | project direction | unpadded |
| Intelligent | 4 | project direction | 8-byte aligned |
| Edge | 4 (same encoder, same rules) | project direction | unpadded (accepted as is) |
| Discovery | 3: 20 zero bytes, then raw RGB565 | always 0 (row by row), whatever the project direction | 8-byte aligned |
Discovery, Enhanced and Edge offer the 20 Basic component types (the Intelligent-only ones are
greyed out) with exactly the Basic default attributes; Enhanced and Edge draw like Basic on the
canvas (3D frame order, colours).
Format 4 (Intelligent series) -- decoded and re-encoded byte-identically (28 Editor samples, all
four directions, with and without alpha):
@@ -227,8 +240,10 @@ four directions, with and without alpha):
with zero slots to 8.
- How the Editor encodes: split the pixels into runs of one colour of at most 13; pack 8 runs
per block; a block of eight 13-runs of one colour becomes op 14 (consecutive such blocks merge,
N = 104 × blocks, at most 39); a block of eight single pixels becomes a literal block
(consecutive ones merge, N = 8 × blocks).
N = 104 × blocks, at most 39). Busy stretches become literal pixels: when the next block would
have at least 7 runs covering at most 10 pixels (and 8+ pixels are left), the next **8 pixels**
go into a literal block, and this repeats (merging) while the condition holds (12 designed run
patterns, plus the 28 samples).
- Alpha section: 7-bit alpha (`a * 127 // 255`) per pixel in storage order, run-length coded --
a byte with bit 7 set is one pixel of alpha `b & 0x7F`, otherwise `b` is the alpha and the next
byte the run length (≤ 255). Fully transparent pixels store colour 0.
+5 -3
View File
@@ -51,9 +51,11 @@ TextSelects, several of each other type):
## Rules learned from the Editor
- Colours: RGB565 is expanded differently per series. Basic replicates the top bits
(`r<<3 | r>>2`); Intelligent scales (`r*255//31`, `g*255//63`), so `0xC618` shows as
(198,195,198) on Basic and (197,194,197) on Intelligent.
- Colours: component colours (bco, pco, ...) are scaled on every series (`r*255//31`,
`g*255//63`), so `0xC618` shows as (197,194,197); format-0 picture pixels are bit-replicated
(`r<<3 | r>>2`); format-3/4 pictures as decoded. (Until 2026-11 nxhmi replicated component
colours on Basic -- off by one level in some channels; earlier comparisons used a tolerance
that hid it. Now checked with zero tolerance on Basic, Enhanced, Discovery and Edge.)
- Intelligent 3D frames draw the left edge after the bottom one (dark bottom-left corner on
3D down); Basic draws it the other way round.
- TextSelect: items (`path`, CR LF separated) in cells of `hig` rows inside the frame; the