Changed MatrixEffect to use color palettes.

This commit is contained in:
Fabian Schlenz 2019-06-04 05:55:24 +02:00
parent b2bc8aa75e
commit 46062945ff
4 changed files with 26 additions and 7 deletions

View File

@ -5,6 +5,7 @@
#include "Effect.h" #include "Effect.h"
#include "config.h" #include "config.h"
#include "my_fastled.h" #include "my_fastled.h"
#include "my_color_palettes.h"
class MatrixEffectColumn { class MatrixEffectColumn {
private: private:

View File

@ -0,0 +1,8 @@
#pragma once
#include "my_fastled.h"
//CRGBPalette16 palette_fire;
//CRGBPalette16 palette_matrix;
extern const TProgmemRGBGradientPalette_byte palette_fire[] FL_PROGMEM;
extern const TProgmemRGBGradientPalette_byte palette_matrix[] FL_PROGMEM;

12
src/color_palettes.cpp Normal file
View File

@ -0,0 +1,12 @@
#include "my_color_palettes.h"
__attribute__ ((aligned(4))) extern const TProgmemRGBGradientPalette_byte palette_fire[] FL_PROGMEM = {
0, 0, 0, 0, //black
128, 255, 0, 0, //red
224, 255,255, 0, //bright yellow
255, 255,255,255 }; //full white
__attribute__ ((aligned(4))) extern const TProgmemRGBGradientPalette_byte palette_matrix[] FL_PROGMEM = {
0, 0, 0, 0, // black
200, 0,255, 0, // green
255, 255,255,255 }; // white

View File

@ -1,9 +1,11 @@
#include "effect_matrix.h" #include "effect_matrix.h"
#include "my_color_palettes.h"
#include "functions.h" #include "functions.h"
MatrixEffectColumn::MatrixEffectColumn() { } MatrixEffectColumn::MatrixEffectColumn() {
}
MatrixEffectColumn::MatrixEffectColumn(Window* win, int xPos) { MatrixEffectColumn::MatrixEffectColumn(Window* win, int xPos) : MatrixEffectColumn() {
window = win; window = win;
x = xPos; x = xPos;
start(); start();
@ -24,11 +26,7 @@ void MatrixEffectColumn::advance() {
void MatrixEffectColumn::draw() { void MatrixEffectColumn::draw() {
for(int i=0; i<length; i++) { for(int i=0; i<length; i++) {
CRGB color; setPixel(*window, x, y-i, ColorFromPalette((CRGBPalette16)palette_matrix, 255 * (length - i) / length));
if (i==0) color=CHSV(85, 0, 192);
else color=CHSV(85, 255, 255/(length-1)*(length-i));
setPixel(*window, x, y-i, color);
} }
} }