Render gauge needles pixel-exact

The needle is the display's own routine, measured on 112 needles in the
Editor simulator: tip from quadrant-reduced sin/cos, truncated; line from
tip to centre with a biased DDA; wider needles stamp wid x wid squares
along a line shortened by wid - 1. Length follows the height.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mangavalkandClaude Opus 5.5 committed 2026-11-15 16:05:41 +01:00
1 parent 9b50eea03f
commit f0bcc608b1
7 files changed
+67 -14

No files matched your search

+1 -1
View File
@@ -15,7 +15,7 @@ byte for byte, or a file written by nxhmi was opened in the Editor and showed th
| Readable JSON (enum names, colours) | done for every value list the Editor documents |
| Pictures | Basic series **complete**; Intelligent compressed format **missing** |
| Fonts | black/white **complete** incl. generation from TrueType; anti-aliased **missing** |
| Rendering pages like the Editor | **pixel-identical** for most components incl. picture skins; radio ~93-97 %, QR placeholder |
| Rendering pages like the Editor | **pixel-identical** for most components incl. picture skins, radios and gauges; QR placeholder |
| 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 |
| Compiling `.tft` firmware | **research only** -- not possible yet |
+9 -2
View File
@@ -10,7 +10,7 @@ The demo project (`demo/demo.HMI`, built by `examples/make_demo.py`):
| Page | Differing pixels | Notes |
|---|---|---|
| home | 30 | name-tag edges (checkbox) and gauge needle anti-aliasing |
| home | 25 | name-tag edges (checkbox, buttons) |
| controls | 5 | name-tag edges |
| gallery | 1 | name-tag edge |
@@ -31,7 +31,7 @@ Per component (dedicated test pages):
| 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 |
| gauge (every angle, needle width 1-8, odd/even/non-square sizes) | 100 % | the needle routine, see below |
| radio (all sizes, also non-square) | 100 % | the display's own circle routine, see below |
| QR code | placeholder only | |
| hotspot, touch cap, timer, variable | nothing drawn (same as the Editor) | |
@@ -53,6 +53,13 @@ Per component (dedicated test pages):
start at `x = r, y = 0`; plot the 8 symmetric points; `y += 1`; if
`x*x - x + y*y + 2*y > r*r + 1` then `x -= 1`; repeat while `x >= y`. Filled circles are every
pixel inside that ring. Verified for every radius 1..159 against the Editor's simulator.
- Gauge needle (verified on 112 needles): centre `(w//2, h//2)`, length `h//2 - wid` (the
*height* sets it, also for non-square gauges, so the needle can leave the box). Tip =
centre + `(int(-len*cos a), int(-len*sin a))` with `val` in degrees, 0 = left, 90 = up, where
sin/cos are taken after reducing the angle to 0..90 degrees (so `sin 30` is a hair under 0.5
and `24*sin 30` truncates to 11). The line runs from the tip to the centre: step the major
axis, minor offset `(k*minor + minor - 1) // major`. Width > 1: every line pixel is stamped
with a `wid` x `wid` square starting at `-(wid//2)`.
- 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.