move pixelmatrix dimensions to separate config
This commit is contained in:
parent
188c408506
commit
968507ad7b
|
@ -1,5 +1,7 @@
|
|||
#include "NeoPatterns.h"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
NeoPatterns::NeoPatterns(uint16_t pixels, uint8_t pin, uint8_t type, void (*callback)()) :
|
||||
Adafruit_NeoPixel(pixels, pin, type)
|
||||
{
|
||||
|
@ -336,45 +338,47 @@ void NeoPatterns::SmoothUpdate() {
|
|||
uint8_t g = (uint8_t)(c >> 8);
|
||||
uint8_t b = (uint8_t)c;
|
||||
|
||||
movingPoint_x = movingPoint_x + 8 + random(-random(0, 1 + 1), random(0, 1 + 1) + 1);
|
||||
movingPoint_y = movingPoint_y + 8 + random(-random(0, 1 + 1), random(0, 1 + 1) + 1);
|
||||
if (movingPoint_x < 8) {
|
||||
movingPoint_x = 8 - movingPoint_x;
|
||||
} else if (movingPoint_x >= 16) {
|
||||
movingPoint_x = 22 - movingPoint_x;
|
||||
movingPoint_x = movingPoint_x + WIDTH + random(-random(0, 1 + 1), random(0, 1 + 1) + 1);
|
||||
movingPoint_y = movingPoint_y + HEIGHT + random(-random(0, 1 + 1), random(0, 1 + 1) + 1);
|
||||
if (movingPoint_x < WIDTH) {
|
||||
movingPoint_x = WIDTH - movingPoint_x;
|
||||
} else if (movingPoint_x >= (2*WIDTH)) {
|
||||
//movingPoint_x = 22 - movingPoint_x; //unklar warum 22? fuer WIDTH=8
|
||||
movingPoint_x = (2*WIDTH) - movingPoint_x;
|
||||
} else {
|
||||
movingPoint_x -= 8;
|
||||
movingPoint_x -= WIDTH;
|
||||
}
|
||||
|
||||
if (movingPoint_y < 8) {
|
||||
movingPoint_y = 8 - movingPoint_y;
|
||||
} else if (movingPoint_y >= 16) {
|
||||
movingPoint_y = 22 - movingPoint_y;
|
||||
if (movingPoint_y < HEIGHT) {
|
||||
movingPoint_y = HEIGHT - movingPoint_y;
|
||||
} else if (movingPoint_y >= (2*HEIGHT)) {
|
||||
//movingPoint_y = 22 - movingPoint_y;
|
||||
movingPoint_y = (2*HEIGHT) - movingPoint_y;
|
||||
} else {
|
||||
movingPoint_y -= 8;
|
||||
movingPoint_y -= HEIGHT;
|
||||
}
|
||||
uint8_t startx = movingPoint_x;
|
||||
uint8_t starty = movingPoint_y;
|
||||
|
||||
for (int i = 0; i < Strength; i++) {
|
||||
|
||||
movingPoint_x = startx + 8 + random(-random(0, 2 + 1), random(0, 2 + 1) + 1);
|
||||
movingPoint_y = starty + 8 + random(-random(0, 2 + 1), random(0, 2 + 1) + 1);
|
||||
movingPoint_x = startx + WIDTH + random(-random(0, 2 + 1), random(0, 2 + 1) + 1);
|
||||
movingPoint_y = starty + HEIGHT + random(-random(0, 2 + 1), random(0, 2 + 1) + 1);
|
||||
|
||||
if (movingPoint_x < 8) {
|
||||
movingPoint_x = 8 - movingPoint_x;
|
||||
} else if (movingPoint_x >= 16) {
|
||||
movingPoint_x = 22 - movingPoint_x;
|
||||
if (movingPoint_x < WIDTH) {
|
||||
movingPoint_x = WIDTH - movingPoint_x;
|
||||
} else if (movingPoint_x >= (2*WIDTH)) {
|
||||
movingPoint_x = (2*WIDTH) - movingPoint_x;
|
||||
} else {
|
||||
movingPoint_x -= 8;
|
||||
movingPoint_x -= WIDTH;
|
||||
}
|
||||
|
||||
if (movingPoint_y < 8) {
|
||||
movingPoint_y = 8 - movingPoint_y;
|
||||
} else if (movingPoint_y >= 16) {
|
||||
movingPoint_y = 22 - movingPoint_y;
|
||||
if (movingPoint_y < HEIGHT) {
|
||||
movingPoint_y = HEIGHT - movingPoint_y;
|
||||
} else if (movingPoint_y >= (2*HEIGHT)) {
|
||||
movingPoint_y = (2*HEIGHT) - movingPoint_y;
|
||||
} else {
|
||||
movingPoint_y -= 8;
|
||||
movingPoint_y -= HEIGHT;
|
||||
}
|
||||
|
||||
if (pixelR[xyToPos(movingPoint_x, movingPoint_y)] < r) {
|
||||
|
@ -613,9 +617,9 @@ uint32_t NeoPatterns::Wheel(byte WheelPos)
|
|||
// Convert x y pixel position to matrix position
|
||||
uint8_t NeoPatterns::xyToPos(int x, int y) {
|
||||
if (y % 2 == 0) {
|
||||
return (y * 8 + x);
|
||||
return (y * WIDTH + x);
|
||||
} else {
|
||||
return (y * 8 + (7 - x));
|
||||
return (y * WIDTH + (WIDTH-1 - x));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
#ifndef CONFIG_H
|
||||
#define CONFIG_H
|
||||
|
||||
//8x8 Matrix
|
||||
/*
|
||||
#define WIDTH 8 //WIDTH is along consecutive pixels
|
||||
#define HEIGHT 8
|
||||
#define NUMPIXELS 64 // 8x8 Matrix
|
||||
*/
|
||||
|
||||
//3x6 LED Box
|
||||
#define WIDTH 3
|
||||
#define HEIGHT 6
|
||||
#define NUMPIXELS 18 // 3x6 LED Box
|
||||
|
||||
#endif
|
|
@ -6,8 +6,12 @@
|
|||
#include <avr/power.h>
|
||||
#endif
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#define PIN D2 //data pin for ws2812 (pixelprojektor @ ctdo: PIN 2) // Für pixelpad: Pin2
|
||||
#define NUMPIXELS 64
|
||||
|
||||
|
||||
|
||||
|
||||
NeoPatterns strip = NeoPatterns(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800, &StripComplete);
|
||||
|
||||
|
@ -214,6 +218,7 @@ void setup() {
|
|||
ArduinoOTA.onStart([]() {
|
||||
strip.clear();
|
||||
strip.setBrightness(64);
|
||||
strip.show();
|
||||
});
|
||||
ArduinoOTA.onEnd([]() {
|
||||
strip.clear();
|
||||
|
|
Loading…
Reference in New Issue