From b32f719e95ef3c35c46da5c99538017ef925c026 Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Fri, 12 Aug 2022 10:44:05 -0700 Subject: [PATCH] funtional testing (#593) functional optional moved to common location topology signed warnings cleaned up --- .../NeoPixelMosaicDump/NeoPixelMosaicDump.ino | 11 +++++++---- .../NeoPixelTilesDump/NeoPixelTilesDump.ino | 11 +++++++---- .../NeoPixelTopologyDump.ino | 11 +++++++---- src/NeoPixelBus.h | 16 ---------------- src/internal/NeoEase.h | 2 ++ src/internal/NeoMosaic.h | 7 ++++--- src/internal/NeoTiles.h | 7 ++++--- src/internal/NeoTopology.h | 4 ++-- src/internal/NeoUtil.h | 16 ++++++++++++++++ 9 files changed, 49 insertions(+), 36 deletions(-) diff --git a/examples/topologies/NeoPixelMosaicDump/NeoPixelMosaicDump.ino b/examples/topologies/NeoPixelMosaicDump/NeoPixelMosaicDump.ino index 6b70b6f..4854b00 100644 --- a/examples/topologies/NeoPixelMosaicDump/NeoPixelMosaicDump.ino +++ b/examples/topologies/NeoPixelMosaicDump/NeoPixelMosaicDump.ino @@ -41,10 +41,13 @@ NeoMosaic mosaic( void DumpMosaic() { + int16_t totalWidth = static_cast(mosaic.getWidth()); + int16_t totalHeight = static_cast(mosaic.getHeight()); + Serial.println(); Serial.print("\t\t"); - for (int x = 0; x < mosaic.getWidth(); x++) + for (int16_t x = 0; x < totalWidth; x++) { Serial.print(x); Serial.print("\t"); @@ -52,19 +55,19 @@ void DumpMosaic() Serial.println(); Serial.print("\t---"); - for (int x = 0; x < mosaic.getWidth(); x++) + for (int16_t x = 0; x < totalWidth; x++) { Serial.print("--------"); } Serial.println(); - for (int y = 0; y < mosaic.getHeight(); y++) + for (int16_t y = 0; y < totalHeight; y++) { Serial.print(" "); Serial.print(y); Serial.print("\t|\t"); - for (int x = 0; x < mosaic.getWidth(); x++) + for (int16_t x = 0; x < totalWidth; x++) { NeoTopologyHint hint = mosaic.TopologyHint(x, y); diff --git a/examples/topologies/NeoPixelTilesDump/NeoPixelTilesDump.ino b/examples/topologies/NeoPixelTilesDump/NeoPixelTilesDump.ino index 2849c56..c95a0d2 100644 --- a/examples/topologies/NeoPixelTilesDump/NeoPixelTilesDump.ino +++ b/examples/topologies/NeoPixelTilesDump/NeoPixelTilesDump.ino @@ -45,10 +45,13 @@ NeoTiles tiles( void DumpTopo() { + int16_t totalWidth = static_cast(tiles.getWidth()); + int16_t totalHeight = static_cast(tiles.getHeight()); + Serial.println(); Serial.print("\t\t"); - for (int x = 0; x < tiles.getWidth(); x++) + for (int16_t x = 0; x < totalWidth; x++) { Serial.print(x); Serial.print("\t"); @@ -56,19 +59,19 @@ void DumpTopo() Serial.println(); Serial.print("\t---"); - for (int x = 0; x < tiles.getWidth(); x++) + for (int16_t x = 0; x < totalWidth; x++) { Serial.print("--------"); } Serial.println(); - for (int y = 0; y < tiles.getHeight(); y++) + for (int16_t y = 0; y < totalHeight; y++) { Serial.print(" "); Serial.print(y); Serial.print("\t|\t"); - for (int x = 0; x < tiles.getWidth(); x++) + for (int16_t x = 0; x < totalWidth; x++) { NeoTopologyHint hint = tiles.TopologyHint(x, y); diff --git a/examples/topologies/NeoPixelTopologyDump/NeoPixelTopologyDump.ino b/examples/topologies/NeoPixelTopologyDump/NeoPixelTopologyDump.ino index aa78a25..d0e5548 100644 --- a/examples/topologies/NeoPixelTopologyDump/NeoPixelTopologyDump.ino +++ b/examples/topologies/NeoPixelTopologyDump/NeoPixelTopologyDump.ino @@ -31,10 +31,13 @@ NeoTopology topo(PanelWidth, PanelHeight); void DumpTopo() { + int16_t totalWidth = static_cast(topo.getWidth()); + int16_t totalHeight = static_cast(topo.getHeight()); + Serial.println(); Serial.print("\t\t"); - for (int x = 0; x < topo.getWidth(); x++) + for (int16_t x = 0; x < totalWidth; x++) { Serial.print(x); Serial.print("\t"); @@ -42,19 +45,19 @@ void DumpTopo() Serial.println(); Serial.print("\t--"); - for (int x = 0; x < topo.getWidth(); x++) + for (int16_t x = 0; x < totalWidth; x++) { Serial.print("--------"); } Serial.println(); - for (int y = 0; y < topo.getHeight(); y++) + for (int16_t y = 0; y < totalHeight; y++) { Serial.print(" "); Serial.print(y); Serial.print("\t|\t"); - for (int x = 0; x < topo.getWidth(); x++) + for (int16_t x = 0; x < totalWidth; x++) { Serial.print(topo.Map(x, y)); Serial.print("\t"); diff --git a/src/NeoPixelBus.h b/src/NeoPixelBus.h index b54dd2b..280b664 100644 --- a/src/NeoPixelBus.h +++ b/src/NeoPixelBus.h @@ -27,22 +27,6 @@ License along with NeoPixel. If not, see #include -// some platforms do not come with STL or properly defined one, specifically functional -// if you see... -// undefined reference to `std::__throw_bad_function_call()' -// ...then you can either add the platform symbol to the list so NEOPIXEBUS_NO_STL gets defined or -// go to boards.txt and enable c++ by adding (teensy31.build.flags.libs=-lstdc++) and set to "smallest code" option in Arduino -// -#if defined(ARDUINO_ARCH_AVR) || defined(ARDUINO_ARCH_MEGAAVR) || defined(STM32L432xx) || defined(STM32L476xx) || defined(ARDUINO_ARCH_SAM) -#define NEOPIXEBUS_NO_STL 1 -#endif - -// some platforms do not define this standard progmem type for some reason -// -#ifndef PGM_VOID_P -#define PGM_VOID_P const void * -#endif - // '_state' flags for internal state #define NEO_DIRTY 0x80 // a change was made to pixel data that requires a show diff --git a/src/internal/NeoEase.h b/src/internal/NeoEase.h index 77a3460..d370261 100644 --- a/src/internal/NeoEase.h +++ b/src/internal/NeoEase.h @@ -26,6 +26,8 @@ License along with NeoPixel. If not, see #pragma once +#include "internal/NeoUtil.h" + #if defined(NEOPIXEBUS_NO_STL) typedef float(*AnimEaseFunction)(float unitValue); diff --git a/src/internal/NeoMosaic.h b/src/internal/NeoMosaic.h index 551bd53..08c82f1 100644 --- a/src/internal/NeoMosaic.h +++ b/src/internal/NeoMosaic.h @@ -58,7 +58,7 @@ public: uint16_t totalWidth = getWidth(); uint16_t totalHeight = getHeight(); - if (x >= totalWidth) + if (x >= static_cast(totalWidth)) { x = totalWidth - 1; } @@ -67,7 +67,7 @@ public: x = 0; } - if (y >= totalHeight) + if (y >= static_cast(totalHeight)) { y = totalHeight - 1; } @@ -107,7 +107,8 @@ public: uint16_t totalWidth = getWidth(); uint16_t totalHeight = getHeight(); - if (x < 0 || x >= totalWidth || y < 0 || y >= totalHeight) + if (x < 0 || x >= static_cast(totalWidth) || + y < 0 || y >= static_cast(totalHeight)) { return NeoTopologyHint_OutOfBounds; } diff --git a/src/internal/NeoTiles.h b/src/internal/NeoTiles.h index 2c0ca83..896df1f 100644 --- a/src/internal/NeoTiles.h +++ b/src/internal/NeoTiles.h @@ -52,7 +52,7 @@ public: uint16_t totalWidth = getWidth(); uint16_t totalHeight = getHeight(); - if (x >= totalWidth) + if (x >= static_cast(totalWidth)) { x = totalWidth - 1; } @@ -61,7 +61,7 @@ public: x = 0; } - if (y >= totalHeight) + if (y >= static_cast(totalHeight)) { y = totalHeight - 1; } @@ -101,7 +101,8 @@ public: uint16_t totalWidth = getWidth(); uint16_t totalHeight = getHeight(); - if (x < 0 || x >= totalWidth || y < 0 || y >= totalHeight) + if (x < 0 || x >= static_cast(totalWidth) || + y < 0 || y >= static_cast(totalHeight)) { return NeoTopologyHint_OutOfBounds; } diff --git a/src/internal/NeoTopology.h b/src/internal/NeoTopology.h index 224c1db..42cc289 100644 --- a/src/internal/NeoTopology.h +++ b/src/internal/NeoTopology.h @@ -47,7 +47,7 @@ public: uint16_t Map(int16_t x, int16_t y) const { - if (x >= _width) + if (x >= static_cast(_width)) { x = _width - 1; } @@ -55,7 +55,7 @@ public: { x = 0; } - if (y >= _height) + if (y >= static_cast(_height)) { y = _height - 1; } diff --git a/src/internal/NeoUtil.h b/src/internal/NeoUtil.h index 67bb187..d7ed30e 100644 --- a/src/internal/NeoUtil.h +++ b/src/internal/NeoUtil.h @@ -26,6 +26,22 @@ License along with NeoPixel. If not, see #pragma once +// some platforms do not come with STL or properly defined one, specifically functional +// if you see... +// undefined reference to `std::__throw_bad_function_call()' +// ...then you can either add the platform symbol to the list so NEOPIXEBUS_NO_STL gets defined or +// go to boards.txt and enable c++ by adding (teensy31.build.flags.libs=-lstdc++) and set to "smallest code" option in Arduino +// +#if defined(ARDUINO_ARCH_AVR) || defined(ARDUINO_ARCH_MEGAAVR) || defined(STM32L432xx) || defined(STM32L476xx) || defined(ARDUINO_ARCH_SAM) +#define NEOPIXEBUS_NO_STL 1 +#endif + +// some platforms do not define this standard progmem type for some reason +// +#ifndef PGM_VOID_P +#define PGM_VOID_P const void * +#endif + #ifndef countof #define countof(array) (sizeof(array)/sizeof(array[0])) #endif