feat: load printer configuration from .env
Configure the 80 mm thermal printer (576 dots) via a committed .env file, loaded at startup with dotenvy. Real environment variables take precedence. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -35,6 +35,13 @@ struct PreviewFrame {
|
||||
}
|
||||
|
||||
fn main() -> Result<(), Box<dyn Error>> {
|
||||
// Load `.env` before any thread starts, since it sets process variables.
|
||||
// Values already present in the real environment take precedence.
|
||||
match dotenvy::dotenv() {
|
||||
Ok(path) => eprintln!("[config INFO] Loaded {}", path.display()),
|
||||
Err(error) if error.not_found() => {}
|
||||
Err(error) => eprintln!("[config ERROR] Could not load .env: {error}"),
|
||||
}
|
||||
// One OpenCV inference thread per worker leaves CPU time for the camera/UI
|
||||
// on the dual-core kiosk instead of each model spawning two busy threads.
|
||||
core::set_num_threads(1)?;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
//! ESC/POS thermal printing for captured photos.
|
||||
//!
|
||||
//! Configuration (environment variables, read once at startup):
|
||||
//! Configuration (environment variables or the committed `.env`; read once at
|
||||
//! startup):
|
||||
//! - `PHOTOBOOTH_PRINTER`: where to send print data. Either a device path such as
|
||||
//! `/dev/usb/lp0` (USB printer class) or a raw network printer as
|
||||
//! `tcp://host[:port]` (port defaults to 9100). Printing is disabled when unset.
|
||||
|
||||
Reference in New Issue
Block a user