Skip to content

Commit 8c6518b

Browse files
committed
fix: keyword-spotting
1 parent b70551b commit 8c6518b

File tree

2 files changed

+25
-85
lines changed

2 files changed

+25
-85
lines changed

examples/keyword-spotting/sketch/heart_frames.h

Lines changed: 12 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -4,69 +4,16 @@
44
* SPDX-License-Identifier: MPL-2.0
55
*/
66

7-
const uint32_t LittleHeart[] = {
8-
0x20360000,
9-
0x11010409,
10-
0x100140,
11-
0x0
7+
const uint32_t HeartStatic[4] = {0x00006c04, 0x90208088, 0x02800800,
8+
0x00000000};
9+
10+
const uint32_t HeartAnim[][5] = {
11+
{0x1dc11108, 0x08404104, 0x04401400, 0x40000000, 55}, // 1
12+
{0x3fe31198, 0x0cc06306, 0x0c603600, 0xe0000000, 55}, // 2
13+
{0x3fe31198, 0x0cc06306, 0x0c603600, 0xe0000000, 55}, // 3
14+
{0x7ff711f8, 0x0fc07707, 0x1c707701, 0xf0000000, 55}, // 4
15+
{0xffff11f8, 0x0fc07f07, 0xbc78f783, 0xf8000000, 55}, // 5
16+
{0xffff11f8, 0x0fc07f07, 0xfc7ff7ef, 0xfe000000, 55}, // 6
17+
{0xffff11f8, 0x0fc07f07, 0xfc7ff7ff, 0xff000000, 55}, // 7
18+
{0xffff11f8, 0x0fc07f07, 0xfc7ff7ff, 0xff000000, 55} // 8
1219
};
13-
14-
const uint32_t* HeartStatic[] = { LittleHeart };
15-
16-
const uint32_t Heart1[] = {
17-
0x108883b8,
18-
0x20820210,
19-
0x280220,
20-
0x2
21-
};
22-
23-
const uint32_t Heart2[] = {
24-
0x1988c7fc,
25-
0x60c60330,
26-
0x6c0630,
27-
0x7
28-
};
29-
30-
const uint32_t Heart3[] = {
31-
0x1988c7fc,
32-
0x60c60330,
33-
0x6c0630,
34-
0x7
35-
};
36-
37-
const uint32_t Heart4[] = {
38-
0x1f88effe,
39-
0xe0ee03f0,
40-
0x80ee0e38,
41-
0xf
42-
};
43-
44-
const uint32_t Heart5[] = {
45-
0x1f88ffff,
46-
0xe0fe03f0,
47-
0xc1ef1e3d,
48-
0x1f
49-
};
50-
51-
const uint32_t Heart6[] = {
52-
0x1f88ffff,
53-
0xe0fe03f0,
54-
0xf7effe3f,
55-
0x7f
56-
};
57-
58-
const uint32_t Heart7[] = {
59-
0x1f88ffff,
60-
0xe0fe03f0,
61-
0xffeffe3f,
62-
0xff
63-
};
64-
65-
const uint32_t Heart8[] = {
66-
0x1f88ffff,
67-
0xe0fe03f0,
68-
0xffeffe3f,
69-
0xff
70-
};
71-
72-
const uint32_t* HeartAnim[] = { Heart1, Heart2, Heart3, Heart4, Heart5, Heart6, Heart7, Heart8 };

examples/keyword-spotting/sketch/sketch.ino

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,33 @@
22
//
33
// SPDX-License-Identifier: MPL-2.0
44

5+
#include <Arduino_LED_Matrix.h>
56
#include <Arduino_RouterBridge.h>
7+
68
#include "heart_frames.h"
79

8-
// TODO: those will go into an header file.
9-
extern "C" void matrixWrite(const uint32_t* buf);
10-
extern "C" void matrixBegin();
10+
Arduino_LED_Matrix matrix;
1111

1212
bool awake = false;
1313

1414
void setup() {
15-
matrixBegin();
16-
playAnimation(HeartStatic, 1, 1, 2000);
15+
matrix.begin();
16+
matrix.clear();
17+
18+
matrix.loadFrame(HeartStatic);
19+
1720
Bridge.begin();
18-
Bridge.provide("keyword_detected", wake_up);
21+
Bridge.provide("keyword_detected", wake_up);
1922
}
2023

2124
void loop() {
2225
if (awake) {
23-
playAnimation(HeartAnim, 8, 1, 50);
26+
matrix.loadSequence(HeartAnim);
27+
matrix.playSequence();
2428
delay(1000);
25-
playAnimation(HeartStatic, 1, 1, 2000);
29+
matrix.loadFrame(HeartStatic);
2630
awake = false;
2731
}
2832
}
2933

30-
void playAnimation(const uint32_t* frames[], int frameCount, int repeat, int frameDelay) {
31-
for (int r = 0; r < repeat; r++) {
32-
for (int i = 0; i < frameCount; i++) {
33-
matrixWrite(frames[i]);
34-
delay(frameDelay);
35-
}
36-
}
37-
}
38-
39-
void wake_up() {
40-
awake = true;
41-
}
34+
void wake_up() { awake = true; }

0 commit comments

Comments
 (0)