feat: implement flashing support (0x08/0x09) with 1Hz timer
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user