Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5527a4b

Browse files
fix Morse Identification Example
1 parent a3b3f8e commit 5527a4b

File tree

5 files changed

+45
-48
lines changed

5 files changed

+45
-48
lines changed

‎.idea/workspace.xml‎

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎examples/MicromlColorIdentificationExample/MicromlColorIdentificationExample.ino‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// uncomment when you have a model.h
22
// to tun the classification
3-
//#define CLASSIFY
3+
//#define CLASSIFY
44

55
#define S2 2
66
#define S3 3
Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,52 @@
1+
// uncomment when you have a model.h
2+
// to tun the classification
3+
// #define CLASSIFY
4+
15
#define IN 4
26
#define NUM_SAMPLES 30
37
#define INTERVAL 100
48

5-
69
double features[NUM_SAMPLES];
710

11+
#if defined(CLASSIFY)
12+
#include "model.h"
13+
14+
void classify() {
15+
Serial.print("Detected letter: ");
16+
Serial.println(classIdxToName(predict(features)));
17+
}
18+
#endif
19+
20+
void setup() {
21+
Serial.begin(115200);
22+
pinMode(IN, INPUT_PULLUP);
23+
}
24+
25+
void loop() {
26+
if (digitalRead(IN) == 0) {
27+
recordButtonStatus();
28+
printFeatures();
29+
#if defined(CLASSIFY)
30+
classify();
31+
#endif
32+
delay(1000);
33+
}
34+
35+
delay(10);
36+
}
37+
38+
void printFeatures() {
39+
const uint16_t numFeatures = sizeof(features) / sizeof(double);
40+
41+
for (int i = 0; i < numFeatures; i++) {
42+
Serial.print(features[i]);
43+
Serial.print(i == numFeatures - 1 ? '\n' : ',');
44+
}
45+
}
846

947
void recordButtonStatus() {
1048
for (int i = 0; i < NUM_SAMPLES; i++) {
1149
features[i] = digitalRead(IN);
1250
delay(INTERVAL);
1351
}
14-
}
15-
16-
#include "record.h"
17-
//#include "classify.h"
52+
}

‎examples/MicromlMorseIdentificationExample/classify.h‎

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,3 @@
11
void printFeatures();
22

33

4-
void setup() {
5-
Serial.begin(115200);
6-
pinMode(IN, INPUT_PULLUP);
7-
}
8-
9-
void loop() {
10-
if (digitalRead(IN) == 0) {
11-
recordButtonStatus();
12-
printFeatures();
13-
delay(1000);
14-
}
15-
16-
delay(10);
17-
}
18-
19-
void printFeatures() {
20-
const uint16_t numFeatures = sizeof(features) / sizeof(double);
21-
22-
for (int i = 0; i < numFeatures; i++) {
23-
Serial.print(features[i]);
24-
Serial.print(i == numFeatures - 1 ? '\n' : ',');
25-
}
26-
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /