Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove hw_v1 #164

Merged
merged 1 commit into from
Apr 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading