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:
mangavalkandClaude Opus 5.5 committed 2026-11-15 15:11:02 +01:00
commit 69e22cfb06
70 files changed
+25058

No files matched your search

+35
View File
@@ -0,0 +1,35 @@
import unittest
import helpers # noqa: F401
from nxhmi import enums
class Enums(unittest.TestCase):
def test_colours_exact_roundtrip(self):
for v in range(0, 0x10000, 37):
self.assertEqual(enums.hex_to_rgb565(enums.rgb565_to_hex(v)), v)
self.assertEqual(enums.rgb565_to_hex(0xF800), "#ff0000")
def test_general_and_per_type(self):
self.assertEqual(enums.to_label(116, "xcen", "u8", 2), "right")
self.assertEqual(enums.to_label(52, "sta", "u8", 1), "string") # variable type
self.assertEqual(enums.to_label(121, "sta", "u8", 0), "no background")
self.assertEqual(enums.to_label(58, "sta", "u8", 1), "has") # QR logo
self.assertEqual(enums.to_label(98, "style", "u8", 4), "3D_Auto")
self.assertEqual(enums.to_label(116, "style", "u8", 4), 4) # not a text style
def test_from_label(self):
self.assertEqual(enums.from_label(116, "xcen", "u8", "Center"), 1)
self.assertEqual(enums.from_label(116, "bco", "u16", "#ffffff"), 0xFFFF)
self.assertEqual(enums.from_label(116, "x", "u16", 7), 7)
self.assertEqual(enums.from_label(116, "x", "u16", "0x10"), 16)
with self.assertRaises(ValueError):
enums.from_label(116, "xcen", "u8", "sideways")
def test_strings_untouched(self):
self.assertEqual(enums.to_label(116, "txt", "str", "#abc"), "#abc")
if __name__ == "__main__":
unittest.main()