there are 2 StepData entries per row. Each StepData entry has 2 fields
corrected - but simply increments a pointer without knowing the dimensions of the matrix
output
Begin
1 200, 2 300,
3 300, 9 100,
4 150, 7 30,
#include <Arduino.h>
// Steps
struct StepData{
char command;
int position;
};
const int step1_rows = 3;
const int step1_cols = 2;
StepData step1_sequence [step1_rows][step1_cols] = {
{ {'1', 200}, {'2', 300} },
{ {'3', 300}, {'9', 100} },
{ {'4', 150}, {'7', 30} },
};
char s [90];
// -----------------------------------------------------------------------------
void printMultidimensionalArray (
void *voidPointer,
int rows,
int cols)
{
StepData *p = (StepData *) voidPointer;
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
sprintf (s, " %c %4d,", p->command, p->position);
Serial.print (s);
p++;
}
Serial.println ();
}
}
// -----------------------------------------------------------------------------
void setup ()
{
Serial.begin (115200);
Serial.println ("Begin");
printMultidimensionalArray (step1_sequence, step1_rows, step1_cols);
}
void loop ()
{
}