feat: ESP-NOW link, beat sync and control messages in the C++ driver
- espnow_link, ctrl_msg and beat_sync: the reliable link, envelopes and beat-synced timing. - ctrl_msg: accept an envelope with the trailing save byte. - patterns_frame() and espnow_link_poll() split out of their tasks, so the WebAssembly simulator can drive one frame and one link pass from a timer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
94e300f6ad
commit
24dd5ffb15
30 files changed
+2159
-158
No files matched your search
@@ -8,6 +8,7 @@
|
||||
#include <cstring>
|
||||
|
||||
#include "esp_random.h"
|
||||
#include "beat_sync.h"
|
||||
#include "effects.h"
|
||||
|
||||
int clampi(int v, int lo, int hi)
|
||||
@@ -57,9 +58,9 @@ rgb mix(rgb a, rgb b, int k)
|
||||
return o;
|
||||
}
|
||||
|
||||
int sgn(const fx_t &f, int v)
|
||||
int sgn(const fx_t &, int v)
|
||||
{
|
||||
return f.pr->reverse ? -v : v;
|
||||
return v; // reverse mirrors the strip only (led_at), it does not change direction
|
||||
}
|
||||
|
||||
int led_at(const fx_t &f, int i)
|
||||
@@ -95,13 +96,11 @@ bool due(uint32_t now, uint32_t &last, uint32_t d)
|
||||
return false;
|
||||
}
|
||||
|
||||
// The beat is 500 ms here (there is no beat source on this board)
|
||||
uint32_t dur(const fx_t &f, int v)
|
||||
// A preset's timing is always milliseconds. Beats belong to sequences and animations, which the
|
||||
// controller plays, so a preset never follows the tempo.
|
||||
uint32_t dur(const fx_t &, int v)
|
||||
{
|
||||
if (v < 0) {
|
||||
v = 0;
|
||||
}
|
||||
return f.pr->beat_time ? (uint32_t)(v * 500 / 4) : (uint32_t)v;
|
||||
return v < 0 ? 0 : (uint32_t)v;
|
||||
}
|
||||
|
||||
int get_colours(const fx_t &f, const rgb *def, int ndef, rgb *out)
|
||||
|
||||
Reference in new issue
Block a user