#include <FastLED.h>
#include "FlameGEN.h"
#define PIECES_COUNT 9
#define LED_COUNT (2+4+6+8+8+8+8+2+2)
// pieces config (offset,length)
const uint8_t pieces[PIECES_COUNT][2] =
{
{0 * MAT_W + 3, 2},
{1 * MAT_W + 2, 4},
{2 * MAT_W + 1, 6},
{3 * MAT_W + 0, 8},
{4 * MAT_W + 0, 8},
{5 * MAT_W + 0, 8},
{6 * MAT_W + 0, 8},
{7 * MAT_W + 1, 2},
{7 * MAT_W + 5, 2},
};
CRGB matrix_heart[LED_COUNT];
void convertToHeart(CRGB mx[], CRGB mxhrt[]) {
int t = 0;
for (int i = 0; i < PIECES_COUNT; i++) {
for (int j = 0; j < pieces[i][1]; j++) {
mxhrt[t++] = mx[pieces[i][0] + j];
}
}
}
void setup() {
FastLED.addLeds<MAT_TYPE, MAT_PIN>(matrix, (MAT_H * MAT_W ));
FastLED.addLeds<MAT_TYPE, 9>(matrix_heart, LED_COUNT);
FastLED.setBrightness(BRIGHT);
FastLED.clear();
FastLED.show();
for ( uint16_t i = 0; i < rows; ++i ) {
for ( uint16_t j = 0; j < cols; ++j ) {
if ( i == 0 ) pix[i][j] = NCOLORS - 1;
else pix[i][j] = 0;
}
}
#ifdef SERIAL
Serial.begin(115200); while (!Serial);
Serial.print("Pin "); Serial.print(MAT_PIN);
Serial.print(", brightness "); Serial.print(BRIGHT);
Serial.print(", FPS "); Serial.println(FPS);
#endif
#ifdef DISPLAY_TEST
FastLED.clear();
for ( uint16_t i = 0; i < cols; ++i ) {
for (uint16_t j = 0; j < rows; ++j) {
matrix[pos(i, j)] = colors[NCOLORS - 1];
}
convertToHeart(matrix, matrix_heart);
FastLED.show();
delay(1000 / FPS);
for (uint16_t j = 0; j < rows; ++j) {
matrix[pos(i, j)] = 0;
}
}
for ( uint16_t i = 0; i < rows; ++i ) {
for (uint16_t j = 0; j < cols; ++j) {
matrix[pos(j, i)] = colors[NCOLORS - 1];
}
convertToHeart(matrix, matrix_heart);
FastLED.show();
delay(1000 / FPS);
for (uint16_t j = 0; j < cols; ++j) {
matrix[pos(j, i)] = 0;
}
}
/** Show the color map briefly at the extents of the display. This "demo"
is meant to help establish correct origin, extents, colors, and
brightness. You can cut or comment this out if you don't need it;
it's not important to functionality otherwise.
*/
uint16_t y = 0;
FastLED.clear();
for ( int i = NCOLORS - 1; i >= 0; --i ) {
if ( y < rows ) {
for (uint16_t j = 0; j < cols; ++j) {
matrix[pos(j, y)] = colors[i];
}
y++;
}
else break;
}
convertToHeart(matrix, matrix_heart);
FastLED.show();
delay(2000);
#endif
FastLED.clear();
FastLED.show();
analogReference(INTERNAL); // 1.1V
}
void loop() {
uint16_t i, j;
make_fire();
// Set and draw
// И это переделать нахуй
for ( i = 0; i < rows; ++i ) {
for ( j = 0; j < cols; ++j ) {
matrix[pos(j, i)] = colors[pix[i][j]];
}
}
convertToHeart(matrix, matrix_heart);
FastLED.show();
int v=analogRead(A0);
// Serial.println(v);
delay(10);
}