Skip to content

Commit

Permalink
Merge pull request #164 from card-io-ecg/old
Browse files Browse the repository at this point in the history
Remove hw_v1
  • Loading branch information
bugadani committed Apr 21, 2024
2 parents 256a402 + b513990 commit 2134d6c
Show file tree
Hide file tree
Showing 12 changed files with 3 additions and 635 deletions.
2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,8 @@ esp-wifi = { git = "https://github.com/esp-rs/esp-wifi", rev = "d200a167237f03cf
[features]
default = ["defmt"]

battery_adc = []
battery_max17055 = ["dep:max17055"]

hw_v1 = ["battery_adc", "esp32s3"]
hw_v2 = ["battery_max17055", "esp32s3"] # skipped v3
hw_v4 = ["battery_max17055", "esp32s3"]
hw_v6 = ["battery_max17055"] # skipped v5, v6 has S3 and C6 options
Expand Down
3 changes: 1 addition & 2 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,13 @@ fn main() {

// Ensure that only a single HW version
let hw_features = [
(cfg!(feature = "hw_v1"), HwVersion::V1),
(cfg!(feature = "hw_v2"), HwVersion::V2),
(cfg!(feature = "hw_v4"), HwVersion::V4),
(cfg!(feature = "hw_v6"), HwVersion::V6),
];

let Some(hw_version) = get_unique(hw_features) else {
panic!("Exactly 1 hardware version must be selected via its Cargo feature (hw_v1, hw_v2, hw_v4, hw_v6)");
panic!("Exactly 1 hardware version must be selected via its Cargo feature (hw_v2, hw_v4, hw_v6)");
};

let build_config = BuildConfig { mcu, hw_version };
Expand Down
145 changes: 0 additions & 145 deletions src/board/drivers/battery_monitor/battery_adc.rs

This file was deleted.

41 changes: 2 additions & 39 deletions src/board/drivers/battery_monitor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,9 @@ use embassy_sync::mutex::Mutex;
use embedded_hal::digital::InputPin;
use gui::screens::{BatteryInfo, ChargingState};

#[cfg(feature = "battery_adc")]
pub mod battery_adc;
#[cfg(feature = "battery_max17055")]
pub mod battery_fg;

#[cfg(feature = "battery_adc")]
use crate::board::{
drivers::battery_monitor::battery_adc::{
monitor_task_adc as monitor_task, BatteryAdcData as BatteryData,
},
BatteryAdc as BatterySensorImpl,
};

#[cfg(feature = "battery_max17055")]
use crate::board::{
drivers::battery_monitor::battery_fg::{
Expand All @@ -27,10 +17,10 @@ use crate::board::{
BatteryFg as BatterySensorImpl,
};

#[cfg(any(feature = "battery_adc", feature = "battery_max17055"))]
#[cfg(feature = "battery_max17055")]
use crate::board::LOW_BATTERY_PERCENTAGE;

#[cfg(any(feature = "battery_adc", feature = "battery_max17055"))]
#[cfg(feature = "battery_max17055")]
use embassy_executor::Spawner;

#[derive(Default, Clone, Copy)]
Expand Down Expand Up @@ -142,33 +132,6 @@ impl<VBUS: InputPin, CHG: InputPin> BatteryMonitor<VBUS, CHG> {
}
}

#[cfg(feature = "battery_adc")]
impl<VBUS: InputPin, CHG: InputPin> BatteryMonitor<VBUS, CHG> {
fn convert_battery_data(&self, data: BatteryData) -> BatteryInfo {
use signal_processing::battery::BatteryModel;

let battery_model = BatteryModel {
voltage: (2750, 4200),
charge_current: (0, 1000),
};

let charge_current = if self.is_charging() {
None
} else {
Some(data.charge_current)
};

let percentage = battery_model.estimate(data.voltage, charge_current);

BatteryInfo {
voltage: data.voltage,
charging_state: self.charging_state(),
percentage,
is_low: percentage < LOW_BATTERY_PERCENTAGE,
}
}
}

#[cfg(feature = "battery_max17055")]
impl<VBUS: InputPin, CHG: InputPin> BatteryMonitor<VBUS, CHG> {
pub fn convert_battery_data(&mut self, data: BatteryData) -> BatteryInfo {
Expand Down
145 changes: 0 additions & 145 deletions src/board/hardware/v1.rs

This file was deleted.

Loading

0 comments on commit 2134d6c

Please sign in to comment.