I am building a Infrared Remote with Arduino. Each Command for the Infrared transmitter is storred as an array of microsecond delays for a logic signal based on the RC-5 standard.
For example:
// Command #1866: Command:$1865
// Protocol: RC5, Parameters: D=30U F=10U
const uint16_t repeat_Command__1865[] PROGMEM = { 889U, 889U, 1778U, 1778U, 889U, 889U, 889U, 889U, 889U, 889U, 1778U, 889U, 889U, 889U, 889U, 1778U, 1778U, 1778U, 1778U, 65535U };
Because i want to first check which commands work on the devices i want to controll i want to check every available command inside the RC5 standard. Its 5-Bit Address and 6-Bit Commands result in about 2000 Commands i need to check. I generate these commands with a programm called IRScrutinizer which spitts out the microsecond delays when i give it the device Addres (1-15) and the command (1-63). It generates the above code. I have a way to generate all 2000 commands via a script. So what i have is 2000 Arrays named like: repeat_Command_{Number of Command}
As i read now there is no easy way in c++ to access variables by a variable defining the name of a variable.....
So i need to switch case trough all commands inside a for loop like this:
void loop() {
Serial.println(F("Looping trough all Numbers"));
for (int i = 0; i<1983;i++)
{
delay(1000)
}
switch (i) {
case 1L:
sendRaw(repeat_Command_, 24U, 36U);
break;
case 2L:
sendRaw(repeat_Command__1, 22U, 36U);
break;
case 3L:
sendRaw(repeat_Command__2, 24U, 36U);
break;
.
.
.
But this uses to much memory for the Arduino to handle. Since i use Progmem the problem is only the switch case argument.
My idea was to store the commands in a multidimensional array and then accessing each "row" in a forloop.
But how can i do that?
When i try:
const uint16_t commands[1][] PROGMEM = {1,2,3,4};
const uint16_t commands[2][] PROGMEM = {5,6,7,8};
This does not work and i would not expect it to but i dont know my way with array good enough to do that.
I get an error:
declaration of 'commands' as multidimensional array must have bounds for all dimensions except the first
The problem is that the length of each command is not fixed.
Another way would be to genereate the arrays with the microseconds inside the for loop. But this a whole nother logic problem i would like to rather not solve :D