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,37 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
sys.path.insert(0, os.path.join(ROOT, "src"))
|
||||
FIXTURE = os.path.join(ROOT, "tests", "fixtures", "demo_editor_saved.HMI")
|
||||
|
||||
try:
|
||||
import PIL # noqa: F401
|
||||
HAVE_PIL = True
|
||||
except ImportError:
|
||||
HAVE_PIL = False
|
||||
|
||||
|
||||
def demo_project():
|
||||
"""The demo project, built from code (needs Pillow)."""
|
||||
sys.path.insert(0, os.path.join(ROOT, "examples"))
|
||||
import make_demo
|
||||
return make_demo.build()
|
||||
|
||||
|
||||
def bitwise_word_crc(data, crc=0xFFFFFFFF):
|
||||
"""Reference: STM32-style CRC-32, each byte zero-extended to a 32-bit word, bit by bit."""
|
||||
for b in data:
|
||||
crc ^= b
|
||||
for _ in range(32):
|
||||
crc = ((crc << 1) ^ 0x04C11DB7) & 0xFFFFFFFF if crc & 0x80000000 else (crc << 1) & 0xFFFFFFFF
|
||||
return crc
|
||||
|
||||
|
||||
def bitwise_dword_crc(data, crc=0xFFFFFFFF):
|
||||
"""Reference: STM32-style CRC-32 over little-endian 32-bit words, bit by bit."""
|
||||
for i in range(0, len(data), 4):
|
||||
crc ^= int.from_bytes(data[i:i + 4], "little")
|
||||
for _ in range(32):
|
||||
crc = ((crc << 1) ^ 0x04C11DB7) & 0xFFFFFFFF if crc & 0x80000000 else (crc << 1) & 0xFFFFFFFF
|
||||
return crc
|
||||
Reference in new issue
Block a user