Configuration

Struct Configuration 

Source
pub struct Configuration {
    pub cpu_clock: CpuClock,
    pub spi_frequency: HertzU32,
    pub display_refresh_order: RefreshOrder,
    pub display_rotation: Rotation,
    pub display_tearing: TearingEffect,
    pub adc_cfg: AdcCfg,
    pub i2s_tx_config: I2sTxConfig,
    pub buzzer_config: BuzzerConfig,
}
Expand description

Top-level configuration passed to crate::Lilka::init.

All fields have sensible defaults via Configuration::default. Use struct-update syntax to override only what you need:

use lilkaoxide::prelude::*;

let config = LilkaConfiguration {
    display_rotation: mipidsi::options::Rotation::Deg90,
    ..LilkaConfiguration::default()
};

§Field reference

FieldTypeDefaultDescription
cpu_clock[CpuClock]system defaultESP32-S3 core frequency.
spi_frequencyHertzU3260 MHzSPI2 clock for display + SD.
display_refresh_order[RefreshOrder]defaultST7789 line-scan order.
display_rotation[Rotation]Deg270Screen rotation (landscape).
display_tearing[TearingEffect]OffTearing-effect output signal.
adc_cfgAdcCfg11 dB attenuationBattery ADC channel config.
i2s_tx_configI2sTxConfig44 100 Hz stereoI2S audio output config.
buzzer_configBuzzerConfig4 kHz / 50 %PWM buzzer config.

Fields§

§cpu_clock: CpuClock

CPU clock speed. Higher speeds increase performance but also current draw.

§spi_frequency: HertzU32

SPI2 bus clock. Both the display (ST7789) and the SD card share this bus. The ST7789 supports up to ~80 MHz; SD cards typically max out at 25 MHz. 60 MHz is a balanced default that works reliably with both devices.

§display_refresh_order: RefreshOrder

Controls the order in which the ST7789 controller scans rows and columns during a frame refresh. Changing this can fix visual artifacts on some panels.

§display_rotation: Rotation

Physical rotation of the display image. The Lilka is held in landscape mode, so the default Deg270 maps the (0,0) origin to the top-left corner.

§display_tearing: TearingEffect

Enables the tearing-effect (TE) output signal on the ST7789. Leave Off unless you are implementing vsync-locked rendering.

§adc_cfg: AdcCfg

Battery ADC channel configuration. The default 11 dB attenuation allows measurement up to ~3.1 V which covers a typical Li-Po discharge range.

§i2s_tx_config: I2sTxConfig

I2S transmitter configuration (sample rate, channel count, bit depth, TDM standard).

§buzzer_config: BuzzerConfig

PWM buzzer configuration (frequency, duty cycle, timer resolution).

Implementations§

Source§

impl Configuration

Source

pub fn new( spi_frequency: HertzU32, cpu_clock: CpuClock, display_refresh_order: RefreshOrder, display_rotation: Rotation, display_tearing: TearingEffect, adc_cfg: AdcCfg, i2s_tx_config: I2sTxConfig, buzzer_config: BuzzerConfig, ) -> Configuration

Creates a fully-specified Configuration.

Prefer using struct-update syntax with Configuration::default when you only want to override a few fields — it is more readable and less error-prone than listing every argument.

§Parameters
  • spi_frequency — SPI2 clock. 60.MHz() is a safe default.
  • cpu_clock — CPU core frequency. CpuClock::default() starts at 240 MHz.
  • display_refresh_order — ST7789 pixel scan order.
  • display_rotation — Screen rotation; use Rotation::Deg270 for landscape.
  • display_tearing — TE signal; use TearingEffect::Off unless you need vsync.
  • adc_cfg — ADC1 attenuation for the battery pin.
  • i2s_tx_config — Audio output format and sample rate.
  • buzzer_config — Buzzer frequency and duty cycle.
§Example
use lilkaoxide::prelude::*;
use lilkaoxide::{LilkaConfiguration, AdcCfg, I2sTxConfig};
use esp_hal::analog::adc::Attenuation;
use esp_hal::clock::CpuClock;
use fugit::RateExtU32;

use mipidsi::options::{RefreshOrder, Rotation, TearingEffect};

let config = LilkaConfiguration::new(
    80.MHz(),                     // spi_frequency
    CpuClock::default(),          // cpu_clock
    RefreshOrder::default(),      // display_refresh_order
    Rotation::Deg270,             // display_rotation
    TearingEffect::Off,           // display_tearing
    AdcCfg { attenuation: Attenuation::_11dB },
    I2sTxConfig::default(),
    BuzzerConfig::default(),
);

Trait Implementations§

Source§

impl Default for Configuration

Source§

fn default() -> Configuration

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Configuration

§

impl RefUnwindSafe for Configuration

§

impl Send for Configuration

§

impl Sync for Configuration

§

impl Unpin for Configuration

§

impl UnwindSafe for Configuration

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

Source§

impl<T> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.