mirror of
https://github.com/Djeeberjr/fw-anwesenheit.git
synced 2025-07-01 08:44:18 +00:00
moved related files into own module
This commit is contained in:
parent
3e079c905f
commit
09725c1e04
@ -8,10 +8,10 @@ use tokio::{join, time::sleep};
|
||||
use crate::hardware::{Buzzer, StatusLed};
|
||||
|
||||
#[cfg(not(feature = "mock_pi"))]
|
||||
use crate::{gpio_buzzer::GPIOBuzzer, spi_led::SpiLed};
|
||||
use crate::{hardware::GPIOBuzzer, hardware::SpiLed};
|
||||
|
||||
#[cfg(feature = "mock_pi")]
|
||||
use crate::mock::{MockBuzzer, MockLed};
|
||||
use crate::hardware::{MockBuzzer, MockLed};
|
||||
|
||||
const LED_BLINK_DURATION: Duration = Duration::from_secs(1);
|
||||
|
||||
|
@ -1,11 +1,14 @@
|
||||
use anyhow::Result;
|
||||
use std::time::Duration;
|
||||
|
||||
#[cfg(feature = "mock_pi")]
|
||||
use crate::mock::MockHotspot;
|
||||
mod gpio_buzzer;
|
||||
mod hotspot;
|
||||
mod mock;
|
||||
mod spi_led;
|
||||
|
||||
#[cfg(not(feature = "mock_pi"))]
|
||||
use crate::hotspot::NMHotspot;
|
||||
pub use gpio_buzzer::GPIOBuzzer;
|
||||
pub use mock::{MockBuzzer, MockHotspot, MockLed};
|
||||
pub use spi_led::SpiLed;
|
||||
|
||||
pub trait StatusLed {
|
||||
fn turn_off(&mut self) -> Result<()>;
|
||||
@ -32,11 +35,11 @@ pub trait Hotspot {
|
||||
pub fn create_hotspot() -> Result<impl Hotspot> {
|
||||
#[cfg(feature = "mock_pi")]
|
||||
{
|
||||
Ok(MockHotspot {})
|
||||
Ok(mock::MockHotspot {})
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "mock_pi"))]
|
||||
{
|
||||
NMHotspot::new_from_env()
|
||||
hotspot::NMHotspot::new_from_env()
|
||||
}
|
||||
}
|
17
src/main.rs
17
src/main.rs
@ -1,12 +1,8 @@
|
||||
#![allow(dead_code)]
|
||||
|
||||
use activity_fairing::{ActivityNotifier, spawn_idle_watcher};
|
||||
use anyhow::Result;
|
||||
use feedback::{Feedback, FeedbackImpl};
|
||||
use hardware::{Hotspot, create_hotspot};
|
||||
use id_store::IDStore;
|
||||
use log::{error, info, warn};
|
||||
use pm3::run_pm3;
|
||||
use std::{
|
||||
env::{self, args},
|
||||
sync::Arc,
|
||||
@ -24,20 +20,15 @@ use tokio::{
|
||||
};
|
||||
use webserver::start_webserver;
|
||||
|
||||
mod activity_fairing;
|
||||
use crate::{hardware::{create_hotspot, Hotspot}, pm3::run_pm3, store::IDStore, webserver::{spawn_idle_watcher, ActivityNotifier}};
|
||||
|
||||
mod feedback;
|
||||
mod gpio_buzzer;
|
||||
mod hardware;
|
||||
mod hotspot;
|
||||
mod id_mapping;
|
||||
mod id_store;
|
||||
mod logger;
|
||||
mod mock;
|
||||
mod parser;
|
||||
mod pm3;
|
||||
mod spi_led;
|
||||
mod logger;
|
||||
mod tally_id;
|
||||
mod webserver;
|
||||
mod store;
|
||||
|
||||
const STORE_PATH: &str = "./data.json";
|
||||
|
||||
|
4
src/pm3/mod.rs
Normal file
4
src/pm3/mod.rs
Normal file
@ -0,0 +1,4 @@
|
||||
mod runner;
|
||||
mod parser;
|
||||
|
||||
pub use runner::run_pm3;
|
@ -1,9 +1,10 @@
|
||||
use crate::{id_mapping::IDMapping, tally_id::TallyID};
|
||||
use anyhow::{Result, anyhow};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use tokio::fs;
|
||||
|
||||
use crate::{store::IDMapping, tally_id::TallyID};
|
||||
|
||||
/// Represents a single day that IDs can attend
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub struct AttendanceDay {
|
5
src/store/mod.rs
Normal file
5
src/store/mod.rs
Normal file
@ -0,0 +1,5 @@
|
||||
mod id_store;
|
||||
mod id_mapping;
|
||||
|
||||
pub use id_store::IDStore;
|
||||
pub use id_mapping::{IDMapping,Name};
|
6
src/webserver/mod.rs
Normal file
6
src/webserver/mod.rs
Normal file
@ -0,0 +1,6 @@
|
||||
mod server;
|
||||
mod activity_fairing;
|
||||
|
||||
pub use activity_fairing::{ActivityNotifier,spawn_idle_watcher};
|
||||
pub use server::start_webserver;
|
||||
|
@ -14,10 +14,9 @@ use tokio::select;
|
||||
use tokio::sync::Mutex;
|
||||
use tokio::sync::broadcast::Sender;
|
||||
|
||||
use crate::activity_fairing::ActivityNotifier;
|
||||
use crate::id_mapping::{IDMapping, Name};
|
||||
use crate::id_store::IDStore;
|
||||
use crate::store::{IDMapping, IDStore, Name};
|
||||
use crate::tally_id::TallyID;
|
||||
use crate::webserver::ActivityNotifier;
|
||||
|
||||
#[derive(Embed)]
|
||||
#[folder = "web/dist"]
|
Loading…
x
Reference in New Issue
Block a user