having a bit of trouble figuring out what exactly the issue is here. I am using a template function to pass the information on array(s) passed to my display function. Simply, I have an array that contains the intensities of pixels (0-255) and I am passing the array size (2-d array) of rows and columns.
Here is the code:
[code]
// neopixel strip larson scanner
#include <Adafruit_NeoPixel.h>
#define PIN A3
Adafruit_NeoPixel strip = Adafruit_NeoPixel(8, PIN, NEO_GRB + NEO_KHZ800);
#define DEBUG_UART 0
uint32_t c = 0;
int wait;
int interval = 150;
void colorwave(uint8_t *pattern, size_t rows, size_t cols) {
static uint32_t previousMillis = 0;
static uint8_t indexI = 0;
static uint8_t indexJ = 0;
uint8_t g = 0;
uint8_t r = 120;
uint8_t b = 0;
for (uint16_t indexI = 0; indexI < strip.numPixels(); indexI++)
{
uint32_t c = strip.Color(pattern[indexJ][indexI], g, b);
strip.setPixelColor(indexI, c);
strip.show();
}
if (millis() - previousMillis >= interval)
{
if (indexJ <= 5)
{
indexJ++;
}
else
{
indexJ = 0;
}
previousMillis = millis();
}
}
uint8_t pattern1[6][8] = {
{0, 23, 105, 255, 105, 23, 0, 23},
{23, 0, 23, 105, 255, 105, 23, 0},
{105, 23, 0, 23, 105, 255, 105, 23},
{255, 105, 23, 0, 23, 105, 255, 105},
{105, 255, 105, 23, 0, 23, 105, 255},
{23, 105, 255, 105, 23, 0, 23, 105},
};
void setup()
{
strip.begin();
strip.setBrightness(32);
strip.show(); // Initialize all pixels to 'off'
}
template <size_t rows, size_t cols> void display_pattern(const int (&pattern)[rows][cols])
{
colorwave(&pattern[0][0], rows, cols);
}
void loop()
{
colorwave(pattern1);
}
[/code]
and this is the errors:
/home/pi/Arduino/code/wave_neo_template/wave_neo_template.ino: In function ‘void colorwave(uint8_t*, size_t, size_t)’:
wave_neo_template:20:52: error: invalid types ‘uint8_t {aka unsigned char}[uint16_t {aka short unsigned int}]’ for array subscript
uint32_t c = strip.Color(pattern[indexJ][indexI], g, b);
^
/home/pi/Arduino/code/wave_neo_template/wave_neo_template.ino: In function ‘void loop()’:
wave_neo_template:62:21: error: cannot convert ‘uint8_t ()[8] {aka unsigned char ()[8]}’ to ‘uint8_t* {aka unsigned char*}’ for argument ‘1’ to ‘void colorwave(uint8_t*, size_t, size_t)’
colorwave(pattern1);
^
Using library Adafruit_NeoPixel at version 1.6.0 in folder: /home/pi/Downloads/arduino-1.8.12/examples/libraries/Adafruit_NeoPixel
exit status 1
invalid types ‘uint8_t {aka unsigned char}[uint16_t {aka short unsigned int}]’ for array subscript
So, apparently the array subscript does not like the uint8_t type, it also does not like the uint32_t, or uint16_t, or int, or byte!
The function strip.Color(r, g, b) wants unint8_t according to teh Neopixel library documentation.
I honestly do not know what exactly the problem is.
Any help would be appreciated.
Roger