因此,现在我决定推出我自己的简单数据格式,以保持项目移动。我还担心存储提示数据的方式不会占用内存。
因为我使用的是128KB闪存的Ardunio Mega,我想在使用SD卡之前使用它。使用优秀的Flash Library访问PROGMEM非常简单,我可以在几分钟内完成测试草图。
对于电机控制,我使用专用电机控制器板使用串行通信。每个电路板控制两个电机。为了测试我需要发送的最大数据量是四个值:速率,斜率,x目标,y目标,以便进行移动以便确定我的电机数据格式。当我添加时间戳和电路板ID值时,这将会改变。
使用Flash lib,您可以定义FLASH_TABLE,将其存储在PROGMEM中,然后使用简单的数组括号访问它。用几千个条目进行测试显示没有问题。
因此,它成为一个简单的任务,将数据拉出并发送到独立主板或在内部使用。
//简单的例子:
#include <Flash.h>
FLASH_TABLE(int, command_table, 4 /* width of table */,
{111, 222, 333, 444},
{1001, 900,, -4567},
{1002, 1000,, -4567},
{1003, 1100,, -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;
}
MIDI格式是通常用于这类非音乐数据的(AB)。 (剧院照明等)也许你也可以将它用于你的机器人芭蕾。 MIDI是极其轻便的存储大小,并且相对容易解析。 – wildplasser
@wildplasser - 有趣,谢谢。我也看过MIDI ab /用于这个,但那完全没有发生在我身上。 –
它具有内置的核心功能:定时,提示/同步,多个声音/通道。 (IIRC循环/重复稍后添加)。 – wildplasser