diff --git a/Cargo.toml b/Cargo.toml index 26f5887..eb97dfc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,6 +18,7 @@ rppal = "0.14" ws2818-rgb-led-spi-driver = { path = "./lib-ws2818-rgb-led-spi-driver" } common = { path = "./common" } webui = { path = "./webui" } +dotenv = "0.15.0" [profile.release] lto = true diff --git a/src/main.rs b/src/main.rs index 7e3c244..9888823 100644 --- a/src/main.rs +++ b/src/main.rs @@ -44,6 +44,9 @@ use strip::LedStrip; use ui::console_ui_loop; fn main() -> ProgramResult<()> { + // Initialize any config + dotenv::dotenv().ok(); + // Strip control transmitter and receiver let (strip_tx, strip_rx) = channel::(); let (console_strip_tx, webui_strip_tx) = (strip_tx.clone(), strip_tx); @@ -53,7 +56,12 @@ fn main() -> ProgramResult<()> { make_child(message_tx.clone(), move |message_tx| -> ProgramResult<()> { let mut strip = LedStrip::new(strip::Config { // I have 89 right now, but start off with 20 - num_lights: 89, + num_lights: std::env::var("NUM_LIGHTS") + .as_ref() + .map(String::as_str) + .unwrap_or("89") + .parse() + .unwrap(), // Skip 14 lights shift_lights: 14, // Scaling factor (scale 0..255)