simple test, fully working 'Sporttafel'
This commit is contained in:
commit
5c795aaad3
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
.pio
|
||||||
8
platformio.ini
Normal file
8
platformio.ini
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
[env:ws2812b]
|
||||||
|
platform = espressif32
|
||||||
|
board = esp32dev
|
||||||
|
framework = arduino
|
||||||
|
lib_deps = https://github.com/adafruit/Adafruit_NeoPixel
|
||||||
|
upload_port = /dev/ttyUSB0
|
||||||
|
upload_speed = 460800
|
||||||
|
monitor_speed = 115200
|
||||||
54
src/main.cpp
Normal file
54
src/main.cpp
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
#include <Adafruit_NeoPixel.h>
|
||||||
|
|
||||||
|
#define countof(a) (sizeof(a) / sizeof((a)[0]))
|
||||||
|
|
||||||
|
#define ___ 0
|
||||||
|
#define TTT 85
|
||||||
|
#define HHH 127
|
||||||
|
#define XXX 255
|
||||||
|
|
||||||
|
#define GPIO 26
|
||||||
|
#define PIXELS (4 * 7 * 6 + 4 * 4)
|
||||||
|
#define BRIGHTNESS 32
|
||||||
|
|
||||||
|
Adafruit_NeoPixel pixels(PIXELS, GPIO, NEO_GRB + NEO_KHZ800);
|
||||||
|
|
||||||
|
struct color {
|
||||||
|
uint8_t r, g, b;
|
||||||
|
};
|
||||||
|
|
||||||
|
color colors[] = {
|
||||||
|
{XXX, ___, ___},
|
||||||
|
{HHH, HHH, ___},
|
||||||
|
{___, XXX, ___},
|
||||||
|
{___, HHH, HHH},
|
||||||
|
{___, ___, XXX},
|
||||||
|
{HHH, ___, HHH},
|
||||||
|
{TTT, TTT, TTT},
|
||||||
|
};
|
||||||
|
|
||||||
|
color *c = colors;
|
||||||
|
|
||||||
|
int step = 0;
|
||||||
|
|
||||||
|
int dir = 1;
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
delay(500);
|
||||||
|
Serial.begin(115200);
|
||||||
|
Serial.println("\n\n\nstartup");
|
||||||
|
pixels.begin();
|
||||||
|
pixels.setBrightness(BRIGHTNESS);
|
||||||
|
pixels.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
pixels.setPixelColor(step, c->r, c->g, c->b);
|
||||||
|
pixels.show();
|
||||||
|
|
||||||
|
step += dir;
|
||||||
|
if (step < 0 || step > PIXELS - 1) {
|
||||||
|
dir = -dir;
|
||||||
|
c = (c + 1 - colors) % countof(colors) + colors;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user