You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -81,20 +81,271 @@ The Modulino are daisy-chained leveraging the Qwiic I2C connection with the Nano
81
81
82
82
### Programming
83
83
84
+
Let's go through some important code sections to make this project fully operational, starting with the Protocol Stack setting and required libraries:
85
+
84
86
In the Arduino IDE upper menu, after selecting the **Nano Matter board** from the Silicon Labs core, navigate to **Tools > Protocol stack** and select **None**.
85
87
86
88

87
89
88
90
***The code will only compile if the Protocol Stack is set to None.***
89
91
90
-
You can download the complete project code from [here](assets/magic_wand_modulino.zip).
91
-
92
-
Let's go through some important code sections to make this application fully operational, starting with the required libraries:
93
-
94
92
Download the `Modulino.h` library from the Arduino IDE Library Manager. This will enable the support for the Modulino Pixels and the Modulino Movement.
case NO_GESTURE: Serial.print("No gesture"); break;
245
+
}
246
+
Serial.print(": ");
247
+
Serial.print(interpreter->output(0)->data.f[i]);
248
+
Serial.println();
249
+
if (output->gesture[i] > max_val) {
250
+
max_val = output->gesture[i];
251
+
max_i = i;
252
+
}
253
+
}
254
+
255
+
// Print the graphical representation of the recognized gesture
256
+
if (max_val >= DETECTION_THRESHOLD) {
257
+
switch(max_i) {
258
+
case WING_GESTURE:
259
+
Serial.println("detection = wing (W)");
260
+
Serial.println("* *");
261
+
Serial.println("* *");
262
+
Serial.println("* * *");
263
+
Serial.println(" * * * * ");
264
+
Serial.println(" * * ");
265
+
266
+
// Green leds for W gesture
267
+
for (int i = 0; i < 10; i++) {
268
+
for (int j = 0; j < 8; j++) {
269
+
setPixel(j, GREEN);
270
+
}
271
+
delay(200);
272
+
273
+
for (int j = 0; j < 8; j++) {
274
+
setPixel(j, OFF);
275
+
}
276
+
delay(200);
277
+
}
278
+
break;
279
+
case RING_GESTURE:
280
+
Serial.println("detection = ring (O)");
281
+
Serial.println(" ***** ");
282
+
Serial.println(" * * ");
283
+
Serial.println("* *");
284
+
Serial.println(" * * ");
285
+
Serial.println(" ***** ");
286
+
287
+
// Yellow leds for O gesture
288
+
for (int i = 0; i < 10; i++) {
289
+
for (int j = 0; j < 8; j++) {
290
+
setPixel(j, YELLOW);
291
+
}
292
+
delay(200);
293
+
294
+
for (int j = 0; j < 8; j++) {
295
+
setPixel(j, OFF);
296
+
}
297
+
delay(200);
298
+
}
299
+
break;
300
+
case NO_GESTURE:
301
+
Serial.println("No gesture");
302
+
break;
303
+
}
304
+
}
305
+
306
+
// reset LEDs to steady state (blue)
307
+
for (int i = 0; i < 8; i++) {
308
+
setPixel(i, BLUE);
309
+
}
310
+
} else {
311
+
printf("error: inference failed");
312
+
}
313
+
}
314
+
315
+
bool accelerometer_setup() {
316
+
Modulino.begin();
317
+
bool status = imu.begin();
318
+
319
+
return status;
320
+
}
321
+
322
+
void accelerometer_read(acc_data_t* dst, int n) {
323
+
int i = 0;
324
+
325
+
while (i < n) {
326
+
uint8_t acceleroStatus;
327
+
acceleroStatus = imu.available();
328
+
329
+
if (acceleroStatus == 1) {
330
+
float acceleration[3];
331
+
332
+
imu.update();
333
+
334
+
acceleration[0] = imu.getX();
335
+
acceleration[1] = imu.getY();
336
+
acceleration[2] = imu.getZ();
337
+
338
+
dst[i] = (acceleration[0]*1000+4000)/8000;
339
+
dst[i+1] = (acceleration[1]*1000+4000)/8000;
340
+
dst[i+2] = (acceleration[2]*1000+4000)/8000;
341
+
342
+
i+=SIGNAL_CHANNELS;
343
+
}
344
+
}
345
+
}
346
+
```
347
+
***Be aware that your sketch needs the model header `sl_tflite_micro_model.c` that is included in the [complete code download file](assets/magic_wand_modulino.zip).***
348
+
98
349
After the libraries import, several variables and structures are declared that has to be with the Machine Learning implementation:
0 commit comments