openhmi-nx: decode, encode, render Nextion HMI projects; .tft research
Black-box reverse-engineered .HMI format (container, three checksums, pages, all 31 component types, pictures, fonts), readable JSON, page renderer matching Nextion Editor, demo project built from code and a test suite (66 tests). See docs/COVERAGE.md for status. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
69e22cfb06
70 files changed
+25058
No files matched your search
@@ -0,0 +1,55 @@
|
||||
# Page rendering vs. Nextion Editor
|
||||
|
||||
`python -m nxhmi render project.HMI out/` draws every page the way Nextion Editor 1.68 shows it on
|
||||
its canvas. Verified by capturing the Editor's canvas at 100 % zoom and comparing pixel by pixel
|
||||
(ignoring the Editor's yellow name tags and its 2-px selection outline).
|
||||
|
||||
## Results
|
||||
|
||||
The demo project (`demo/demo.HMI`, built by `examples/make_demo.py`):
|
||||
|
||||
| Page | Differing pixels | Notes |
|
||||
|---|---|---|
|
||||
| home | 94 | all in the two radio buttons and at name-tag edges |
|
||||
| controls | 5 | name-tag edges |
|
||||
| gallery | 1 | name-tag edge |
|
||||
|
||||
A real 6-page user project (pictures, 32-px bitmap font, texts, 3D buttons, sliders): every page
|
||||
pixel-identical apart from 0-5 px at name-tag edges.
|
||||
|
||||
Per component (dedicated test pages):
|
||||
|
||||
| Component | Match | Notes |
|
||||
|---|---|---|
|
||||
| text (all xcen/ycen, solid / crop / image background, border, 3D up/down) | 100 % | |
|
||||
| text with word wrap | 100 % | the text block is aligned as a whole, lines left-aligned in it |
|
||||
| number (plain, fixed length, hex, currency, negative), xfloat | 100 % | |
|
||||
| button, dual-state button (colour and picture skins, on/off) | 100 % | "on" with 3D style is drawn pressed (3D down) |
|
||||
| scrolling text (static) | 100 % | |
|
||||
| progress bar (horizontal, vertical, picture mode) | 100 % | |
|
||||
| slider (horizontal, vertical, auto cursor, picture background and cursor) | 100 % | auto cursor = square as thick as the slider; position truncates |
|
||||
| checkbox (3D down, border, flat) | 100 % | |
|
||||
| picture, crop (also smaller than the component) | 100 % | only the picture's real area is drawn |
|
||||
| waveform (frame + grid) | 100 % | horizontal grid lines count from the bottom |
|
||||
| gauge | 99.3 - 100 % | needle anti-aliasing differs by a few px |
|
||||
| radio | ~93 - 97 % | circle outline/dot differ by +-1 px at some radii (work in progress) |
|
||||
| QR code | placeholder only | |
|
||||
| hotspot, touch cap, timer, variable | nothing drawn (same as the Editor) | |
|
||||
|
||||
## Rules learned from the Editor
|
||||
|
||||
- Text never starts above/left of its box: centring clamps at 0 (a 32-px font in a 30-px box
|
||||
starts at the top).
|
||||
- Text is laid out inside the border: 1 px for 3D styles, `borderw` for style "border".
|
||||
- 3D colours are fixed: light (230,226,230), dark (65,68,65) -- top/left light for 3D up/auto,
|
||||
dark for 3D down.
|
||||
- Buttons with a picture background (`sta` crop or image) get no frame.
|
||||
- Pictures are pasted at their real size; a smaller picture leaves the rest untouched.
|
||||
- Checkbox: `bco` fill, `style` frame, checked = `pco` square from w/4 to 3w/4.
|
||||
- Radio: circle sized by the component *width* (clipped to the height); ring radius
|
||||
`(w-1)//2`, colour (65,68,65), filled with `bco`; checked = `pco` dot.
|
||||
- Slider: auto cursor (255) is a square as thick as the slider; position = `int(frac * free)`.
|
||||
- Waveform: vertical grid lines from the left edge, horizontal ones counted from the bottom.
|
||||
|
||||
Not covered yet: exact radio circles, QR codes, Intelligent-only components (need Intelligent
|
||||
picture format 4), anti-aliased fonts, pressed/runtime states.
|
||||
Reference in new issue
Block a user