15 | Edit
16 | components/HelloWorld.vue to test HMR
17 |
21 | Check out 22 | create-vue, the official Vue + Vite starter 25 |
26 |27 | Install 28 | Volar 29 | in your IDE for a better DX 30 |
31 |Click on the Vite and Vue logos to learn more
32 | 33 | 34 | 39 | -------------------------------------------------------------------------------- /app/encoder/rotary_encoder/src/main.rs: -------------------------------------------------------------------------------- 1 | use anyhow::Context; 2 | use esp_idf_svc::{ 3 | hal::{delay::FreeRtos, peripherals::Peripherals}, 4 | log::EspLogger, 5 | sys::link_patches, 6 | }; 7 | use pcnt_encoder::Encoder; 8 | 9 | fn main() -> anyhow::Result<()> { 10 | link_patches(); 11 | EspLogger::initialize_default(); 12 | log::set_max_level(log::LevelFilter::Info); 13 | 14 | println!("setup pins"); 15 | let peripherals = Peripherals::take().context("failed to take Peripherals")?; 16 | let mut pin_a = peripherals.pins.gpio4; 17 | let mut pin_b = peripherals.pins.gpio5; 18 | println!("setup encoder"); 19 | let encoder = Encoder::new(peripherals.pcnt0, &mut pin_a, &mut pin_b)?; 20 | 21 | let mut last_value = 0_i32; 22 | loop { 23 | let value = encoder.get_value()?; 24 | if value != last_value { 25 | println!("value: {value}"); 26 | last_value = value; 27 | } 28 | FreeRtos::delay_ms(100u32); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /core/esp32s3-nrf24l01/Cargo.toml: -------------------------------------------------------------------------------- 1 | # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO 2 | # 3 | # When uploading crates to the registry Cargo will automatically 4 | # "normalize" Cargo.toml files for maximal compatibility 5 | # with all versions of Cargo and also rewrite `path` dependencies 6 | # to registry (e.g., crates.io) dependencies 7 | # 8 | # If you believe there's an error in this file please file an 9 | # issue against the rust-lang/cargo repository. If you're 10 | # editing this file be aware that the upstream Cargo.toml 11 | # will likely look very different (and much more reasonable) 12 | [package] 13 | name = "esp32s3-nrf24l01" 14 | version = "0.1.0" 15 | edition = "2021" 16 | authors = ["silent-rain <2367221387@qq.com>"] 17 | description = "A driver for NRF24L01(+) transceivers on embedded-hal platforms." 18 | keywords = ["driver", "wireless", "nrf", "nrf24l01"] 19 | categories = [] 20 | repository = "" 21 | 22 | [dependencies] 23 | esp-idf-hal = "0.42.5" 24 | anyhow = "1.0.79" 25 | bitfield = "0.14.0" 26 | nb = "1.1.0" 27 | -------------------------------------------------------------------------------- /app/basic/buzzer/src/main.rs: -------------------------------------------------------------------------------- 1 | #![allow(clippy::empty_loop)] 2 | 3 | use esp_idf_svc::{ 4 | hal::{delay::FreeRtos, gpio::PinDriver, peripherals::Peripherals}, 5 | log::EspLogger, 6 | sys::link_patches, 7 | }; 8 | 9 | fn main() -> anyhow::Result<()> { 10 | // It is necessary to call this function once. Otherwise some patches to the runtime 11 | // implemented by esp-idf-sys might not link properly. See https://github.com/esp-rs/esp-idf-template/issues/71 12 | link_patches(); 13 | 14 | // Bind the log crate to the ESP Logging facilities 15 | EspLogger::initialize_default(); 16 | 17 | // 设置日志级别 18 | log::set_max_level(log::LevelFilter::Info); 19 | 20 | // Get the peripherals 21 | let peripherals = Peripherals::take()?; 22 | 23 | let mut buzzer = PinDriver::output(peripherals.pins.gpio4)?; 24 | 25 | log::warn!("loop"); 26 | loop { 27 | buzzer.set_high()?; 28 | FreeRtos::delay_ms(1000); 29 | buzzer.set_low()?; 30 | FreeRtos::delay_ms(1000); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /core/esp32s3-nrf24l01/src/payload.rs: -------------------------------------------------------------------------------- 1 | use core::ops::Deref; 2 | 3 | /// Represents a received packet. Stores 32 bytes and the actual length. 4 | /// 5 | /// Use [`as_ref()`](#method.as_ref) or [`Deref`](#impl-Deref) to 6 | /// obtain a slice of the content. 7 | pub struct Payload { 8 | data: [u8; 32], 9 | len: usize, 10 | } 11 | 12 | impl Payload { 13 | /// Copy a slice 14 | pub fn new(source: &[u8]) -> Self { 15 | let mut data = [0; 32]; 16 | let len = source.len().min(data.len()); 17 | data[0..len].copy_from_slice(&source[0..len]); 18 | Payload { data, len } 19 | } 20 | 21 | /// Read length 22 | #[allow(clippy::len_without_is_empty)] 23 | pub fn len(&self) -> usize { 24 | self.len 25 | } 26 | } 27 | 28 | impl AsRef<[u8]> for Payload { 29 | fn as_ref(&self) -> &[u8] { 30 | &self.data[0..self.len] 31 | } 32 | } 33 | 34 | impl Deref for Payload { 35 | type Target = [u8]; 36 | fn deref(&self) -> &[u8] { 37 | self.as_ref() 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/http/http_server_vue/src/asset.rs: -------------------------------------------------------------------------------- 1 | //! 静态资源文件 2 | #![allow(unused)] 3 | use rust_embed::RustEmbed; 4 | 5 | /// WEB 静态资源 6 | #[derive(Debug, Default, RustEmbed)] 7 | #[folder = "./web/dist/"] 8 | pub struct AssetWebDist; 9 | 10 | impl AssetWebDist { 11 | pub fn to_bytes(path: String) -> Option