Skip to content

Commit

Permalink
- increased ambient light sensors power saving level
Browse files Browse the repository at this point in the history
- reduced operating ambient light level
- slight speed up of LED dimm down time
- LED PWM frequency reduced to 120 Hz
  • Loading branch information
bitmagier committed Sep 8, 2024
1 parent e4cf130 commit 98e61b6
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Here is an overview of what's needed to build and run the software:
- When it comes to the step `espup install`, you should consider using `espup install --targets esp32h2` instead, to avoid installing lots of unnecessary dependencies for unused Espressif targets.
- `cargo build`

After connecting the ESP32-H2 via a flash adapter to an USB computer port:
After connecting the ESP32-H2 via a flash adapter to a USB computer port:
- `cargo run --release` _(flashes the chip)_
- `espflash monitor` _(optional – see ESP32 console output)_

Expand Down
34 changes: 17 additions & 17 deletions code/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion code/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sensor-light"
version = "1.0.2"
version = "1.0.3-pre"
authors = ["bitmagier <[email protected]>"]
edition = "2021"
resolver = "2"
Expand Down
6 changes: 3 additions & 3 deletions code/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ mod peripheral;
pub const LED_POWER_STAGES: u32 = 1000;

/// Percentage of hardware maximum LED brightness we want to reach
pub const LED_MAX_POWER_LEVEL_PERCENT: f32 = 0.18;
pub const LED_MAX_POWER_LEVEL_PERCENT: f32 = 0.15;

/// max. reaction delay when LED Power Phase is in Off or ON state
pub const ON_OFF_REACTION_STEP_DELAY_MS: u32 = 500;

// step-delay (and also max. reaction time) when LED Power Phase is in PowerDown or PowerUp state
pub const LED_DIMM_DOWN_STEP_DELAY_MS: u32 = 18;
pub const LED_DIMM_DOWN_STEP_DELAY_MS: u32 = 15;

pub const LED_DIMM_UP_STEP_DELAY_MS: u32 = 6;

pub const LUX_BUFFER_SIZE: usize = 10;
pub const LUX_THRESHOLD: f32 = 0.75;
pub const LUX_THRESHOLD: f32 = 0.30;

const STATUS_LOG_INTERVAL: Duration = Duration::from_secs(2);

Expand Down
6 changes: 3 additions & 3 deletions code/src/peripheral.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,8 @@ pub fn init_veml7700<I2C: I2c>(

// Initialize the VEML7700 with I2C
let mut veml7700_device = Veml7700::new(i2c_driver);
// PSM mode two (in combination with defaults for other settings) means a refresh time of 1.1 sec
veml7700_device.enable_power_saving(PowerSavingMode::Two).map_err(Error::from)?;
// PSM mode Three (in combination with defaults for other settings) means a refresh time of 2.1 sec
veml7700_device.enable_power_saving(PowerSavingMode::Three).map_err(Error::from)?;
veml7700_device.enable().map_err(Error::from)?;
Ok(veml7700_device)
}
Expand All @@ -299,7 +299,7 @@ where
C: LedcChannel<SpeedMode=<T as LedcTimer>::SpeedMode>,
T: LedcTimer + 'static,
{
let freq = 250.Hz();
let freq = 120.Hz();
let resolution = Resolution::Bits12;

let timer_config = TimerConfig::default()
Expand Down

0 comments on commit 98e61b6

Please sign in to comment.