Skip to content

Commit

Permalink
Version 2.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ArminJo committed Feb 5, 2021
1 parent 8b6bb30 commit 0434b70
Show file tree
Hide file tree
Showing 22 changed files with 136 additions and 62 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# [NeoPatterns](https://github.com/ArminJo/NeoPatterns) for NeoPixel strips and Snake game for NeoPixel matrix.
Available as Arduino library "NeoPatterns"

### [Version 2.3.1](https://github.com/ArminJo/NeoPatterns/releases) - work in progress
### [Version 2.3.2](https://github.com/ArminJo/NeoPatterns/archive/master.zip) - work in progress

[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
[![Installation instructions](https://www.ardu-badge.com/badge/NeoPatterns.svg?)](https://www.ardu-badge.com/NeoPatterns)
Expand Down Expand Up @@ -38,7 +38,6 @@ the included NeoPixel library is an extensions of the Adafruit NeoPixel library
- drawBarFromColorArray() - uses a color array for the different colors of the bar pixel.
- dimColor() - by 50%.
- gamma5() - returns gamma brightness value from a linear input.
- gamma5WithSpecialZero()
- gamma5FromColor() - returns the gamma corrected color.
- Wheel() - returns colors from a color wheel starting ar red.
as well as functions for getting color parts
Expand Down Expand Up @@ -77,7 +76,7 @@ Modify it by commenting them out or in, or change the values if applicable. Or d
|-|-|-|-|
| `SUPPORT_RGBW` | enabled | NeoPixel.h | Can be disabled by commenting out `#define SUPPORT_RGBW` or defining `DO_NOT_SUPPORT_RGBW`. Disable it if you only have RGB pixels and do not require RGBW pixels support. Disabling saves up to 400 bytes FLASH for the AllPatternsOnMultiDevices example. |
| `DO_NOT_USE_MATH_PATTERNS` | disabled | NeoPatterns.h | Disables the `BOUNCING_BALL` pattern. Saves up to 640 to 1140 bytes FLASH, depending if floating point and sqrt() are already used otherwise. |
| `SUPPORT_ONLY_DEFAULT_GEOMETRY` | disabled | MatrixNeoPixel.h | If you have only default geometry, i.e. Pixel 0 is at bottom right of matrix, matrix is row major (horizontal) and same pixel order across each line (no zig-zag) you can save 560 bytes FLASH and 3 bytes RAM. |
| `SUPPORT_ONLY_DEFAULT_GEOMETRY` | disabled | MatrixNeoPixel.h | If you have only default geometry, i.e. Pixel 0 is at bottom right of matrix, matrix is row major (horizontal) and same pixel order across each line (no zig-zag) you can save 560 bytes (and more) FLASH and 3 bytes RAM. |

### Modifying compile options with Arduino IDE
First use *Sketch > Show Sketch Folder (Ctrl+K)*.<br/>
Expand All @@ -101,11 +100,14 @@ NeoPatterns on breadboard
![NeoPatterns on breadboard](https://github.com/ArminJo/NeoPatterns/blob/master/extras/Breadboard_complete.jpg)

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

### Version 2.3.1
- Changed type of TotalStepCounter from uint16_t to int16_t.
- Added `SnowMatrix` pattern.
- Improved debugging.
- Fixed random() bug for ESP32.
- Improved Fire cooling.

### Version 2.3.0
- Changed TickerUpdate() and loadPicture() and their callers to achieve that YOffset is consistent with Y direction and origin.
Expand Down
4 changes: 2 additions & 2 deletions examples/AllPatternOnOneStrip/AllPatternOnOneStrip.ino
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ void setup() {

#ifdef INFO
Serial.begin(115200);
#if defined(__AVR_ATmega32U4__) || defined(SERIAL_USB) || defined(SERIAL_PORT_USBVIRTUAL)
delay(2000); // To be able to connect Serial monitor after reset and before first printout
#if defined(__AVR_ATmega32U4__) || defined(SERIAL_USB) || defined(SERIAL_PORT_USBVIRTUAL) || defined(ARDUINO_attiny3217)
delay(2000); // To be able to connect Serial monitor after reset or power up and before first printout
#endif
// Just to know which program is running on my Arduino
Serial.println(F("START " __FILE__ " from " __DATE__ "\r\nUsing library version " VERSION_NEOPATTERNS));
Expand Down
15 changes: 8 additions & 7 deletions examples/AllPatternsOnMultiDevices/ADCUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,11 @@ uint8_t checkAndWaitForReferenceAndChannelToSwitch(uint8_t aChannelNumber, uint8
*/
uint8_t tNewReference = (aReference << SHIFT_VALUE_FOR_REFERENCE);
ADMUX = aChannelNumber | tNewReference;
if ((tOldADMUX & MASK_FOR_ADC_REFERENCE) != tNewReference) {
if (aReference == INTERNAL) {
/*
* Switch reference from DEFAULT to INTERNAL
*/
delayMicroseconds(8000); // experimental value is >= 7600 us for Nano board and 6200 for UNO board
}
if ((tOldADMUX & MASK_FOR_ADC_REFERENCE) != tNewReference && aReference == INTERNAL) {
/*
* Switch reference from DEFAULT to INTERNAL
*/
delayMicroseconds(8000); // experimental value is >= 7600 us for Nano board and 6200 for UNO board
} else if ((tOldADMUX & 0x0F) != aChannelNumber) {
if (aChannelNumber == ADC_1_1_VOLT_CHANNEL_MUX) {
/*
Expand Down Expand Up @@ -298,6 +296,7 @@ uint16_t readUntil4ConsecutiveValuesAreEqual(uint8_t aChannelNumber, uint8_t aDe
/*
* !!! Function without handling of switched reference and channel.!!!
* Use it ONLY if you only call getVCCVoltageSimple() or getVCCVoltageMillivoltSimple() in your program.
* !!! Resolution is only 20 millivolt !!!
*/
float getVCCVoltageSimple(void) {
// use AVCC with (optional) external capacitor at AREF pin as reference
Expand All @@ -308,6 +307,7 @@ float getVCCVoltageSimple(void) {
/*
* !!! Function without handling of switched reference and channel.!!!
* Use it ONLY if you only call getVCCVoltageSimple() or getVCCVoltageMillivoltSimple() in your program.
* !!! Resolution is only 20 millivolt !!!
*/
uint16_t getVCCVoltageMillivoltSimple(void) {
// use AVCC with external capacitor at AREF pin as reference
Expand Down Expand Up @@ -336,6 +336,7 @@ float getVCCVoltage(void) {
/*
* Read value of 1.1 volt internal channel using VCC as reference.
* Handles reference and channel switching by introducing the appropriate delays.
* !!! Resolution is only 20 millivolt !!!
*/
uint16_t getVCCVoltageMillivolt(void) {
uint8_t tOldADMUX = checkAndWaitForReferenceAndChannelToSwitch(ADC_1_1_VOLT_CHANNEL_MUX, DEFAULT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ void setup() {
pinMode(LED_BUILTIN, OUTPUT);

Serial.begin(115200);
#if defined(__AVR_ATmega32U4__) || defined(SERIAL_USB) || defined(SERIAL_PORT_USBVIRTUAL)
delay(2000); // To be able to connect Serial monitor after reset and before first printout
#if defined(__AVR_ATmega32U4__) || defined(SERIAL_USB) || defined(SERIAL_PORT_USBVIRTUAL) || defined(ARDUINO_attiny3217)
delay(2000); // To be able to connect Serial monitor after reset or power up and before first printout
#endif
// Just to know which program is running on my Arduino
Serial.println(F("START " __FILE__ " from " __DATE__ "\r\nUsing library version " VERSION_NEOPATTERNS));
Expand Down
4 changes: 2 additions & 2 deletions examples/MatrixDemo/MatrixDemo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ void setup() {
pinMode(LED_BUILTIN, OUTPUT);

Serial.begin(115200);
#if defined(__AVR_ATmega32U4__) || defined(SERIAL_USB) || defined(SERIAL_PORT_USBVIRTUAL)
delay(2000); // To be able to connect Serial monitor after reset and before first printout
#if defined(__AVR_ATmega32U4__) || defined(SERIAL_USB) || defined(SERIAL_PORT_USBVIRTUAL) || defined(ARDUINO_attiny3217)
delay(2000); // To be able to connect Serial monitor after reset or power up and before first printout
#endif
// Just to know which program is running on my Arduino
Serial.println(F("START " __FILE__ " from " __DATE__ "\r\nUsing library version " VERSION_NEOPATTERNS));
Expand Down
4 changes: 2 additions & 2 deletions examples/MatrixFire/MatrixFire.ino
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ void setup() {
pinMode(LED_BUILTIN, OUTPUT);

Serial.begin(115200);
#if defined(__AVR_ATmega32U4__) || defined(SERIAL_USB) || defined(SERIAL_PORT_USBVIRTUAL)
delay(2000); // To be able to connect Serial monitor after reset and before first printout
#if defined(__AVR_ATmega32U4__) || defined(SERIAL_USB) || defined(SERIAL_PORT_USBVIRTUAL) || defined(ARDUINO_attiny3217)
delay(2000); // To be able to connect Serial monitor after reset or power up and before first printout
#endif
// Just to know which program is running on my Arduino
Serial.println(F("START " __FILE__ " from " __DATE__ "\r\nUsing library version " VERSION_NEOPATTERNS));
Expand Down
4 changes: 2 additions & 2 deletions examples/MatrixShowAllColors/MatrixShowAllColors.ino
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ void setup() {
pinMode(LED_BUILTIN, OUTPUT);

Serial.begin(115200);
#if defined(__AVR_ATmega32U4__) || defined(SERIAL_USB) || defined(SERIAL_PORT_USBVIRTUAL)
delay(2000); // To be able to connect Serial monitor after reset and before first printout
#if defined(__AVR_ATmega32U4__) || defined(SERIAL_USB) || defined(SERIAL_PORT_USBVIRTUAL) || defined(ARDUINO_attiny3217)
delay(2000); // To be able to connect Serial monitor after reset or power up and before first printout
#endif
// Just to know which program is running on my Arduino
Serial.println(F("START " __FILE__ " from " __DATE__ "\r\nUsing library version " VERSION_NEOPATTERNS));
Expand Down
4 changes: 2 additions & 2 deletions examples/MatrixSnow/MatrixSnow.ino
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ void setup() {
pinMode(LED_BUILTIN, OUTPUT);

Serial.begin(115200);
#if defined(__AVR_ATmega32U4__) || defined(SERIAL_USB) || defined(SERIAL_PORT_USBVIRTUAL)
delay(2000); // To be able to connect Serial monitor after reset and before first printout
#if defined(__AVR_ATmega32U4__) || defined(SERIAL_USB) || defined(SERIAL_PORT_USBVIRTUAL) || defined(ARDUINO_attiny3217)
delay(2000); // To be able to connect Serial monitor after reset or power up and before first printout
#endif
// Just to know which program is running on my Arduino
Serial.println(F("START " __FILE__ " from " __DATE__ "\r\nUsing library version " VERSION_NEOPATTERNS));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ void setup() {
pinMode(LED_BUILTIN, OUTPUT);

Serial.begin(115200);
#if defined(__AVR_ATmega32U4__) || defined(SERIAL_USB) || defined(SERIAL_PORT_USBVIRTUAL)
delay(2000); // To be able to connect Serial monitor after reset and before first printout
#if defined(__AVR_ATmega32U4__) || defined(SERIAL_USB) || defined(SERIAL_PORT_USBVIRTUAL) || defined(ARDUINO_attiny3217)
delay(2000); // To be able to connect Serial monitor after reset or power up and before first printout
#endif
// Just to know which program is running on my Arduino
Serial.println(F("START " __FILE__ " from " __DATE__ "\r\nUsing library version " VERSION_NEOPATTERNS));
Expand Down
4 changes: 2 additions & 2 deletions examples/NeoPatternsSimpleDemo/NeoPatternsSimpleDemo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ NeoPatterns bar16 = NeoPatterns(16, PIN_NEOPIXEL_BAR_16, NEO_GRB + NEO_KHZ800, &

void setup() {
Serial.begin(115200);
#if defined(__AVR_ATmega32U4__) || defined(SERIAL_USB) || defined(SERIAL_PORT_USBVIRTUAL)
delay(2000); // To be able to connect Serial monitor after reset and before first printout
#if defined(__AVR_ATmega32U4__) || defined(SERIAL_USB) || defined(SERIAL_PORT_USBVIRTUAL) || defined(ARDUINO_attiny3217)
delay(2000); // To be able to connect Serial monitor after reset or power up and before first printout
#endif
// Just to know which program is running on my Arduino
Serial.println(F("START " __FILE__ " from " __DATE__ "\r\nUsing library version " VERSION_NEOPATTERNS));
Expand Down
2 changes: 1 addition & 1 deletion examples/OpenLedRace/AVRUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*
*/

#if defined(__AVR__)
#if defined(__AVR__) && !(defined(__AVR_ATtiny1616__) || defined(__AVR_ATtiny3216__) || defined(__AVR_ATtiny3217__))
#include "AVRUtils.h"
#include <avr/interrupt.h>
#include <stdlib.h> // for __malloc_margin
Expand Down
4 changes: 2 additions & 2 deletions examples/OpenLedRace/OpenLedRace.ino
Original file line number Diff line number Diff line change
Expand Up @@ -687,8 +687,8 @@ void setup() {
#endif

Serial.begin(115200);
#if defined(__AVR_ATmega32U4__) || defined(SERIAL_USB) || defined(SERIAL_PORT_USBVIRTUAL)
delay(2000); // To be able to connect Serial monitor after reset and before first printout
#if defined(__AVR_ATmega32U4__) || defined(SERIAL_USB) || defined(SERIAL_PORT_USBVIRTUAL) || defined(ARDUINO_attiny3217)
delay(2000); // To be able to connect Serial monitor after reset or power up and before first printout
#endif
// Just to know which program is running on my Arduino
Serial.println(F("START " __FILE__ " from " __DATE__ "\r\nUsing library version " VERSION_NEOPATTERNS));
Expand Down
4 changes: 2 additions & 2 deletions examples/SnakeAutorun/SnakeAutorun.ino
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ void setup() {
pinMode(LED_BUILTIN, OUTPUT);

Serial.begin(115200);
#if defined(__AVR_ATmega32U4__) || defined(SERIAL_USB) || defined(SERIAL_PORT_USBVIRTUAL)
delay(2000); // To be able to connect Serial monitor after reset and before first printout
#if defined(__AVR_ATmega32U4__) || defined(SERIAL_USB) || defined(SERIAL_PORT_USBVIRTUAL) || defined(ARDUINO_attiny3217)
delay(2000); // To be able to connect Serial monitor after reset or power up and before first printout
#endif
// Just to know which program is running on my Arduino
Serial.println(F("START " __FILE__ " from " __DATE__ "\r\nUsing library version " VERSION_NEOPATTERNS));
Expand Down
4 changes: 2 additions & 2 deletions examples/SnakeGame/SnakeGame.ino
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ void setup() {
pinMode(LED_BUILTIN, OUTPUT);

Serial.begin(115200);
#if defined(__AVR_ATmega32U4__) || defined(SERIAL_USB) || defined(SERIAL_PORT_USBVIRTUAL)
delay(2000); // To be able to connect Serial monitor after reset and before first printout
#if defined(__AVR_ATmega32U4__) || defined(SERIAL_USB) || defined(SERIAL_PORT_USBVIRTUAL) || defined(ARDUINO_attiny3217)
delay(2000); // To be able to connect Serial monitor after reset or power up and before first printout
#endif
// Just to know which program is running on my Arduino
Serial.println(F("START " __FILE__ " from " __DATE__ "\r\nUsing library version " VERSION_NEOPATTERNS));
Expand Down
4 changes: 2 additions & 2 deletions examples/SnowFlakes/SnowFlakes.ino
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ void setup() {
pinMode(LED_BUILTIN, OUTPUT);

Serial.begin(115200);
#if defined(__AVR_ATmega32U4__) || defined(SERIAL_USB) || defined(SERIAL_PORT_USBVIRTUAL)
delay(2000); // To be able to connect Serial monitor after reset and before first printout
#if defined(__AVR_ATmega32U4__) || defined(SERIAL_USB) || defined(SERIAL_PORT_USBVIRTUAL) || defined(ARDUINO_attiny3217)
delay(2000); // To be able to connect Serial monitor after reset or power up and before first printout
#endif
// Just to know which program is running on my Arduino
Serial.println(F("START " __FILE__ " from " __DATE__ "\r\nUsing library version " VERSION_NEOPATTERNS));
Expand Down
4 changes: 2 additions & 2 deletions examples/TwoPatternsOnOneStrip/TwoPatternsOnOneStrip.ino
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ void setup() {
pinMode(LED_BUILTIN, OUTPUT);

Serial.begin(115200);
#if defined(__AVR_ATmega32U4__) || defined(SERIAL_USB) || defined(SERIAL_PORT_USBVIRTUAL)
delay(2000); // To be able to connect Serial monitor after reset and before first printout
#if defined(__AVR_ATmega32U4__) || defined(SERIAL_USB) || defined(SERIAL_PORT_USBVIRTUAL) || defined(ARDUINO_attiny3217)
delay(2000); // To be able to connect Serial monitor after reset or power up and before first printout
#endif
// Just to know which program is running on my Arduino
Serial.println(F("START " __FILE__ " from " __DATE__ "\r\nUsing library version " VERSION_NEOPATTERNS));
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version=2.3.1
author=Armin Joachimsmeyer
maintainer=Armin Joachimsmeyer <[email protected]>
sentence=Patterns for NeoPixel strips and matrixes including the patterns of the NeoPattern example by Adafruit.<br/>
paragraph=Patterns from Adafruit are: <ul><li>SCANNER</li><li>STRIPES</li><li>DELAY</li><li>PROCESS_SELECTIVE</li><li>FADE_SELECTIVE</li></ul>The original SCANNER pattern is extended and includes the CYLON as well as the ROCKET or FALLING_STAR pattern. The more versatile STRIPES pattern replaces the old THEATER_CHASE one.<br/><br/>NeoPixel-Matrix pattern are:<ul><li>MOVING_PICTURE</li><li>MOVE</li><li>TICKER</li><li>FIRE</li><li>SNAKE</li></ul>The SNAKE pattern is an implementation of the Snake game and can be played with 2 or 4 buttons attached to the Arduino.<br/>The SnakeAutorun example will start <b>your own code to solve the Snake game</b> provided in the function getNextSnakeDirection().<br/><br/>YouTube demos are available under <a href="https://github.com/ArminJo/NeoPatterns">https://github.com/ArminJo/NeoPatterns</a>.<br/><br/>Includes an <b>OpenLedRace</b> example for 2 players.<br/><br/><b>New: </b>- Changed type of TotalStepCounter from uint16_t to int16_t. Added SnowMatrix pattern. Fixed random() bug for ESP32.<br/>
paragraph=Patterns from Adafruit are: <ul><li>SCANNER</li><li>STRIPES</li><li>DELAY</li><li>PROCESS_SELECTIVE</li><li>FADE_SELECTIVE</li></ul>The original SCANNER pattern is extended and includes the CYLON as well as the ROCKET or FALLING_STAR pattern. The more versatile STRIPES pattern replaces the old THEATER_CHASE one.<br/><br/>NeoPixel-Matrix pattern are:<ul><li>MOVING_PICTURE</li><li>MOVE</li><li>TICKER</li><li>FIRE</li><li>SNAKE</li></ul>The SNAKE pattern is an implementation of the Snake game and can be played with 2 or 4 buttons attached to the Arduino.<br/>The SnakeAutorun example will start <b>your own code to solve the Snake game</b> provided in the function getNextSnakeDirection().<br/><br/>YouTube demos are available under <a href="https://github.com/ArminJo/NeoPatterns">https://github.com/ArminJo/NeoPatterns</a>.<br/><br/>Includes an <b>OpenLedRace</b> example for 2 players.<br/><br/><b>New: </b>Changed type of TotalStepCounter from uint16_t to int16_t. Added SnowMatrix pattern. Fixed random() bug for ESP32. Improved Fire cooling.<br/>
category=Display
url=https://github.com/ArminJo/NeoPatterns
architectures=avr,megaAVR,esp8266,esp32,STM32
Expand Down
6 changes: 3 additions & 3 deletions src/LongUnion.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
*
*/

#ifndef UNIONS_H_
#define UNIONS_H_
#ifndef LONG_UNION_H
#define LONG_UNION_H

#include <Arduino.h>
#include <stdint.h>
Expand Down Expand Up @@ -84,6 +84,6 @@ union LongUnion {
int32_t Long;
};

#endif // UNIONS_H_
#endif // LONG_UNION_H

#pragma once
Loading

0 comments on commit 0434b70

Please sign in to comment.