Skip to content

Commit 27d10a5

Browse files
committed
Add findSomething function
1 parent cdfa2fe commit 27d10a5

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

SampleProjects/DoSomething/do-something.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,19 @@ int doSomething(void) {
44
millis(); // this line is only here to test that we're able to refer to the builtins
55
return 4;
66
};
7+
8+
static const struct something table[] = {
9+
{ 1, "abc" },
10+
{ 2, "xyz" },
11+
{ 4, "123" },
12+
};
13+
14+
const struct something *findSomething(int id) {
15+
for (unsigned int i = 0; i < 3; i++) {
16+
if (table[i].id == id) {
17+
return &table[i];
18+
}
19+
}
20+
return nullptr;
21+
}
22+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
11
#pragma once
22
#include <Arduino.h>
33
int doSomething(void);
4+
5+
struct something {
6+
int id;
7+
const char *text;
8+
};
9+
10+
const struct something *findSomething(int id);
11+

0 commit comments

Comments
 (0)