suggestions for programming structure and storing of animatronic sequences

So for now I have decided to roll my own simple data format in order to keep the project moving (on another forum, someone had suggested using MIDI as a data format).. I was also concerned about storing cue data in a way that doesn't eat up RAM.

Since I am using an Ardunio Mega with 128 KB of Flash memory I want to use that before resorting to an SD card. With the excellent Flash Library (http://arduiniana.org/libraries/flash/) accessing PROGMEM is very easy and I was able to rough out a test sketch in minutes.

For motor control I am using dedicated motor controller boards using serial comm. Each board controls two motors. For testing, the maximum data size I needed to send was four values: rate, slope, x target, y target in order to make a move so that determines my data format for motors. This will change when I add a timestamp and board ID values.

With the Flash lib, you can define a FLASH_TABLE, store it in PROGMEM and then access it using simple array bracket access. Testing with a couple of thousand entries shows no issues.

So it becomes a simple task of pulling data out and sending it to the standalone boards or using it internally for my LEDs.

// simple example:

    #include <Flash.h>
    
    FLASH_TABLE(int, command_table, 4 /* width of table */, 
        {111, 222, 333, 444},
        {1001, 900, 3210, -4567},
        {1002, 1000, 3210, -4567},
        {1003, 1100, 3210, -4567},
        {666, 777, 888, 999}
        );
         
    void setup() {
        Serial.begin(9600);
        Serial.print("Mem: "); Serial.println(availableMemory());
     
        // Determine the size of the array
        Serial.print("Rows: "); Serial.println(command_table.rows());
        Serial.print("Cols: "); Serial.println(command_table.cols());
        Serial.print("RAM: "); Serial.println(sizeof(command_table));
     
         Serial.print(command_table[8][0]);
         Serial.print("s");
         Serial.print(command_table[8][1]);
         Serial.print("r");
         Serial.print(command_table[8][2]);
         Serial.print("x");
         Serial.print(command_table[8][3]);
         Serial.print("y");
         Serial.println("gi");  
    }
    
    void loop() {
    
     
    }
    
    int availableMemory() 
    {
      int size = 1024;
      byte *buf;
      while ((buf = (byte *) malloc(--size)) == NULL);
      free(buf);
      return size;
    }