Inky-Frame
Drivers and Utilities for Pinorami InkyFrame Devices
Rust library with helpers and API functions to design programs for InkyFrame devices or take advantage of any of the supplied embedded device utilities.
InkyFrame Devices
The Inky Frame 7.3 version uses different methods to update the display and set color information and is not directly supported. (I am open to pull requests to add support :3)
While the 5.7 model is supported, I don't have one on-hand to test. Specifically, the Display buffer size; it might need to be adjusted.
Supported Devices
Support for devices matches the underlying RPSP support library. View the RPSP README for more information.
Exposed Libraries
While this library is written for InkyFrame devices, the helper utilities contained in this library can be used with any embedded device.
- UC8159 eInk SPI Driver with 7-Color Dithering
- SD Card SPI Driver
- FAT Filesystem Driver (with long filename support!)
- TGA Image Parser
- PCF85063A RTC I2C Driver
Note
You'll need to make sure you have the flip-link linker installed before compiling.
To do this, use the command cargo install flip-link to install it.
Additional Cargo Configuration
For best results, create a .cargo/config.toml file in your project root directory
and specify somthing like this:
[]
= [
"-C", "linker=flip-link",
"-C", "link-arg=--nmagic",
"-C", "link-arg=-Tlink.x",
"-Z", "trap-unreachable=no",
"-C", "no-vectorize-loops",
]
[]
= "thumbv6m-none-eabi"
Requires the nightly version of the compiler to use "-Z", "trap-unreachable=no",
and can be removed, but will increase binary size slightly.
Extra bonus points if you add:
= "probe-rs run --chip RP2040"
Under the rustflags option. This allows you to flash the firmware on the device
directly from cargo run. (Pico debug probe probe and probe-rs required. Can be
installed using cargo install probe-rs-tools. Pico probe can be made from another
Pico! see here).
Lastly, these are the recommended profile settings for best program results. These
go inside the Cargo.toml file in the project root directory.
[]
= 2
= false
= 3
= false
= 1
= true
= true
[]
= "fat"
= "abort"
= false
= true
= 3
= false
= 1
= false
= false
Usage
To use this library, just import inky_frame::InkyBoard and call InkyBoard::get().
On the first call, the device and it's clocks will be initialized and setup fully.
The configuration is automatic and uses the ROSC as the system clock, disables the XOSC and PLLs and allows for DORMANT sleep, for maximum power savings.
This is similar to the RPSP Pico::get() setup and init behavior. The InkyBoard
struct actually has Deref for the Pico struct and can be used as a drop-in replacement.
To supply main, you must setup the main function with the #[rpsp::entry] macro,
which will setup the locks and properly redirect execution to the selected function.
Basic programs should look something like this:
!
If you're not using something like defmt, (which is not included by default)
you'll need a panic_handler. The example below is a pretty basic one that just
loops the CPU:
!
For the below examples, the panic_handler is omitted, so if you want to use
these, you'll need to add it in order for it to compile.
Inky Examples
InkyBoard
The InkyBoard struct exposes many helper functions to use the default peripherals
on the board.
let i = get;
i.sync_rtc_to_pcf; // Same as the Python function "pico_rtc_to_pcf"
i.sync_pcf_to_rtc; // Same as the Python function "pcf_to_pico_rtc"
// Same as the Python function "sleep_for"
// THIS IS IN SECONDS!! Instead of minutes
// Requires unsafe since it will poweroff the Pico
unsafe ;
// Same as the Python function "turn_off"
// Requires unsafe since it will poweroff the Pico
unsafe ;
let w = i.wake_reason; // Receives the reason the Pico was woken.
w.wake_from_rtc; // Same as the Python function "woken_by_rtc"
w.wake_from_ext; // Same as the Python function "woken_by_ext_trigger"
w.wake_from_button; // Same as the Python function "woken_by_button"
let pcf = i.pcf; // Pointer to the PCF85063A RTC
pcf.set_byte.unwrap; // Exposes the free 1-byte register of the PCF
let _ = pcf.get_byte.unwrap;
// Pointer to the I2C bus
// This is the bus the PCF is running on.
let i2c_bus = i.i2c_bus;
// Pointer to the SPI bus
// This is the bus the SDCard and Inky are running on.
// The bus is not initialized until this is first called.
let spi_bus = i.spi_bus;
// Create the SDCard and wrap it with the FAT filesystem driver
// Will initialize the SPI bus.
// This is not owned by the "InkyBoard" struct, so multiple calls to this will
// attempt to recreate it.
let sd = i.sd_card;
Buttons
use ;
!
Leds
use ;
!
PCF RTC
use InkyBoard;
use AlarmConfig;
use ;
!
SD Card and FAT File System
use Storage;
use Card;
use InkyBoard;
use PinID;
!
Inky and TGA Image Parsing
use TgaParser;
use ;
use Storage;
use Card;
use InkyBoard;
!
Low Power Shutoff on Battery
If the JST connector is used, the Frame can power off the Pico and wake it up when a button is pressed or by the PCF RTC alarm, allowing for super low power usage.
use InkyBoard;
!
Standard Examples
These are taken from here,
but are modified to show the drop-in replacement of the InkyBoard struct.
GPIO
Control Pin output:
use InkyBoard;
use PinID;
!
Read Pin output:
use InkyBoard;
use PinID;
!
UART
use InkyBoard;
use PinID;
use ;
!
Time and Sleep
use InkyBoard;
!
Watchdog
use InkyBoard;
!