Skip to content

Commit

Permalink
Changed fire cooling
Browse files Browse the repository at this point in the history
  • Loading branch information
ArminJo committed Dec 16, 2020
1 parent 51770cf commit be63505
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 16 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ New Patterns are added, a snake game running on a matrix is included and you can
| YouTube Video of NeoPatternsDemo | YouTube Video of MatrixDemo on a 10x10 matrix |
| :-: | :-: |
| [![Demonstration of NeoPatterns](https://i.ytimg.com/vi/CsB7FkywCRQ/hqdefault.jpg)](https://www.youtube.com/watch?v=CsB7FkywCRQ) | [![Demonstration of MatrixDemo on a 10x10 matrix](https://i.ytimg.com/vi/URsq28l2PEQ/hqdefault.jpg)](https://www.youtube.com/watch?v=URsq28l2PEQ) |
| YouTube Video of NeoPatternsDemo on a long matrix | YouTube Video of Fire on on a long matrix |
| [![Demonstration of NeoPatterns on a long matrix ](https://i.ytimg.com/vi/y_fmAEUqhFg/hqdefault.jpg)](https://www.youtube.com/watch?v=y_fmAEUqhFg) | [![Demonstration of Fire on a long matrix ](https://i.ytimg.com/vi/CgW5T-mRSvQ/hqdefault.jpg)](https://youtu.be/CgW5T-mRSvQ?t=43) |

# PATTERNS
## Patterns from [Adafruit](https://www.adafruit.com/)
Expand Down Expand Up @@ -99,13 +101,12 @@ NeoPatterns on breadboard
![NeoPatterns on breadboard](https://github.com/ArminJo/NeoPatterns/blob/master/extras/Breadboard_complete.jpg)

# Revision History
### Version 2.3.2 - work in progress

### Version 2.3.1
- Removed restriction to 8 columns for `FireMatrix` pattern.
### Version 2.3.1 - work in progress
- Added `SnowMatrix` pattern.

### Version 2.3.0
- Changed TickerUpdate() and loadPicture() and their callers to achieve that YOffset is consistent with Y direction and origin.
- Removed restriction to 8 columns for `FireMatrix` pattern.

### Version 2.2.2 + 2.2.3 (2.2.2 was an incomplete version)
- Fixed bugs if rows are not equal columns.
Expand Down
2 changes: 1 addition & 1 deletion examples/AllPatternsOnMultiDevices/ADCUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/gpl.html>.
*/

#if defined(__AVR__) && (! defined(__AVR_ATmega4809__))
#include "ADCUtils.h"
#if defined(__AVR__) && defined(ADATE)

// Union to speed up the combination of low and high bytes to a word
// it is not optimal since the compiler still generates 2 unnecessary moves
Expand Down
5 changes: 5 additions & 0 deletions examples/AllPatternsOnMultiDevices/ADCUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#if defined(__AVR__) && (! defined(__AVR_ATmega4809__))
#include <Arduino.h>
#if defined(ADATE)

// PRESCALE4 => 13 * 4 = 52 microseconds per ADC conversion at 1 MHz Clock => 19,2 kHz
#define ADC_PRESCALE2 1 // 26 microseconds per ADC conversion at 1 MHz
Expand Down Expand Up @@ -102,6 +103,9 @@
#define ADC_1_1_VOLT_CHANNEL_MUX 0x1E
#define ADC_GND_CHANNEL_MUX 0x1F
#define INTERNAL INTERNAL1V1

#else
#error "No temperature channel definitions specified for this AVR CPU"
#endif

uint16_t readADCChannel(uint8_t aChannelNumber);
Expand All @@ -125,6 +129,7 @@ uint16_t getVCCVoltageMillivolt(void);
void printVCCVoltageMillivolt(Print* aSerial);
float getTemperature(void);

#endif // defined(ADATE)
#endif // defined(__AVR__)
#endif /* SRC_ADCUTILS_H_ */

Expand Down
13 changes: 7 additions & 6 deletions examples/MatrixFire/MatrixFire.ino
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,14 @@ void loop() {
/*
* Can set cooling and sparking parameters by potentiometers
*/
// set cooling. 10 to 25 are sensible with optimum around 19
// NeoPixelMatrix.PatternLength = map(analogRead(A0), 0, 1023, 5, 100);
// Serial.print(F("Cooling="));
// Serial.print(NeoPixelMatrix.PatternLength);
// set cooling. 10 to 25 are sensible with optimum around 14 to 20
NeoPixelMatrix.PatternLength = map(analogRead(A0), 0, 1023, 2, 40);
Serial.print(F("Cooling="));
Serial.println(NeoPixelMatrix.PatternLength);

// NeoPixelMatrix.TotalStepCounter = map(analogRead(A1), 0, 1023, 30, 200);
// Not yet implemented
// NeoPixelMatrix.PatternFlags = map(analogRead(A1), 0, 1023, 30, 200);
// Serial.print(F(" Sparking="));
// Serial.println(NeoPixelMatrix.TotalStepCounter);
// Serial.println(NeoPixelMatrix.PatternFlags);

}
4 changes: 4 additions & 0 deletions src/Colors.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ typedef uint32_t color32_t;
#define COLOR32_WHITE_HALF COLOR32(128,128,128) // to reduce power consumption
#define COLOR32_WHITE_QUARTER COLOR32(64,64,64) // to reduce power consumption
#define COLOR32_WHITE_EIGHTH COLOR32(32,32,32) // to reduce power consumption
#define COLOR32_WHITE_16TH COLOR32(16,16,16)
#define COLOR32_WHITE_32TH COLOR32(8,8,8)
#define COLOR32_WHITE_64TH COLOR32(4,4,4)
#define COLOR32_WHITE_32TH COLOR32(8,8,8)
#define COLOR32_RED COLOR32(255,0,0)
#define COLOR32_RED_HALF COLOR32(128,0,0)
#define COLOR32_RED_QUARTER COLOR32(64,0,0)
Expand Down
9 changes: 6 additions & 3 deletions src/MatrixNeoPatterns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ void MatrixNeoPatterns::setInitHeat() {
#else
tRandomValue.ULong = random();
#endif
initalHeatLine[tIndex] = (tRandomValue.UBytes[i] % (255-40)) + 40;
// Values from 40 to 255
initalHeatLine[tIndex] = (tRandomValue.UBytes[i] - 40) + 40; // 40 is somewhat over represented
// initalHeatLine[tIndex] = ((tRandomValue.UBytes[i] * (255 - 40)) >> 8) + 40; // the correct one - just in case
tIndex++;
if (tIndex >= Columns) {
return;
Expand All @@ -145,6 +147,7 @@ void MatrixNeoPatterns::Fire(uint16_t aNumberOfSteps, uint16_t aIntervalMillis)
Interval = aIntervalMillis;
Direction = DIRECTION_UP;
TotalStepCounter = aNumberOfSteps + 1; // + 1 step for the last pattern to show
PatternLength = MATRIX_FIRE_COOLING_PER_8_ROWS * 8 / Rows; // cooling affects the height of fire, the greater the value the smaller the fire
Index = 3; // to call setInitHeat(); at startup

// just to be sure
Expand Down Expand Up @@ -240,8 +243,8 @@ bool MatrixNeoPatterns::FireMatrixUpdate() {
uint8_t tNewHeatValue = MatrixOld[mapXYToArray(x, y, Columns + 2)] + (tConvolutionSumTimes256 / 256);

// - COOLING and clipping to zero
if (tNewHeatValue > MATRIX_FIRE_COOLING) {
tNewHeatValue -= MATRIX_FIRE_COOLING;
if (tNewHeatValue > PatternLength) {
tNewHeatValue -= PatternLength;
} else {
tNewHeatValue = 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/MatrixNeoPatterns.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ extern const uint8_t fontNumbers4x6[] PROGMEM; // the font for showing numbers
#define NUMBERS_FONT_WIDTH 4
#define NUMBERS_FONT_HEIGHT 6

#define MATRIX_FIRE_COOLING 20 // 10 to 25 are sensible with optimum around 19
#define MATRIX_FIRE_COOLING_PER_8_ROWS 15 // for 8 rows 10 to 25 are sensible with optimum around 15
/*
* The sum SHOULD be 0!!!
* The Matrix which describes the contribution of each surrounding pixel to the next heat value.
Expand Down
3 changes: 2 additions & 1 deletion src/NeoPatterns.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,10 @@ void __attribute__((weak)) UserPattern2(NeoPatterns *aNeoPatterns, color32_t aCo

/*
* Version 2.3.1 - 12/2020
* - Removed restriction to 8 columns for `FireMatrix` pattern.
* - Added `SnowMatrix` pattern.
*
* Version 2.3.0 - 12/2020
* - Removed restriction to 8 columns for `FireMatrix` pattern.
* - Changed TickerUpdate() and loadPicture() and their callers to achieve that YOffset is consistent with Y direction and origin.
*
* Version 2.2.2 /2.2.3- 12/2020
Expand Down

0 comments on commit be63505

Please sign in to comment.