mirror of
https://github.com/Djeeberjr/fw-anwesenheit.git
synced 2025-10-13 15:06:39 +00:00
fixed many warning by removing unused imports
Removed a lot of imports — believe me, so many imports were totally unnecessary. Nobody’s seen imports like these. Cleaned up the code, made it faster, smarter, the best code. People are talking about it! Tremendous work by me. Some say i am the best at it. It may be true.
This commit is contained in:
parent
9dd2f88cbc
commit
0f5ca88ae4
@ -2,7 +2,7 @@ use embassy_time::{Duration, Timer};
|
||||
use esp_hal::{Async, uart::Uart};
|
||||
use log::{debug, info};
|
||||
|
||||
use crate::{TallyPublisher, store::TallyID};
|
||||
use crate::TallyPublisher;
|
||||
|
||||
#[embassy_executor::task]
|
||||
pub async fn rfid_reader_task(mut uart_device: Uart<'static, Async>, chan: TallyPublisher) {
|
||||
|
@ -1,3 +1,4 @@
|
||||
use chrono::{TimeZone, Utc};
|
||||
use ds3231::{
|
||||
Config, DS3231, DS3231Error, InterruptControl, Oscillator, SquareWaveFrequency,
|
||||
TimeRepresentation,
|
||||
@ -9,7 +10,6 @@ use esp_hal::{
|
||||
use log::{debug, error, info};
|
||||
|
||||
use crate::{FEEDBACK_STATE, drivers, feedback, store::Date};
|
||||
use chrono::{TimeZone, Utc};
|
||||
|
||||
include!(concat!(env!("OUT_DIR"), "/build_time.rs"));
|
||||
|
||||
@ -49,7 +49,7 @@ impl RTCClock {
|
||||
pub async fn get_date(&mut self) -> Date {
|
||||
let (year, month, day) = unix_to_ymd_string(self.get_time().await);
|
||||
|
||||
let mut buffer: Date = [0; 10] ;
|
||||
let mut buffer: Date = [0; 10];
|
||||
|
||||
// Write YYYY
|
||||
buffer[0] = b'0' + ((year / 1000) % 10) as u8;
|
||||
@ -70,7 +70,6 @@ impl RTCClock {
|
||||
|
||||
buffer
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fn unix_to_ymd_string(timestamp: u64) -> (u16, u8, u8) {
|
||||
@ -82,11 +81,11 @@ fn unix_to_ymd_string(timestamp: u64) -> (u16, u8, u8) {
|
||||
|
||||
// Convert to proleptic Gregorian date
|
||||
civil_from_days(days_since_epoch as i64 + UNIX_OFFSET_DAYS as i64)
|
||||
}
|
||||
}
|
||||
|
||||
// This function returns (year, month, day).
|
||||
// Based on the algorithm by Howard Hinnant.
|
||||
fn civil_from_days(z: i64) -> (u16, u8, u8) {
|
||||
// This function returns (year, month, day).
|
||||
// Based on the algorithm by Howard Hinnant.
|
||||
fn civil_from_days(z: i64) -> (u16, u8, u8) {
|
||||
let mut z = z;
|
||||
z -= 60; // shift epoch for algorithm
|
||||
let era = (z >= 0).then_some(z).unwrap_or(z - 146096) / 146097;
|
||||
@ -98,7 +97,7 @@ fn unix_to_ymd_string(timestamp: u64) -> (u16, u8, u8) {
|
||||
let d = doy - (153 * mp + 2) / 5 + 1; // [1, 31]
|
||||
let m = mp + (if mp < 10 { 3 } else { -9 }); // [1, 12]
|
||||
((y + (m <= 2) as i64) as u16, m as u8, d as u8)
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn rtc_config(i2c: I2c<'static, Async>) -> DS3231<I2c<'static, Async>> {
|
||||
let mut rtc: DS3231<I2c<'static, Async>> = DS3231::new(i2c, RTC_ADDRESS);
|
||||
|
@ -1,8 +1,7 @@
|
||||
use embassy_time::{Delay, Duration, Timer};
|
||||
use esp_hal::{delay, gpio::Output, peripherals, rmt::ConstChannelAccess};
|
||||
use embassy_time::{Duration, Timer};
|
||||
use esp_hal::{peripherals, rmt::ConstChannelAccess};
|
||||
use esp_hal_smartled::SmartLedsAdapterAsync;
|
||||
use init::hardware;
|
||||
use log::{debug, error, info};
|
||||
use log::debug;
|
||||
use smart_leds::SmartLedsWriteAsync;
|
||||
use smart_leds::colors::{BLACK, GREEN, RED, YELLOW};
|
||||
use smart_leds::{brightness, colors::BLUE};
|
||||
|
@ -1,13 +1,10 @@
|
||||
use core::cell::RefCell;
|
||||
|
||||
use bleps::att::Att;
|
||||
use critical_section::Mutex;
|
||||
use ds3231::InterruptControl;
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_net::Stack;
|
||||
|
||||
use embassy_time::{Duration, Timer};
|
||||
use esp_hal::gpio::{Input, InputConfig};
|
||||
use esp_hal::Blocking;
|
||||
use esp_hal::gpio::Input;
|
||||
use esp_hal::i2c::master::Config;
|
||||
use esp_hal::peripherals::{
|
||||
GPIO0, GPIO1, GPIO16, GPIO17, GPIO18, GPIO19, GPIO20, GPIO21, GPIO22, GPIO23, I2C0, RMT, SPI2,
|
||||
@ -15,8 +12,6 @@ use esp_hal::peripherals::{
|
||||
};
|
||||
use esp_hal::rmt::{ConstChannelAccess, Rmt};
|
||||
use esp_hal::spi::master::{Config as Spi_config, Spi};
|
||||
|
||||
use esp_hal::Blocking;
|
||||
use esp_hal::time::Rate;
|
||||
use esp_hal::timer::timg::TimerGroup;
|
||||
use esp_hal::{
|
||||
@ -28,16 +23,12 @@ use esp_hal::{
|
||||
uart::Uart,
|
||||
};
|
||||
use esp_hal_smartled::{SmartLedsAdapterAsync, buffer_size_async};
|
||||
use esp_println::dbg;
|
||||
use esp_println::logger::init_logger;
|
||||
use log::{debug, error, info};
|
||||
use log::{debug, error};
|
||||
|
||||
use crate::FEEDBACK_STATE;
|
||||
use crate::init::network;
|
||||
use crate::init::sd_card::{setup_sdcard, SDCardPersistence};
|
||||
use crate::init::sd_card::{SDCardPersistence, setup_sdcard};
|
||||
use crate::init::wifi;
|
||||
use crate::store::AttendanceDay;
|
||||
use crate::store::persistence::Persistence;
|
||||
|
||||
/*************************************************
|
||||
* GPIO Pinout Xiao Esp32c6
|
||||
|
@ -1,5 +1,4 @@
|
||||
use core::{net::Ipv4Addr, str::FromStr};
|
||||
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_net::{Ipv4Cidr, Runner, Stack, StackResources, StaticConfigV4};
|
||||
use embassy_time::{Duration, Timer};
|
||||
|
@ -21,14 +21,14 @@ use esp_hal::{gpio::InputConfig, peripherals};
|
||||
use log::{debug, info};
|
||||
use static_cell::make_static;
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
use crate::{
|
||||
init::sd_card::SDCardPersistence,
|
||||
store::{Date, IDStore, TallyID},
|
||||
webserver::start_webserver,
|
||||
};
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
mod drivers;
|
||||
mod feedback;
|
||||
mod init;
|
||||
|
@ -1,8 +1,9 @@
|
||||
use super::TallyID;
|
||||
use alloc::collections::BTreeMap;
|
||||
use alloc::string::String;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::TallyID;
|
||||
|
||||
#[derive(Clone, Serialize, Deserialize)]
|
||||
pub struct Name {
|
||||
pub first: String,
|
||||
|
@ -1,13 +1,11 @@
|
||||
use crate::drivers::rtc;
|
||||
use crate::drivers::rtc::RTCClock;
|
||||
use crate::store::persistence::Persistence;
|
||||
use alloc::vec::Vec;
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
|
||||
use super::Date;
|
||||
use super::IDMapping;
|
||||
use super::TallyID;
|
||||
use alloc::vec::Vec;
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
use crate::store::persistence::Persistence;
|
||||
|
||||
#[derive(Clone, Serialize, Deserialize, Debug)]
|
||||
pub struct AttendanceDay {
|
||||
@ -75,7 +73,6 @@ impl<T: Persistence> IDStore<T> {
|
||||
/// Add a new id for the current day
|
||||
/// Returns false if ID is already present at the current day.
|
||||
pub async fn add_id(&mut self, id: TallyID, current_date: Date) -> bool {
|
||||
|
||||
if self.current_day.date == current_date {
|
||||
let changed = self.current_day.add_id(id);
|
||||
if changed {
|
||||
|
@ -1,11 +1,12 @@
|
||||
use heapless::String;
|
||||
|
||||
pub use id_mapping::{IDMapping, Name};
|
||||
pub use id_store::{IDStore,AttendanceDay};
|
||||
|
||||
mod id_mapping;
|
||||
pub mod persistence;
|
||||
mod id_store;
|
||||
|
||||
use heapless::String;
|
||||
pub use id_mapping::{IDMapping, Name};
|
||||
pub use id_store::{IDStore,AttendanceDay};
|
||||
|
||||
pub type TallyID = [u8; 6];
|
||||
pub type Date = [u8; 10];
|
||||
|
||||
|
@ -4,6 +4,7 @@ use picoserve::{
|
||||
response::{self, IntoResponse},
|
||||
};
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::{
|
||||
store::{Name, hex_string_to_tally_id},
|
||||
webserver::{app::AppState, sse::IDEvents},
|
||||
@ -40,6 +41,6 @@ pub async fn add_mapping(
|
||||
store.mapping.add_mapping(tally_id, data.name);
|
||||
}
|
||||
|
||||
pub async fn get_idevent(State(state): State<AppState>) -> impl IntoResponse{
|
||||
pub async fn get_idevent(State(state): State<AppState>) -> impl IntoResponse {
|
||||
response::EventStream(IDEvents(state.chan.subscriber().unwrap()))
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user