atomvm_gleam/pico

Types

Erlang calendar:date() — {Year, Month, Day}.

pub type Date {
  Date(year: Int, month: Int, day: Int)
}

Constructors

  • Date(year: Int, month: Int, day: Int)

Erlang calendar:datetime() — {{Year, Month, Day}, {Hour, Minute, Second}}.

pub type DateTime {
  DateTime(date: Date, time: TimeOfDay)
}

Constructors

Pico / RP2-specific AtomVM APIs (pico module).

CYW43 GPIO helpers are Pico-W only. The onboard LED is typically CYW43 GPIO 0.

Source: libs/avm_rp2/src/pico.erl. Docs: Module pico. Errors from Pico NIFs and helpers.

Known reason atoms are Gleam constructors (so {error, not_supported} is Error(NotSupported)). Bare AtomVM error becomes Failed. Anything else lands in Other as a string.

pub type Error {
  Failed
  NotSupported
  Badarg
  Timeout
  Other(String)
}

Constructors

  • Failed
  • NotSupported
  • Badarg
  • Timeout
  • Other(String)

Digital level for CYW43 GPIO write. Mapped to Erlang 0 / 1 in FFI (matching upstream pico:cyw43_arch_gpio_put/2).

Naming matches gpio.Level (PinHigh / PinLow).

pub type Level {
  PinHigh
  PinLow
}

Constructors

  • PinHigh
  • PinLow

Erlang calendar:time() — {Hour, Minute, Second}.

pub type TimeOfDay {
  TimeOfDay(hour: Int, minute: Int, second: Int)
}

Constructors

  • TimeOfDay(hour: Int, minute: Int, second: Int)

Values

pub fn cyw43_arch_gpio_get(gpio: Int) -> Result(Int, Error)

Read a CYW43 GPIO pin (0..2). Pico-W only. Returns 0 or 1.

See pico:cyw43_arch_gpio_get/1.

pub fn cyw43_arch_gpio_put(
  gpio: Int,
  level: Level,
) -> Result(Nil, Error)

Write a CYW43 GPIO pin (0..2). Pico-W only. Typically drives the onboard LED (GPIO 0).

See pico:cyw43_arch_gpio_put/2.

pub fn error_to_string(error: Error) -> String

Format an Error for logging.

pub fn rtc_set_datetime(datetime: DateTime) -> Result(Nil, Error)

Set the RTC clock from a calendar:datetime()-shaped value.

See pico:rtc_set_datetime/1.

✨ Search Document