11 template<u
int8_t DATA_PIN, u
int32_t RGB_ORDER, u
int16_t NUM_LEDS>
12 class FireStripPCB :
public FastLED_NeoPixel<NUM_LEDS, DATA_PIN, RGB_ORDER>
17 #define USE_FIRESTRIP_TEMPLATE 1
19 template<u
int8_t DATA_PIN, u
int32_t RGB_ORDER, u
int16_t NUM_LEDS>
24 Adafruit_NeoPixel(NUM_LEDS, DATA_PIN, RGB_ORDER)
48 #if USE_FIRESTRIP_TEMPLATE
49 template<u
int8_t DATA_PIN, u
int32_t RGB_ORDER = GRB, u
int16_t NUM_LEDS = 8>
55 private Adafruit_NeoPixel,
60 #if USE_FIRESTRIP_TEMPLATE
68 kRGBW = NEO_GRBW + NEO_KHZ800,
69 kRGB = NEO_GRB + NEO_KHZ800
72 FireStrip(
const byte pin, PixelType type = kRGBW,
const int id = 0) :
73 Adafruit_NeoPixel(NUM_LEDS, pin, type),
92 fEffectType = kSparkEffect;
93 fEffectEnd = millis() + duration;
102 fEffectType = kFireEffect;
103 fEffectEnd = millis() + duration;
114 fEffectType = kNoEffect;
115 for (
unsigned i = 0; i < NUM_LEDS; i++)
126 setBrightness(BRIGHT);
135 uint32_t currentTime = millis();
141 if (currentTime > fNextTime)
145 setAll(0x33+random(0x77), 0x33+random(0x77), 0xFF);
151 fNextTime = currentTime + 10+(10*random(2,5));
152 fFlipFlop = !fFlipFlop;
156 if (currentTime > fNextTime)
159 fNextTime = currentTime + 10+(10*random(2,5));
160 fFlipFlop = !fFlipFlop;
164 if (currentTime > fEffectEnd)
181 if (*cmd++ ==
'F' && *cmd++ ==
'S')
186 if (cmd[1] ==
'F' && cmd[2] ==
'F' && cmd[3] ==
'\0')
196 spark(atoi(&cmd[1]));
211 #if USE_FIRESTRIP_TEMPLATE
222 void setPixelColor(uint16_t n, uint32_t c)
227 void setPixelColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b)
232 constexpr
static int NUM_LEDS = 8;
245 int fEffectType = kNoEffect;
251 static long atoi(
const char* s)
254 while (*s >=
'0' && *s <=
'9')
256 val = val * 10 + (*s++ -
'0');
261 void setAll(
byte red,
byte green,
byte blue)
263 for (
unsigned i = 0; i < NUM_LEDS; i++)
265 setPixelColor(i, red, green, blue);
270 void fire(
int Cooling,
unsigned Sparking)
272 static byte heat[NUM_LEDS];
276 for (
int i = 0; i < NUM_LEDS; i++)
278 cooldown = random(0, ((Cooling * 10) / NUM_LEDS) + 2);
280 if (cooldown>heat[i])
286 heat[i] = heat[i] - cooldown;
291 for (
int k= NUM_LEDS - 1; k >= 2; k--)
293 heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2]) / 3;
297 if (random(255) < Sparking)
300 heat[y] = heat[y] + random(160,255);
304 for (
int j = 0; j < NUM_LEDS; j++)
306 setPixelHeatColor(j, heat[j]);
312 void setPixelHeatColor(
int pixel,
byte temperature)
315 byte t192 = round((temperature/255.0)*191);
318 byte heatramp = t192 & 0x3F;
325 setPixelColor(pixel, 255, 255, heatramp);
327 else if (t192 > 0x40)
330 setPixelColor(pixel, 255, heatramp, 0);
335 setPixelColor(pixel, heatramp, 0, 0);