Skip to content

Commit 497ecae

Browse files
committed
update files
1 parent 9ee6b97 commit 497ecae

File tree

205 files changed

+57293
-94
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

205 files changed

+57293
-94
lines changed

arc_design_contest/2021/HLJU_Pathological_Voice_Diagnosis/src/CppAddWrapper.h

Lines changed: 0 additions & 11 deletions
This file was deleted.

arc_design_contest/2021/HLJU_Pathological_Voice_Diagnosis/src/FFT.c renamed to arc_design_contest/2021/HLJU_Pathological_Voice_Diagnosis/src/FFT.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ unsigned char fftx(Complex *d,int m)
124124
*di = temp;
125125
}
126126
}
127+
127128
return 1;
128129
}
129130

arc_design_contest/2021/HLJU_Pathological_Voice_Diagnosis/src/main.c renamed to arc_design_contest/2021/HLJU_Pathological_Voice_Diagnosis/src/main.cc

Lines changed: 59 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,15 @@
3434
/* middleware level*/
3535
#include "u8g.h"
3636

37+
extern "C" {
3738
#include "wm8978.h"
3839
#include "wm8978i2s.h"
40+
}
3941
#include "codec.h"
4042
#include "mfcc.h"
4143

4244
#include <stdlib.h>
43-
#include "CppAddWrapper.h"
45+
#include "tensorflow/lite/micro/examples/voice_detection_experimental/main_functions.h"
4446

4547
u8g_t u8g;
4648

@@ -51,86 +53,35 @@ void u8g_prepare(void) {
5153
u8g_SetFontPosTop(&u8g); /* set the reference position for the character and string draw procedure */
5254
}
5355

54-
/** first page in OLED */
55-
void u8g_box_frame(uint8_t a) {
56-
//u8g_DrawStr(&u8g, 0, 0, "hello lnmm haha!"); /* draws a string at the specified x/y position */
57-
u8g_DrawStr(&u8g, 0, 0, "hello Heathy");
58-
//u8g_DrawBox(&u8g, 5,10,20,10); /* draw a box (filled frame), starting at x/y position (upper left edge) */
59-
//u8g_DrawBox(&u8g, 10+a,15,30,7);
60-
//u8g_DrawStr(&u8g, 0, 30, "drawFrame");
61-
//u8g_DrawFrame(&u8g, 5,10+30,20,10); /* draw a frame, starting at x/y position (upper left edge) */
62-
//u8g_DrawFrame(&u8g, 10+a,15+30,30,7);
63-
}
64-
65-
/** second page in OLED */
66-
void u8g_string(uint8_t a) {
67-
u8g_DrawStr(&u8g, 30+a,31, " 0");
68-
u8g_DrawStr90(&u8g, 30,31+a, " 90"); /* rotate string output by 90 degree */
69-
u8g_DrawStr180(&u8g, 30-a,31, " 180"); /* rotate string output by 180 degree */
70-
u8g_DrawStr270(&u8g, 30,31-a, " 270"); /* rotate string output by 270 degree */
71-
}
72-
73-
/** third page in OLED */
74-
void u8g_line(uint8_t a) {
75-
u8g_DrawStr(&u8g, 0, 0, "drawLine");
76-
u8g_DrawLine(&u8g, 7+a, 10, 40, 55); /* draw a line from (x1, y1) to (x2, y2) */
77-
u8g_DrawLine(&u8g, 7+a*2, 10, 60, 55);
78-
u8g_DrawLine(&u8g, 7+a*3, 10, 80, 55);
79-
u8g_DrawLine(&u8g, 7+a*4, 10, 100, 55);
56+
void u8g_box_frame_path() {
57+
u8g_DrawStr(&u8g, 20, 20, "Detection Result:"); /* draws a string at the specified x/y position */
58+
u8g_DrawStr(&u8g, 30, 40, "Pathological");
8059
}
8160

82-
/** forth page in OLED */
83-
void u8g_ascii_1(void) {
84-
char s[2] = " ";
85-
uint8_t x, y;
86-
u8g_DrawStr(&u8g, 0, 0, "ASCII page 1");
87-
for( y = 0; y < 6; y++ ) {
88-
for( x = 0; x < 16; x++ ) {
89-
s[0] = y*16 + x + 32;
90-
u8g_DrawStr(&u8g, x*7, y*10+10, s);
91-
}
92-
}
61+
void u8g_box_frame_heal() {
62+
u8g_DrawStr(&u8g, 20, 20, "Detection Result:"); /* draws a string at the specified x/y position */
63+
u8g_DrawStr(&u8g, 45, 40, "Healthy");
9364
}
9465

95-
/** fifth page in OLED */
96-
void u8g_ascii_2(void) {
97-
char s[2] = " ";
98-
uint8_t x, y;
99-
u8g_DrawStr(&u8g, 0, 0, "ASCII page 2");
100-
for( y = 0; y < 6; y++ ) {
101-
for( x = 0; x < 16; x++ ) {
102-
s[0] = y*16 + x + 160;
103-
u8g_DrawStr(&u8g, x*7, y*10+10, s);
104-
}
105-
}
66+
/** draw five pages in OLED */
67+
void draw_path() {
68+
u8g_prepare();
69+
u8g_box_frame_path();
10670
}
10771

108-
uint8_t draw_state = 0;
109-
110-
/** draw five pages in OLED */
111-
void draw(void) {
72+
void draw_heal() {
11273
u8g_prepare();
113-
switch(draw_state >> 3) {
114-
case 0: u8g_box_frame(draw_state&7); break;
115-
//case 1: u8g_string(draw_state&7); break;
116-
//case 2: u8g_line(draw_state&7); break;
117-
//case 3: u8g_ascii_1(); break;
118-
//case 4: u8g_ascii_2(); break;
119-
}
74+
u8g_box_frame_heal();
12075
}
12176

122-
//extern DEV_BUFFER rx_buffer;
123-
//static MFCC_STR mfcc_str;
77+
static MFCC_STR mfcc_str;
12478

12579
void run_mic(MFCC_STR* mfcc_str, int8_t* mfcc_buffer)
12680
{
127-
mfcc_init(mfcc_str, NUM_MFCC_COEFFS, FRAME_LEN, MFCC_DEC_BITS);
128-
129-
//printf("mfcc init\n");
130-
81+
13182
wm8978_init_func();//Config the WM8978 through I2C.
13283

133-
//printf("wm8978_init_func init\n");
84+
printf("wm8978_init_func init\n");
13485

13586
int16_t* rx_buffer1 = (int16_t*)malloc(sizeof(int16_t) * 640*18);
13687

@@ -145,57 +96,82 @@ void run_mic(MFCC_STR* mfcc_str, int8_t* mfcc_buffer)
14596
printf("The audio_buf malloc failed\n");
14697
}
14798

148-
//printf("codec init\n");
99+
printf("codec init\n");
149100

150101
CODEC_init(audio_buf, rx_buffer1);//Start I2S transfer and interrupts.
151102

152-
//printf("codec end\n");
103+
printf("codec end\n");
153104

154105
extract_features(mfcc_str, audio_buf, mfcc_buffer);
155106

156-
//for(int i = 0; i < NUM_FRAMES * NUM_MFCC_COEFFS; i++)
157-
// printf("%d ", mfcc_buffer[i]);
158-
//printf("\n");
107+
for(int i = 0; i < NUM_FRAMES * NUM_MFCC_COEFFS; i++)
108+
printf("%d ", mfcc_buffer[i]);
109+
printf("\n");
159110

160111

161112
free(rx_buffer1);
162113
free(audio_buf);
163-
164114
}
165115

166-
void run_oled()
116+
void oled_init()
167117
{
168118
EMBARC_PRINTF("oled init\n");
169119
u8g_InitComFn(&u8g, &u8g_dev_ssd1306_128x64_2x_i2c, U8G_COM_SSD_I2C);
170120
//EMBARC_PRINTF("u8glib\r\n");
171121
EMBARC_PRINTF("Display Width: %u, Display Height: %u\r\n" , u8g_GetWidth(&u8g), u8g_GetHeight(&u8g));
172122
u8g_Begin(&u8g);
173123

124+
}
174125

175-
printf("draw oled\n");
126+
void show_pathological_result()
127+
{
176128
u8g_FirstPage(&u8g);
177-
do {
178-
draw();
129+
do
130+
{
131+
draw_path();
179132
} while (u8g_NextPage(&u8g));
180133

181134
}
182135

136+
void show_healthy_result()
137+
{
138+
u8g_FirstPage(&u8g);
139+
do
140+
{
141+
draw_heal();
142+
} while (u8g_NextPage(&u8g));
143+
144+
}
145+
146+
183147
/** main entry for running ntshell */
184148
int main(void)
185-
{
149+
{
150+
151+
mfcc_init(&mfcc_str, NUM_MFCC_COEFFS, FRAME_LEN, MFCC_DEC_BITS);
152+
printf("mfcc init\n");
153+
186154
int8_t* mfcc_buffer = (int8_t*)malloc(sizeof(int8_t) * NUM_FRAMES * NUM_MFCC_COEFFS);
187155
if (mfcc_buffer == NULL)
188156
{
189157
printf("The mfcc_buffer malloc failed\n");
190158
}
191159

192-
MFCC_STR mfcc_str;
193-
194-
cppsetup();
195160
run_mic(&mfcc_str, mfcc_buffer);
196161

197-
cpploop(mfcc_buffer);
198-
run_oled();
162+
int result = run_model(mfcc_buffer);
163+
164+
printf("result = %d\n", result);
165+
166+
oled_init();
167+
168+
if(result == 1 )
169+
{
170+
show_pathological_result();
171+
}else if(result == 0)
172+
{
173+
show_healthy_result();
174+
}
199175

200176
free(mfcc_buffer);
201177

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Application name
2+
APPL ?= graphic_u8glib
3+
4+
#
5+
# root dir of embARC
6+
#
7+
EMBARC_ROOT = ../../..
8+
9+
LIB_SEL = embarc_mli
10+
11+
MID_SEL = common u8glib
12+
13+
# application source dirs
14+
APPL_CSRC_DIR = . \
15+
tensorflow/lite/c
16+
17+
APPL_ASMSRC_DIR = .
18+
19+
APPL_CXXSRC_DIR = . \
20+
tensorflow/lite/core/api \
21+
tensorflow/lite/kernels \
22+
tensorflow/lite/kernels/internal \
23+
tensorflow/lite/micro \
24+
tensorflow/lite/micro/arc_iotdk \
25+
tensorflow/lite/micro/kernels \
26+
tensorflow/lite/micro/kernels/arc_mli \
27+
tensorflow/lite/micro/memory_planner \
28+
tensorflow/lite/micro/testing \
29+
tensorflow/lite/micro/tools/make/downloads/person_model_int8 \
30+
tensorflow/lite/micro/examples/voice_detection_experimental \
31+
32+
# application include dirs
33+
APPL_INC_DIR = . \
34+
tensorflow/lite \
35+
tensorflow/lite/c \
36+
tensorflow/lite/core/api \
37+
tensorflow/lite/micro/examples/voice_detection_experimental \
38+
tensorflow/lite/kernels \
39+
tensorflow/lite/kernels/internal \
40+
tensorflow/lite/micro \
41+
tensorflow/lite/micro/kernels \
42+
tensorflow/lite/micro/kernels/arc_mli \
43+
tensorflow/lite/micro/memory_planner \
44+
tensorflow/lite/micro/testing \
45+
tensorflow/lite/schema \
46+
third_party/arc_mli_iotdk_arcem9d/include \
47+
third_party/arc_mli_iotdk_arcem9d/include/api \
48+
third_party/flatbuffers/include \
49+
third_party/flatbuffers/include/flatbuffers \
50+
third_party/gemmlowp \
51+
third_party/gemmlowp/fixedpoint \
52+
third_party/gemmlowp/internal \
53+
third_party/kissfft \
54+
third_party/ruy
55+
56+
# application library
57+
APPL_LIBS ?= third_party/arc_mli_iotdk_arcem9d/bin/libmli.a
58+
59+
# include current project makefile
60+
COMMON_COMPILE_PREREQUISITES += makefile
61+
62+
### Options above must be added before include options.mk ###
63+
# include key embARC build system makefile
64+
include $(EMBARC_ROOT)/options/options.mk

0 commit comments

Comments
 (0)