Changed MatrixEffect to use color palettes.
This commit is contained in:
parent
b2bc8aa75e
commit
46062945ff
@ -5,6 +5,7 @@
|
||||
#include "Effect.h"
|
||||
#include "config.h"
|
||||
#include "my_fastled.h"
|
||||
#include "my_color_palettes.h"
|
||||
|
||||
class MatrixEffectColumn {
|
||||
private:
|
||||
|
8
include/my_color_palettes.h
Normal file
8
include/my_color_palettes.h
Normal 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
12
src/color_palettes.cpp
Normal 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
|
@ -1,9 +1,11 @@
|
||||
#include "effect_matrix.h"
|
||||
#include "my_color_palettes.h"
|
||||
#include "functions.h"
|
||||
|
||||
MatrixEffectColumn::MatrixEffectColumn() { }
|
||||
MatrixEffectColumn::MatrixEffectColumn() {
|
||||
}
|
||||
|
||||
MatrixEffectColumn::MatrixEffectColumn(Window* win, int xPos) {
|
||||
MatrixEffectColumn::MatrixEffectColumn(Window* win, int xPos) : MatrixEffectColumn() {
|
||||
window = win;
|
||||
x = xPos;
|
||||
start();
|
||||
@ -24,11 +26,7 @@ void MatrixEffectColumn::advance() {
|
||||
|
||||
void MatrixEffectColumn::draw() {
|
||||
for(int i=0; i<length; i++) {
|
||||
CRGB color;
|
||||
if (i==0) color=CHSV(85, 0, 192);
|
||||
else color=CHSV(85, 255, 255/(length-1)*(length-i));
|
||||
|
||||
setPixel(*window, x, y-i, color);
|
||||
setPixel(*window, x, y-i, ColorFromPalette((CRGBPalette16)palette_matrix, 255 * (length - i) / length));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user