mirror of
https://gitlab.com/zwirbel/illucat.git
synced 2025-12-14 17:35:22 +01:00
64 lines
1.9 KiB
C++
64 lines
1.9 KiB
C++
#ifndef __NEOPATTERN_API_MODES__
|
|
#define __NEOPATTERN_API_MODES__
|
|
|
|
#include "NeoPattern.cpp"
|
|
|
|
enum PIXEL_MODE { PIXELS_OFF = 0, COLOR_WHEEL_MODE = 1, COLOR_MODE = 2, PATTERN_MODE = 3};
|
|
typedef void (*PIXEL_FP)(NeoPattern*, const char *);
|
|
|
|
/*
|
|
Array of function pointers to be used as lookup table using the int values of PIXEL_MODE.
|
|
TODO header file + separate functions instead of lambdas
|
|
*/
|
|
const PIXEL_FP PIXEL_FNCS[] = {
|
|
/*
|
|
PIXESL_OFF
|
|
Sets all pixels to black.
|
|
*/
|
|
[](NeoPattern* pixels, const char *color){
|
|
pixels->clear();
|
|
pixels->ColorSet(0);
|
|
},
|
|
/*
|
|
COLOR_WHEEL_MODE
|
|
Input: integer color from 0 to 155
|
|
Uses the color wheel to set a color.
|
|
If given integer is <= 1, set the color to black.
|
|
By using this function, Color1 and Color2 is set on the pixels;
|
|
Color1 = new color, Color2 = last color.
|
|
*/
|
|
[](NeoPattern* pixels, const char *color){
|
|
int c1 = atoi(color);
|
|
int c2 = pixels->Color1;
|
|
pixels->Color1 = c1;
|
|
pixels->Color2 = c2;
|
|
pixels->ActivePattern = NONE;
|
|
if(c1 <= 1) {
|
|
pixels->ColorSet(0);
|
|
return;
|
|
}
|
|
pixels->ColorSet(pixels->Wheel(c1));
|
|
},
|
|
/*
|
|
COLOR_MODE
|
|
sets the color from an rgb int
|
|
*/
|
|
[](NeoPattern* pixels, const char *color){
|
|
pixels->ActivePattern = NONE;
|
|
pixels->ColorSet(atoi(color));
|
|
},
|
|
/*
|
|
PATTERN_MODE
|
|
Input: id of the pattern
|
|
Sets the active pattern on the strip.
|
|
As every pattern has another API, all fields need to be set before, for example by using COLOR_WHEEL_MODE.
|
|
*/
|
|
[](NeoPattern* pixels, const char *id){
|
|
pattern p = (pattern)atoi(id);
|
|
pixels->Interval = 50;
|
|
pixels->TotalSteps = pixels->numPixels();
|
|
pixels->ActivePattern = p;
|
|
}
|
|
};
|
|
|
|
#endif |