mirror of
https://github.com/FliegendeWurst/raspi-oled.git
synced 2024-11-08 13:20:37 +00:00
Fix TOTP paging
This commit is contained in:
parent
30683b42f0
commit
f4d42943af
@ -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,
|
||||
|
@ -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<D: DrawTarget<Color = Rgb565>> Screensaver<D> for Measurements {
|
||||
}
|
||||
|
||||
impl<D: DrawTarget<Color = Rgb565>> Draw<D> for Measurements {
|
||||
fn draw_with_ctx(&self, ctx: &ContextDefault<D>, disp: &mut D, rng: &mut crate::Rng) -> Result<bool, D::Error> {
|
||||
fn draw_with_ctx(&self, ctx: &ContextDefault<D>, disp: &mut D, _rng: &mut crate::Rng) -> Result<bool, D::Error> {
|
||||
if self.drawn.load(std::sync::atomic::Ordering::Relaxed) {
|
||||
return Ok(false);
|
||||
}
|
||||
@ -416,7 +416,7 @@ impl<D: DrawTarget<Color = Rgb565>> Draw<D> for Measurements {
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
fn draw(&self, disp: &mut D, rng: &mut crate::Rng) -> Result<bool, <D as DrawTarget>::Error> {
|
||||
fn draw(&self, _disp: &mut D, _rng: &mut crate::Rng) -> Result<bool, <D as DrawTarget>::Error> {
|
||||
panic!("draw without ctx");
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -405,7 +405,11 @@ fn main_loop(mut disp: Oled, mut ctx: ContextDefault<Oled>) {
|
||||
}
|
||||
pop_last = true;
|
||||
},
|
||||
[3, 2] => {
|
||||
[3, 2, 1] => {
|
||||
enable_pwm().unwrap();
|
||||
pop_last = true;
|
||||
},
|
||||
[3, 2, 3] => {
|
||||
disable_pwm().unwrap();
|
||||
pop_last = true;
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user