diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3b62e99..149769e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -24,7 +24,10 @@ jobs: - 'Cargo.lock' - '.github/workflows/**' - if: steps.changes.outputs.rust == 'true' - run: cargo build + run: | + cargo build --target=thumbv6m-none-eabi + cd examples/adafruit_rgb + cargo build --target=thumbv6m-none-eabi rustdoc: runs-on: ubuntu-latest diff --git a/.gitignore b/.gitignore index 22d3516..5acc388 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ # Generated by Cargo # will have compiled files and executables -/target/ +target/ # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries # More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html diff --git a/Cargo.toml b/Cargo.toml index e97b946..7f17ba1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,23 +16,7 @@ embedded-graphics-core = { optional = true, version = "0.4.0" } [package.metadata.docs.rs] all-features = true -[dev-dependencies] -cortex-m-rt = "0.7.3" -cortex-m = "0.7.7" -panic-halt = "0.2.0" -stm32g0xx-hal = {version = "0.2.0", features = ["rt", "stm32g071"]} -tinybmp = "0.5.0" -embedded-graphics = "0.8.1" - [features] adafruit_rgb_13x9 = [] embedded_graphics = ["embedded-graphics-core"] default = ["adafruit_rgb_13x9", "embedded_graphics"] - -[[example]] -name = "stm32" -required-features = ["adafruit_rgb_13x9"] - -[[example]] -name = "gaypride" -required-features = ["adafruit_rgb_13x9", "embedded_graphics"] diff --git a/Makefile b/Makefile index bffd57a..4a83099 100644 --- a/Makefile +++ b/Makefile @@ -1,2 +1,3 @@ build-all: - cargo build --target=thumbv6m-none-eabi --examples --all-features + cd examples/adafruit_rgb && \ + cargo build --target=thumbv6m-none-eabi --examples --all-features diff --git a/README.md b/README.md index fdae30f..51882ea 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ is31fl3741 = { version = "0.3.0", features = ["adafruit13x9"] } This driver contains optional support for the [embedded-graphics](https://docs.rs/embedded-graphics/latest/embedded_graphics/) library. Enable the `embedded_graphics` feature to use it. -The `gaypride` example shows off a use of this. +The `adafruit_rgb/gaypride` example shows off a use of this. ## Inspiration diff --git a/examples/adafruit_rgb/Cargo.toml b/examples/adafruit_rgb/Cargo.toml new file mode 100644 index 0000000..96a77cb --- /dev/null +++ b/examples/adafruit_rgb/Cargo.toml @@ -0,0 +1,22 @@ +[package] +name = "stm3" +version = "0.2.0" +edition = "2021" +publish = false + +[dependencies] +is31fl3741 = { path = "../../", features = [ "adafruit_rgb_13x9", "embedded_graphics" ] } +embedded-hal = "0.2.7" +cortex-m-rt = "0.7.3" +cortex-m = "0.7.7" +fugit = "0.3.7" +panic-halt = { version = "0.2.0" } +stm32g0xx-hal = {version = "0.2.0", features = ["rt", "stm32g071"]} +tinybmp = "0.5.0" +embedded-graphics = "0.8.1" + +[[example]] +name = "stm32" + +[[example]] +name = "gaypride" diff --git a/examples/adafruit_rgb/README.md b/examples/adafruit_rgb/README.md new file mode 100644 index 0000000..ad4a013 --- /dev/null +++ b/examples/adafruit_rgb/README.md @@ -0,0 +1,9 @@ +# Adafruit RGB 13x9 with STM Nucleo + +## Build and run + +``` +cargo build --target=thumbv6m-none-eabi +cargo build --target=thumbv6m-none-eabi --example stm32 +cargo build --target=thumbv6m-none-eabi --example gaypride +``` diff --git a/examples/gaypride.bmp b/examples/adafruit_rgb/examples/gaypride.bmp similarity index 100% rename from examples/gaypride.bmp rename to examples/adafruit_rgb/examples/gaypride.bmp diff --git a/examples/gaypride.rs b/examples/adafruit_rgb/examples/gaypride.rs similarity index 94% rename from examples/gaypride.rs rename to examples/adafruit_rgb/examples/gaypride.rs index d7635f9..6d14951 100644 --- a/examples/gaypride.rs +++ b/examples/adafruit_rgb/examples/gaypride.rs @@ -7,6 +7,7 @@ use panic_halt as _; // use cortex_m::delay::Delay; use cortex_m_rt::entry; use is31fl3741::devices::AdafruitRGB13x9; +use fugit::RateExtU32; use embedded_graphics::{image::Image, pixelcolor::Rgb888, prelude::*}; use stm32g0xx_hal::{ @@ -29,7 +30,7 @@ fn main() -> ! { let sda = gpiob.pb9.into_open_drain_output_in_state(PinState::High); let scl = gpiob.pb8.into_open_drain_output_in_state(PinState::High); - let i2c = dp.I2C1.i2c(sda, scl, 100.khz(), &mut rcc); + let i2c = dp.I2C1.i2c(sda, scl, 100.kHz(), &mut rcc); // // https://github.com/adafruit/Adafruit_CircuitPython_IS31FL3741/blob/main/adafruit_is31fl3 741/adafruit_rgbmatrixqt.py#L53-L65 diff --git a/examples/stm32.rs b/examples/adafruit_rgb/examples/stm32.rs similarity index 94% rename from examples/stm32.rs rename to examples/adafruit_rgb/examples/stm32.rs index 6dd083c..bb25f4e 100644 --- a/examples/stm32.rs +++ b/examples/adafruit_rgb/examples/stm32.rs @@ -7,6 +7,7 @@ use panic_halt as _; // use cortex_m::delay::Delay; use cortex_m_rt::entry; use is31fl3741::devices::AdafruitRGB13x9; +use fugit::RateExtU32; use stm32g0xx_hal::{ prelude::*, @@ -27,7 +28,7 @@ fn main() -> ! { let sda = gpiob.pb9.into_open_drain_output_in_state(PinState::High); let scl = gpiob.pb8.into_open_drain_output_in_state(PinState::High); - let i2c = dp.I2C1.i2c(sda, scl, 100.khz(), &mut rcc); + let i2c = dp.I2C1.i2c(sda, scl, 100.kHz(), &mut rcc); // // https://github.com/adafruit/Adafruit_CircuitPython_IS31FL3741/blob/main/adafruit_is31fl3 741/adafruit_rgbmatrixqt.py#L53-L65 diff --git a/examples/adafruit_rgb/src/lib.rs b/examples/adafruit_rgb/src/lib.rs new file mode 100644 index 0000000..0c9ac1a --- /dev/null +++ b/examples/adafruit_rgb/src/lib.rs @@ -0,0 +1 @@ +#![no_std]