Support Hexadecimal Page Numbers (e.g. 1FF, 12E)

- Refactored  to parse page numbers as nibbles ((T<<4)|U) instead of decimal, preventing collisions between hex and decimal pages.
- Updated  to format page IDs as Hex.
- Updated  to display page IDs as Hex in the list.
- Ensures filler/housekeeping pages are correctly isolated.
This commit is contained in:
2026-01-11 11:52:29 +01:00
parent 8c393c8f9e
commit 4b7b73e9a3
3 changed files with 11 additions and 3 deletions

View File

@@ -191,7 +191,13 @@ def parse_header(data: bytearray):
pu = decode_hamming_8_4(data[0])
pt = decode_hamming_8_4(data[1])
page_num = (pt & 0xF) * 10 + (pu & 0xF)
# Use BCD/Hex-like storage: High nibble is Tens, Low nibble is Units.
# This preserves Hex pages (A-F) without colliding with decimal pages.
# E.g. Page 1FF -> Tens=F(15), Units=F(15) -> 0xFF (255)
# Page 12E -> Tens=2, Units=E(14) -> 0x2E (46)
# Page 134 -> Tens=3, Units=4 -> 0x34 (52)
# 0x2E != 0x34. No collision.
page_num = ((pt & 0xF) << 4) | (pu & 0xF)
# Subcode: S1, S2, S3, S4
# S1 (low), S2, S3, S4 (high)

View File

@@ -81,7 +81,8 @@ class Page:
@property
def full_page_number(self):
return f"{self.magazine}{self.page_number:02d}"
# Format as Hex to support A-F pages
return f"{self.magazine}{self.page_number:02X}"
@dataclass
class TeletextService:

View File

@@ -496,7 +496,8 @@ class MainWindow(QMainWindow):
sorted_keys = sorted(self.page_groups.keys())
for mag, pnum in sorted_keys:
label = f"{mag}{pnum:02d}"
# Display as Hex
label = f"{mag}{pnum:02X}"
item = QListWidgetItem(label)
item.setData(Qt.ItemDataRole.UserRole, (mag, pnum))
self.page_list.addItem(item)