14 uint32_t X = (uint32_t)
x << Q;
15 uint32_t
y = (1u << Q);
18 for (
int i = 0; i < 4; i++) {
19 y = (
y + (X /
y)) >> 1;
21 return static_cast<int16_t
>(
y) >> 8;
82 int32_t pt =
mSim->geti16(xx, yy);
111 int16_t *prev, int16_t *diff)
const {
116 *diff = *curr - *prev;
121 return static_cast<int8_t
>(
geti16(
x,
y) >> 8);
126 if (
mSim->getHalfDuplex()) {
127 uint16_t v2 =
static_cast<uint16_t
>(value);
130 return half_duplex_blend_linear(v2);
132 return half_duplex_blend_sqrt_q15(v2);
135 return static_cast<uint8_t
>(((
static_cast<uint16_t
>(value) + 32768)) >> 8);
152 int dx =
static_cast<int>(i) - rad;
153 int dy =
static_cast<int>(j) - rad;
155 if (
ABS(dx) +
ABS(dy) > rad) {
160 if (
mSim->has(xx, yy)) {
166 const bool sign_matches = (pt >= 0) == (v16 >= 0);
173 uint16_t abs_pt =
static_cast<uint16_t
>(
ABS(pt));
174 uint16_t abs_v16 =
static_cast<uint16_t
>(
ABS(v16));
175 if (abs_v16 > abs_pt) {
202 for (uint32_t
x = 0;
x < w; ++
x) {
203 for (uint32_t
y = 0;
y < h; ++
y) {
280 int16_t *diff)
const {
285 *diff = *curr - *prev;
290 return static_cast<int8_t
>(
geti16(
x) >> 8);
310 if (
mSim->getHalfDuplex()) {
311 uint16_t v2 =
static_cast<uint16_t
>(value);
314 return half_duplex_blend_linear(v2);
316 return half_duplex_blend_sqrt_q15(v2);
319 return static_cast<uint8_t
>(((
static_cast<uint16_t
>(value) + 32768)) >> 8);
UISlider speed("Speed", 1.0f, -20.0f, 20.0f, 0.01f)
UISlider dampening("Dampening", 6.0f, 0.0f, 10.0f, 0.1f)
void setf(size_t x, float value)
fl::scoped_ptr< WaveSimulation1D_Real > mSim
void init(uint32_t length, SuperSample factor, float speed, int dampening)
WaveSimulation1D(uint32_t length, SuperSample factor=SuperSample::SUPER_SAMPLE_NONE, float speed=0.16f, int dampening=6)
int8_t geti8(size_t x) const
int16_t geti16(size_t x) const
float getf(size_t x) const
int getDampenening() const
void setSpeed(float speed)
void setDampening(int damp)
void setExtraFrames(uint8_t extra)
uint8_t getu8(size_t x) const
int16_t geti16Previous(size_t x) const
bool geti16All(size_t x, int16_t *curr, int16_t *prev, int16_t *diff) const
uint32_t getLength() const
int16_t geti16(size_t x, size_t y) const
uint32_t getWidth() const
void init(uint32_t width, uint32_t height, SuperSample factor, float speed, int dampening)
int getDampenening() const
void setExtraFrames(uint8_t extra)
uint32_t getHeight() const
int8_t geti8(size_t x, size_t y) const
fl::Grid< int16_t > mChangeGrid
fl::scoped_ptr< WaveSimulation2D_Real > mSim
void setSpeed(float speed)
bool geti16All(size_t x, size_t y, int16_t *curr, int16_t *prev, int16_t *diff) const
float getf(size_t x, size_t y) const
uint8_t getu8(size_t x, size_t y) const
void seti16(size_t x, size_t y, int16_t value)
void setf(size_t x, size_t y, float value)
bool has(size_t x, size_t y) const
void setDampening(int damp)
WaveSimulation2D(uint32_t W, uint32_t H, SuperSample factor=SuperSample::SUPER_SAMPLE_NONE, float speed=0.16f, float dampening=6.0f)
int16_t geti16Previous(size_t x, size_t y) const
UISlider length("Length", 1.0f, 0.0f, 1.0f, 0.01f)
Implements the FastLED namespace macros.
uint8_t half_duplex_blend_sqrt_q15(uint16_t x)
uint8_t half_duplex_blend_linear(uint16_t x)
int16_t float_to_fixed(float f)
FASTLED_FORCE_INLINE T clamp(T value, T min, T max)
Implements a simple red square effect for 2D LED grids.