60 lines
1.5 KiB
C++
60 lines
1.5 KiB
C++
#ifndef CYCLONEHELPER_H
|
|
#define CYCLONEHELPER_H
|
|
|
|
#include "Arduino.h"
|
|
#include "Point2D.h"
|
|
#include "LEDHAL2D.h"
|
|
|
|
class CycloneHelper {
|
|
public:
|
|
CycloneHelper(CRGB _color, uint16_t _originX, uint16_t _originY,
|
|
uint8_t _radius, uint8_t _spinDirection) : color(_color), originX(_originX),
|
|
originY(_originY), radius(_radius), spinDirection(_spinDirection),
|
|
currentDrawAngle(0) {
|
|
|
|
numberOfTails = (uint8_t) round(PI * _radius * 2);
|
|
|
|
tailColors = new CRGB[numberOfTails];
|
|
tailPoints = new Point2D[numberOfTails];
|
|
|
|
float redScaler = ((float) color.red) / numberOfTails;
|
|
float greenScaler = ((float) color.green) / numberOfTails;
|
|
float blueScaler = ((float) color.blue) / numberOfTails;
|
|
|
|
for(uint8_t i = 0; i < numberOfTails; i++) {
|
|
tailColors[i] = CRGB(
|
|
min(round(redScaler * (i + 1)), color.red),
|
|
min(round(greenScaler * (i + 1)), color.green),
|
|
min(round(blueScaler * (i + 1)), color.blue)
|
|
);
|
|
}
|
|
|
|
nextPoint = Point2D(
|
|
_originX + (uint16_t) round(radius * cosf(currentDrawAngle)),
|
|
_originY + (uint16_t) round(radius * sinf(currentDrawAngle))
|
|
);
|
|
}
|
|
|
|
void updateAndRedraw(LEDHAL2D* matrix);
|
|
private:
|
|
CRGB
|
|
color;
|
|
CRGB*
|
|
tailColors;
|
|
Point2D
|
|
nextPoint;
|
|
Point2D*
|
|
tailPoints;
|
|
int8_t
|
|
spinDirection;
|
|
uint8_t
|
|
radius,
|
|
numberOfTails;
|
|
uint16_t
|
|
originX,
|
|
originY;
|
|
int16_t
|
|
currentDrawAngle;
|
|
};
|
|
|
|
#endif |