36 lines
824 B
Rust
36 lines
824 B
Rust
use config::{Config, ConfigError, File};
|
|
use rpi_led_matrix::LedColor;
|
|
use serde::Deserialize;
|
|
|
|
#[derive(Debug, Deserialize, Clone)]
|
|
pub struct SpacecraftConfig {
|
|
pub spacecraft_name: String,
|
|
pub spacecraft_id: u64,
|
|
pub color: (u8, u8, u8),
|
|
}
|
|
|
|
impl SpacecraftConfig {
|
|
fn color(&self) -> LedColor {
|
|
LedColor {
|
|
red: self.color.0,
|
|
green: self.color.1,
|
|
blue: self.color.2,
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Debug, Deserialize, Clone)]
|
|
pub struct VisualizerConfig {
|
|
pub dsn_address: String,
|
|
pub polling_rate: u64,
|
|
pub spacecraft: Vec<SpacecraftConfig>,
|
|
}
|
|
|
|
impl VisualizerConfig {
|
|
pub fn new(config_path: &str) -> Result<Self, ConfigError> {
|
|
let mut cfg = Config::new();
|
|
cfg.merge(File::with_name(config_path))?;
|
|
cfg.try_into()
|
|
}
|
|
}
|