1#![doc = include_str!("../README.md")]
2#![cfg_attr(target_os = "none", no_std)]
3
4pub mod button;
5#[cfg(target_os = "none")]
6pub mod clock_sync {
7 pub use device_envoy_core::clock_sync::ClockSyncRuntime as ClockSyncEsp;
101 pub use device_envoy_core::clock_sync::ClockSyncStatic as ClockSyncStaticEsp;
103 pub use device_envoy_core::clock_sync::{
104 h12_m_s, ClockSync, ClockSyncTick, UnixSeconds, ONE_DAY, ONE_MINUTE, ONE_SECOND,
105 };
106}
107#[cfg(target_os = "none")]
108#[doc(hidden)]
109pub mod time_sync {
110 pub use device_envoy_core::clock_sync::UnixSeconds;
113 pub use device_envoy_core::time_sync::{TimeSync, TimeSyncEvent, TimeSyncStatic};
114}
115pub mod audio_player;
116pub mod flash_block;
117pub mod init_and_start;
118pub mod ir;
119#[cfg(target_os = "none")]
120pub mod lcd_text;
121#[cfg(target_os = "none")]
122pub mod led;
123pub mod led2d;
124pub mod led4;
125pub mod led_strip;
126#[cfg(target_os = "none")]
127pub mod rfid;
128mod rmt;
129mod rmt_mode;
130#[cfg(target_os = "none")]
131pub mod servo;
132#[cfg(target_os = "none")]
133mod servo_player;
134pub mod wifi_auto;
135
136#[cfg(doc)]
137pub mod docs {
138 pub mod development_guide {
140 #![doc = include_str!("docs/development_guide.md")]
141 }
142}
143
144pub use device_envoy_core::tone;
145use device_envoy_core::wifi_auto::WifiAutoError;
146#[doc(hidden)]
148pub use paste::paste as __paste;
149
150#[doc(hidden)]
152#[macro_export]
153macro_rules! __validate_keyword_fields_expr {
154 (
155 macro_name: $macro_name:literal,
156 allowed_macro: $allowed_macro:path,
157 fields: [ $( $field:ident : $value:expr ),* $(,)? ]
158 ) => {
159 const _: () = {
160 $( $allowed_macro!($field, $macro_name); )*
161 #[allow(non_snake_case)]
162 mod __device_envoy_keyword_fields_uniqueness {
163 $( pub(super) mod $field {} )*
164 }
165 };
166 };
167
168 (
169 macro_name: $macro_name:literal,
170 allowed_macro: $allowed_macro:path,
171 fields: [ $($fields:tt)* ]
172 ) => {
173 compile_error!(concat!($macro_name, " fields must use `name: value` syntax"));
174 };
175}
176
177#[cfg(all(target_arch = "riscv32", target_os = "none"))]
187mod _esp_radio_nvs_stubs {
188 #[unsafe(no_mangle)]
189 unsafe extern "C" fn __esp_radio_misc_nvs_deinit() {}
190
191 #[unsafe(no_mangle)]
192 unsafe extern "C" fn __esp_radio_misc_nvs_init() -> i32 {
193 0
194 }
195}
196
197#[doc(hidden)]
198#[cfg(target_os = "none")]
199pub use esp_hal;
200#[doc(hidden)]
201#[cfg(target_os = "none")]
202pub use esp_rtos;
203
204pub type Result<T, E = Error> = core::result::Result<T, E>;
205
206#[derive(Debug)]
207#[non_exhaustive]
208pub enum Error {
209 TaskSpawn(embassy_executor::SpawnError),
210 #[cfg(target_os = "none")]
211 FlashStorage(esp_storage::FlashStorageError),
212 InvalidFlashRegion,
213 IndexOutOfBounds,
214 FormatError,
215 StorageCorrupted,
216 FlashRegionMismatch,
217 Led4BitsToIndexesFull,
218 MissingCustomWifiAutoField,
219 Ntp(&'static str),
220 #[cfg(target_os = "none")]
221 Rmt(esp_hal::rmt::Error),
222 #[cfg(target_os = "none")]
223 SpiConfig(esp_hal::spi::master::ConfigError),
224 #[cfg(target_os = "none")]
225 Spi(esp_hal::spi::Error),
226 #[cfg(target_os = "none")]
227 Mfrc522Init(esp_hal_mfrc522::consts::PCDErrorCode),
228 #[cfg(target_os = "none")]
229 Mfrc522Version(esp_hal_mfrc522::consts::PCDErrorCode),
230 #[cfg(target_os = "none")]
231 I2cConfig(esp_hal::i2c::master::ConfigError),
232 #[cfg(target_os = "none")]
233 LedcTimer(esp_hal::ledc::timer::Error),
234 #[cfg(target_os = "none")]
235 LedcChannel(esp_hal::ledc::channel::Error),
236 #[cfg(target_os = "none")]
237 WifiInit(esp_radio::InitializationError),
238 #[cfg(target_os = "none")]
239 Wifi(esp_radio::wifi::WifiError),
240}
241
242impl From<embassy_executor::SpawnError> for Error {
243 fn from(e: embassy_executor::SpawnError) -> Self {
244 Self::TaskSpawn(e)
245 }
246}
247
248impl From<device_envoy_core::led4::Led4BitsToIndexesError> for Error {
249 fn from(error: device_envoy_core::led4::Led4BitsToIndexesError) -> Self {
250 match error {
251 device_envoy_core::led4::Led4BitsToIndexesError::Full => Self::Led4BitsToIndexesFull,
252 }
253 }
254}
255
256impl From<WifiAutoError> for Error {
257 fn from(error: WifiAutoError) -> Self {
258 match error {
259 WifiAutoError::FormatError => Self::FormatError,
260 WifiAutoError::StorageCorrupted => Self::StorageCorrupted,
261 WifiAutoError::MissingCustomWifiAutoField => Self::MissingCustomWifiAutoField,
262 }
263 }
264}
265
266#[cfg(target_os = "none")]
267impl From<esp_storage::FlashStorageError> for Error {
268 fn from(error: esp_storage::FlashStorageError) -> Self {
269 Self::FlashStorage(error)
270 }
271}
272
273#[cfg(target_os = "none")]
274impl From<esp_radio::InitializationError> for Error {
275 fn from(error: esp_radio::InitializationError) -> Self {
276 Self::WifiInit(error)
277 }
278}
279
280#[cfg(target_os = "none")]
281impl From<esp_hal::rmt::Error> for Error {
282 fn from(error: esp_hal::rmt::Error) -> Self {
283 Self::Rmt(error)
284 }
285}
286
287#[cfg(target_os = "none")]
288impl From<esp_hal::spi::master::ConfigError> for Error {
289 fn from(error: esp_hal::spi::master::ConfigError) -> Self {
290 Self::SpiConfig(error)
291 }
292}
293
294#[cfg(target_os = "none")]
295impl From<esp_hal::i2c::master::ConfigError> for Error {
296 fn from(error: esp_hal::i2c::master::ConfigError) -> Self {
297 Self::I2cConfig(error)
298 }
299}
300
301#[cfg(target_os = "none")]
302impl From<esp_hal::spi::Error> for Error {
303 fn from(error: esp_hal::spi::Error) -> Self {
304 Self::Spi(error)
305 }
306}
307
308#[cfg(target_os = "none")]
309impl From<esp_hal::ledc::timer::Error> for Error {
310 fn from(error: esp_hal::ledc::timer::Error) -> Self {
311 Self::LedcTimer(error)
312 }
313}
314
315#[cfg(target_os = "none")]
316impl From<esp_hal::ledc::channel::Error> for Error {
317 fn from(error: esp_hal::ledc::channel::Error) -> Self {
318 Self::LedcChannel(error)
319 }
320}
321
322#[cfg(target_os = "none")]
323impl From<esp_radio::wifi::WifiError> for Error {
324 fn from(error: esp_radio::wifi::WifiError) -> Self {
325 Self::Wifi(error)
326 }
327}