From 8830e925971a070f246042a162feb9e0ca4c6676 Mon Sep 17 00:00:00 2001 From: Kat Inskip Date: Fri, 17 Oct 2025 09:37:25 -0700 Subject: [PATCH] feat: clean up some more .w. --- Cargo.lock | 52 +++++++++++++++++++++++++++++++++++++--------------- Cargo.toml | 7 ++++--- diagram.json | 33 --------------------------------- flake.nix | 2 +- justfile | 8 ++++++++ src/main.rs | 17 +++++++++++++++-- wokwi.toml | 9 --------- 7 files changed, 65 insertions(+), 63 deletions(-) delete mode 100644 diagram.json create mode 100644 justfile delete mode 100644 wokwi.toml diff --git a/Cargo.lock b/Cargo.lock index 083a7f5..008e920 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -52,21 +52,6 @@ version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" -[[package]] -name = "blinky" -version = "0.1.0" -dependencies = [ - "display-interface-spi", - "embedded-graphics", - "embedded-hal-bus", - "esp-alloc", - "esp-backtrace", - "esp-bootloader-esp-idf", - "esp-hal", - "esp-println", - "ili9341", -] - [[package]] name = "byte-slice-cast" version = "1.2.3" @@ -352,6 +337,27 @@ dependencies = [ "embedded-io 0.7.1", ] +[[package]] +name = "embedded-layout" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a90553247f2b05c59ac7894ea13d830636c2b1203fa03bff400eddbd1fa9f52" +dependencies = [ + "embedded-graphics", + "embedded-layout-macros", +] + +[[package]] +name = "embedded-layout-macros" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f6e621fe4c7e05b695274b722dc0a60bacd1c8696b58191baa0154713d52400" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.102", +] + [[package]] name = "embedded-storage" version = "0.3.1" @@ -857,6 +863,22 @@ version = "0.4.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" +[[package]] +name = "meepy" +version = "0.1.0" +dependencies = [ + "display-interface-spi", + "embedded-graphics", + "embedded-hal-bus", + "embedded-layout", + "esp-alloc", + "esp-backtrace", + "esp-bootloader-esp-idf", + "esp-hal", + "esp-println", + "ili9341", +] + [[package]] name = "memchr" version = "2.7.4" diff --git a/Cargo.toml b/Cargo.toml index e2684b1..8495761 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,14 +1,15 @@ [package] -name = "blinky" +name = "meepy" version = "0.1.0" -authors = ["Sergio Gasquez "] +authors = ["kittywitch"] edition = "2021" -license = "MIT OR Apache-2.0" +license = "MIT" [dependencies] display-interface-spi = "0.5.0" embedded-graphics = "0.8.1" embedded-hal-bus = "0.3.0" +embedded-layout = "0.4.2" esp-alloc = { version = "0.9.0", features = ["esp32c3"] } esp-backtrace = { version = "0.18.0", features = [ "esp32c3", diff --git a/diagram.json b/diagram.json deleted file mode 100644 index 31a7a6f..0000000 --- a/diagram.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "version": 1, - "author": "Sergio Gasquez Arcos", - "editor": "wokwi", - "parts": [ - { - "type": "board-esp32-c3-rust-1", - "id": "esp", - "top": -126.57, - "left": 46.35, - "attrs": { - "builder": "rust-nostd-esp" - } - } - ], - "connections": [ - [ - "esp:21", - "$serialMonitor:RX", - "", - [] - ], - [ - "esp:20", - "$serialMonitor:TX", - "", - [] - ] - ], - "serialMonitor": { - "display": "auto" - } -} diff --git a/flake.nix b/flake.nix index ab7cf32..d587b7b 100644 --- a/flake.nix +++ b/flake.nix @@ -23,7 +23,7 @@ pkgs.espflash pkgs.pkg-config pkgs.stdenv.cc - #pkgs.rust-analyzer + #pkgs.rust-analyzer #pkgs.bacon #pkgs.systemdMinimal #pkgs.lunarvim diff --git a/justfile b/justfile new file mode 100644 index 0000000..7991b7f --- /dev/null +++ b/justfile @@ -0,0 +1,8 @@ +arch := "riscv32imc-unknown-none-elf" +pakidg := shell('toml get -r Cargo.toml package.name') +exe := justfile_directory() / "target" / arch / "release" / pakidg + +build: + #!/usr/bin/env bash + cargo build --release && \ + sudo espflash flash {{exe}} diff --git a/src/main.rs b/src/main.rs index 64dc0b7..ac7214c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -152,8 +152,8 @@ impl<'spi> TFT<'spi> { .with_mode(Mode::_0) } - pub fn clear(&mut self, color: Rgb565) { - self.display.clear(color).unwrap(); + pub fn clear(&mut self, color: Bgr565) { + self.display.clear(candyflip(color)).unwrap(); } pub fn part_clear(&mut self, x: i32, y: i32, w: u32, h: u32) { @@ -163,6 +163,18 @@ impl<'spi> TFT<'spi> { .unwrap(); } + pub fn containing_recty(&mut self, x: i32, y: i32, w: u32, h: u32) { + Rectangle::new(Point::new(x, y), Size::new(w, h)) + .into_styled(PrimitiveStyle::with_stroke(Bgr565::CYAN, 1)) + .draw(&mut self.draw_target()) + .unwrap(); + } + + pub fn container(&mut self, margin: i32, y: i32, h: u32) { + let width = self.display.bounding_box().size.width; + self.containing_recty(margin, y, width - margin as u32, h); + } + pub fn println(&mut self, text: &str, x: i32, y: i32) { let style = MonoTextStyle::new(&FONT_8X13, Bgr565::WHITE); Text::with_alignment(text, Point::new(x, y), style, Alignment::Center) @@ -186,6 +198,7 @@ fn main() -> ! { let mut tft = TFT::new(peripherals.SPI2, sclk, miso, mosi, cs, rst, dc); tft.draw_target().clear(Bgr565::BLACK); + tft.container(2, 2, 16); tft.println("nya~! -w-", 100, 40); loop { diff --git a/wokwi.toml b/wokwi.toml deleted file mode 100644 index 265a082..0000000 --- a/wokwi.toml +++ /dev/null @@ -1,9 +0,0 @@ -[wokwi] -version = 1 -# Exercise -# firmware = "target/riscv32imc-unknown-none-elf/release/blinky" -# elf = "target/riscv32imc-unknown-none-elf/release/blinky" - -# Solution -firmware = 'target/riscv32imc-unknown-none-elf/release/examples/blinky' -elf = 'target/riscv32imc-unknown-none-elf/release/examples/blinky'