Add CustomEffects as usermod: step 3: effects start working
This commit is contained in:
@@ -88,55 +88,19 @@ enum Externals
|
|||||||
};
|
};
|
||||||
|
|
||||||
#if ARTI_PLATFORM != ARTI_ARDUINO
|
#if ARTI_PLATFORM != ARTI_ARDUINO
|
||||||
class WS2812FX {
|
|
||||||
public:
|
|
||||||
uint16_t matrixWidth = 16, matrixHeight = 16;
|
|
||||||
|
|
||||||
uint16_t XY(uint16_t x, uint16_t y)
|
|
||||||
{
|
|
||||||
return x%matrixWidth + y%matrixHeight * matrixWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t millis()
|
|
||||||
{
|
|
||||||
return 1000; // no millis defined for non embedded yet
|
|
||||||
}
|
|
||||||
|
|
||||||
float arti_external_function(uint8_t function, float par1 = floatNull, float par2 = floatNull, float par3 = floatNull, float par4 = floatNull, float par5 = floatNull);
|
|
||||||
float arti_get_external_variable(uint8_t variable, float par1 = floatNull, float par2 = floatNull, float par3 = floatNull);
|
|
||||||
void arti_set_external_variable(float value, uint8_t variable, float par1 = floatNull, float par2 = floatNull, float par3 = floatNull);
|
|
||||||
}; //class WS2812FX
|
|
||||||
|
|
||||||
WS2812FX strip = WS2812FX();
|
|
||||||
|
|
||||||
#define PI 3.141592654
|
#define PI 3.141592654
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
float ARTI::arti_external_function(uint8_t function, float par1, float par2, float par3, float par4, float par5)
|
float ARTI::arti_external_function(uint8_t function, float par1, float par2, float par3, float par4, float par5)
|
||||||
{
|
{
|
||||||
return strip.arti_external_function(function, par1, par2, par3, par4, par5);
|
|
||||||
}
|
|
||||||
|
|
||||||
float ARTI::arti_get_external_variable(uint8_t variable, float par1, float par2, float par3)
|
|
||||||
{
|
|
||||||
return strip.arti_get_external_variable(variable, par1, par2, par3);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ARTI::arti_set_external_variable(float value, uint8_t variable, float par1, float par2, float par3)
|
|
||||||
{
|
|
||||||
strip.arti_set_external_variable(value, variable, par1, par2, par3);
|
|
||||||
}
|
|
||||||
|
|
||||||
float WS2812FX::arti_external_function(uint8_t function, float par1, float par2, float par3, float par4, float par5) {
|
|
||||||
// MEMORY_ARTI("fun %d(%f, %f, %f)\n", function, par1, par2, par3);
|
// MEMORY_ARTI("fun %d(%f, %f, %f)\n", function, par1, par2, par3);
|
||||||
#if ARTI_PLATFORM == ARTI_ARDUINO
|
#if ARTI_PLATFORM == ARTI_ARDUINO
|
||||||
switch (function) {
|
switch (function) {
|
||||||
case F_setPixelColor: {
|
case F_setPixelColor: {
|
||||||
if (par3 == floatNull)
|
if (par3 == floatNull)
|
||||||
setPixelColor(((uint16_t)par1)%SEGLEN, (uint32_t)par2);
|
SEGMENT.setPixelColor(((uint16_t)par1)%SEGLEN, (uint32_t)par2);
|
||||||
else
|
else
|
||||||
setPixelColorXY((uint16_t)par1, (uint16_t)par2, (uint32_t)par3);
|
SEGMENT.setPixelColorXY((uint16_t)par1, (uint16_t)par2, (uint32_t)par3);
|
||||||
return floatNull;
|
return floatNull;
|
||||||
}
|
}
|
||||||
case F_setPixels:
|
case F_setPixels:
|
||||||
@@ -144,18 +108,18 @@ float WS2812FX::arti_external_function(uint8_t function, float par1, float par2,
|
|||||||
return floatNull;
|
return floatNull;
|
||||||
case F_hsv:
|
case F_hsv:
|
||||||
{
|
{
|
||||||
CRGB color = CHSV(par1, par2, par3);
|
CRGB color = CHSV((uint8_t)par1, (uint8_t)par2, (uint8_t)par3);
|
||||||
return RGBW32(color.r, color.g, color.b, 0);
|
return RGBW32(color.r, color.g, color.b, 0);
|
||||||
}
|
}
|
||||||
case F_rgbw:
|
case F_rgbw:
|
||||||
return RGBW32(par1, par2, par3, par4);
|
return RGBW32((uint8_t)par1, (uint8_t)par2, (uint8_t)par3, (uint8_t)par4);
|
||||||
|
|
||||||
case F_setRange: {
|
case F_setRange: {
|
||||||
setRange((uint16_t)par1, (uint16_t)par2, (uint32_t)par3);
|
strip.setRange((uint16_t)par1, (uint16_t)par2, (uint32_t)par3);
|
||||||
return floatNull;
|
return floatNull;
|
||||||
}
|
}
|
||||||
case F_fill: {
|
case F_fill: {
|
||||||
fill((uint32_t)par1);
|
SEGMENT.fill((uint32_t)par1);
|
||||||
return floatNull;
|
return floatNull;
|
||||||
}
|
}
|
||||||
case F_colorBlend:
|
case F_colorBlend:
|
||||||
@@ -164,7 +128,11 @@ float WS2812FX::arti_external_function(uint8_t function, float par1, float par2,
|
|||||||
return SEGMENT.color_wheel((uint8_t)par1);
|
return SEGMENT.color_wheel((uint8_t)par1);
|
||||||
case F_colorFromPalette:
|
case F_colorFromPalette:
|
||||||
{
|
{
|
||||||
CRGB color = ColorFromPalette(SEGPALETTE, (uint8_t)par1, (uint8_t)par2, LINEARBLEND);
|
CRGB color;
|
||||||
|
if (par2 == floatNull)
|
||||||
|
color = ColorFromPalette(SEGPALETTE, (uint8_t)par1);
|
||||||
|
else
|
||||||
|
color = ColorFromPalette(SEGPALETTE, (uint8_t)par1, (uint8_t)par2); //brightness
|
||||||
return RGBW32(color.r, color.g, color.b, 0);
|
return RGBW32(color.r, color.g, color.b, 0);
|
||||||
}
|
}
|
||||||
case F_beatSin:
|
case F_beatSin:
|
||||||
@@ -182,12 +150,12 @@ float WS2812FX::arti_external_function(uint8_t function, float par1, float par2,
|
|||||||
return SEGCOLOR((uint8_t)par1);
|
return SEGCOLOR((uint8_t)par1);
|
||||||
|
|
||||||
case F_shift: {
|
case F_shift: {
|
||||||
uint32_t saveFirstPixel = getPixelColor(0);
|
uint32_t saveFirstPixel = SEGMENT.getPixelColor(0);
|
||||||
for (uint16_t i=0; i<SEGLEN-1; i++)
|
for (uint16_t i=0; i<SEGLEN-1; i++)
|
||||||
{
|
{
|
||||||
setPixelColor(i, getPixelColor((uint16_t)(i + par1)%SEGLEN));
|
SEGMENT.setPixelColor(i, SEGMENT.getPixelColor((uint16_t)(i + par1)%SEGLEN));
|
||||||
}
|
}
|
||||||
setPixelColor(SEGLEN - 1, saveFirstPixel);
|
SEGMENT.setPixelColor(SEGLEN - 1, saveFirstPixel);
|
||||||
return floatNull;
|
return floatNull;
|
||||||
}
|
}
|
||||||
case F_circle2D: {
|
case F_circle2D: {
|
||||||
@@ -341,7 +309,8 @@ float WS2812FX::arti_external_function(uint8_t function, float par1, float par2,
|
|||||||
return function;
|
return function;
|
||||||
}
|
}
|
||||||
|
|
||||||
float WS2812FX::arti_get_external_variable(uint8_t variable, float par1, float par2, float par3) {
|
float ARTI::arti_get_external_variable(uint8_t variable, float par1, float par2, float par3)
|
||||||
|
{
|
||||||
// MEMORY_ARTI("get %d(%f, %f, %f)\n", variable, par1, par2, par3);
|
// MEMORY_ARTI("get %d(%f, %f, %f)\n", variable, par1, par2, par3);
|
||||||
#if ARTI_PLATFORM == ARTI_ARDUINO
|
#if ARTI_PLATFORM == ARTI_ARDUINO
|
||||||
switch (variable)
|
switch (variable)
|
||||||
@@ -442,9 +411,8 @@ float WS2812FX::arti_get_external_variable(uint8_t variable, float par1, float p
|
|||||||
return variable;
|
return variable;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ledsSet; //check if leds is set
|
void ARTI::arti_set_external_variable(float value, uint8_t variable, float par1, float par2, float par3)
|
||||||
|
{
|
||||||
void WS2812FX::arti_set_external_variable(float value, uint8_t variable, float par1, float par2, float par3) {
|
|
||||||
#if ARTI_PLATFORM == ARTI_ARDUINO
|
#if ARTI_PLATFORM == ARTI_ARDUINO
|
||||||
// MEMORY_ARTI("%s %s %u %u (%u)\n", spaces+50-depth, variable_name, par1, par2, esp_get_free_heap_size());
|
// MEMORY_ARTI("%s %s %u %u (%u)\n", spaces+50-depth, variable_name, par1, par2, esp_get_free_heap_size());
|
||||||
switch (variable)
|
switch (variable)
|
||||||
@@ -460,7 +428,6 @@ void WS2812FX::arti_set_external_variable(float value, uint8_t variable, float p
|
|||||||
else
|
else
|
||||||
SEGMENT.setPixelColorXY((uint16_t)par1%SEGMENT.virtualWidth(), (uint16_t)par2%SEGMENT.virtualHeight(), value); //2D value!!
|
SEGMENT.setPixelColorXY((uint16_t)par1%SEGMENT.virtualWidth(), (uint16_t)par2%SEGMENT.virtualHeight(), value); //2D value!!
|
||||||
|
|
||||||
ledsSet = true;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -477,14 +444,13 @@ void WS2812FX::arti_set_external_variable(float value, uint8_t variable, float p
|
|||||||
else
|
else
|
||||||
RUNLOG_ARTI("arti_set_external_variable: leds(%f, %f) := %f\n", par1, par2, value);
|
RUNLOG_ARTI("arti_set_external_variable: leds(%f, %f) := %f\n", par1, par2, value);
|
||||||
|
|
||||||
ledsSet = true;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ERROR_ARTI("Error: arti_set_external_variable: %u not implemented\n", variable);
|
ERROR_ARTI("Error: arti_set_external_variable: %u not implemented\n", variable);
|
||||||
errorOccurred = true;
|
errorOccurred = true;
|
||||||
} //arti_set_external_variable
|
}
|
||||||
|
|
||||||
bool ARTI::loop()
|
bool ARTI::loop()
|
||||||
{
|
{
|
||||||
@@ -505,8 +471,6 @@ bool ARTI::loop()
|
|||||||
const char * function_name = "renderFrame";
|
const char * function_name = "renderFrame";
|
||||||
Symbol* function_symbol = global_scope->lookup(function_name);
|
Symbol* function_symbol = global_scope->lookup(function_name);
|
||||||
|
|
||||||
ledsSet = false;
|
|
||||||
|
|
||||||
if (function_symbol != nullptr) { //calling undefined function: pre-defined functions e.g. print
|
if (function_symbol != nullptr) { //calling undefined function: pre-defined functions e.g. print
|
||||||
|
|
||||||
foundRenderFunction = true;
|
foundRenderFunction = true;
|
||||||
@@ -553,14 +517,6 @@ bool ARTI::loop()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if leds has been set during interpret(renderLed)
|
|
||||||
if (ledsSet) {
|
|
||||||
// Serial.println("ledsSet");
|
|
||||||
arti_external_function(F_setPixels);
|
|
||||||
}
|
|
||||||
// else
|
|
||||||
// Serial.println("not ledsSet");
|
|
||||||
|
|
||||||
if (!foundRenderFunction)
|
if (!foundRenderFunction)
|
||||||
{
|
{
|
||||||
ERROR_ARTI("%s renderFrame or renderLed not found\n", spaces+50-depth);
|
ERROR_ARTI("%s renderFrame or renderLed not found\n", spaces+50-depth);
|
||||||
@@ -582,9 +538,3 @@ bool ARTI::loop()
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
} // loop
|
} // loop
|
||||||
|
|
||||||
#if ARTI_PLATFORM == ARTI_ARDUINO
|
|
||||||
|
|
||||||
ARTI * arti;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -56,6 +56,21 @@ function loadLogFile(name, attempt) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function uploadFileWithText(name, text)
|
||||||
|
{
|
||||||
|
var req = new XMLHttpRequest();
|
||||||
|
req.addEventListener('load', function(){showToast(this.responseText,this.status >= 400)});
|
||||||
|
req.addEventListener('error', function(e){showToast(e.stack,true);});
|
||||||
|
req.open("POST", "/upload");
|
||||||
|
var formData = new FormData();
|
||||||
|
|
||||||
|
var blob = new Blob([text], {type : 'application/text'});
|
||||||
|
var fileOfBlob = new File([blob], name);
|
||||||
|
formData.append("upload", fileOfBlob);
|
||||||
|
|
||||||
|
req.send(formData);
|
||||||
|
}
|
||||||
|
|
||||||
function saveCE(name, segID) {
|
function saveCE(name, segID) {
|
||||||
showToast("Saving " + name);
|
showToast("Saving " + name);
|
||||||
|
|
||||||
|
|||||||
@@ -2,12 +2,11 @@
|
|||||||
|
|
||||||
#include "wled.h"
|
#include "wled.h"
|
||||||
|
|
||||||
#include "arti.h"
|
|
||||||
#include "arti_wled.h"
|
#include "arti_wled.h"
|
||||||
|
|
||||||
//declare weathermod global variables (always precede with weather_ (psuedo class static variables)
|
//declare weathermod global variables (always precede with weather_ (psuedo class static variables)
|
||||||
static uint32_t usermods_pushLoop = 0; //effect pushes loop to execute. might be interesting for audioreactive too
|
static uint32_t usermods_pushLoop = 0; //effect pushes loop to execute. might be interesting for audioreactive too
|
||||||
|
ARTI * arti;
|
||||||
|
|
||||||
//effect function
|
//effect function
|
||||||
uint16_t mode_customEffect(void) {
|
uint16_t mode_customEffect(void) {
|
||||||
|
|||||||
@@ -634,8 +634,6 @@ typedef struct Segment {
|
|||||||
} segment;
|
} segment;
|
||||||
//static int segSize = sizeof(Segment);
|
//static int segSize = sizeof(Segment);
|
||||||
|
|
||||||
#define floatNull -32768 //WLEDSR Custom Effects
|
|
||||||
|
|
||||||
// main "strip" class
|
// main "strip" class
|
||||||
class WS2812FX { // 96 bytes
|
class WS2812FX { // 96 bytes
|
||||||
typedef uint16_t (*mode_ptr)(void); // pointer to mode function
|
typedef uint16_t (*mode_ptr)(void); // pointer to mode function
|
||||||
@@ -900,12 +898,6 @@ class WS2812FX { // 96 bytes
|
|||||||
|
|
||||||
void
|
void
|
||||||
estimateCurrentAndLimitBri(void);
|
estimateCurrentAndLimitBri(void);
|
||||||
|
|
||||||
public:
|
|
||||||
//WLEDSR Custom Effects
|
|
||||||
float arti_external_function(uint8_t function, float par1 = floatNull, float par2 = floatNull, float par3 = floatNull, float par4 = floatNull, float par5 = floatNull);
|
|
||||||
float arti_get_external_variable(uint8_t variable, float par1 = floatNull, float par2 = floatNull, float par3 = floatNull);
|
|
||||||
void arti_set_external_variable(float value, uint8_t variable, float par1 = floatNull, float par2 = floatNull, float par3 = floatNull);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const char JSON_mode_names[];
|
extern const char JSON_mode_names[];
|
||||||
|
|||||||
@@ -684,11 +684,7 @@ function populateSegments(s)
|
|||||||
let li = lastinfo;
|
let li = lastinfo;
|
||||||
segCount = 0; lowestUnused = 0; lSeg = 0;
|
segCount = 0; lowestUnused = 0; lSeg = 0;
|
||||||
|
|
||||||
console.log(s);
|
|
||||||
|
|
||||||
for (var inst of (s.seg||[])) {
|
for (var inst of (s.seg||[])) {
|
||||||
console.log(inst);
|
|
||||||
|
|
||||||
segCount++;
|
segCount++;
|
||||||
|
|
||||||
let i = parseInt(inst.id);
|
let i = parseInt(inst.id);
|
||||||
|
|||||||
3870
wled00/html_ui.h
3870
wled00/html_ui.h
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user