Swipe backwards
This commit is contained in:
parent
aa76900244
commit
0bbb5d278c
|
@ -0,0 +1,4 @@
|
||||||
|
generated_3d
|
||||||
|
build
|
||||||
|
*.FCStd1
|
||||||
|
*.blend1
|
|
@ -13,6 +13,7 @@ struct EffectAlexaSwipeConfig
|
||||||
float swipeSpeed; // in degrees per second
|
float swipeSpeed; // in degrees per second
|
||||||
float bellCurveWidthInLeds;
|
float bellCurveWidthInLeds;
|
||||||
float startPosition;
|
float startPosition;
|
||||||
|
bool forward;
|
||||||
ColorRGBW primaryColor;
|
ColorRGBW primaryColor;
|
||||||
ColorRGBW secondaryColor;
|
ColorRGBW secondaryColor;
|
||||||
};
|
};
|
||||||
|
@ -39,6 +40,16 @@ public:
|
||||||
primaryColor_(rgb2hsv(cfg.primaryColor)),
|
primaryColor_(rgb2hsv(cfg.primaryColor)),
|
||||||
secondaryColor_(rgb2hsv(cfg.secondaryColor))
|
secondaryColor_(rgb2hsv(cfg.secondaryColor))
|
||||||
{
|
{
|
||||||
|
if (cfg.forward)
|
||||||
|
{
|
||||||
|
currentPosition_ = 0;
|
||||||
|
direction_ = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
currentPosition_ = float(NUM_LEDS) / 2.0f + bellCurveWidth_ / 2;
|
||||||
|
direction_ = -1;
|
||||||
|
}
|
||||||
//#ifndef PLATFORM_NATIVE
|
//#ifndef PLATFORM_NATIVE
|
||||||
// Serial.printf("Primary color %f, %f, %f\n", primaryColor_.h, primaryColor_.s, primaryColor_.v);
|
// Serial.printf("Primary color %f, %f, %f\n", primaryColor_.h, primaryColor_.s, primaryColor_.v);
|
||||||
// Serial.printf("Secondary color %f, %f, %f\n", secondaryColor_.h, secondaryColor_.s, secondaryColor_.v);
|
// Serial.printf("Secondary color %f, %f, %f\n", secondaryColor_.h, secondaryColor_.s, secondaryColor_.v);
|
||||||
|
@ -60,19 +71,17 @@ public:
|
||||||
const int led1 = startPosition_ + i;
|
const int led1 = startPosition_ + i;
|
||||||
const int led2 = startPosition_ - i;
|
const int led2 = startPosition_ - i;
|
||||||
const ColorRGBW color = getColor(x);
|
const ColorRGBW color = getColor(x);
|
||||||
//#ifndef PLATFORM_NATIVE
|
|
||||||
// Serial.printf("Setting %d and %d to %d, %d, %d\n", led1, led2, color.r, color.g, color.b);
|
|
||||||
//#endif
|
|
||||||
setLedRGBW(ledStrip_, led1, color);
|
setLedRGBW(ledStrip_, led1, color);
|
||||||
setLedRGBW(ledStrip_, led2, color);
|
setLedRGBW(ledStrip_, led2, color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
currentPosition_ += speed_;
|
currentPosition_ += direction_ * speed_;
|
||||||
currentPosition_ = std::min(currentPosition_, float(NUM_LEDS) / 2.0f + bellCurveWidth_ / 2);
|
currentPosition_ = std::min(currentPosition_, float(NUM_LEDS) / 2.0f + bellCurveWidth_ / 2);
|
||||||
|
currentPosition_ = std::max(currentPosition_, 0.0f);
|
||||||
return DELAY_MS;
|
return DELAY_MS;
|
||||||
}
|
}
|
||||||
|
|
||||||
//private:
|
private:
|
||||||
void getParams(float x, float &interpFac, float &brightness)
|
void getParams(float x, float &interpFac, float &brightness)
|
||||||
{
|
{
|
||||||
brightness = (x < bellCurveWidth_) ? bellCurveApproximation(bellCurveWidth_ / 2 - x, invBellCurveWidth_) : 1.0f;
|
brightness = (x < bellCurveWidth_) ? bellCurveApproximation(bellCurveWidth_ / 2 - x, invBellCurveWidth_) : 1.0f;
|
||||||
|
@ -95,14 +104,7 @@ public:
|
||||||
interpFac * secondaryColor_.s + (1.0f - interpFac) * primaryColor_.s,
|
interpFac * secondaryColor_.s + (1.0f - interpFac) * primaryColor_.s,
|
||||||
interpFac * secondaryColor_.v + (1.0f - interpFac) * primaryColor_.v};
|
interpFac * secondaryColor_.v + (1.0f - interpFac) * primaryColor_.v};
|
||||||
result.v *= brightness;
|
result.v *= brightness;
|
||||||
|
return hsv2rgb(result);
|
||||||
const auto converted = hsv2rgb(result);
|
|
||||||
//#ifndef PLATFORM_NATIVE
|
|
||||||
// Serial.printf("Coord %f, interp %f, bright %f, h %f, s %f, v %f, r %d, g %d, b %d\n", x,
|
|
||||||
// interpFac, brightness, result.h, result.s, result.v, converted.r,
|
|
||||||
// converted.g, converted.b);
|
|
||||||
//#endif
|
|
||||||
return converted;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TLedStrip &ledStrip_;
|
TLedStrip &ledStrip_;
|
||||||
|
@ -120,6 +122,7 @@ public:
|
||||||
|
|
||||||
const ColorHSV primaryColor_;
|
const ColorHSV primaryColor_;
|
||||||
const ColorHSV secondaryColor_;
|
const ColorHSV secondaryColor_;
|
||||||
|
float direction_;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Traits
|
// Traits
|
||||||
|
|
|
@ -22,6 +22,7 @@ Esp32DriverRGBW ledDriver;
|
||||||
|
|
||||||
LedTask<decltype(ledStrip)> ledTask;
|
LedTask<decltype(ledStrip)> ledTask;
|
||||||
|
|
||||||
|
bool fox;
|
||||||
void tag_handler(uint8_t *sn)
|
void tag_handler(uint8_t *sn)
|
||||||
{
|
{
|
||||||
// serial number is always 5 bytes long
|
// serial number is always 5 bytes long
|
||||||
|
@ -33,19 +34,27 @@ void tag_handler(uint8_t *sn)
|
||||||
if (sn[4] == 0x30)
|
if (sn[4] == 0x30)
|
||||||
{
|
{
|
||||||
Serial.println("Fuchs");
|
Serial.println("Fuchs");
|
||||||
|
fox = true;
|
||||||
//ledTask.startEffect(EffectCircularConfig{2 * 360, 180, ColorRGBW{0, 0, 255, 0}});
|
//ledTask.startEffect(EffectCircularConfig{2 * 360, 180, ColorRGBW{0, 0, 255, 0}});
|
||||||
ledTask.startEffect(EffectAlexaSwipeConfig{20, 30, 3 * 360, 3, 180, ColorRGBW{0, 255, 0, 0}, ColorRGBW{0, 0, 255, 0}});
|
ledTask.startEffect(EffectAlexaSwipeConfig{20, 30, 3 * 360, 3, 180, true, ColorRGBW{0, 255, 0, 0}, ColorRGBW{0, 0, 255, 0}});
|
||||||
}
|
}
|
||||||
if (sn[4] == 0xf0)
|
if (sn[4] == 0xf0)
|
||||||
{
|
{
|
||||||
Serial.println("Eule");
|
Serial.println("Eule");
|
||||||
|
fox = false;
|
||||||
ledTask.startEffect(EffectCircularConfig{360, 180, ColorRGBW{0, 0, 255, 0}});
|
ledTask.startEffect(EffectCircularConfig{360, 180, ColorRGBW{0, 0, 255, 0}});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Serial.println("Nichts");
|
Serial.println("Nichts");
|
||||||
ledTask.startEffect(EffectStaticConfig{ColorRGBW{0, 0, 0, 0}});
|
if (fox)
|
||||||
|
{
|
||||||
|
fox = false;
|
||||||
|
ledTask.startEffect(EffectAlexaSwipeConfig{20, 30, 3 * 360, 3, 180, false, ColorRGBW{0, 255, 0, 0}, ColorRGBW{0, 0, 255, 0}});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ledTask.startEffect(EffectStaticConfig{ColorRGBW{0, 0, 0, 0}});
|
||||||
}
|
}
|
||||||
//led.transmit();
|
//led.transmit();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue