看起来像
ArduinoSTL 1.1.0
不包括
unordered_map
map
这样地。
-
下载Arduino STL ZIP文件并将其放在好的地方
-
然后就可以编译了,尽管有很多关于未使用变量的STL警告。
#include <ArduinoSTL.h>
#include <iostream>
#include <string>
#include <map>
struct key_entry {
std::string name;
std::string down;
std::string up;
key_entry() : name(), down(), up() {}
key_entry(const std::string& n, const std::string& d, const std::string& u) :
name(n),
down(d),
up(u)
{}
};
using keydict = std::map<unsigned int, key_entry>;
keydict kd = {
{0x28, {"KEY_ENTER", "\x5a", "\xf0\x5a"}},
{0x29, {"KEY_ESC", "\x76", "\xf0\x76"}}
};
void setup() {
Serial.begin( 115200 );
}
void loop() {
auto& a = kd[0x29];
// use a.down or a.up (or a.name for debugging)
Serial.write(a.up.c_str(), a.up.size());
}