#![doc = include_str!("../README.md")]
#![cfg_attr(target_os = "none", no_std)]
#[cfg(all(
target_os = "none",
not(any(
feature = "esp32",
feature = "esp32c2",
feature = "esp32c3",
feature = "esp32c5",
feature = "esp32c6",
feature = "esp32c61",
feature = "esp32h2",
feature = "esp32s2",
feature = "esp32s3"
))
))]
compile_error!(
"Select one chip feature for embedded builds: `esp32`, `esp32c2`, `esp32c3`, `esp32c5`, `esp32c6`, `esp32c61`, `esp32h2`, `esp32s2`, or `esp32s3` (with `--no-default-features --features <chip>`)."
);
#[cfg(all(
target_os = "none",
any(
all(feature = "esp32", feature = "esp32c2"),
all(feature = "esp32", feature = "esp32c3"),
all(feature = "esp32", feature = "esp32c5"),
all(feature = "esp32", feature = "esp32c6"),
all(feature = "esp32", feature = "esp32c61"),
all(feature = "esp32", feature = "esp32h2"),
all(feature = "esp32", feature = "esp32s2"),
all(feature = "esp32", feature = "esp32s3"),
all(feature = "esp32c2", feature = "esp32c3"),
all(feature = "esp32c2", feature = "esp32c5"),
all(feature = "esp32c2", feature = "esp32c6"),
all(feature = "esp32c2", feature = "esp32c61"),
all(feature = "esp32c2", feature = "esp32h2"),
all(feature = "esp32c2", feature = "esp32s2"),
all(feature = "esp32c2", feature = "esp32s3"),
all(feature = "esp32c3", feature = "esp32c5"),
all(feature = "esp32c3", feature = "esp32c6"),
all(feature = "esp32c3", feature = "esp32c61"),
all(feature = "esp32c3", feature = "esp32h2"),
all(feature = "esp32c3", feature = "esp32s2"),
all(feature = "esp32c3", feature = "esp32s3"),
all(feature = "esp32c5", feature = "esp32c6"),
all(feature = "esp32c5", feature = "esp32c61"),
all(feature = "esp32c5", feature = "esp32h2"),
all(feature = "esp32c5", feature = "esp32s2"),
all(feature = "esp32c5", feature = "esp32s3"),
all(feature = "esp32c6", feature = "esp32h2"),
all(feature = "esp32c6", feature = "esp32c61"),
all(feature = "esp32c6", feature = "esp32s2"),
all(feature = "esp32c6", feature = "esp32s3"),
all(feature = "esp32c61", feature = "esp32h2"),
all(feature = "esp32c61", feature = "esp32s2"),
all(feature = "esp32c61", feature = "esp32s3"),
all(feature = "esp32h2", feature = "esp32s2"),
all(feature = "esp32h2", feature = "esp32s3"),
all(feature = "esp32s2", feature = "esp32s3"),
)
))]
compile_error!("Select exactly one chip feature for embedded builds, not both.");
pub mod button;
#[cfg(all(target_os = "none", esp_has_wifi))]
pub mod clock_sync {
pub use device_envoy_core::clock_sync::ClockSyncRuntime as ClockSyncEsp;
pub use device_envoy_core::clock_sync::ClockSyncStatic as ClockSyncStaticEsp;
pub use device_envoy_core::clock_sync::{
ClockSync, ClockSyncTick, ONE_DAY, ONE_MINUTE, ONE_SECOND, UnixSeconds, h12_m_s,
};
pub use device_envoy_core::{Error as CoreError, Result as CoreResult};
}
#[cfg(all(target_os = "none", esp_has_wifi))]
#[doc(hidden)]
pub mod time_sync {
pub use device_envoy_core::clock_sync::UnixSeconds;
pub use device_envoy_core::time_sync::{TimeSync, TimeSyncEvent, TimeSyncStatic};
}
#[cfg(esp_has_i2s)]
pub mod audio_player;
pub mod flash_block;
pub mod init_and_start;
#[cfg(esp_has_rmt)]
pub mod ir;
#[cfg(target_os = "none")]
pub mod lcd_text;
#[cfg(target_os = "none")]
pub mod led;
#[cfg(any(feature = "host", target_os = "none"))]
pub mod led2d;
pub mod led4;
#[cfg(target_os = "none")]
pub mod led_strip;
#[cfg(target_os = "none")]
pub mod rfid;
#[cfg(esp_has_rmt)]
mod rmt;
mod rmt_mode;
#[cfg(all(target_os = "none", esp_has_ledc))]
pub mod servo;
#[cfg(all(target_os = "none", esp_has_ledc))]
mod servo_player;
#[cfg(any(feature = "host", esp_has_wifi))]
pub mod wifi_auto;
#[cfg(doc)]
pub mod docs {
pub mod development_guide {
#![doc = include_str!("docs/development_guide.md")]
}
}
pub use device_envoy_core::tone;
#[cfg(any(feature = "host", esp_has_wifi))]
use device_envoy_core::wifi_auto::WifiAutoError;
#[doc(hidden)]
pub use paste::paste as __paste;
#[doc(hidden)]
#[macro_export]
macro_rules! __validate_keyword_fields_expr {
(
macro_name: $macro_name:literal,
allowed_macro: $allowed_macro:path,
fields: [ $( $field:ident : $value:expr ),* $(,)? ]
) => {
const _: () = {
$( $allowed_macro!($field, $macro_name); )*
#[allow(non_snake_case)]
mod __device_envoy_keyword_fields_uniqueness {
$( pub(super) mod $field {} )*
}
};
};
(
macro_name: $macro_name:literal,
allowed_macro: $allowed_macro:path,
fields: [ $($fields:tt)* ]
) => {
compile_error!(concat!($macro_name, " fields must use `name: value` syntax"));
};
}
#[cfg(all(target_arch = "riscv32", target_os = "none"))]
mod _esp_radio_nvs_stubs {
#[unsafe(no_mangle)]
unsafe extern "C" fn __esp_radio_misc_nvs_deinit() {}
#[unsafe(no_mangle)]
unsafe extern "C" fn __esp_radio_misc_nvs_init() -> i32 {
0
}
}
#[doc(hidden)]
#[cfg(target_os = "none")]
pub use esp_hal;
#[doc(hidden)]
#[cfg(target_os = "none")]
pub use esp_rtos;
pub type Result<T, E = Error> = core::result::Result<T, E>;
#[derive(Debug)]
#[non_exhaustive]
pub enum Error {
TaskSpawn(embassy_executor::SpawnError),
Core(device_envoy_core::Error),
#[cfg(target_os = "none")]
FlashStorage(esp_storage::FlashStorageError),
InvalidFlashRegion,
IndexOutOfBounds,
FormatError,
StorageCorrupted,
FlashRegionMismatch,
Led4BitsToIndexesFull,
MissingCustomWifiAutoField,
Ntp(&'static str),
#[cfg(all(target_os = "none", esp_has_rmt))]
RmtConfig(esp_hal::rmt::ConfigError),
#[cfg(all(target_os = "none", esp_has_rmt))]
Rmt(esp_hal::rmt::Error),
#[cfg(target_os = "none")]
SpiConfig(esp_hal::spi::master::ConfigError),
#[cfg(target_os = "none")]
Spi(esp_hal::spi::Error),
#[cfg(target_os = "none")]
Mfrc522Init(esp_hal_mfrc522::consts::PCDErrorCode),
#[cfg(target_os = "none")]
Mfrc522Version(esp_hal_mfrc522::consts::PCDErrorCode),
#[cfg(target_os = "none")]
I2cConfig(esp_hal::i2c::master::ConfigError),
#[cfg(all(target_os = "none", esp_has_ledc))]
LedcTimer(esp_hal::ledc::timer::Error),
#[cfg(all(target_os = "none", esp_has_ledc))]
LedcChannel(esp_hal::ledc::channel::Error),
#[cfg(all(target_os = "none", esp_has_wifi))]
Wifi(esp_radio::wifi::WifiError),
}
impl From<embassy_executor::SpawnError> for Error {
fn from(e: embassy_executor::SpawnError) -> Self {
Self::TaskSpawn(e)
}
}
impl From<device_envoy_core::Error> for Error {
fn from(error: device_envoy_core::Error) -> Self {
match error {
device_envoy_core::Error::TaskSpawn(spawn_error) => Self::TaskSpawn(spawn_error),
core_error => Self::Core(core_error),
}
}
}
impl From<device_envoy_core::led4::Led4BitsToIndexesError> for Error {
fn from(error: device_envoy_core::led4::Led4BitsToIndexesError) -> Self {
match error {
device_envoy_core::led4::Led4BitsToIndexesError::Full => Self::Led4BitsToIndexesFull,
}
}
}
#[cfg(any(feature = "host", esp_has_wifi))]
impl From<WifiAutoError> for Error {
fn from(error: WifiAutoError) -> Self {
match error {
WifiAutoError::FormatError => Self::FormatError,
WifiAutoError::StorageCorrupted => Self::StorageCorrupted,
WifiAutoError::MissingCustomWifiAutoField => Self::MissingCustomWifiAutoField,
}
}
}
#[cfg(target_os = "none")]
impl From<esp_storage::FlashStorageError> for Error {
fn from(error: esp_storage::FlashStorageError) -> Self {
Self::FlashStorage(error)
}
}
#[cfg(all(target_os = "none", esp_has_rmt))]
impl From<esp_hal::rmt::ConfigError> for Error {
fn from(error: esp_hal::rmt::ConfigError) -> Self {
Self::RmtConfig(error)
}
}
#[cfg(all(target_os = "none", esp_has_rmt))]
impl From<esp_hal::rmt::Error> for Error {
fn from(error: esp_hal::rmt::Error) -> Self {
Self::Rmt(error)
}
}
#[cfg(target_os = "none")]
impl From<esp_hal::spi::master::ConfigError> for Error {
fn from(error: esp_hal::spi::master::ConfigError) -> Self {
Self::SpiConfig(error)
}
}
#[cfg(target_os = "none")]
impl From<esp_hal::i2c::master::ConfigError> for Error {
fn from(error: esp_hal::i2c::master::ConfigError) -> Self {
Self::I2cConfig(error)
}
}
#[cfg(target_os = "none")]
impl From<esp_hal::spi::Error> for Error {
fn from(error: esp_hal::spi::Error) -> Self {
Self::Spi(error)
}
}
#[cfg(all(target_os = "none", esp_has_ledc))]
impl From<esp_hal::ledc::timer::Error> for Error {
fn from(error: esp_hal::ledc::timer::Error) -> Self {
Self::LedcTimer(error)
}
}
#[cfg(all(target_os = "none", esp_has_ledc))]
impl From<esp_hal::ledc::channel::Error> for Error {
fn from(error: esp_hal::ledc::channel::Error) -> Self {
Self::LedcChannel(error)
}
}
#[cfg(all(target_os = "none", esp_has_wifi))]
impl From<esp_radio::wifi::WifiError> for Error {
fn from(error: esp_radio::wifi::WifiError) -> Self {
Self::Wifi(error)
}
}