Skip to content

Commit

Permalink
propegate colorblind mode beyond start/stop
Browse files Browse the repository at this point in the history
  • Loading branch information
cooperq committed Nov 25, 2024
1 parent c307464 commit 0e7ba51
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions bin/src/daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ async fn run_server(
debug_mode: config.debug_mode,
analysis_status_lock,
analysis_sender,
colorblind_mode: config.colorblind_mode,
});

let app = Router::new()
Expand Down
10 changes: 9 additions & 1 deletion bin/src/diag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,16 @@ pub async fn start_recording(State(state): State<Arc<ServerState>>) -> Result<(S
let qmdl_writer = QmdlWriter::new(qmdl_file);
state.diag_device_ctrl_sender.send(DiagDeviceCtrlMessage::StartRecording((qmdl_writer, analysis_file))).await
.map_err(|e| (StatusCode::INTERNAL_SERVER_ERROR, format!("couldn't send stop recording message: {}", e)))?;
state.ui_update_sender.send(framebuffer::DisplayState::Recording).await

let display_state: framebuffer::DisplayState;
if state.colorblind_mode {
display_state = framebuffer::DisplayState::RecordingCBM;
} else {
display_state = framebuffer::DisplayState::Recording;
}
state.ui_update_sender.send(display_state).await
.map_err(|e| (StatusCode::INTERNAL_SERVER_ERROR, format!("couldn't send ui update message: {}", e)))?;

Ok((StatusCode::ACCEPTED, "ok".to_string()))
}

Expand Down
2 changes: 2 additions & 0 deletions bin/src/framebuffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ pub enum DisplayState {
Recording,
Paused,
WarningDetected,
RecordingCBM,
}

impl From<DisplayState> for Color565 {
fn from(state: DisplayState) -> Self {
match state {
DisplayState::Paused => Color565::White,
DisplayState::Recording => Color565::Green,
DisplayState::RecordingCBM => Color565::Blue,
DisplayState::WarningDetected => Color565::Red,
}
}
Expand Down
3 changes: 2 additions & 1 deletion bin/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ pub struct ServerState {
pub ui_update_sender: Sender<framebuffer::DisplayState>,
pub analysis_status_lock: Arc<RwLock<AnalysisStatus>>,
pub analysis_sender: Sender<AnalysisCtrlMessage>,
pub debug_mode: bool
pub debug_mode: bool,
pub colorblind_mode: bool,
}

pub async fn get_qmdl(State(state): State<Arc<ServerState>>, Path(qmdl_name): Path<String>) -> Result<Response, (StatusCode, String)> {
Expand Down

0 comments on commit 0e7ba51

Please sign in to comment.