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:
@@ -191,7 +191,13 @@ def parse_header(data: bytearray):
|
|||||||
pu = decode_hamming_8_4(data[0])
|
pu = decode_hamming_8_4(data[0])
|
||||||
pt = decode_hamming_8_4(data[1])
|
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
|
# Subcode: S1, S2, S3, S4
|
||||||
# S1 (low), S2, S3, S4 (high)
|
# S1 (low), S2, S3, S4 (high)
|
||||||
|
|||||||
@@ -81,7 +81,8 @@ class Page:
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def full_page_number(self):
|
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
|
@dataclass
|
||||||
class TeletextService:
|
class TeletextService:
|
||||||
|
|||||||
@@ -496,7 +496,8 @@ class MainWindow(QMainWindow):
|
|||||||
sorted_keys = sorted(self.page_groups.keys())
|
sorted_keys = sorted(self.page_groups.keys())
|
||||||
|
|
||||||
for mag, pnum in sorted_keys:
|
for mag, pnum in sorted_keys:
|
||||||
label = f"{mag}{pnum:02d}"
|
# Display as Hex
|
||||||
|
label = f"{mag}{pnum:02X}"
|
||||||
item = QListWidgetItem(label)
|
item = QListWidgetItem(label)
|
||||||
item.setData(Qt.ItemDataRole.UserRole, (mag, pnum))
|
item.setData(Qt.ItemDataRole.UserRole, (mag, pnum))
|
||||||
self.page_list.addItem(item)
|
self.page_list.addItem(item)
|
||||||
|
|||||||
Reference in New Issue
Block a user