feat: Optimize .t42 loading and improve decoder fidelity
Build Linux / Build Linux (push) Successful in 1m29s
Build Windows / Build Windows (push) Successful in 4m46s

This commit is contained in:
Daniel Dybing
2026-02-21 20:44:26 +01:00
parent 18fef7b049
commit a15ba67b1a
4 changed files with 161 additions and 130 deletions
+21 -3
View File
@@ -65,9 +65,13 @@ class Page:
Can have multiple subpages.
"""
magazine: int
page_number: int # 00-99
sub_code: int = 0 # Subpage code (0000 to 3F7F hex usually, simplest is 0-99 equivalent)
language: int = 0 # National Option (0-7)
page_number: int # 00-99 (Hex storage: 0x00-0xFF)
sub_code: int = 0 # 13-bit subcode (0000 to 3F7F hex)
# Control bits C4-C14
control_bits: int = 0
language: int = 0 # National Option (0-7, from C12-C14)
packets: List[Packet] = field(default_factory=list)
@property
@@ -75,6 +79,20 @@ class Page:
# Format as Hex to support A-F pages
return f"{self.magazine}{self.page_number:02X}"
def get_control_bit(self, n: int) -> bool:
""" Returns value of control bit Cn (4-14) """
if 4 <= n <= 14:
return bool((self.control_bits >> (n - 4)) & 1)
return False
def set_control_bit(self, n: int, value: bool):
""" Sets value of control bit Cn (4-14) """
if 4 <= n <= 14:
if value:
self.control_bits |= (1 << (n - 4))
else:
self.control_bits &= ~(1 << (n - 4))
def calculate_crc(self) -> int:
"""
Calculates the CRC-16 checksum for the page.