add colorblind mode. Fixes #77

This commit is contained in:
Cooper Quintin
2024-11-25 10:55:45 -08:00
committed by Will Greenberg
parent 7addf3a67f
commit 87f9cc403b
3 changed files with 14 additions and 1 deletions

View File

@@ -9,6 +9,7 @@ struct ConfigFile {
debug_mode: Option<bool>,
ui_level: Option<u8>,
enable_dummy_analyzer: Option<bool>,
colorblind_mode: Option<bool>,
}
#[derive(Debug)]
@@ -18,6 +19,7 @@ pub struct Config {
pub debug_mode: bool,
pub ui_level: u8,
pub enable_dummy_analyzer: bool,
pub colorblind_mode: bool,
}
impl Default for Config {
@@ -28,6 +30,7 @@ impl Default for Config {
debug_mode: false,
ui_level: 1,
enable_dummy_analyzer: false,
colorblind_mode: false,
}
}
}
@@ -42,6 +45,7 @@ pub fn parse_config<P>(path: P) -> Result<Config, RayhunterError> where P: AsRef
parsed_config.debug_mode.map(|v| config.debug_mode = v);
parsed_config.ui_level.map(|v| config.ui_level = v);
parsed_config.enable_dummy_analyzer.map(|v| config.enable_dummy_analyzer = v);
parsed_config.colorblind_mode.map(|v| config.colorblind_mode = v);
}
Ok(config)
}

View File

@@ -21,6 +21,7 @@ use crate::framebuffer::Framebuffer;
use analysis::{get_analysis_status, run_analysis_thread, start_analysis, AnalysisCtrlMessage, AnalysisStatus};
use axum::response::Redirect;
use diag::{get_analysis_report, start_recording, stop_recording, DiagDeviceCtrlMessage};
use framebuffer::Color565;
use log::{info, error};
use rayhunter::diag_device::DiagDevice;
use axum::routing::{get, post};
@@ -142,12 +143,17 @@ fn run_ctrl_c_thread(
fn update_ui(task_tracker: &TaskTracker, config: &config::Config, mut ui_shutdown_rx: oneshot::Receiver<()>, mut ui_update_rx: Receiver<framebuffer::DisplayState>) -> JoinHandle<()> {
static IMAGE_DIR: Dir<'_> = include_dir!("$CARGO_MANIFEST_DIR/static/images/");
let mut display_color: Color565;
let display_level = config.ui_level;
if display_level == 0 {
info!("Invisible mode, not spawning UI.");
}
let mut display_color = framebuffer::Color565::Green;
if config.colorblind_mode {
display_color = framebuffer::Color565::Blue;
} else {
display_color = framebuffer::Color565::Green;
}
task_tracker.spawn_blocking(move || {
let mut fb: Framebuffer = Framebuffer::new();