Skip to content

Fix historic mode: slider directly drives LED matrix instead of auto-playback - #3

Draft
Vaibhav-Hariani with Copilot wants to merge 2 commits into
mainfrom
copilot/redesign-historic-timestamp-mode
Draft

Fix historic mode: slider directly drives LED matrix instead of auto-playback#3
Vaibhav-Hariani with Copilot wants to merge 2 commits into
mainfrom
copilot/redesign-historic-timestamp-mode

Conversation

Copilot AI commented Feb 26, 2026

Copy link
Copy Markdown

Historic mode used autonomous timestamp playback in driver.py — on every Streamlit re-render the UI wrote the same viewing_timestamp back to metadata, causing the driver to endlessly reset to the slider's position and auto-advance independently of user input.

Changes

raspi_code/driver.py

  • Main loop: Replaced the auto-playback state machine (starting_timestamp, viewing_idx, historic_timestamps, historic_start_index, speed, ticks) with a single last_historic_timestamp guard. The driver now renders exactly the timestamp the slider writes to metadata — nothing more.
  • historic_mode(): Added clear_all_leds() before each render to prevent LED state from bleeding across timestamp transitions. Removed the update_metadata(in_type=LIVE) fallback on missing data, which caused a tight mode-switching loop between the UI and driver when a timestamp had no records.
# Before: auto-advance independent of slider
if db_state.viewing_timestamp != starting_timestamp or speed != db_state.speed:
    viewing_idx = historic_timestamps.index(starting_timestamp)
else:
    viewing_idx += 1          # driver races ahead on its own

# After: slider is sole authority
if current_viewing_timestamp != last_historic_timestamp:
    station_states = historic_mode(station_states, current_viewing_timestamp)
    last_historic_timestamp = current_viewing_timestamp

frontend/app.py

  • Removed the "Playback Speed" slider and its speed argument from update_metadata() — meaningless now that the driver no longer auto-advances.
Original prompt

Currently, there's significant issues with historic mode synchronizing with the raspberry pi driver & the streamlit frontend app.py. Carefully redesign the historic timestamp mode so that, when users specify a given timestamp from the slider, the raspberry pi writes to the driver to carefully update the LED matrices.

Created from VS Code.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: Vaibhav-Hariani <62775035+Vaibhav-Hariani@users.noreply.github.com>
Copilot AI changed the title [WIP] Redesign historic mode synchronization with Raspberry Pi driver Fix historic mode: slider directly drives LED matrix instead of auto-playback Feb 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants