feat: implement flashing support (0x08/0x09) with 1Hz timer
Some checks failed
Build Windows / Build Windows (push) Has been cancelled
Build Linux / Build Linux (push) Has been cancelled

This commit is contained in:
2026-02-21 12:49:20 +01:00
parent 6d88b59e04
commit 38884c8f33

View File

@@ -63,6 +63,12 @@ class TeletextCanvas(QWidget):
self.service = None # Reference to TeletextService for DRCS/Shared data
self.subset_idx = 0 # Default English
# Flashing state
self.flash_on = True
self.flash_timer = QTimer(self)
self.flash_timer.timeout.connect(self.toggle_flash)
self.flash_timer.start(500) # 500ms toggle (1Hz flash rate)
# Teletext is 40 columns x 25 rows
# We will render to a fixed size QImage and scale it
self.cols = 40
@@ -87,6 +93,12 @@ class TeletextCanvas(QWidget):
self.cursor_is_graphics = False # Tracked during draw
# Blinking cursor timer could be added, for now static inverted is fine or toggle on timer elsewhere
def toggle_flash(self):
self.flash_on = not self.flash_on
if self.page:
self.redraw()
self.update()
def get_byte_at(self, x, y):
if not self.page: return 0
@@ -274,6 +286,7 @@ class TeletextCanvas(QWidget):
hold_graphics = False
held_char = 0x20 # Space
double_height = False
flashing = False
last_visible_idx = -1
bg_segments = [(0, bg)] # Track BG changes: (index, color)
@@ -364,6 +377,10 @@ class TeletextCanvas(QWidget):
break
painter.fillRect(k * self.cell_w, y, self.cell_w, self.cell_h * 2, cell_bg)
elif byte_val == 0x08: # Start Flashing
flashing = True
elif byte_val == 0x09: # Steady
flashing = False
elif byte_val == 0x19: # Contiguous Graphics
contiguous = True
elif byte_val == 0x1A: # Separated Graphics
@@ -410,6 +427,8 @@ class TeletextCanvas(QWidget):
# Draw Foreground
if draw_fg:
# If flashing is active and flash is in 'off' state, skip drawing FG
if not (flashing and not self.flash_on):
# Calculate height
# For Mosaics, we use the height param.
# For Alphanumerics, we scale the painter.