Skip to content

Commit

Permalink
Move examples into subdirectory
Browse files Browse the repository at this point in the history
This allows us to have different dependencies for different examples in
the futures.
And it makes it easier for new users to get started. They can just copy
the example folder.

Signed-off-by: Daniel Schaefer <[email protected]>
  • Loading branch information
JohnAZoidberg committed Oct 14, 2024
1 parent 9598a66 commit 7412d78
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 22 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -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
Expand Down
16 changes: 0 additions & 16 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
22 changes: 22 additions & 0 deletions examples/adafruit_rgb/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
9 changes: 9 additions & 0 deletions examples/adafruit_rgb/README.md
Original file line number Diff line number Diff line change
@@ -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
```
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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::*,
Expand All @@ -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

Expand Down
1 change: 1 addition & 0 deletions examples/adafruit_rgb/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#![no_std]

0 comments on commit 7412d78

Please sign in to comment.