From d944fc1de3a595286cedc164541a0e82c841c448 Mon Sep 17 00:00:00 2001 From: Ivan Li Date: Tue, 3 May 2022 11:11:36 +0800 Subject: [PATCH] style: clean up. --- Cargo.toml | 3 +-- src/main.rs | 5 ++--- src/screen.rs | 9 ++++----- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0588737..550a976 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ opt-level = "s" [profile.dev] debug = true # Symbols are nice and they don't increase the size on Flash -opt-level = "z" +opt-level = "z" [features] pio = ["esp-idf-sys/pio"] @@ -21,7 +21,6 @@ embedded-graphics = "0.7.1" embedded-hal = "1.0.0-alpha.8" esp-idf-hal = "0.37.3" esp-idf-sys = {version = "0.31.5", features = ["binstart"]} -log = "0.4.16" ssd1306 = "0.7.0" [build-dependencies] diff --git a/src/main.rs b/src/main.rs index 9cead4b..168500a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,4 @@ use esp_idf_sys as _; -use log::*; use std::{thread, time::Duration}; mod beep; @@ -23,7 +22,7 @@ fn main() { let gpio10 = peripherals.pins.gpio10; println!("Starting screen"); - let mut screen = screen::Screen::new(i2c0, gpio9, gpio10).expect("Failed to create screen"); + screen::Screen::new(i2c0, gpio9, gpio10).expect("Failed to create screen"); thread::spawn(move || { let mut blink = @@ -51,7 +50,7 @@ fn main() { .into_output() .expect("Failed to set GPIO2 as output"), ); - while true { + loop { if dc_out_ctl.state { dc_out_ctl.off().expect("Failed to turn DC_OUT_CTL off"); } else { diff --git a/src/screen.rs b/src/screen.rs index 37186a9..f4c203e 100644 --- a/src/screen.rs +++ b/src/screen.rs @@ -1,4 +1,4 @@ -use anyhow::{Result, Error}; +use anyhow::{Result}; use embedded_graphics::{ mono_font::{ascii::FONT_10X20, MonoTextStyle}, pixelcolor::Rgb565, @@ -13,7 +13,6 @@ use esp_idf_hal::{ i2c::{self, Master, I2C0}, prelude::*, }; -use log::info; use ssd1306::{ mode::{BufferedGraphicsMode, DisplayConfig}, prelude::I2CInterface, @@ -46,7 +45,7 @@ impl Screen { let di = ssd1306::I2CDisplayInterface::new(i2c); let mut delay = delay::Ets; - delay.delay_ms(10_u32); + delay.delay_ms(10_u32)?; let mut display = ssd1306::Ssd1306::new( di, @@ -64,12 +63,12 @@ impl Screen { let mut instance = Screen { display }; - instance.drawBoot()?; + instance.draw_boot()?; Ok(instance) } - pub fn drawBoot(&mut self) -> Result<()> + pub fn draw_boot(&mut self) -> Result<()> { println!("LED rendering done"); self.display.clear();