diff --git a/src/bin/ccs811.rs b/src/bin/ccs811.rs index bf3d1d3..050c948 100644 --- a/src/bin/ccs811.rs +++ b/src/bin/ccs811.rs @@ -4,25 +4,25 @@ use linux_embedded_hal::I2cdev; const CCS811_ADDR: u8 = 0x5A; // or 0x5B -const CCS811_STATUS: u8 = 0x00; -const CCS811_MEAS_MODE: u8 = 0x01; -const CCS811_ALG_RESULT_DATA: u8 = 0x02; -const CCS811_RAW_DATA: u8 = 0x03; -const CCS811_ENV_DATA: u8 = 0x05; -const CCS811_NTC: u8 = 0x06; -const CCS811_THRESHOLDS: u8 = 0x10; -const CCS811_BASELINE: u8 = 0x11; -const CCS811_HW_ID: u8 = 0x20; -const CCS811_HW_VERSION: u8 = 0x21; -const CCS811_FW_BOOT_VERSION: u8 = 0x23; -const CCS811_FW_APP_VERSION: u8 = 0x24; -const CCS811_ERROR_ID: u8 = 0xE0; -const CCS811_APP_START: u8 = 0xF4; -const CCS811_SW_RESET: u8 = 0xFF; +pub const CCS811_STATUS: u8 = 0x00; +pub const CCS811_MEAS_MODE: u8 = 0x01; +pub const CCS811_ALG_RESULT_DATA: u8 = 0x02; +pub const CCS811_RAW_DATA: u8 = 0x03; +pub const CCS811_ENV_DATA: u8 = 0x05; +pub const CCS811_NTC: u8 = 0x06; +pub const CCS811_THRESHOLDS: u8 = 0x10; +pub const CCS811_BASELINE: u8 = 0x11; +pub const CCS811_HW_ID: u8 = 0x20; +pub const CCS811_HW_VERSION: u8 = 0x21; +pub const CCS811_FW_BOOT_VERSION: u8 = 0x23; +pub const CCS811_FW_APP_VERSION: u8 = 0x24; +pub const CCS811_ERROR_ID: u8 = 0xE0; +pub const CCS811_APP_START: u8 = 0xF4; +pub const CCS811_SW_RESET: u8 = 0xFF; -struct CCS811 { +pub struct CCS811 { i2c: I2cdev, - addr: u8, + pub addr: u8, } impl CCS811 { @@ -79,7 +79,7 @@ impl CCS811 { } } -enum CCS811DriveMode { +pub enum CCS811DriveMode { Idle = 0, EverySecond = 1, Every10Seconds = 2, diff --git a/src/bin/draw/measurements.rs b/src/bin/draw/measurements.rs index 624df93..aef86a3 100644 --- a/src/bin/draw/measurements.rs +++ b/src/bin/draw/measurements.rs @@ -3,7 +3,7 @@ use std::{any::Any, fs, ops::Sub, sync::atomic::AtomicBool, time::Duration}; use embedded_graphics::{ image::ImageRaw, mono_font::{ - ascii::{FONT_10X20, FONT_4X6, FONT_5X8, FONT_6X9, FONT_9X15}, + ascii::{FONT_4X6, FONT_5X8, FONT_6X9, FONT_9X15}, mapping::StrGlyphMapping, DecorationDimensions, MonoFont, MonoTextStyleBuilder, }, @@ -85,7 +85,7 @@ impl> Screensaver for Measurements { } impl> Draw for Measurements { - fn draw_with_ctx(&self, ctx: &ContextDefault, disp: &mut D, rng: &mut crate::Rng) -> Result { + fn draw_with_ctx(&self, ctx: &ContextDefault, disp: &mut D, _rng: &mut crate::Rng) -> Result { if self.drawn.load(std::sync::atomic::Ordering::Relaxed) { return Ok(false); } @@ -416,7 +416,7 @@ impl> Draw for Measurements { Ok(true) } - fn draw(&self, disp: &mut D, rng: &mut crate::Rng) -> Result::Error> { + fn draw(&self, _disp: &mut D, _rng: &mut crate::Rng) -> Result::Error> { panic!("draw without ctx"); } diff --git a/src/bin/draw/totp.rs b/src/bin/draw/totp.rs index 9011738..f41d8fd 100644 --- a/src/bin/draw/totp.rs +++ b/src/bin/draw/totp.rs @@ -13,7 +13,7 @@ use embedded_graphics::{ }; use totp_rs::TOTP; -use crate::{screensaver::Screensaver, Context, ContextDefault, Draw, BLACK}; +use crate::{screensaver::Screensaver, Draw, BLACK}; #[derive(Debug, Clone)] pub struct Totp { @@ -33,6 +33,9 @@ impl Totp { pub fn next_page(&mut self) { self.page += 1; + if self.secrets.len() < self.page * 6 { + self.page = 0; + } } } diff --git a/src/bin/main_loop.rs b/src/bin/main_loop.rs index c388f00..59397a5 100644 --- a/src/bin/main_loop.rs +++ b/src/bin/main_loop.rs @@ -405,7 +405,11 @@ fn main_loop(mut disp: Oled, mut ctx: ContextDefault) { } pop_last = true; }, - [3, 2] => { + [3, 2, 1] => { + enable_pwm().unwrap(); + pop_last = true; + }, + [3, 2, 3] => { disable_pwm().unwrap(); pop_last = true; },