Skip to main content

Crate m5unified

Crate m5unified 

Source
Expand description

Safe Rust wrapper for a small M5Unified C ABI surface.

The API is intentionally shaped around M5Unified’s common examples while keeping Rust call sites safe and host-checkable. Hardware calls are provided by m5unified-sys; on non-ESP-IDF targets that crate supplies no-op stubs so examples compile in CI.

§Example

use m5unified::{colors, M5Unified};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut m5 = M5Unified::begin()?;

    m5.display.fill_screen(colors::BLACK);
    m5.display.set_text_size(2);
    m5.display.println("hello from Rust")?;

    loop {
        m5.update();
        if m5.buttons.a().was_pressed() {
            m5.display.println("Button A")?;
        }
        m5.delay_ms(16);
    }
}

Modules§

colors
Common RGB565 color constants used by the translated examples.

Structs§

Aw32001
Axp192
Axp2101
Axp2101IrqStatus
Bq27220
Button
Buttons
Color565
Date
DateTime
Display
DisplayRef
ExtPortBusConfig
ExtPortMask
External port mask for boards with independently switchable power outputs.
ExternalDisplayConfig
ExternalSpeakerConfig
I2cBus
I2cDevice
Imu
ImuConvertParams
ImuData
ImuDevice
ImuRawData
ImuSensorMask
Ina226
Ina226Config
INA226 power monitor configuration.
Ina3221
IoExpander
Ip5306
Led
LedColor
LedPowerHub
LedStrip
LedStripConfig
LedStripRmtConfig
Log
M5Timer
M5Unified
Top-level handle for M5Unified-backed board features.
M5UnifiedConfig
Mic
MicConfig
Pi4ioe5v6408
Point
Power
Py32Pmic
RawPlaybackOptions
RawVec3
RecordingOptions
Rect
Rtc
RtcDevice
SdCard
Mounted SD card handle.
SdSpiConfig
SPI configuration for mounting an SD card through ESP-IDF’s SDSPI driver.
Size
Speaker
SpeakerConfig
Time
ToneOptions
Touch
TouchDetail
TouchPoint
Vec3
WavPlaybackOptions

Enums§

AudioQueueState
Aw32001ChargeStatus
Charge state reported directly by the AW32001 charger.
Axp192PekPress
Latched AXP192 PEK button press state.
Axp2101ChargeStatus
Charge state reported directly by the AXP2101 PMIC.
Axp2101PekPress
Latched AXP2101 PEK button press state.
Board
ButtonId
ButtonState
ChargeState
Battery charge state reported by M5Unified.
DisplayFont
DisplayKind
EpdMode
Error
Errors returned by the high-level wrapper.
ImuAxis
ImuDeviceKind
ImuKind
Ina226ConversionTime
INA226 bus or shunt conversion time.
Ina226Mode
INA226 operation mode.
Ina226Sampling
INA226 sample averaging rate.
LedStripColorOrder
LedType
LogLevel
LogTarget
PinName
PowerType
M5Unified PMIC type.
Py32PmicPekPress
Latched PY32 PMIC power-key press state.
RtcDeviceKind
TextDatum
TouchState

Constants§

SD_MOUNT_PATH
FAT VFS mount path used by the native SD SPI helper.

Functions§

sd_begin
Mount an SD card using the board SD SPI pins reported by M5Unified.
sd_begin_with_config
Mount an SD card using explicit SPI pins and mount options.
sd_end
Unmount the SD card mounted by sd_begin or sd_begin_with_config.
sd_is_mounted
Return whether this shim has an SD card mounted at SD_MOUNT_PATH.

Type Aliases§

RawLogCallback