Skip to content

Instantly share code, notes, and snippets.

@davidwhitney
Created November 12, 2019 22:42
Show Gist options
  • Save davidwhitney/ad694616673e61eaaeb3e482768b5c97 to your computer and use it in GitHub Desktop.
Save davidwhitney/ad694616673e61eaaeb3e482768b5c97 to your computer and use it in GitHub Desktop.
typedef struct {
const char* key;
int value[100];
} key_value_pair;
const auto empty = new key_value_pair();
key_value_pair images[] {
{"snowman", {1, 2, 3, 4, 5} },
{"pig", {5, 2, 4, 5, 6} }
};
key_value_pair* value_for(const char* key) {
for (auto i = 0; i < sizeof images; i++){
if (images[i].key != key) { continue; }
return &images[i];
}
return empty;
}
void print_bytes() {
auto kvp = value_for("pig");
for (auto i = 0; i < 100; i++) {
Serial.print(kvp->value[i]);
}
}
@davidwhitney
Copy link
Author

For Arduino

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment