use esp_idf_sys as _;
//use hello_world::sht3xb::{Sht3x,Address, Repeatability};
// If using the `binstart` feature of `esp-idf-sys`, always keep this module imported
use log::*;
use esp_idf_hal::{
delay::FreeRtos,
i2c::{I2cConfig, I2cDriver},
peripherals::Peripherals,
prelude::*
};
use esp_println::println;
use shared_bus::{BusManagerSimple};
use core::fmt::Write;
use sht3x::{SHT3x, Repeatability};
//use crates::sht3xb::{Address, Repeatability, SHT3x};
use ssd1306::{prelude::*, I2CDisplayInterface, Ssd1306};
fn main() -> anyhow::Result<()>{
// It is necessary to call this function once. Otherwise some patches to the runtime
// implemented by esp-idf-sys might not link properly. See https://github.com/esp-rs/esp-idf-template/issues/71
esp_idf_sys::link_patches();
// Bind the log crate to the ESP Logging facilities
esp_idf_svc::log::EspLogger::initialize_default();
let mut peripherals=Peripherals::take().unwrap();
println!("hello\r\n");
let mut sda=peripherals.pins.gpio8;
let mut scl=peripherals.pins.gpio10;
let config=I2cConfig::new().baudrate(400.kHz().into());
let mut i2c=I2cDriver::new(&mut peripherals.i2c0,&mut sda,&mut scl,&config).unwrap();
//let i2c_bus=BusManagerSimple::new(i2c);
//let mut sensor=Sht3x::new(&mut i2c,Address::Low);
let interface=I2CDisplayInterface::new(i2c);
//let mut sensor=SHT3x::new(i2c_bus.acquire_i2c(),FreeRtos,sht3x::Address::Low);
let mut display = Ssd1306::new(
interface,
DisplaySize128x64,
DisplayRotation::Rotate0,
).into_terminal_mode();
display.init().unwrap();
display.clear().unwrap();
// Spam some characters to the display
for c in 97..123 {
let _ = display.write_str(unsafe { core::str::from_utf8_unchecked(&[c]) });
}
for c in 65..91 {
let _ = display.write_str(unsafe { core::str::from_utf8_unchecked(&[c]) });
}
println!("init finished\r\n");
loop{
println!("looping");
FreeRtos::delay_ms(1000);
//let m = sensor.measure(Repeatability::High).unwrap();
// println!("Temp: {:.2} Humidity: {:.2}\r\n", m.temperature as f32/100.0, m.humidity as f32 /100.0);
}
}
Loading
esp32-c3-devkitm-1
esp32-c3-devkitm-1