Display direction and character encoding in main.HMI
Byte 12 is the display direction (90-degree steps) and byte 13 the character encoding -- the docs had them swapped. Basic panels are portrait at 0 degrees, Intelligent ones landscape, so new Intelligent projects used to open in portrait. new_project takes portrait= and encoding=; all 24 Editor encodings are mapped; parse_main reports both. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
842591a14c
commit
a93cb58b96
7 files changed
+77
-21
No files matched your search
+28
-2
@@ -23,8 +23,34 @@ MODELS = {
|
||||
BY_ID = {v[0]: k for k, v in MODELS.items()}
|
||||
SERIES = {0: "Basic", 3: "Intelligent"}
|
||||
|
||||
# main.HMI text-encoding index (offset 12). Only the value seen in real projects is listed.
|
||||
ENCODINGS = {"iso-8859-1": 1}
|
||||
# main.HMI offset 12: display direction, in 90-degree steps as chosen in the Editor
|
||||
# (Setting > Display: 0 / 90 / 180 / 270). Basic panels are portrait at 0 degrees, so the
|
||||
# landscape sizes listed above need 90 or 270; Intelligent panels are landscape at 0 and 180.
|
||||
NATIVE_PORTRAIT = {0: True, 3: False}
|
||||
|
||||
|
||||
def direction_byte(model: str, landscape: bool = True, flipped: bool = False) -> int:
|
||||
"""main.HMI byte 12 for a landscape/portrait project on this model (flipped = +180 degrees)."""
|
||||
portrait_native = NATIVE_PORTRAIT[lookup(model)[1]]
|
||||
return (1 if landscape == portrait_native else 0) + (2 if flipped else 0)
|
||||
|
||||
|
||||
def page_size(model: str, direction: int):
|
||||
"""(width, height) of the pages for main.HMI byte 12 = direction."""
|
||||
_, series, w, h = lookup(model)
|
||||
landscape = (direction % 2 == 1) == NATIVE_PORTRAIT[series]
|
||||
return (w, h) if landscape else (h, w)
|
||||
|
||||
|
||||
# main.HMI offset 13: character encoding, value -> name as in the Editor's Setting > Display list.
|
||||
# Measured by choosing each entry in Nextion Editor 1.68 and saving.
|
||||
ENCODINGS = {
|
||||
"ascii": 1, "gb2312": 2, "iso-8859-1": 3, "iso-8859-2": 4, "iso-8859-3": 5, "iso-8859-4": 6,
|
||||
"iso-8859-5": 7, "iso-8859-6": 8, "iso-8859-7": 9, "iso-8859-8": 10, "iso-8859-9": 11,
|
||||
"iso-8859-13": 12, "iso-8859-15": 13, "iso-8859-11": 14, "ks_c_5601-1987": 15, "big5": 16,
|
||||
"windows-1255": 17, "windows-1256": 18, "windows-1257": 19, "windows-1258": 20,
|
||||
"windows-874": 21, "koi8-r": 22, "shift-jis": 23, "utf-8": 24,
|
||||
}
|
||||
|
||||
|
||||
def lookup(model: str):
|
||||
|
||||
Reference in new issue
Block a user