Unloading at effect end
This commit is contained in:
parent
148de04e6f
commit
a84e242a37
@ -42,6 +42,7 @@ uint16_t WS2812FX::mode_static(void) {
|
|||||||
* Custom mode. Executes WebAssembly fx() function
|
* Custom mode. Executes WebAssembly fx() function
|
||||||
*/
|
*/
|
||||||
uint16_t WS2812FX::mode_custom(void) {
|
uint16_t WS2812FX::mode_custom(void) {
|
||||||
|
if (SEGENV.call == 0) wasmfx.init();
|
||||||
wasmfx.run();
|
wasmfx.run();
|
||||||
return FRAMETIME;
|
return FRAMETIME;
|
||||||
}
|
}
|
||||||
|
@ -386,6 +386,10 @@ class WS2812FX {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isResetRequired() {
|
||||||
|
return _requiresReset;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flags that before the next effect is calculated,
|
* Flags that before the next effect is calculated,
|
||||||
* the internal segment state should be reset.
|
* the internal segment state should be reset.
|
||||||
@ -630,8 +634,7 @@ class WS2812FX {
|
|||||||
setPixelColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b, uint8_t w = 0),
|
setPixelColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b, uint8_t w = 0),
|
||||||
show(void),
|
show(void),
|
||||||
setColorOrder(uint8_t co),
|
setColorOrder(uint8_t co),
|
||||||
setPixelSegment(uint8_t n),
|
setPixelSegment(uint8_t n);
|
||||||
initWasm(void);
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
isRgbw = false,
|
isRgbw = false,
|
||||||
|
@ -144,6 +144,7 @@ void WS2812FX::service() {
|
|||||||
|
|
||||||
// reset the segment runtime data if needed, called before isActive to ensure deleted
|
// reset the segment runtime data if needed, called before isActive to ensure deleted
|
||||||
// segment's buffers are cleared
|
// segment's buffers are cleared
|
||||||
|
if (SEGENV.isResetRequired()) wasmfx.end();
|
||||||
SEGENV.resetIfRequired();
|
SEGENV.resetIfRequired();
|
||||||
|
|
||||||
if (!SEGMENT.isActive()) continue;
|
if (!SEGMENT.isActive()) continue;
|
||||||
@ -1085,8 +1086,4 @@ uint32_t WS2812FX::gamma32(uint32_t color)
|
|||||||
return ((w << 24) | (r << 16) | (g << 8) | (b));
|
return ((w << 24) | (r << 16) | (g << 8) | (b));
|
||||||
}
|
}
|
||||||
|
|
||||||
void WS2812FX::initWasm() {
|
|
||||||
wasmfx.init();
|
|
||||||
}
|
|
||||||
|
|
||||||
WS2812FX* WS2812FX::instance = nullptr;
|
WS2812FX* WS2812FX::instance = nullptr;
|
@ -252,6 +252,7 @@ void userLoop();
|
|||||||
//wasm.cpp
|
//wasm.cpp
|
||||||
void wasmInit();
|
void wasmInit();
|
||||||
void wasmRun();
|
void wasmRun();
|
||||||
|
void wasmEnd();
|
||||||
|
|
||||||
class WASMFX {
|
class WASMFX {
|
||||||
public:
|
public:
|
||||||
@ -263,6 +264,10 @@ class WASMFX {
|
|||||||
wasmRun();
|
wasmRun();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void end() {
|
||||||
|
wasmEnd();
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t now();
|
uint32_t now();
|
||||||
uint32_t speed();
|
uint32_t speed();
|
||||||
uint32_t intensity();
|
uint32_t intensity();
|
||||||
|
@ -222,10 +222,6 @@ void wasm_task(void*)
|
|||||||
if (result) FATAL("Func", result);
|
if (result) FATAL("Func", result);
|
||||||
|
|
||||||
Serial.println(F("WASM init success!"));
|
Serial.println(F("WASM init success!"));
|
||||||
|
|
||||||
// Should not arrive here
|
|
||||||
|
|
||||||
//while (true) {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wasmInit()
|
void wasmInit()
|
||||||
@ -266,5 +262,11 @@ void wasmRun() {
|
|||||||
Serial.print(":");
|
Serial.print(":");
|
||||||
Serial.println(info.line);
|
Serial.println(info.line);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wasmEnd() {
|
||||||
|
if (module) m3_FreeModule(module); module = nullptr;
|
||||||
|
if (runtime) m3_FreeRuntime(runtime); runtime = nullptr;
|
||||||
|
if (env) m3_FreeEnvironment(env); env = nullptr;
|
||||||
}
|
}
|
@ -313,7 +313,6 @@ void WLED::setup()
|
|||||||
if (!pinManager.isPinAllocated(STATUSLED)) pinMode(STATUSLED, OUTPUT);
|
if (!pinManager.isPinAllocated(STATUSLED)) pinMode(STATUSLED, OUTPUT);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wasmfx.init();
|
|
||||||
DEBUG_PRINTLN(F("Initializing strip"));
|
DEBUG_PRINTLN(F("Initializing strip"));
|
||||||
beginStrip();
|
beginStrip();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user