summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorandromeda <andromeda@lenovo>2026-04-06 16:10:48 +0200
committerandromeda <andromeda@lenovo>2026-04-06 16:10:48 +0200
commit202e26714acc31bdf984d2eb6bd114f1b37ab83f (patch)
tree9fcfd3e202c04cf7f6ebef063d16a827ab27f1d2 /src/main.rs
parent8942975bc4ba972d67b7cd3e86dbb3ece5612816 (diff)
rgb
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
new file mode 100644
index 0000000..312fe20
--- /dev/null
+++ b/src/main.rs
@@ -0,0 +1,36 @@
+#![no_std]
+#![no_main]
+
+use esp_backtrace as _; // panic_handler
+use esp_hal::{rmt::Rmt, time::Rate};
+use esp_hal_smartled::{SmartLedsAdapter, smart_led_buffer};
+use smart_leds::RGB;
+
+use esp32c6_play::{init, sin, wait_ms, write_rgb};
+
+// This creates a default app-descriptor required by the esp-idf bootloader.
+// For more information see: <https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/system/app_image_format.html#application-description>
+esp_bootloader_esp_idf::esp_app_desc!();
+
+#[esp_hal::main]
+fn main() -> ! {
+ let peripherals = init();
+
+ let mut led_buffer = smart_led_buffer!(1);
+ let mut rgb_led = {
+ let frequency = Rate::from_mhz(80);
+ let rmt = Rmt::new(peripherals.RMT, frequency).expect("failed to initialize RMT0");
+ SmartLedsAdapter::new(rmt.channel0, peripherals.GPIO8, &mut led_buffer)
+ };
+
+ loop {
+ for i in 0..255 {
+ let r: u8 = i;
+ let g: u8 = i + 255 / 3; // phase shifted a third
+ let b: u8 = i + 2 * (255 / 3); // phase shifted two thirds
+ write_rgb(&mut rgb_led, RGB::new(sin(r), sin(g), sin(b)));
+
+ wait_ms(8);
+ }
+ }
+}