diff --git a/src/config.rs b/src/config.rs index dd37850..974d60b 100644 --- a/src/config.rs +++ b/src/config.rs @@ -78,8 +78,28 @@ impl Default for Config { } pub fn save_config(path: &str, config: &Config) -> Result<(), Box> { - let contents = serde_yaml::to_string(config)?; - fs::write(path, contents)?; + let mut s = String::new(); + s.push_str("# Hardware offset in milliseconds for correcting capture latency.\n"); + s.push_str(&format!("hardwareOffsetMs: {}\n\n", config.hardware_offset_ms)); + + s.push_str("# Enable automatic clock synchronization.\n"); + s.push_str("# When enabled, the system will perform an initial full sync, then periodically\n"); + s.push_str("# nudge the clock to keep it aligned with the LTC source.\n"); + s.push_str(&format!("autoSyncEnabled: {}\n\n", config.auto_sync_enabled)); + + s.push_str("# Default nudge in milliseconds for adjtimex control.\n"); + s.push_str(&format!("defaultNudgeMs: {}\n\n", config.default_nudge_ms)); + + s.push_str("# Time-turning offsets. All values are added to the incoming LTC time.\n"); + s.push_str("# These can be positive or negative.\n"); + s.push_str("timeturnerOffset:\n"); + s.push_str(&format!(" hours: {}\n", config.timeturner_offset.hours)); + s.push_str(&format!(" minutes: {}\n", config.timeturner_offset.minutes)); + s.push_str(&format!(" seconds: {}\n", config.timeturner_offset.seconds)); + s.push_str(&format!(" frames: {}\n", config.timeturner_offset.frames)); + s.push_str(&format!(" milliseconds: {}\n", config.timeturner_offset.milliseconds)); + + fs::write(path, s)?; Ok(()) } diff --git a/src/main.rs b/src/main.rs index 516d482..e265210 100644 --- a/src/main.rs +++ b/src/main.rs @@ -47,6 +47,9 @@ hardwareOffsetMs: 20 # nudge the clock to keep it aligned with the LTC source. autoSyncEnabled: false +# Default nudge in milliseconds for adjtimex control. +defaultNudgeMs: 2 + # Time-turning offsets. All values are added to the incoming LTC time. # These can be positive or negative. timeturnerOffset: @@ -54,6 +57,7 @@ timeturnerOffset: minutes: 0 seconds: 0 frames: 0 + milliseconds: 0 "#; /// If no `config.yml` exists alongside the binary, write out the default.