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:
mangavalkandClaude Opus 5.5 committed 2026-11-15 16:36:10 +01:00
1 parent 842591a14c
commit a93cb58b96
7 files changed
+77 -21

No files matched your search

+16
View File
@@ -22,6 +22,22 @@ class NewProject(unittest.TestCase):
self.assertEqual(Page.parse(h.read("0.pa")).name, "start")
self.assertEqual(project.project_size(h), (480, 320))
def test_direction_and_encoding(self):
# measured in the Editor: Basic panels are portrait at 0 degrees, Intelligent landscape
basic = project.new_project("NX4832T035_011")
self.assertEqual(basic.read("main.HMI")[12:14], bytes([1, 3])) # 90 degrees, iso-8859-1
tall = project.new_project("NX4832T035_011", portrait=True)
self.assertEqual(tall.read("main.HMI")[12], 0)
self.assertEqual(project.project_size(tall), (320, 480))
intel = project.new_project("NX4827P043_011")
self.assertEqual(intel.read("main.HMI")[12], 0)
self.assertEqual(project.project_size(intel), (480, 272))
info = project.parse_main(project.new_project(encoding="utf-8").read("main.HMI"))
self.assertEqual((info["direction"], info["encoding"]), (90, "utf-8"))
self.assertEqual(models.ENCODINGS["gb2312"], 2)
with self.assertRaises(ValueError):
project.new_project(encoding="latin-9")
def test_every_model(self):
for name, (mid, series, w, hgt) in models.MODELS.items():
h = project.new_project(name)