From 10a3d07c839ca0c6ebbe973631bfa8acfde4990d Mon Sep 17 00:00:00 2001 From: Alistair Francis Date: Thu, 13 Jun 2024 10:53:49 +1000 Subject: [PATCH] demos: More st7789 to the demo directory Signed-off-by: Alistair Francis --- .gitignore | 1 + Cargo.toml | 10 +--------- Makefile | 19 ++++++++++++++++++ demos/st7789/Cargo.toml | 20 +++++++++++++++++++ demos/st7789/build.rs | 3 +++ .../st7789.rs => demos/st7789/src/main.rs | 0 6 files changed, 44 insertions(+), 9 deletions(-) create mode 100644 demos/st7789/Cargo.toml create mode 100644 demos/st7789/build.rs rename examples/st7789.rs => demos/st7789/src/main.rs (100%) diff --git a/.gitignore b/.gitignore index 93d91b91..1027b62f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /Cargo.lock /nightly/target /target +/demos/*/target diff --git a/Cargo.toml b/Cargo.toml index 298dc2e4..afa96dc0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,18 +48,9 @@ libtock_temperature = { path = "apis/sensors/temperature" } embedded-hal = { version = "1.0", optional = true } -[dev-dependencies] -mipidsi = "0.8.0" -display-interface-spi = "0.5" -embedded-graphics = "0.8" - [build-dependencies] libtock_build_scripts = { path = "build_scripts" } -[[example]] -name = "st7789" -required-features = ["rust_embedded"] - [profile.dev] debug = true lto = true @@ -90,6 +81,7 @@ members = [ "apis/sensors/proximity", "apis/sensors/temperature", "apis/storage/key_value", + "demos/st7789", "panic_handlers/debug_panic", "panic_handlers/small_panic", "platform", diff --git a/Makefile b/Makefile index ce9ba28d..59421d5b 100644 --- a/Makefile +++ b/Makefile @@ -110,6 +110,9 @@ examples: toolchain EXCLUDE_RUNTIME := --exclude libtock --exclude libtock_runtime \ --exclude libtock_debug_panic --exclude libtock_small_panic +# Arguments to pass to cargo to exclude demo crates. +EXCLUDE_RUNTIME := $(EXCLUDE_RUNTIME) --exclude st7789 + # Arguments to pass to cargo to exclude crates that cannot be tested by Miri. In # addition to excluding libtock_runtime, Miri also cannot test proc macro crates # (and in fact will generate broken data that causes cargo test to fail). @@ -130,6 +133,7 @@ test: examples --target=thumbv7em-none-eabi --workspace LIBTOCK_PLATFORM=hifive1 cargo clippy $(EXCLUDE_STD) \ --target=riscv32imac-unknown-none-elf --workspace + $(MAKE) apollo3-st7789 cd nightly && \ MIRIFLAGS="-Zmiri-strict-provenance -Zmiri-symbolic-alignment-check" \ cargo miri test $(EXCLUDE_MIRI) --manifest-path=../Cargo.toml \ @@ -215,6 +219,14 @@ $(1): toolchain mkdir -p target/tbf/$(1) cp target/$(1)/$(2)/release/examples/$(EXAMPLE).{tab,tbf} \ target/tbf/$(1) + +.PHONY: $(1)-st7789 +$(1)-st7789: toolchain + cd demos/st7789 && LIBTOCK_PLATFORM=$(1) cargo run $(features) \ + $(release) --target=$(2) --target-dir=target/$(1) + mkdir -p target/tbf/$(1) + cp demos/st7789/target/$(1)/$(2)/release/st7789.{tab,tbf} \ + target/tbf/$(1) endef # Creates the `make flash- EXAMPLE=` targets. Arguments: @@ -225,6 +237,12 @@ flash-$(1): toolchain LIBTOCK_PLATFORM=$(1) cargo run --example $(EXAMPLE) $(features) \ $(release) --target=$(2) --target-dir=target/flash-$(1) -- \ --deploy=tockloader + +.PHONY: flash-$(1)-st7789 +flash-$(1)-st7789: toolchain + cd demos/st7789 && LIBTOCK_PLATFORM=$(1) cargo run $(features) \ + $(release) --target=$(2) --target-dir=target/flash-$(1) -- \ + --deploy=tockloader endef $(eval $(call platform_build,apollo3,thumbv7em-none-eabi)) @@ -261,4 +279,5 @@ $(eval $(call platform_flash,clue_nrf52840,thumbv7em-none-eabi)) clean: cargo clean rm -fr nightly/target/ + cd demos/st7789 && cargo clean $(MAKE) -C tock clean diff --git a/demos/st7789/Cargo.toml b/demos/st7789/Cargo.toml new file mode 100644 index 00000000..e75a5471 --- /dev/null +++ b/demos/st7789/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "st7789" +version = "0.1.0" +edition = "2021" +rust-version.workspace = true +authors = ["Alistair Francis "] +description = """A demo to drive a ST7789 display via SPI using libtock-rs.""" +license = "Apache-2.0 OR MIT" + +[dependencies] +libtock = { path = "../../", features = ["rust_embedded"] } + +embedded-hal = "1.0" + +mipidsi = "0.8.0" +display-interface-spi = "0.5" +embedded-graphics = "0.8" + +[build-dependencies] +libtock_build_scripts = { path = "../../build_scripts" } diff --git a/demos/st7789/build.rs b/demos/st7789/build.rs new file mode 100644 index 00000000..d39f0124 --- /dev/null +++ b/demos/st7789/build.rs @@ -0,0 +1,3 @@ +fn main() { + libtock_build_scripts::auto_layout(); +} diff --git a/examples/st7789.rs b/demos/st7789/src/main.rs similarity index 100% rename from examples/st7789.rs rename to demos/st7789/src/main.rs