void FlamesLegMode::fire2012() { // Step 1. Cool down every cell a little for (int i = 0; i < _pixelCount; i++) _heat[i] = qsub8(_heat[i], random8(0, ((_cooling * 10) / _pixelCount) + 2)); // Step 2. Heat from each cell drifts 'up' and diffuses a little for (int k = _pixelCount - 3; k > _half; k--) _heat[k] = (_heat[k - 1] + _heat[k - 2] + _heat[k - 2] ) / 3; for (int k = 0; k < (_half - 3); k++) _heat[k] = (_heat[k + 1] + _heat[k + 2] + _heat[k + 2] ) / 3; // Step 3. Randomly ignite new 'sparks' of _heat near the bottom //if (random8() < SPARKING) if ((_currentTime - _lastStepTime) < 200) { for (int i = _half - 6; i < (_half + 6); i++) _heat[i] = 230; } else if (random8() < _sparking) { int y_back = random8(_half, _half + 6); int y_front = random8(_half - 6, _half); _heat[y_back] = qadd8(_heat[y_back], random8(160, 256)); _heat[y_front] = qadd8(_heat[y_front], random8(160, 256)); } // Step 4. Map from _heat cells to LED colors for (int j = 0; j < _pixelCount; j++) _pixels[j] = heatColor(_heat[j]); }
uint16_t fire2012(uint16_t tick, uint32_t color) { // Fire2012 by Mark Kriegsman, July 2012 // as part of "Five Elements" shown here: http://youtu.be/knWiGsmgycY // adapted from example included with fastLED if(tick == 0) { random16_add_entropy( random()); static byte heat[NUM_LEDS]; // Array of temperature readings at each simulation cell // Step 1. Cool down every cell a little for( int i = 0; i < NUM_LEDS; i++) { heat[i] = qsub8( heat[i], random8(0, ((COOLING * 10) / NUM_LEDS) + 2)); } // Step 2. Heat from each cell drifts 'up' and diffuses a little for( int k= NUM_LEDS - 1; k >= 2; k--) { heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3; } // Step 3. Randomly ignite new 'sparks' of heat near the bottom if( random8() < SPARKING) { int y = random8(7); heat[y] = qadd8( heat[y], random8(160,255) ); } // Step 4. Map from heat cells to LED colors for(uint16_t j = 0; j < NUM_LEDS; j++) { CRGB hColor = HeatColor(heat[j]); uint32_t red = hColor.red; uint32_t green = hColor.green; uint32_t blue = hColor.blue; uint32_t intColor = (red<<16)+(green<<8)+blue; setLedColor(j, HeatColor(heat[j])); } } return 4; }
// Fill the x/y array of 8-bit noise values using the inoise8 function. void fillnoise8() { // If we're runing at a low "speed", some 8-bit artifacts become visible // from frame-to-frame. In order to reduce this, we can do some fast data-smoothing. // The amount of data smoothing we're doing depends on "speed". uint8_t dataSmoothing = 0; if( speed < 50) { dataSmoothing = 200 - (speed * 4); } for(int i = 0; i < MAP_WIDTH/2 + 1; i++) { int ioffset = scale * i; for(int j = 0; j < MAP_WIDTH/2 + 1; j++) { int joffset = scale * j; uint8_t data = inoise8(x + joffset,y + ioffset,z); // The range of the inoise8 function is roughly 16-238. // These two operations expand those values out to roughly 0..255 // You can comment them out if you want the raw noise data. data = qsub8(data,16); data = qadd8(data,scale8(data,39)); if( dataSmoothing ) { uint8_t olddata = noise[i][j]; uint8_t newdata = scale8( olddata, dataSmoothing) + scale8( data, 256 - dataSmoothing); data = newdata; } noise[i][j] = data; } } z += speed; // apply slow drift to X and Y, just for visual variation. x += speed * xDrift / 8; y -= speed * yDrift / 16; }
void rgb_matrix_decrease_speed(void) { rgb_matrix_config.speed = qsub8(rgb_matrix_config.speed, RGB_MATRIX_SPD_STEP); eeconfig_update_rgb_matrix(rgb_matrix_config.raw);//EECONFIG needs to be increased to support this }
void rgb_matrix_decrease_val(void) { rgb_matrix_config.val = qsub8(rgb_matrix_config.val, RGB_MATRIX_VAL_STEP); eeconfig_update_rgb_matrix(rgb_matrix_config.raw); }
void rgb_matrix_decrease_sat(void) { rgb_matrix_config.sat = qsub8(rgb_matrix_config.sat, RGB_MATRIX_SAT_STEP); eeconfig_update_rgb_matrix(rgb_matrix_config.raw); }