More testing
This commit is contained in:
@@ -8,6 +8,12 @@ Tested
|
||||
- AlternateMatrix
|
||||
- CollisionStrip
|
||||
- CollisionMatrix
|
||||
- ColorRandomizerStrip (When used with ColorRandomizerMatrix, broken)
|
||||
- ColorRanzomizerMatrix (When used with ColorRandomizerStrip, broken)
|
||||
- CycleLightStrip
|
||||
- CycleLightMatrix
|
||||
- FluidColorMatrix
|
||||
- RicochetMatrix (Broken)
|
||||
|
||||
|
||||
*I need to write something here*
|
||||
|
||||
@@ -17,7 +17,7 @@ class ColorRandomizerMatrix : public MatrixAnimation {
|
||||
uint8_t _numColors, CRGB* _colors, ColorRandomizerType _type) :
|
||||
MatrixAnimation(_matrix, _refName, _updateTime), numColors(_numColors),
|
||||
colors(new CRGB[_numColors]), fade(_fade), colorRandomizerInt(0),
|
||||
scale(DEFAULT_MATRIX_FADER) {
|
||||
scale(DEFAULT_MATRIX_FADER), type(_type) {
|
||||
for(uint8_t i = 0; i < _numColors; i++) {
|
||||
colors[i] = _colors[i];
|
||||
}
|
||||
|
||||
@@ -9,7 +9,8 @@ class RicochetHelper {
|
||||
RicochetHelper() {}
|
||||
RicochetHelper(int16_t _startPosX, int16_t _startPosY, int16_t _width, int16_t _height,
|
||||
CRGB _color) : currentX(_startPosX), currentY(_startPosY), width(_width),
|
||||
height(_height), xDir(random(0, 101) > 51 ? -1 : 1), yDir(random(0, 100) > 51 ? -1 : 1) {}
|
||||
height(_height), xDir(random(0, 101) > 51 ? -1 : 1), yDir(random(0, 100) > 51 ? -1 : 1),
|
||||
color(_color) {}
|
||||
|
||||
int16_t getCurrentXPos() { return currentX; }
|
||||
int16_t getCurrentYPos() { return currentY; }
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
#include "ColorRandomizerMatrix.h"
|
||||
|
||||
void ColorRandomizerMatrix::execute() {
|
||||
Serial.println("In Execute");
|
||||
if(fade && isFading) {
|
||||
CRGB color;
|
||||
|
||||
if(colorRandomizerInt == 0) {
|
||||
for(uint16_t i = 0; i < type == ColorRandomizerType::HORIZONTAL_COLORRANDOMIZER ? matrix->getHeight() : matrix->getWidth(); i++) {
|
||||
for(uint16_t i = 0; i < (type == ColorRandomizerType::HORIZONTAL_COLORRANDOMIZER ? matrix->getHeight() : matrix->getWidth()); i++) {
|
||||
if(type == ColorRandomizerType::HORIZONTAL_COLORRANDOMIZER) {
|
||||
color = matrix->getColor(0, i);
|
||||
} else {
|
||||
@@ -19,7 +20,7 @@ void ColorRandomizerMatrix::execute() {
|
||||
|
||||
colorRandomizerInt++;
|
||||
} else if(colorRandomizerInt > 0 && colorRandomizerInt < scale + 1) {
|
||||
for(uint16_t i = 0; i < type == ColorRandomizerType::HORIZONTAL_COLORRANDOMIZER ? matrix->getHeight() : matrix->getWidth(); i++) {
|
||||
for(uint16_t i = 0; i < (type == ColorRandomizerType::HORIZONTAL_COLORRANDOMIZER ? matrix->getHeight() : matrix->getWidth()); i++) {
|
||||
if(type == ColorRandomizerType::HORIZONTAL_COLORRANDOMIZER) {
|
||||
matrix->drawFastHLine(0, i, matrix->getWidth(), matrix->getColor(0, i) - fadingValues[i]);
|
||||
} else {
|
||||
@@ -33,14 +34,17 @@ void ColorRandomizerMatrix::execute() {
|
||||
isFading = false;
|
||||
}
|
||||
} else {
|
||||
Serial.println("Setup Colors");
|
||||
uint8_t rand;
|
||||
|
||||
for(uint16_t i = 0; i < type == ColorRandomizerType::HORIZONTAL_COLORRANDOMIZER ? matrix->getHeight() : matrix->getWidth(); i++) {
|
||||
for(uint16_t i = 0; i < (type == ColorRandomizerType::HORIZONTAL_COLORRANDOMIZER ? matrix->getHeight() : matrix->getWidth()); i++) {
|
||||
rand = random(0, numColors);
|
||||
|
||||
if(type == ColorRandomizerType::HORIZONTAL_COLORRANDOMIZER) {
|
||||
Serial.println("Draw Horizontal");
|
||||
matrix->drawFastHLine(0, i, matrix->getWidth(), colors[rand]);
|
||||
} else {
|
||||
Serial.println("Draw Vertical");
|
||||
matrix->drawFastVLine(i, 0, matrix->getHeight(), colors[rand]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,9 +8,9 @@ void ColorRandomizerStrip::execute() {
|
||||
for(uint16_t i = 0; i < strip->getNumLEDs(); i++) {
|
||||
color = strip->getColor(i);
|
||||
|
||||
fadingValues[i].red = (ceil((float)color.red/scale));
|
||||
fadingValues[i].green = (ceil((float)color.green/scale));
|
||||
fadingValues[i].blue = (ceil((float)color.blue/scale));
|
||||
fadingValues[i].red = (uint8_t)(ceil((float)color.red/scale));
|
||||
fadingValues[i].green = (uint8_t)(ceil((float)color.green/scale));
|
||||
fadingValues[i].blue = (uint8_t)(ceil((float)color.blue/scale));
|
||||
}
|
||||
|
||||
colorRandomizerInt++;
|
||||
|
||||
@@ -9,18 +9,37 @@ void RicochetMatrix::initialize() {
|
||||
randomSeed(random(0, 10000000));
|
||||
balls[i] = new RicochetHelper(random(0, matrix->getWidth()), random(0, matrix->getHeight()),
|
||||
matrix->getWidth(), matrix->getHeight(), colors[random(0, numColors)]);
|
||||
|
||||
Serial.print("Ball ");
|
||||
Serial.println(i);
|
||||
Serial.print("X ");
|
||||
Serial.println(balls[i]->getCurrentXPos());
|
||||
Serial.print("Y ");
|
||||
Serial.println(balls[i]->getCurrentYPos());
|
||||
Serial.print("CR ");
|
||||
Serial.println(balls[i]->getCurrentColor().red);
|
||||
Serial.print("CG ");
|
||||
Serial.println(balls[i]->getCurrentColor().green);
|
||||
Serial.print("CB ");
|
||||
Serial.println(balls[i]->getCurrentColor().blue);
|
||||
}
|
||||
}
|
||||
|
||||
void RicochetMatrix::execute() {
|
||||
Serial.println("Pre Clear");
|
||||
matrix->clearLEDs();
|
||||
Serial.println("Post Clear");
|
||||
|
||||
Serial.println("Positional Updates");
|
||||
for(uint16_t i = 0; i < numBalls; i++) {
|
||||
balls[i]->updatePositions();
|
||||
|
||||
matrix->drawPixel(balls[i]->getCurrentXPos(), balls[i]->getCurrentYPos(),
|
||||
balls[i]->getCurrentColor());
|
||||
}
|
||||
Serial.println("Post Positional Updates");
|
||||
|
||||
Serial.println("Pre Request Show");
|
||||
matrix->requestShow();
|
||||
Serial.println("Post Request Show");
|
||||
}
|
||||
41
src/main.cpp
41
src/main.cpp
@@ -14,6 +14,12 @@
|
||||
#include "AlternateMatrix.h"
|
||||
#include "CollisionStrip.h"
|
||||
#include "CollisionMatrix.h"
|
||||
#include "ColorRandomizerMatrix.h"
|
||||
#include "ColorRandomizerStrip.h"
|
||||
#include "CycleLightStrip.h"
|
||||
#include "CycleLightMatrix.h"
|
||||
#include "FluidColorMatrix.h"
|
||||
#include "RicochetMatrix.h"
|
||||
|
||||
#define NUMLEDS 24
|
||||
#define WIDTH 6
|
||||
@@ -59,9 +65,9 @@ void setup() {
|
||||
animationMatrix->enable();
|
||||
|
||||
animationMatrix2 = new AlternateMatrix(lm2, "Alternate Matrix 2", 150, rainbow, 6, AlternateType::VERTICAL_ALTERNATE);
|
||||
animationMatrix2->enable();*/
|
||||
animationMatrix2->enable();
|
||||
|
||||
animation = new CollisionStrip(hal, "Collision Strip", 150, CRGB::Orange, CRGB::Green);
|
||||
/*animation = new CollisionStrip(hal, "Collision Strip", 150, CRGB::Orange, CRGB::Green);
|
||||
animation->enable();
|
||||
|
||||
animationMatrix = new CollisionMatrix(lm1, "Collision Matrix", 1000, CRGB::Orange, CRGB::Green, CollisionType::HORIZONTAL_COLLISION);
|
||||
@@ -69,6 +75,33 @@ void setup() {
|
||||
|
||||
animationMatrix2 = new CollisionMatrix(lm2, "Collision Matrix 2", 1000, CRGB::Orange, CRGB::Green, CollisionType::VERTICAL_COLLISION);
|
||||
animationMatrix2->enable();
|
||||
|
||||
animation = new ColorRandomizerStrip(hal, "Color Randomizer Strip", 50, true, 6, rainbow);
|
||||
animation->enable();
|
||||
|
||||
animationMatrix = new ColorRandomizerMatrix(lm1, "Color Randomizer Matrix", 300, false, 6, rainbow, ColorRandomizerType::HORIZONTAL_COLORRANDOMIZER);
|
||||
animationMatrix->enable();
|
||||
|
||||
animationMatrix2 = new ColorRandomizerMatrix(lm2, "Color Randomizer Matrix 2", 300, false, 6, rainbow, ColorRandomizerType::VERTICAL_COLORRANDOMIZER);
|
||||
animationMatrix2->enable();
|
||||
|
||||
animation = new CycleLightStrip(hal, "Cycle Light Strip", 250, 6, rainbow);
|
||||
animation->enable();
|
||||
|
||||
animationMatrix = new CycleLightMatrix(lm1, "Cycle Light Matrix", 250, rainbow, 6, CycleLightType::HORIZONTAL_CYCLELIGHT);
|
||||
animationMatrix->enable();
|
||||
|
||||
animationMatrix2 = new CycleLightMatrix(lm2, "Cycle Light Matrix 2", 250, rainbow, 6, CycleLightType::VERTICAL_CYCLELIGHT);
|
||||
animationMatrix2->enable();
|
||||
|
||||
animationMatrix = new FluidColorMatrix(lm1, "Fluid Color", 30, FluidColorType::PIXEL_BY_PIXEL_FLUIDCOLOR, FluidColorResolution::FULL_FLUIDCOLOR);
|
||||
animationMatrix->enable();
|
||||
|
||||
animationMatrix2 = new FluidColorMatrix(lm2, "Fluid Color 2", 30, FluidColorType::VERTICAL_FLUIDCOLOR, FluidColorResolution::FULL_FLUIDCOLOR);
|
||||
animationMatrix2->enable();*/
|
||||
|
||||
animationMatrix = new RicochetMatrix(hal2D, "Ricochet Matrix", 150, 10, rainbow, 6);
|
||||
animationMatrix->enable();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
@@ -76,9 +109,9 @@ void loop() {
|
||||
hal->setColor(i, rainbow[(i + shiftNumber) % 6]);
|
||||
}*/
|
||||
|
||||
animation->update();
|
||||
//animation->update();
|
||||
animationMatrix->update();
|
||||
animationMatrix2->update();
|
||||
//animationMatrix2->update();
|
||||
|
||||
/*for(uint16_t i = 0; i < WIDTH * HEIGHT; i++) {
|
||||
hal2D->setColor(i, CRGB::Red);
|
||||
|
||||
Reference in New Issue
Block a user