#define FASTLED_ALLOW_INTERRUPTS 0
#include <FastLED.h>
#include "palettes.h"
#include "functions.h"
#import<FastLED.h>
//#define MATRIX 16 //could be 16, 24, 32, 40 and 48
#define DATA_PIN 3
#define LED_TYPE WS2811
#define COLOR_ORDER GRB
int BRIGHTNESS = 255;
CRGBPalette16 currentPalette;
//
//++++++++++++++++++++++++
#define LED_COLS 15 // resolution of cilindrical lookup table
#define LED_ROWS 16
//#define NUM_LEDS 240
bool setupm = 1;
#define C_X (LED_COLS / 2)
#define C_Y (LED_ROWS / 2)
float XY_angle[LED_COLS][LED_ROWS];
float XY_radius[LED_COLS][LED_ROWS];
#define NUM_LEDS 256
//++++++++++++++++++++++++++++
CRGB leds[NUM_LEDS];
// https://github.com/DmytroKorniienko/FireLamp_JeeUI/tree/dev
// kostyamat\
//#define NUM_LEDS 256
#define COUNT 5
float posX[COUNT];
float posY[COUNT];
uint8_t aimX[COUNT];
uint8_t aimY[COUNT];
float XSradius[COUNT];
byte Shue[255];;
CRGB color[COUNT];
byte starPoints[COUNT];
bool run[COUNT];
bool load = true;
const byte Smax = max(0, 32);//заполнение
const float speedFactor = NUM_LEDS/256;
//++++++++++++++++++++
extern const uint8_t gGradientPaletteCount;
uint8_t gCurrentPaletteNumber = 0;
//++++++++++++++++++++++++++
byte ZstarPoints[COUNT];
const float ZZSSspeed = (float) NUM_LEDS / 255; // Speed normalization for different matrix sizes
const float ZaddRadius = (float) NUM_LEDS / 600; // Normalization of increase in radius
// of a circle for different matrix sizes
void ZZSdrawPixelXYF(float x, float y, CRGB color) {
if (x < 0 || y < 0 || x > ((float) LED_COLS - 1) || y > ((float) LED_ROWS - 1)) return;
uint8_t xx = (x - (int) x) * 255, yy = (y - (int) y) * 255, ix = 255 - xx, iy = 255 - yy;
// calculate the intensities for each affected pixel
#define WU_WEIGHT(a, b)((uint8_t)(((a) * (b) + (a) + (b)) >> 8))
uint8_t wu[4] = {
WU_WEIGHT(ix, iy),
WU_WEIGHT(xx, iy),
WU_WEIGHT(ix, yy),
WU_WEIGHT(xx, yy)
};
// multiply the intensities by the colour, and saturating-add them to the pixels
for (uint8_t i = 0; i < 4; i++) {
int16_t xn = x + (i & 1), yn = y + ((i >> 1) & 1);
CRGB clr = leds[XY(xn, yn)];
clr.r = qadd8(clr.r, ( (color.r) * wu[i]) >> 8);
clr.g = qadd8(clr.g, ( (color.g) * wu[i]) >> 8);
clr.b = qadd8(clr.b , ( (color.b) * wu[i]) >> 8);
leds[XY(xn, yn)] = clr++;
}
}
void ZXZSdrawPixelXYF(float x, float y, CRGB color) {
if (x < 0 || y < 0 || x > ((float) LED_COLS - 1) || y > ((float) LED_ROWS - 1)) return;
uint8_t xx = (x - (int) x) * 255, yy = (y - (int) y) * 255, ix = 255 - xx, iy = 255 - yy;
// calculate the intensities for each affected pixel
#define WU_WEIGHT(a, b)((uint8_t)(((a) * (b) + (a) + (b)) >> 8))
uint8_t wu[4] = {
WU_WEIGHT(ix, iy),
WU_WEIGHT(xx, iy),
WU_WEIGHT(ix, yy),
WU_WEIGHT(xx, yy)
};
// multiply the intensities by the colour, and saturating-add them to the pixels
for (uint8_t i = 0; i < 4; i++) {
int16_t xn = x + (i & 1), yn = y + ((i >> 1) & 1);
CRGB clr = (leds[XY(xn, yn)]);
clr.r = qadd8((clr.r ), ( (color.r) * wu[i]) >> 8)+1;
clr.g = qadd8( (clr.g ), ( (color.g) * wu[i]) >> 8);
clr.b = qadd8( (clr.b ), ( (color.b) * wu[i]) >> 8);
leds[XY(xn, yn)] = clr;
}
}
void ZZSdrawCircleF(float x0, float y0, float radius,
const CRGB & color, float step = 0.25) {
fadeToBlackBy(leds, NUM_LEDS, 30);
float a = radius-1, b = 0.;
float radiusError = step -a;
if (radius <= step * 2) {
ZZSdrawPixelXYF(x0, y0,color);
ZZSdrawPixelXYF(x0, y0,color);
return;
}
while (a >= b) {
ZZSdrawPixelXYF(a + x0, b + y0, color);
ZZSdrawPixelXYF(b + x0, a + y0, color);
ZZSdrawPixelXYF(-a + x0, b + y0, color);
ZZSdrawPixelXYF(-b + x0, a + y0, color);
ZZSdrawPixelXYF(-a + x0, -b + y0, color);
ZZSdrawPixelXYF(-b + x0, -a + y0, color);
ZZSdrawPixelXYF(a + x0, -b + y0, color);
ZZSdrawPixelXYF(b + x0, -a + y0, color);
//+++++++++++++++++++++
b += step;
if (radiusError < 0.)
radiusError += 2. * b + step;
else {
a -= step+sin8(170);
radiusError += 2 * (b - a + step);
}
}
}
void ZXZSdrawCircleF(float x0, float y0, float radius,
const CRGB & color, float step = 0.25) {
fadeToBlackBy(leds, NUM_LEDS, 13);
float a = radius-1, b = 0.;
float radiusError = step -a;
if (radius <= step * 2) {
ZXZSdrawPixelXYF(x0, y0,color);
ZXZSdrawPixelXYF(x0, y0,color);
return;
}
while (a >= b) {
//+++++++++++++++++++++
ZXZSdrawPixelXYF(a + x0, b + y0, color);
ZXZSdrawPixelXYF(b + x0, a + y0, color);
ZXZSdrawPixelXYF(-a + x0, b + y0, color);
ZXZSdrawPixelXYF(-b + x0, a + y0, color);
ZXZSdrawPixelXYF(-a + x0, -b + y0, color);
ZXZSdrawPixelXYF(-b + x0, -a + y0, color);
ZXZSdrawPixelXYF(a + x0, -b + y0, color);
ZXZSdrawPixelXYF(b + x0, -a + y0, color);
b += step;
if (radiusError < 0.)
radiusError += 2. * b + step;
else {
a -= step+sin8(30);
radiusError += 2 * (b - a + step);
}
}
}
void ZXXZSdrawCircleF(float x0, float y0, float radius,
const CRGB & color, float step = 0.25) {
fadeToBlackBy(leds, NUM_LEDS, 30);
float a = radius-1, b = 0.;
float radiusError = step -a;
if (radius <= step * 2) {
ZXZSdrawPixelXYF(x0, y0,color);
ZXZSdrawPixelXYF(x0, y0,color);
return;
}
while (a >= b) {
//+++++++++++++++++++++
ZXZSdrawPixelXYF(a + x0, b + y0, color);
ZXZSdrawPixelXYF(b + x0, a + y0, color);
ZXZSdrawPixelXYF(-a + x0, b + y0, color);
ZXZSdrawPixelXYF(-b + x0, a + y0, color);
ZXZSdrawPixelXYF(-a + x0, -b + y0, color);
ZXZSdrawPixelXYF(-b + x0, -a + y0, color);
ZXZSdrawPixelXYF(a + x0, -b + y0, color);
ZXZSdrawPixelXYF(b + x0, -a + y0, color);
b += step;
if (radiusError < 0.)
radiusError += 2. * b + step;
else {
a -=step+1;
radiusError += 2 * (b - a + step);
}
}
// blur2d(leds, LED_COLS, LED_ROWS, 150);
}
void ZXXXZSdrawCircleF(float x0, float y0, float radius,
const CRGB & color, float step = 0.25) {
//color = ColorFromPalette(GgTargetPalette,leds,222);
fadeToBlackBy(leds, NUM_LEDS, 30);
float a = radius-1, b = 0.;
float radiusError = step -a;
/*if (radius <= step * 2) {
ZXZSdrawPixelXYF(x0, y0,color);
ZXZSdrawPixelXYF(x0, y0,color);
return;
}*/
while (a >= b-10) {
ZXZSdrawPixelXYF(a + x0, b + y0, color);
ZXZSdrawPixelXYF(b + x0, a + y0, color);
ZXZSdrawPixelXYF(-a + x0, b + y0, color);
ZXZSdrawPixelXYF(-b + x0, a + y0, color);
ZXZSdrawPixelXYF(-a + x0, -b + y0, color);
ZXZSdrawPixelXYF(-b + x0, -a + y0, color);
ZXZSdrawPixelXYF(a + x0, -b + y0, color);
ZXZSdrawPixelXYF(b + x0, -a + y0, color);
//+++++++++++++++++++++
b += step;
if (radiusError < 0.)
radiusError += 2. * b + step;
else {
a -= step;//+sin8(170)
radiusError += 2 * (b - a + step);
}
}
}
void ZZdrawLineF(float x1, float y1, float x2, float y2,
const CRGB & color) {
float deltaX = fabs(x2 - x1);
float deltaY = fabs(y2 - y1);
float error = deltaX - deltaY;
float signX = x1 < x2 ? 0.5 : -0.5;
float signY = y1 < y2 ? 0.5 : -0.5;
while (x1 != x2 || y1 != y2) {
if ((signX > 0. && x1 > x2 + signX) || (signX < 0. && x1 < x2 + signX))
break;
if ((signY > 0. && y1 > y2 + signY) || (signY < 0. && y1 < y2 + signY))
break;
ZZSdrawPixelXYF(x1, y1, color);
float error2 = error;
if (error2 > -deltaY) {
error -= deltaY;
x1 += signX;
}
if (error2 < deltaX) {
error += deltaX;
y1 += signY;
}
}
}
void ZXZdrawLineF(float x1, float y1, float x2, float y2,
const CRGB & color) {
float deltaX = fabs(x2 - x1);
float deltaY = fabs(y2 - y1);
float error = deltaX - deltaY;
float signX = x1 < x2 ? 0.5 : -0.5;
float signY = y1 < y2 ? 0.5 : -0.5;
while (x1 != x2 || y1 != y2) {
if ((signX > 0. && x1 > x2 + signX) || (signX < 0. && x1 < x2 + signX))
break;
if ((signY > 0. && y1 > y2 + signY) || (signY < 0. && y1 < y2 + signY))
break;
ZXZSdrawPixelXYF(x1, y1, color);
float error2 = error;
if (error2 > -deltaY) {
error -= deltaY;
x1 += signX;
}
if (error2 < deltaX) {
error += deltaX;
y1 += signY;
}
}
}
void ZZdrawStarF(float x, float y, float biggy, float little, int16_t points, float dangle, CRGB color) {
float radius2 =(255.0 )/ points;
for (int i = 0; i < points; i++) {
ZZdrawLineF(x + ((little * (sin8(i * radius2 + radius2 / 2 ) - 128.0)) / 128), y + ((little * (cos8(i * radius2 + radius2 / 2 ) - 128.0)) / 128), x + ((biggy * (sin8(i * radius2 ) - 128.0)) / 128), y + ((biggy * (cos8(i * radius2 ) - 128.0)) / 128), color);
// ZZdrawLineF(x + ((little * (sin8(i * radius2 - radius2 / 2 ) - 128.0)) / 128), y + ((little * (cos8(i * radius2 - radius2 / 2 ) - 128.0)) / 128), x + ((biggy * (sin8(i * radius2 ) - 128.0)) / 128), y + ((biggy * (cos8(i * radius2 ) - 128.0)) / 128), color);
// ZZdrawLineF(x + ((little * (sin8(i * radius2 + radius2 / 8 - dangle) - 128.0)) / 128), y + ((little * (cos8(i * radius2 + radius2 / 8 - dangle) - 128.0)) / 128), x + ((biggy * (sin8(i * radius2 - dangle) - 128.0)) / 128), y + ((biggy * (cos8(i * radius2 - dangle) - 128.0)) / 128), color);
////ZZdrawLineF(x + ((little * (sin8(i * radius2 - radius2 / 8 - dangle) - 128.0)) / 128), y + ((little * (cos8(i * radius2 - radius2 / 8 - dangle) - 128.0)) / 128), x + ((biggy * (sin8(i * radius2 - dangle) - 128.0)) / 128), y + ((biggy * (cos8(i * radius2 - dangle) - 128.0)) / 128), color);
// ZZdrawLineF(x + ((little * (sin8(i * radius2 + radius2 / 2 - dangle) - 128.0)) / 128), y + ((little * (cos8(i * radius2 + radius2 / 2 - dangle) - 128.0)) / 128), x + ((biggy * (sin8(i * radius2 - dangle) - 128.0)) / 128), y + ((biggy * (cos8(i * radius2 - dangle) - 128.0)) / 128), color);
// ZZdrawLineF(x + ((little * (sin8(i * radius2 - radius2 / 2 - dangle) - 128.0)) / 128), y + ((little * (cos8(i * radius2 - radius2 / 2 - dangle) - 128.0)) / 128), x + ((biggy * (sin8(i * radius2 - dangle) - 128.0)) / 128), y + ((biggy * (cos8(i * radius2 - dangle) - 128.0)) / 128), color);
}
}
void XZZdrawStarF(float x, float y, float biggy, float little, int16_t points, float dangle, CRGB color) {
float radius2 =(255.0 )/ points;
for (int i = 0; i < points; i++) {
//ZZdrawLineF(x + ((little * (sin8(i * radius2 + radius2 / 2 ) - 128.0)) / 128), y + ((little * (cos8(i * radius2 + radius2 / 2 ) - 128.0)) / 128), x + ((biggy * (sin8(i * radius2 ) - 128.0)) / 128), y + ((biggy * (cos8(i * radius2 ) - 128.0)) / 128), color);
ZZdrawLineF(x + ((little * (sin8(i * radius2 - radius2 / 2 ) - 128.0)) / 128), y + ((little * (cos8(i * radius2 - radius2 / 2 ) - 128.0)) / 128), x + ((biggy * (sin8(i * radius2 ) - 128.0)) / 128), y + ((biggy * (cos8(i * radius2 ) - 128.0)) / 128), color);
}
}
void XXZZdrawStarF(float x, float y, float biggy, float little, int16_t points, float dangle, CRGB color) {
float radius2 =(255.0 )/ points;
for (int i = 0; i < points; i++) {
ZZdrawLineF(x + ((little * (sin8(i * radius2 + radius2 / 2 ) - 128.0)) / 128), y + ((little * (cos8(i * radius2 + radius2 / 2 ) - 128.0)) / 128), x + ((biggy * (sin8(i * radius2 ) - 128.0)) / 128), y + ((biggy * (cos8(i * radius2 ) - 128.0)) / 128), color);
ZZdrawLineF(x + ((little * (sin8(i * radius2 - radius2 / 2 ) - 128.0)) / 128), y + ((little * (cos8(i * radius2 - radius2 / 2 ) - 128.0)) / 128), x + ((biggy * (sin8(i * radius2 ) - 128.0)) / 128), y + ((biggy * (cos8(i * radius2 ) - 128.0)) / 128), color);
}
}
//+++++++++++++++++++++++++++++++++2222
void XXXZZdrawStarF(float x, float y, float biggy, float little, int16_t points, float dangle, CRGB color) {
float radius2 =(255.0 )/ points;
for (int i = 0; i < points; i++) {
//ZZdrawLineF(x + ((little * (sin8(i * radius2 + radius2 / 8 ) - 128.0)) / 128), y + ((little * (cos8(i * radius2 + radius2 / 8 ) - 128.0)) / 128), x + ((biggy * (sin8(i * radius2 ) - 128.0)) / 128), y + ((biggy * (cos8(i * radius2 ) - 128.0)) / 128), color);
ZZdrawLineF(x + ((little * (sin8(i * radius2 - radius2 / 8 ) - 128.0)) / 128), y + ((little * (cos8(i * radius2 - radius2 / 8 ) - 128.0)) / 128), x + ((biggy * (sin8(i * radius2 ) - 128.0)) / 128), y + ((biggy * (cos8(i * radius2 ) - 128.0)) / 128), color);
}
}
void XXXXZZdrawStarF(float x, float y, float biggy, float little, int16_t points, float dangle, CRGB color) {
float radius2 =(255.0 )/ points;
for (int i = 0; i < points; i++) {
ZZdrawLineF(x + ((little * (sin8(i * radius2 + radius2 / 8 ) - 128.0)) / 128), y + ((little * (cos8(i * radius2 + radius2 / 8 ) - 128.0)) / 128), x + ((biggy * (sin8(i * radius2 ) - 128.0)) / 128), y + ((biggy * (cos8(i * radius2 ) - 128.0)) / 128), color);
//ZZdrawLineF(x + ((little * (sin8(i * radius2 - radius2 / 8 ) - 128.0)) / 128), y + ((little * (cos8(i * radius2 - radius2 / 8 ) - 128.0)) / 128), x + ((biggy * (sin8(i * radius2 ) - 128.0)) / 128), y + ((biggy * (cos8(i * radius2 ) - 128.0)) / 128), color);
}
}
void XXXXXZZdrawStarF(float x, float y, float biggy, float little, int16_t points, float dangle, CRGB color) {
float radius2 =(255.0 )/ points;
for (int i = 0; i < points; i++) {
ZZdrawLineF(x + ((little * (sin8(i * radius2 + radius2 / 8 ) - 128.0)) / 128), y + ((little * (cos8(i * radius2 + radius2 / 8 ) - 128.0)) / 128), x + ((biggy * (sin8(i * radius2 ) - 128.0)) / 128), y + ((biggy * (cos8(i * radius2 ) - 128.0)) / 128), color);
ZZdrawLineF(x + ((little * (sin8(i * radius2 - radius2 / 8 ) - 128.0)) / 128), y + ((little * (cos8(i * radius2 - radius2 / 8 ) - 128.0)) / 128), x + ((biggy * (sin8(i * radius2 ) - 128.0)) / 128), y + ((biggy * (cos8(i * radius2 ) - 128.0)) / 128), color);
}
}
void XXXXXXZZdrawStarF(float x, float y, float biggy, float little, int16_t points, float dangle, CRGB color) {
float radius2 =(255.0 )/ points;
for (int i = 0; i < points; i++) {
// ZZdrawLineF(x + ((little * (sin8(i * radius2 + radius2 / 8 - dangle) - 128.0)) / 128), y + ((little * (cos8(i * radius2 + radius2 / 8 - dangle) - 128.0)) / 128), x + ((biggy * (sin8(i * radius2 - dangle) - 128.0)) / 128), y + ((biggy * (cos8(i * radius2 - dangle) - 128.0)) / 128),color);
ZZdrawLineF(x + ((little * (sin8(i * radius2 - radius2 / 8 - dangle) - 128.0)) / 128), y + ((little * (cos8(i * radius2 - radius2 / 8 - dangle) - 128.0)) / 128), x + ((biggy * (sin8(i * radius2 - dangle) - 128.0)) / 128), y + ((biggy * (cos8(i * radius2 - dangle) - 128.0)) / 128), color);
}
}
void XXXXXXXZZdrawStarF(float x, float y, float biggy, float little, int16_t points, float dangle, CRGB color) {
float radius2 =(255.0 )/ points;
for (int i = 0; i < points; i++) {
ZZdrawLineF(x + ((little * (sin8(i * radius2 + radius2 / 8 - dangle) - 128.0)) / 128), y + ((little * (cos8(i * radius2 + radius2 / 8 - dangle) - 128.0)) / 128), x + ((biggy * (sin8(i * radius2 - dangle) - 128.0)) / 128), y + ((biggy * (cos8(i * radius2 - dangle) - 128.0)) / 128),color);
//ZZdrawLineF(x + ((little * (sin8(i * radius2 - radius2 / 8 - dangle) - 128.0)) / 128), y + ((little * (cos8(i * radius2 - radius2 / 8 - dangle) - 128.0)) / 128), x + ((biggy * (sin8(i * radius2 - dangle) - 128.0)) / 128), y + ((biggy * (cos8(i * radius2 - dangle) - 128.0)) / 128), color);
}
}
void XXXXXXXXZZdrawStarF(float x, float y, float biggy, float little, int16_t points, float dangle, CRGB color) {
float radius2 =(255.0 )/ points;
for (int i = 0; i < points; i++) {
ZZdrawLineF(x + ((little * (sin8(i * radius2 + radius2 / 8 - dangle) - 128.0)) / 128), y + ((little * (cos8(i * radius2 + radius2 / 8 - dangle) - 128.0)) / 128), x + ((biggy * (sin8(i * radius2 - dangle) - 128.0)) / 128), y + ((biggy * (cos8(i * radius2 - dangle) - 128.0)) / 128),color);
ZZdrawLineF(x + ((little * (sin8(i * radius2 - radius2 / 8 - dangle) - 128.0)) / 128), y + ((little * (cos8(i * radius2 - radius2 / 8 - dangle) - 128.0)) / 128), x + ((biggy * (sin8(i * radius2 - dangle) - 128.0)) / 128), y + ((biggy * (cos8(i * radius2 - dangle) - 128.0)) / 128), color);
}
}
//
void ZXZdrawStarF(float x, float y, float biggy, float little, int16_t points, float dangle, CRGB color) {
float radius2 =(255.0 )/ points;
for (int i = 0; i < points; i++) {
ZXZdrawLineF(x + ((little * (sin8(i * radius2 + radius2 / 2 ) - 128.0)) / 128), y + ((little * (cos8(i * radius2 + radius2 / 2 ) - 128.0)) / 128), x + ((biggy * (sin8(i * radius2 ) - 128.0)) / 128), y + ((biggy * (cos8(i * radius2 ) - 128.0)) / 128), color);
// ZZdrawLineF(x + ((little * (sin8(i * radius2 - radius2 / 2 ) - 128.0)) / 128), y + ((little * (cos8(i * radius2 - radius2 / 2 ) - 128.0)) / 128), x + ((biggy * (sin8(i * radius2 ) - 128.0)) / 128), y + ((biggy * (cos8(i * radius2 ) - 128.0)) / 128), color);
// ZZdrawLineF(x + ((little * (sin8(i * radius2 + radius2 / 8 - dangle) - 128.0)) / 128), y + ((little * (cos8(i * radius2 + radius2 / 8 - dangle) - 128.0)) / 128), x + ((biggy * (sin8(i * radius2 - dangle) - 128.0)) / 128), y + ((biggy * (cos8(i * radius2 - dangle) - 128.0)) / 128), color);
////ZZdrawLineF(x + ((little * (sin8(i * radius2 - radius2 / 8 - dangle) - 128.0)) / 128), y + ((little * (cos8(i * radius2 - radius2 / 8 - dangle) - 128.0)) / 128), x + ((biggy * (sin8(i * radius2 - dangle) - 128.0)) / 128), y + ((biggy * (cos8(i * radius2 - dangle) - 128.0)) / 128), color);
// ZZdrawLineF(x + ((little * (sin8(i * radius2 + radius2 / 2 - dangle) - 128.0)) / 128), y + ((little * (cos8(i * radius2 + radius2 / 2 - dangle) - 128.0)) / 128), x + ((biggy * (sin8(i * radius2 - dangle) - 128.0)) / 128), y + ((biggy * (cos8(i * radius2 - dangle) - 128.0)) / 128), color);
// ZZdrawLineF(x + ((little * (sin8(i * radius2 - radius2 / 2 - dangle) - 128.0)) / 128), y + ((little * (cos8(i * radius2 - radius2 / 2 - dangle) - 128.0)) / 128), x + ((biggy * (sin8(i * radius2 - dangle) - 128.0)) / 128), y + ((biggy * (cos8(i * radius2 - dangle) - 128.0)) / 128), color);
}
}
void XZXZdrawStarF(float x, float y, float biggy, float little, int16_t points, float dangle, CRGB color) {
float radius2 =(255.0 )/ points;
for (int i = 0; i < points; i++) {
//ZZdrawLineF(x + ((little * (sin8(i * radius2 + radius2 / 2 ) - 128.0)) / 128), y + ((little * (cos8(i * radius2 + radius2 / 2 ) - 128.0)) / 128), x + ((biggy * (sin8(i * radius2 ) - 128.0)) / 128), y + ((biggy * (cos8(i * radius2 ) - 128.0)) / 128), color);
ZXZdrawLineF(x + ((little * (sin8(i * radius2 - radius2 / 2 ) - 128.0)) / 128), y + ((little * (cos8(i * radius2 - radius2 / 2 ) - 128.0)) / 128), x + ((biggy * (sin8(i * radius2 ) - 128.0)) / 128), y + ((biggy * (cos8(i * radius2 ) - 128.0)) / 128), color);
}
}
void XXZXZdrawStarF(float x, float y, float biggy, float little, int16_t points, float dangle, CRGB color) {
float radius2 =(255.0 )/ points;
for (int i = 0; i < points; i++) {
ZXZdrawLineF(x + ((little * (sin8(i * radius2 + radius2 / 2 ) - 128.0)) / 128), y + ((little * (cos8(i * radius2 + radius2 / 2 ) - 128.0)) / 128), x + ((biggy * (sin8(i * radius2 ) - 128.0)) / 128), y + ((biggy * (cos8(i * radius2 ) - 128.0)) / 128), color);
ZXZdrawLineF(x + ((little * (sin8(i * radius2 - radius2 / 2 ) - 128.0)) / 128), y + ((little * (cos8(i * radius2 - radius2 / 2 ) - 128.0)) / 128), x + ((biggy * (sin8(i * radius2 ) - 128.0)) / 128), y + ((biggy * (cos8(i * radius2 ) - 128.0)) / 128), color);
}
}
//+++++++++++++++++++++++++++++++++2222
void XXXZXZdrawStarF(float x, float y, float biggy, float little, int16_t points, float dangle, CRGB color) {
float radius2 =(255.0 )/ points;
for (int i = 0; i < points; i++) {
//ZZdrawLineF(x + ((little * (sin8(i * radius2 + radius2 / 8 ) - 128.0)) / 128), y + ((little * (cos8(i * radius2 + radius2 / 8 ) - 128.0)) / 128), x + ((biggy * (sin8(i * radius2 ) - 128.0)) / 128), y + ((biggy * (cos8(i * radius2 ) - 128.0)) / 128), color);
ZXZdrawLineF(x + ((little * (sin8(i * radius2 - radius2 / 8 ) - 128.0)) / 128), y + ((little * (cos8(i * radius2 - radius2 / 8 ) - 128.0)) / 128), x + ((biggy * (sin8(i * radius2 ) - 128.0)) / 128), y + ((biggy * (cos8(i * radius2 ) - 128.0)) / 128), color);
}
}
void XXXXZXZdrawStarF(float x, float y, float biggy, float little, int16_t points, float dangle, CRGB color) {
float radius2 =(255.0 )/ points;
for (int i = 0; i < points; i++) {
ZXZdrawLineF(x + ((little * (sin8(i * radius2 + radius2 / 8 ) - 128.0)) / 128), y + ((little * (cos8(i * radius2 + radius2 / 8 ) - 128.0)) / 128), x + ((biggy * (sin8(i * radius2 ) - 128.0)) / 128), y + ((biggy * (cos8(i * radius2 ) - 128.0)) / 128), color);
//ZZdrawLineF(x + ((little * (sin8(i * radius2 - radius2 / 8 ) - 128.0)) / 128), y + ((little * (cos8(i * radius2 - radius2 / 8 ) - 128.0)) / 128), x + ((biggy * (sin8(i * radius2 ) - 128.0)) / 128), y + ((biggy * (cos8(i * radius2 ) - 128.0)) / 128), color);
}
}
void XXXXXZXZdrawStarF(float x, float y, float biggy, float little, int16_t points, float dangle, CRGB color) {
float radius2 =(255.0 )/ points;
for (int i = 0; i < points; i++) {
ZXZdrawLineF(x + ((little * (sin8(i * radius2 + radius2 / 8 ) - 128.0)) / 128), y + ((little * (cos8(i * radius2 + radius2 / 8 ) - 128.0)) / 128), x + ((biggy * (sin8(i * radius2 ) - 128.0)) / 128), y + ((biggy * (cos8(i * radius2 ) - 128.0)) / 128), color);
ZXZdrawLineF(x + ((little * (sin8(i * radius2 - radius2 / 8 ) - 128.0)) / 128), y + ((little * (cos8(i * radius2 - radius2 / 8 ) - 128.0)) / 128), x + ((biggy * (sin8(i * radius2 ) - 128.0)) / 128), y + ((biggy * (cos8(i * radius2 ) - 128.0)) / 128), color);
}
}
void XXXXXXZXZdrawStarF(float x, float y, float biggy, float little, int16_t points, float dangle, CRGB color) {
float radius2 =(255.0 )/ points;
for (int i = 0; i < points; i++) {
// ZZdrawLineF(x + ((little * (sin8(i * radius2 + radius2 / 8 - dangle) - 128.0)) / 128), y + ((little * (cos8(i * radius2 + radius2 / 8 - dangle) - 128.0)) / 128), x + ((biggy * (sin8(i * radius2 - dangle) - 128.0)) / 128), y + ((biggy * (cos8(i * radius2 - dangle) - 128.0)) / 128),color);
ZXZdrawLineF(x + ((little * (sin8(i * radius2 - radius2 / 8 - dangle) - 128.0)) / 128), y + ((little * (cos8(i * radius2 - radius2 / 8 - dangle) - 128.0)) / 128), x + ((biggy * (sin8(i * radius2 - dangle) - 128.0)) / 128), y + ((biggy * (cos8(i * radius2 - dangle) - 128.0)) / 128), color);
}
}
void XXXXXXXZXZdrawStarF(float x, float y, float biggy, float little, int16_t points, float dangle, CRGB color) {
float radius2 =(255.0 )/ points;
for (int i = 0; i < points; i++) {
ZXZdrawLineF(x + ((little * (sin8(i * radius2 + radius2 / 8 - dangle) - 128.0)) / 128), y + ((little * (cos8(i * radius2 + radius2 / 8 - dangle) - 128.0)) / 128), x + ((biggy * (sin8(i * radius2 - dangle) - 128.0)) / 128), y + ((biggy * (cos8(i * radius2 - dangle) - 128.0)) / 128),color);
//ZZdrawLineF(x + ((little * (sin8(i * radius2 - radius2 / 8 - dangle) - 128.0)) / 128), y + ((little * (cos8(i * radius2 - radius2 / 8 - dangle) - 128.0)) / 128), x + ((biggy * (sin8(i * radius2 - dangle) - 128.0)) / 128), y + ((biggy * (cos8(i * radius2 - dangle) - 128.0)) / 128), color);
}
}
void XXXXXXXXZXZdrawStarF(float x, float y, float biggy, float little, int16_t points, float dangle, CRGB color) {
float radius2 =(255.0 )/ points;
for (int i = 0; i < points; i++) {
ZXZdrawLineF(x + ((little * (sin8(i * radius2 + radius2 / 8 - dangle) - 128.0)) / 128), y + ((little * (cos8(i * radius2 + radius2 / 8 - dangle) - 128.0)) / 128), x + ((biggy * (sin8(i * radius2 - dangle) - 128.0)) / 128), y + ((biggy * (cos8(i * radius2 - dangle) - 128.0)) / 128),color);
ZXZdrawLineF(x + ((little * (sin8(i * radius2 - radius2 / 8 - dangle) - 128.0)) / 128), y + ((little * (cos8(i * radius2 - radius2 / 8 - dangle) - 128.0)) / 128), x + ((biggy * (sin8(i * radius2 - dangle) - 128.0)) / 128), y + ((biggy * (cos8(i * radius2 - dangle) - 128.0)) / 128), color);
}
}
//
void ZZZdrawStarF(float x, float y, float biggy, float little, int16_t points, float dangle, CRGB color) {
float radius2 = 255.0 / points;
for (int i = 0; i < points; i++) {
//ZZdrawLineF(x + ((little * (sin8(i * radius2 + radius2 / 8 - dangle) - 128.0)) / 128), y + ((little * (cos8(i * radius2 + radius2 / 8 - dangle) - 128.0)) / 128), x + ((biggy * (sin8(i * radius2 - dangle) - 128.0)) / 128), y + ((biggy * (cos8(i * radius2 - dangle) - 128.0)) / 128), color);
//ZZdrawLineF(x + ((little * (sin8(i * radius2 - radius2 / 8 - dangle) - 128.0)) / 128), y + ((little * (cos8(i * radius2 - radius2 / 8 - dangle) - 128.0)) / 128), x + ((biggy * (sin8(i * radius2 - dangle) - 128.0)) / 128), y + ((biggy * (cos8(i * radius2 - dangle) - 128.0)) / 128), color);
//ZZdrawLineF(x + ((little * (sin8(i * radius2 + radius2 / 2 - dangle) - 128.0)) / 128), y + ((little * (cos8(i * radius2 + radius2 / 2 - dangle) - 128.0)) / 128), x + ((biggy * (sin8(i * radius2 - dangle) - 128.0)) / 128), y + ((biggy * (cos8(i * radius2 - dangle) - 128.0)) / 128), color);
//ZZdrawLineF(x + ((little * (sin8(i * radius2 - radius2 / 2 - dangle) - 128.0)) / 128), y + ((little * (cos8(i * radius2 - radius2 / 2 - dangle) - 128.0)) / 128), x + ((biggy * (sin8(i * radius2 - dangle) - 128.0)) / 128), y + ((biggy * (cos8(i * radius2 - dangle) - 128.0)) / 128), color);
//ZZdrawLineF(x + ((little * (sin8(i * radius2 + radius2 / 8 ) - 128.0)) / 128), y + ((little * (cos8(i * radius2 + radius2 / 8 ) - 128.0)) / 128), x + ((biggy * (sin8(i * radius2 ) - 128.0)) / 128), y + ((biggy * (cos8(i * radius2 ) - 128.0)) / 128), color);
//ZZdrawLineF(x + ((little * (sin8(i * radius2 - radius2 / 8 ) - 128.0)) / 128), y + ((little * (cos8(i * radius2 - radius2 / 8 ) - 128.0)) / 128), x + ((biggy * (sin8(i * radius2 ) - 128.0)) / 128), y + ((biggy * (cos8(i * radius2 ) - 128.0)) / 128), color);
//ZZdrawLineF(x + ((little * (sin8(i * radius2 + radius2 / 2 ) - 128.0)) / 128), y + ((little * (cos8(i * radius2 + radius2 / 2 ) - 128.0)) / 128), x + ((biggy * (sin8(i * radius2 ) - 128.0)) / 128), y + ((biggy * (cos8(i * radius2 ) - 128.0)) / 128), color);
//ZZdrawLineF(x + ((little * (sin8(i * radius2 - radius2 / 2 ) - 128.0)) / 128), y + ((little * (cos8(i * radius2 - radius2 / 2 ) - 128.0)) / 128), x + ((biggy * (sin8(i * radius2 ) - 128.0)) / 128), y + ((biggy * (cos8(i * radius2 ) - 128.0)) / 128), color);
}
}
void ZZaimChange(byte idx) {
randomSeed(millis());
aimX[idx] = random16(LED_COLS / 2 , LED_COLS / 2 );
aimY[idx] = random16(LED_ROWS / 2 , LED_ROWS / 2 );
XSradius[idx] =0;
Shue[idx] = random16();
//color[idx] =ColorFromPalette(CloudColors_p,LavaColors_p,RainbowStripeColors_p,RainbowStripeColors_p);
color[idx] = ColorFromPalette(GgTargetPalette, Shue[idx],255); //CHSV(hue, 255, 255);
starPoints[idx] = random(3, 7);
run[idx] = false;
}
void Plamya( CRGB* ledarray, uint16_t numleds, CRGBPalette16& palette)
{
if (setupm) {
setupm = 0;
for (int8_t x = -C_X; x < C_X+(LED_COLS%2); x++) {
for (int8_t y = -C_Y; y < C_Y+(LED_ROWS%2); y++) {
XY_angle[x + C_X][y + C_Y] = atan2(y, x) * (180. / 2. / PI) * LED_COLS;
XY_radius[x + C_X][y + C_Y] = hypot(x, y); //thanks Sutaburosu
}
}
}
static byte scale = 8;
static byte speed = 24;
static uint32_t t;
t += speed;
for (uint8_t x = 0; x < LED_COLS; x++) {
for (uint8_t y = 0; y < LED_ROWS; y++) {
float angle = XY_angle[x][y];
float radius = XY_radius[x][y];
int16_t Bri = inoise8(angle, radius * scale - t) - radius * LED_ROWS;
byte Col = Bri;
if (Bri < 0) Bri = 0;
if(Bri != 0) Bri = 256 - (Bri *0.2);
nblend(leds[XY(x, y)], ColorFromPalette(gTargetPalette, Col, Bri), speed);
}
}
}
//fadeToBlackBy(leds, NUM_LEDS, 25);
void Zvezda () {
if (load) {
for (byte i = 0; i < COUNT; i++) {
ZZaimChange(i);
}
run[0] = true;
load = false;
}
for (byte i = 0; i < COUNT; i++) {
if (XSradius[i] > Smax / COUNT) {
run[i + 1 < COUNT ? i + 1 : 0] = true;
}
static float angle[COUNT];
if (run[i]) {
XSradius[i] += ZaddRadius * speedFactor;
angle[i] += XSradius[i];
switch (Shue[i] % 48) { // Скоректированны
case 0:
ZZSdrawCircleF(aimX[i], aimY[i],1.3*XSradius[i],color[i] ); // рисуем круг
break;
case 1:
ZZdrawStarF(aimX[i], aimY[i], XSradius[i], XSradius[i], 4, angle[i], color[i]); // рисуем квадрат
break;
case 2:
ZZdrawStarF(aimX[i], aimY[i], XSradius[i], XSradius[i], starPoints[i], angle[i], color[i]); // рисуем звезду
break;
case 3:
ZXZSdrawCircleF(aimX[i], aimY[i],1.3*XSradius[i],color[i] ); // рисуем круг
break;
case 4:
XZZdrawStarF(aimX[i], aimY[i], 1.3 * XSradius[i], XSradius[i], 4, angle[i], color[i]); // рисуем квадрат
break;
case 5:
XZZdrawStarF(aimX[i], aimY[i], 2 * XSradius[i], XSradius[i], starPoints[i], angle[i], color[i]); // рисуем звезду
break;
case 6:
ZXXZSdrawCircleF(aimX[i], aimY[i],1.3*XSradius[i],color[i] ); // рисуем круг
break;
case 7:
XXZZdrawStarF(aimX[i], aimY[i], 1.3 * XSradius[i], XSradius[i], 4, angle[i], color[i]); // рисуем квадрат
break;
case 8:
XXZZdrawStarF(aimX[i], aimY[i], 2 * XSradius[i], XSradius[i], starPoints[i], angle[i], color[i]); // рисуем звезду
break;
case 9:
ZXXXZSdrawCircleF(aimX[i], aimY[i],1.3*XSradius[i],color[i] ); // рисуем круг
break;
case 10:
XXXZZdrawStarF(aimX[i], aimY[i], 1.3 * XSradius[i], XSradius[i], 4, angle[i], color[i]); // рисуем квадрат
break;
case 11:
XXXZZdrawStarF(aimX[i], aimY[i], 2 * XSradius[i], XSradius[i], starPoints[i], angle[i], color[i]); // рисуем звезду
break;
case 12:
ZZSdrawCircleF(aimX[i], aimY[i], 2 *XSradius[i], color[i]); // рисуем круг
break;
case 13:
XXXXZZdrawStarF(aimX[i], aimY[i], 1.3 * XSradius[i], XSradius[i], 4, angle[i], color[i]); // рисуем квадрат
break;
case 14:
XXXXZZdrawStarF(aimX[i], aimY[i], 2 * XSradius[i], XSradius[i], starPoints[i], angle[i], color[i]); // рисуем звезду
break;
case 15:
ZXZSdrawCircleF(aimX[i], aimY[i],1.3*XSradius[i],color[i] ); // рисуем круг
break;
case 16:
XXXXXZZdrawStarF(aimX[i], aimY[i], 1.3 * XSradius[i], XSradius[i], 4, angle[i], color[i]); // рисуем квадрат
break;
case 17:
XXXXXZZdrawStarF(aimX[i], aimY[i], 2 * XSradius[i], XSradius[i], starPoints[i], angle[i], color[i]); // рисуем звезду
break;
case 18:
ZXXZSdrawCircleF(aimX[i], aimY[i],1.3*XSradius[i],color[i] ); // рисуем круг
break;
case 19:
XXXXXXZZdrawStarF(aimX[i], aimY[i], 1.3 * XSradius[i], XSradius[i], 4, angle[i], color[i]); // рисуем квадрат
break;
case 20:
XXXXXXZZdrawStarF(aimX[i], aimY[i], 2 * XSradius[i], XSradius[i], starPoints[i], angle[i], color[i]); // рисуем звезду
break;
case 21:
ZXXXZSdrawCircleF(aimX[i], aimY[i],1.3* XSradius[i], color[i]); // рисуем круг
break;
case 22:
XXXXXXXZZdrawStarF(aimX[i], aimY[i], 1.3 * XSradius[i], XSradius[i], 4, angle[i], color[i]); // рисуем квадрат
break;
case 23:
XXXXXXXZZdrawStarF(aimX[i], aimY[i], 2 * XSradius[i], XSradius[i], starPoints[i], angle[i], color[i]); // рисуем звезду
break;
case 24:
ZZSdrawCircleF(aimX[i], aimY[i],1.3*XSradius[i],color[i] ); // рисуем круг
break;
case 25:
ZXZSdrawCircleF(aimX[i], aimY[i],1.3* XSradius[i],color[i] ); // рисуем круг
break;
case 26:
ZXZdrawStarF(aimX[i], aimY[i], 1.3 * XSradius[i], XSradius[i], 4, angle[i], color[i]); // рисуем квадрат
break;
case 27:
ZXZdrawStarF(aimX[i], aimY[i], 2 * XSradius[i], XSradius[i], starPoints[i], angle[i], color[i]); // рисуем звезду
break;
case 28:
ZXXZSdrawCircleF(aimX[i], aimY[i], 2 *XSradius[i], color[i]); // рисуем круг
break;
case 29:
XZXZdrawStarF(aimX[i], aimY[i], 1.3 * XSradius[i], XSradius[i], 4, angle[i], color[i]); // рисуем квадрат
break;
case 30:
XZXZdrawStarF(aimX[i], aimY[i], 2 * XSradius[i], XSradius[i], starPoints[i], angle[i], color[i]); // рисуем звезду
break;
ZXXXZSdrawCircleF(aimX[i], aimY[i],1.3* XSradius[i], color[i]); // рисуем круг
break;
case 31:
XXZXZdrawStarF(aimX[i], aimY[i], 1.3 * XSradius[i], XSradius[i], 4, angle[i], color[i]); // рисуем квадрат
break;
case 32:
XXZXZdrawStarF(aimX[i], aimY[i], 2 * XSradius[i], XSradius[i], starPoints[i], angle[i], color[i]); // рисуем звезду
break;
case 33:
ZZSdrawCircleF(aimX[i], aimY[i], 2 *XSradius[i], color[i]); // рисуем круг
break;
case 34:
XXXZXZdrawStarF(aimX[i], aimY[i], 1.3 * XSradius[i], XSradius[i], 4, angle[i], color[i]); // рисуем квадрат
break;
case 35:
XXXZXZdrawStarF(aimX[i], aimY[i], 2 * XSradius[i], XSradius[i], starPoints[i], angle[i], color[i]); // рисуем звезду
break;
case 36:
ZXZSdrawCircleF(aimX[i], aimY[i],1.3*XSradius[i],color[i] ); // рисуем круг
break;
case 37:
XXXXZXZdrawStarF(aimX[i], aimY[i], 1.3 * XSradius[i], XSradius[i], 4, angle[i], color[i]); // рисуем квадрат
break;
case 38:
XXXXZXZdrawStarF(aimX[i], aimY[i], 2 * XSradius[i], XSradius[i], starPoints[i], angle[i], color[i]); // рисуем звезду
break;
case 39:
ZXXZSdrawCircleF(aimX[i], aimY[i],1.3*XSradius[i],color[i] ); // рисуем круг
break;
case 40:
XXXXXZXZdrawStarF(aimX[i], aimY[i], 1.3 * XSradius[i], XSradius[i], 4, angle[i], color[i]); // рисуем квадрат
break;
case 41:
XXXXXZXZdrawStarF(aimX[i], aimY[i], 2 * XSradius[i], XSradius[i], starPoints[i], angle[i], color[i]); // рисуем звезду
break;
case 42:
ZXXXZSdrawCircleF(aimX[i], aimY[i],1.3*XSradius[i],color[i] ); // рисуем круг
break;
case 43:
XXXXXXZXZdrawStarF(aimX[i], aimY[i], 1.3 * XSradius[i], XSradius[i], 4, angle[i], color[i]); // рисуем квадрат
break;
case 44:
XXXXXXZXZdrawStarF(aimX[i], aimY[i], 2 * XSradius[i], XSradius[i], starPoints[i], angle[i], color[i]); // рисуем звезду
break;
case 45:
ZZSdrawCircleF(aimX[i], aimY[i],1.3*XSradius[i],color[i] ); // рисуем круг
break;
case 46:
XXXXXXXZXZdrawStarF(aimX[i], aimY[i], 1.3 * XSradius[i], XSradius[i], 4, angle[i], color[i]); // рисуем квадрат
break;
case 47:
XXXXXXXZXZdrawStarF(aimX[i], aimY[i], 2 * XSradius[i], XSradius[i], starPoints[i], angle[i], color[i]); // рисуем звезду
break;
}
}
if (XSradius[i] > Smax) ZZaimChange(i++);
}
//delay(16); //fps ~= 60
fadeToBlackBy(leds, NUM_LEDS, 30);
}
#define SECONDS_PER_PALETTE 2
#define GSECONDS_PER_PALETTE 1
void ColorWave()
{
EVERY_N_MILLISECONDS(50) {
//nblendPaletteTowardPalette( gCurrentPalette, gTargetPalette, 16);
nblendPaletteTowardPalette( gCurrentPalette, gTargetPalette, 255);
}
EVERY_N_SECONDS( SECONDS_PER_PALETTE ) {
gCurrentPaletteNumber = random8 (gGradientPaletteCount);
gTargetPalette = paletteArr[ gCurrentPaletteNumber ];
}
Plamya( leds, NUM_LEDS, gCurrentPalette);
}
void ColorWave_Z() //Zvezda
{
EVERY_N_MILLISECONDS(10) {
//nblendPaletteTowardPalette( gCurrentPalette, gTargetPalette, 16);
nblendPaletteTowardPalette( gCurrentPalette, GgTargetPalette, 255);
}
EVERY_N_SECONDS( GSECONDS_PER_PALETTE ) {
gCurrentPaletteNumber = random8 (gGradientPaletteCount);
GgTargetPalette = paletteArr[ gCurrentPaletteNumber ];
}
Zvezda ();
}
void setup()
{
FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS).setDither(BRIGHTNESS < 255); // cpt-city palettes have different color balance
FastLED.setBrightness(BRIGHTNESS);
currentPalette = RainbowColors_p;
randomSeed(analogRead(A0));
}
void loop()
{
LEDS.show();
ColorWave_Z();
//ColorWave();
//FastLED.show();
//FastLED.delay(20);
}
uint16_t XY (uint8_t x, uint8_t y) { return (y * LED_COLS + x);}