From 044c1749ae5df2257719bcbff67eb76141e903d1 Mon Sep 17 00:00:00 2001
From: Birte Kristina Friesel <derf@finalrewind.org>
Date: Sat, 16 Nov 2024 18:16:39 +0100
Subject: [PATCH] Add WS2812b test application

---
 src/app/ws2812b-test/Kconfig      |  6 +++++
 src/app/ws2812b-test/Makefile.inc |  9 +++++++
 src/app/ws2812b-test/main.cc      | 42 +++++++++++++++++++++++++++++++
 3 files changed, 57 insertions(+)
 create mode 100644 src/app/ws2812b-test/Kconfig
 create mode 100644 src/app/ws2812b-test/Makefile.inc
 create mode 100644 src/app/ws2812b-test/main.cc

diff --git a/src/app/ws2812b-test/Kconfig b/src/app/ws2812b-test/Kconfig
new file mode 100644
index 0000000..fdc4884
--- /dev/null
+++ b/src/app/ws2812b-test/Kconfig
@@ -0,0 +1,6 @@
+# Copyright 2020 Birte Kristina Friesel
+#
+# SPDX-License-Identifier: CC0-1.0
+
+prompt "WS2812b Test"
+depends on arch_arduino_nano && meta_driver_neopixel
diff --git a/src/app/ws2812b-test/Makefile.inc b/src/app/ws2812b-test/Makefile.inc
new file mode 100644
index 0000000..d4c4fb8
--- /dev/null
+++ b/src/app/ws2812b-test/Makefile.inc
@@ -0,0 +1,9 @@
+# vim:ft=make
+#
+# Copyright 2020 Birte Kristina Friesel
+#
+# SPDX-License-Identifier: CC0-1.0
+
+ifdef app
+	override arch_drivers += ,neopixel
+endif
diff --git a/src/app/ws2812b-test/main.cc b/src/app/ws2812b-test/main.cc
new file mode 100644
index 0000000..8a4aaff
--- /dev/null
+++ b/src/app/ws2812b-test/main.cc
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2020 Birte Kristina Friesel
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+#include "arch.h"
+#include "driver/neopixel.h"
+#include "driver/stdin.h"
+#include "driver/stdout.h"
+#include <util/delay.h>
+#include <avr/io.h>
+#include <avr/interrupt.h>
+#include <avr/wdt.h>
+
+#define NUM_PIXELS 256
+
+Adafruit_NeoPixel np(NUM_PIXELS, GPIO::pc0, NEO_GRB+NEO_KHZ800);
+
+int main(void)
+{
+	arch.setup();
+	gpio.setup();
+	kout.setup();
+	np.setup();
+
+	unsigned char pixel = 0;
+
+	while (1) {
+		gpio.led_toggle();
+		np.setPixelColor(pixel, np.Color(0, 0, 0));
+		if (pixel == 255) {
+			pixel = 0;
+		} else {
+			pixel++;
+		}
+		np.setPixelColor(pixel, np.Color(64, 64, 64));
+		np.show();
+		_delay_ms(10);
+	}
+
+	return 0;
+}
-- 
GitLab