/*
byte lista[2][4] = {{1,2,3,4}, {5,6,7,8}};
byte qnt_valores = sizeof(lista)/sizeof(lista[0]); // tamanho total de todos os itens / tamanho do primeiro item
void setup()
{
Serial.begin(9600);
Serial.println("Qnt quartetos: " + String(qnt_valores));
DynamicList();
}
void loop(){}
void DynamicList() // global lista
{
// create new_list with new size
byte novo_tamanho = qnt_valores + 1;
byte nova_lista[novo_tamanho][4];
// Assign each value from the original array to the new_list
for (byte i = 0; i < qnt_valores; i++)
{
for (byte j = 0; j < 4; j++)
{
nova_lista[i][j] = lista[i][j];
}
}
// Assign new values
for (byte j = 0; j < 4; j++)
{
nova_lista[novo_tamanho-1][j] = j +9;
}
PrintRecursivoLista(nova_lista, novo_tamanho);
}
void PrintRecursivoLista(byte lista[][4], byte tamanho)
{
for (byte i = 0; i < tamanho; i++)
{
Serial.print("{");
for (byte j = 0; j < 4; j++)
{
Serial.print(String(lista[i][j]) + ",");
}
Serial.println("},");
}
}
// Obj.: Variable size list
// 1. Declare array
// 2. Copy array into other array of larger size
// 3. Add new values
// obs.: can't free up bytes used by original array nor each different array created
*/
// #include <vector>
void setup()
{
Serial.begin(9600);
std::vector<std::array<byte, 4>> lista = {{ {1,2,3,4}, {5,6,7,8} }};
Serial.println(lista[1][3]);
Serial.println(lista[2][3]);
lista.push_back({9,10,11,12});
Serial.println(lista[2][3]);
}
void loop(){delay(9999);}