diff --git a/puff/puffidle-0.bmp b/puff/puffidle-0.bmp new file mode 100644 index 0000000..77eeb76 Binary files /dev/null and b/puff/puffidle-0.bmp differ diff --git a/puff/puffidle-1.bmp b/puff/puffidle-1.bmp new file mode 100644 index 0000000..095dd66 Binary files /dev/null and b/puff/puffidle-1.bmp differ diff --git a/puff/puffidle-10.bmp b/puff/puffidle-10.bmp new file mode 100644 index 0000000..4768ac9 Binary files /dev/null and b/puff/puffidle-10.bmp differ diff --git a/puff/puffidle-11.bmp b/puff/puffidle-11.bmp new file mode 100644 index 0000000..ba64f10 Binary files /dev/null and b/puff/puffidle-11.bmp differ diff --git a/puff/puffidle-12.bmp b/puff/puffidle-12.bmp new file mode 100644 index 0000000..23440a6 Binary files /dev/null and b/puff/puffidle-12.bmp differ diff --git a/puff/puffidle-13.bmp b/puff/puffidle-13.bmp new file mode 100644 index 0000000..d586a63 Binary files /dev/null and b/puff/puffidle-13.bmp differ diff --git a/puff/puffidle-14.bmp b/puff/puffidle-14.bmp new file mode 100644 index 0000000..e059114 Binary files /dev/null and b/puff/puffidle-14.bmp differ diff --git a/puff/puffidle-15.bmp b/puff/puffidle-15.bmp new file mode 100644 index 0000000..6d5d31d Binary files /dev/null and b/puff/puffidle-15.bmp differ diff --git a/puff/puffidle-16.bmp b/puff/puffidle-16.bmp new file mode 100644 index 0000000..49273cf Binary files /dev/null and b/puff/puffidle-16.bmp differ diff --git a/puff/puffidle-17.bmp b/puff/puffidle-17.bmp new file mode 100644 index 0000000..301963d Binary files /dev/null and b/puff/puffidle-17.bmp differ diff --git a/puff/puffidle-18.bmp b/puff/puffidle-18.bmp new file mode 100644 index 0000000..12d2989 Binary files /dev/null and b/puff/puffidle-18.bmp differ diff --git a/puff/puffidle-19.bmp b/puff/puffidle-19.bmp new file mode 100644 index 0000000..92eea8c Binary files /dev/null and b/puff/puffidle-19.bmp differ diff --git a/puff/puffidle-2.bmp b/puff/puffidle-2.bmp new file mode 100644 index 0000000..dcf09ed Binary files /dev/null and b/puff/puffidle-2.bmp differ diff --git a/puff/puffidle-20.bmp b/puff/puffidle-20.bmp new file mode 100644 index 0000000..59a292b Binary files /dev/null and b/puff/puffidle-20.bmp differ diff --git a/puff/puffidle-21.bmp b/puff/puffidle-21.bmp new file mode 100644 index 0000000..6ede98f Binary files /dev/null and b/puff/puffidle-21.bmp differ diff --git a/puff/puffidle-22.bmp b/puff/puffidle-22.bmp new file mode 100644 index 0000000..0427fc1 Binary files /dev/null and b/puff/puffidle-22.bmp differ diff --git a/puff/puffidle-23.bmp b/puff/puffidle-23.bmp new file mode 100644 index 0000000..fef3633 Binary files /dev/null and b/puff/puffidle-23.bmp differ diff --git a/puff/puffidle-24.bmp b/puff/puffidle-24.bmp new file mode 100644 index 0000000..57288fe Binary files /dev/null and b/puff/puffidle-24.bmp differ diff --git a/puff/puffidle-25.bmp b/puff/puffidle-25.bmp new file mode 100644 index 0000000..dcf84ec Binary files /dev/null and b/puff/puffidle-25.bmp differ diff --git a/puff/puffidle-26.bmp b/puff/puffidle-26.bmp new file mode 100644 index 0000000..9b86d93 Binary files /dev/null and b/puff/puffidle-26.bmp differ diff --git a/puff/puffidle-27.bmp b/puff/puffidle-27.bmp new file mode 100644 index 0000000..0529d2c Binary files /dev/null and b/puff/puffidle-27.bmp differ diff --git a/puff/puffidle-28.bmp b/puff/puffidle-28.bmp new file mode 100644 index 0000000..af5986d Binary files /dev/null and b/puff/puffidle-28.bmp differ diff --git a/puff/puffidle-29.bmp b/puff/puffidle-29.bmp new file mode 100644 index 0000000..e8fdffe Binary files /dev/null and b/puff/puffidle-29.bmp differ diff --git a/puff/puffidle-3.bmp b/puff/puffidle-3.bmp new file mode 100644 index 0000000..6ff46a1 Binary files /dev/null and b/puff/puffidle-3.bmp differ diff --git a/puff/puffidle-30.bmp b/puff/puffidle-30.bmp new file mode 100644 index 0000000..67b190c Binary files /dev/null and b/puff/puffidle-30.bmp differ diff --git a/puff/puffidle-31.bmp b/puff/puffidle-31.bmp new file mode 100644 index 0000000..53c7069 Binary files /dev/null and b/puff/puffidle-31.bmp differ diff --git a/puff/puffidle-32.bmp b/puff/puffidle-32.bmp new file mode 100644 index 0000000..52a91b0 Binary files /dev/null and b/puff/puffidle-32.bmp differ diff --git a/puff/puffidle-33.bmp b/puff/puffidle-33.bmp new file mode 100644 index 0000000..bb43483 Binary files /dev/null and b/puff/puffidle-33.bmp differ diff --git a/puff/puffidle-34.bmp b/puff/puffidle-34.bmp new file mode 100644 index 0000000..c383cff Binary files /dev/null and b/puff/puffidle-34.bmp differ diff --git a/puff/puffidle-35.bmp b/puff/puffidle-35.bmp new file mode 100644 index 0000000..d070d22 Binary files /dev/null and b/puff/puffidle-35.bmp differ diff --git a/puff/puffidle-36.bmp b/puff/puffidle-36.bmp new file mode 100644 index 0000000..5e8691e Binary files /dev/null and b/puff/puffidle-36.bmp differ diff --git a/puff/puffidle-37.bmp b/puff/puffidle-37.bmp new file mode 100644 index 0000000..0f3682f Binary files /dev/null and b/puff/puffidle-37.bmp differ diff --git a/puff/puffidle-38.bmp b/puff/puffidle-38.bmp new file mode 100644 index 0000000..cd124cf Binary files /dev/null and b/puff/puffidle-38.bmp differ diff --git a/puff/puffidle-39.bmp b/puff/puffidle-39.bmp new file mode 100644 index 0000000..116f5c3 Binary files /dev/null and b/puff/puffidle-39.bmp differ diff --git a/puff/puffidle-4.bmp b/puff/puffidle-4.bmp new file mode 100644 index 0000000..a83aaf3 Binary files /dev/null and b/puff/puffidle-4.bmp differ diff --git a/puff/puffidle-40.bmp b/puff/puffidle-40.bmp new file mode 100644 index 0000000..68e20f3 Binary files /dev/null and b/puff/puffidle-40.bmp differ diff --git a/puff/puffidle-41.bmp b/puff/puffidle-41.bmp new file mode 100644 index 0000000..6ab0b43 Binary files /dev/null and b/puff/puffidle-41.bmp differ diff --git a/puff/puffidle-42.bmp b/puff/puffidle-42.bmp new file mode 100644 index 0000000..41fadec Binary files /dev/null and b/puff/puffidle-42.bmp differ diff --git a/puff/puffidle-43.bmp b/puff/puffidle-43.bmp new file mode 100644 index 0000000..94aab33 Binary files /dev/null and b/puff/puffidle-43.bmp differ diff --git a/puff/puffidle-44.bmp b/puff/puffidle-44.bmp new file mode 100644 index 0000000..3e443fc Binary files /dev/null and b/puff/puffidle-44.bmp differ diff --git a/puff/puffidle-45.bmp b/puff/puffidle-45.bmp new file mode 100644 index 0000000..7dae2d1 Binary files /dev/null and b/puff/puffidle-45.bmp differ diff --git a/puff/puffidle-46.bmp b/puff/puffidle-46.bmp new file mode 100644 index 0000000..040ba87 Binary files /dev/null and b/puff/puffidle-46.bmp differ diff --git a/puff/puffidle-47.bmp b/puff/puffidle-47.bmp new file mode 100644 index 0000000..4f7c473 Binary files /dev/null and b/puff/puffidle-47.bmp differ diff --git a/puff/puffidle-48.bmp b/puff/puffidle-48.bmp new file mode 100644 index 0000000..0a508ad Binary files /dev/null and b/puff/puffidle-48.bmp differ diff --git a/puff/puffidle-49.bmp b/puff/puffidle-49.bmp new file mode 100644 index 0000000..9007a90 Binary files /dev/null and b/puff/puffidle-49.bmp differ diff --git a/puff/puffidle-5.bmp b/puff/puffidle-5.bmp new file mode 100644 index 0000000..d0b23d3 Binary files /dev/null and b/puff/puffidle-5.bmp differ diff --git a/puff/puffidle-50.bmp b/puff/puffidle-50.bmp new file mode 100644 index 0000000..d64cb59 Binary files /dev/null and b/puff/puffidle-50.bmp differ diff --git a/puff/puffidle-51.bmp b/puff/puffidle-51.bmp new file mode 100644 index 0000000..a3b6cea Binary files /dev/null and b/puff/puffidle-51.bmp differ diff --git a/puff/puffidle-52.bmp b/puff/puffidle-52.bmp new file mode 100644 index 0000000..d9085f1 Binary files /dev/null and b/puff/puffidle-52.bmp differ diff --git a/puff/puffidle-53.bmp b/puff/puffidle-53.bmp new file mode 100644 index 0000000..0a792e3 Binary files /dev/null and b/puff/puffidle-53.bmp differ diff --git a/puff/puffidle-54.bmp b/puff/puffidle-54.bmp new file mode 100644 index 0000000..daaf215 Binary files /dev/null and b/puff/puffidle-54.bmp differ diff --git a/puff/puffidle-55.bmp b/puff/puffidle-55.bmp new file mode 100644 index 0000000..f8c25d7 Binary files /dev/null and b/puff/puffidle-55.bmp differ diff --git a/puff/puffidle-56.bmp b/puff/puffidle-56.bmp new file mode 100644 index 0000000..b676976 Binary files /dev/null and b/puff/puffidle-56.bmp differ diff --git a/puff/puffidle-57.bmp b/puff/puffidle-57.bmp new file mode 100644 index 0000000..f7043c3 Binary files /dev/null and b/puff/puffidle-57.bmp differ diff --git a/puff/puffidle-58.bmp b/puff/puffidle-58.bmp new file mode 100644 index 0000000..86bccc3 Binary files /dev/null and b/puff/puffidle-58.bmp differ diff --git a/puff/puffidle-59.bmp b/puff/puffidle-59.bmp new file mode 100644 index 0000000..2b8e985 Binary files /dev/null and b/puff/puffidle-59.bmp differ diff --git a/puff/puffidle-6.bmp b/puff/puffidle-6.bmp new file mode 100644 index 0000000..5219cd2 Binary files /dev/null and b/puff/puffidle-6.bmp differ diff --git a/puff/puffidle-7.bmp b/puff/puffidle-7.bmp new file mode 100644 index 0000000..69dc8bc Binary files /dev/null and b/puff/puffidle-7.bmp differ diff --git a/puff/puffidle-8.bmp b/puff/puffidle-8.bmp new file mode 100644 index 0000000..b63033f Binary files /dev/null and b/puff/puffidle-8.bmp differ diff --git a/puff/puffidle-9.bmp b/puff/puffidle-9.bmp new file mode 100644 index 0000000..b3c71e1 Binary files /dev/null and b/puff/puffidle-9.bmp differ diff --git a/puff/puffidle.gif b/puff/puffidle.gif new file mode 100755 index 0000000..fd4ce97 Binary files /dev/null and b/puff/puffidle.gif differ diff --git a/puff/resize.sh b/puff/resize.sh new file mode 100755 index 0000000..d01a9f7 --- /dev/null +++ b/puff/resize.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +for image in $(ls puffidle-*.bmp); do + # echo $image + convert $image -define bmp:subtype=RGB565 -alpha off -resize 64x64 $image +done diff --git a/sdkconfig.defaults b/sdkconfig.defaults index a139649..a007ecf 100644 --- a/sdkconfig.defaults +++ b/sdkconfig.defaults @@ -3,7 +3,7 @@ CONFIG_ESP_MAIN_TASK_STACK_SIZE=20000 # Use this to set FreeRTOS kernel tick frequency to 1000 Hz (100 Hz by default). # This allows to use 1 ms granuality for thread sleeps (10 ms by default). -#CONFIG_FREERTOS_HZ=1000 +CONFIG_FREERTOS_HZ=1000 # Workaround for https://github.com/espressif/esp-idf/issues/7631 #CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=n diff --git a/src/emilis.bmp b/src/emilis.bmp new file mode 100644 index 0000000..09f1398 Binary files /dev/null and b/src/emilis.bmp differ diff --git a/src/main.rs b/src/main.rs index b0691a6..5938a64 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,14 +2,14 @@ use std::{error::Error, thread::sleep, time::Duration}; use embedded_graphics::{image::Image, pixelcolor::Rgb565, prelude::*}; use esp_idf_hal::{ - gpio::{Gpio16, Gpio17, Gpio18, Gpio23, Gpio5, Output}, + gpio::{Gpio12, Gpio14, Gpio16, Gpio17, Gpio18, Gpio23, Gpio5, Input, Output}, prelude::{Hertz, Peripherals}, spi::{self, Master, Pins, SPI3}, }; +// If using the `binstart` feature of `esp-idf-sys`, always keep this module imported use esp_idf_sys as _; use rand::Rng; -// If using the `binstart` feature of `esp-idf-sys`, always keep this module imported -use ssd1331::{DisplayRotation::Rotate0, Ssd1331}; +use ssd1331::Ssd1331; use tinybmp::Bmp; fn secondary() -> Result<(), Box> { @@ -28,7 +28,9 @@ fn secondary() -> Result<(), Box> { let sclk: Gpio18 = pins.gpio18.into_output()?; let reset: Gpio5 = pins.gpio5.into_output()?; - // // Set up SPI interface and digital pin. These are stub implementations used in examples. + let read: Gpio12 = pins.gpio12.into_input()?; + let write: Gpio14 = pins.gpio14.into_output()?; + let spiman = spi::Master::, Gpio23, Gpio5, Gpio17>::new( spi3, @@ -45,7 +47,7 @@ fn secondary() -> Result<(), Box> { dma: spi::Dma::Disabled, }, )?; - let mut display = Ssd1331::new(spiman, dc, Rotate0); + let mut display = Ssd1331::new(spiman, dc, ssd1331::DisplayRotation::Rotate180); display.init().unwrap(); display.flush().unwrap(); @@ -56,11 +58,16 @@ fn secondary() -> Result<(), Box> { let eye = Bmp::from_slice(include_bytes!("./eye.bmp")).expect("Failed to load BMP image"); let eye_closed = Bmp::from_slice(include_bytes!("./eye_closed.bmp")).expect("Failed to load BMP image"); + let emilis = Bmp::from_slice(include_bytes!("./emilis.bmp")).expect("Failed to load BMP image"); + print_image(emilis, &mut display, h as u32, w as u32); + sleep(Duration::from_secs(3)); + display.clear(); + puff_idle(&mut display, h as u32, w as u32); loop { print_image(eye, &mut display, h as u32, w as u32); - sleep(Duration::from_secs(rng.gen_range(1..10))); + sleep(Duration::from_secs(rng.gen_range(2..8))); print_image(eye_closed, &mut display, h as u32, w as u32); - sleep(Duration::from_millis(400)) + sleep(Duration::from_millis(190)) } } @@ -85,6 +92,95 @@ fn print_image( display.flush().unwrap(); } +fn puff_idle( + display: &mut Ssd1331< + Master, Gpio23, Gpio5, Gpio17>, + Gpio16, + >, + h: u32, + w: u32, +) -> ! { + let raw = get_puff_raw(); + let mut frames = Vec::>::new(); + for raw_image in raw { + let frame_bmp = Bmp::from_slice(raw_image).unwrap(); + frames.push(frame_bmp); + } + loop { + for frame in &frames { + print_image(*frame, display, h, w); + sleep(Duration::from_millis(1)); + } + } +} + +// Manually unrolled because im gay +fn get_puff_raw() -> Vec<&'static [u8]> { + let mut raw = Vec::<&[u8]>::new(); + raw.push(include_bytes!("../puff/puffidle-0.bmp")); + raw.push(include_bytes!("../puff/puffidle-1.bmp")); + raw.push(include_bytes!("../puff/puffidle-2.bmp")); + raw.push(include_bytes!("../puff/puffidle-3.bmp")); + raw.push(include_bytes!("../puff/puffidle-4.bmp")); + raw.push(include_bytes!("../puff/puffidle-5.bmp")); + raw.push(include_bytes!("../puff/puffidle-6.bmp")); + raw.push(include_bytes!("../puff/puffidle-7.bmp")); + raw.push(include_bytes!("../puff/puffidle-8.bmp")); + raw.push(include_bytes!("../puff/puffidle-9.bmp")); + raw.push(include_bytes!("../puff/puffidle-10.bmp")); + raw.push(include_bytes!("../puff/puffidle-11.bmp")); + raw.push(include_bytes!("../puff/puffidle-12.bmp")); + raw.push(include_bytes!("../puff/puffidle-13.bmp")); + raw.push(include_bytes!("../puff/puffidle-14.bmp")); + raw.push(include_bytes!("../puff/puffidle-15.bmp")); + raw.push(include_bytes!("../puff/puffidle-16.bmp")); + raw.push(include_bytes!("../puff/puffidle-17.bmp")); + raw.push(include_bytes!("../puff/puffidle-18.bmp")); + raw.push(include_bytes!("../puff/puffidle-19.bmp")); + raw.push(include_bytes!("../puff/puffidle-20.bmp")); + raw.push(include_bytes!("../puff/puffidle-21.bmp")); + raw.push(include_bytes!("../puff/puffidle-22.bmp")); + raw.push(include_bytes!("../puff/puffidle-23.bmp")); + raw.push(include_bytes!("../puff/puffidle-24.bmp")); + raw.push(include_bytes!("../puff/puffidle-25.bmp")); + raw.push(include_bytes!("../puff/puffidle-26.bmp")); + raw.push(include_bytes!("../puff/puffidle-27.bmp")); + raw.push(include_bytes!("../puff/puffidle-28.bmp")); + raw.push(include_bytes!("../puff/puffidle-29.bmp")); + raw.push(include_bytes!("../puff/puffidle-30.bmp")); + raw.push(include_bytes!("../puff/puffidle-31.bmp")); + raw.push(include_bytes!("../puff/puffidle-32.bmp")); + raw.push(include_bytes!("../puff/puffidle-33.bmp")); + raw.push(include_bytes!("../puff/puffidle-34.bmp")); + raw.push(include_bytes!("../puff/puffidle-35.bmp")); + raw.push(include_bytes!("../puff/puffidle-36.bmp")); + raw.push(include_bytes!("../puff/puffidle-37.bmp")); + raw.push(include_bytes!("../puff/puffidle-38.bmp")); + raw.push(include_bytes!("../puff/puffidle-39.bmp")); + raw.push(include_bytes!("../puff/puffidle-40.bmp")); + raw.push(include_bytes!("../puff/puffidle-41.bmp")); + raw.push(include_bytes!("../puff/puffidle-42.bmp")); + raw.push(include_bytes!("../puff/puffidle-43.bmp")); + raw.push(include_bytes!("../puff/puffidle-44.bmp")); + raw.push(include_bytes!("../puff/puffidle-45.bmp")); + raw.push(include_bytes!("../puff/puffidle-46.bmp")); + raw.push(include_bytes!("../puff/puffidle-47.bmp")); + raw.push(include_bytes!("../puff/puffidle-48.bmp")); + raw.push(include_bytes!("../puff/puffidle-49.bmp")); + raw.push(include_bytes!("../puff/puffidle-50.bmp")); + raw.push(include_bytes!("../puff/puffidle-51.bmp")); + raw.push(include_bytes!("../puff/puffidle-52.bmp")); + raw.push(include_bytes!("../puff/puffidle-53.bmp")); + raw.push(include_bytes!("../puff/puffidle-54.bmp")); + raw.push(include_bytes!("../puff/puffidle-55.bmp")); + raw.push(include_bytes!("../puff/puffidle-56.bmp")); + raw.push(include_bytes!("../puff/puffidle-57.bmp")); + raw.push(include_bytes!("../puff/puffidle-58.bmp")); + raw.push(include_bytes!("../puff/puffidle-59.bmp")); + + raw +} + fn main() -> Result<(), Box> { sleep(Duration::from_secs(1)); Ok(secondary().unwrap())