diff options
-rw-r--r-- | .gitignore | 186 | ||||
-rw-r--r-- | arduino/fht_test.ino | 68 | ||||
-rw-r--r-- | visualizer/visualizer.py | 53 |
3 files changed, 307 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..470d88b --- /dev/null +++ b/.gitignore | |||
@@ -0,0 +1,186 @@ | |||
1 | # Created by .ignore support plugin (hsz.mobi) | ||
2 | |||
3 | ### C++ template | ||
4 | # Compiled Object files | ||
5 | *.slo | ||
6 | *.lo | ||
7 | *.o | ||
8 | *.obj | ||
9 | |||
10 | # Precompiled Headers | ||
11 | *.gch | ||
12 | *.pch | ||
13 | |||
14 | # Compiled Dynamic libraries | ||
15 | *.so | ||
16 | *.dylib | ||
17 | *.dll | ||
18 | |||
19 | # Fortran module files | ||
20 | *.mod | ||
21 | |||
22 | # Compiled Static libraries | ||
23 | *.lai | ||
24 | *.la | ||
25 | *.a | ||
26 | *.lib | ||
27 | |||
28 | # Executables | ||
29 | *.exe | ||
30 | *.out | ||
31 | *.app | ||
32 | |||
33 | |||
34 | ### Vim template | ||
35 | [._]*.s[a-w][a-z] | ||
36 | [._]s[a-w][a-z] | ||
37 | *.un~ | ||
38 | Session.vim | ||
39 | .netrwhist | ||
40 | *~ | ||
41 | |||
42 | |||
43 | ### JetBrains template | ||
44 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm | ||
45 | |||
46 | *.iml | ||
47 | |||
48 | ## Directory-based project format: | ||
49 | .idea/ | ||
50 | # if you remove the above rule, at least ignore the following: | ||
51 | |||
52 | # User-specific stuff: | ||
53 | # .idea/workspace.xml | ||
54 | # .idea/tasks.xml | ||
55 | # .idea/dictionaries | ||
56 | |||
57 | # Sensitive or high-churn files: | ||
58 | # .idea/dataSources.ids | ||
59 | # .idea/dataSources.xml | ||
60 | # .idea/sqlDataSources.xml | ||
61 | # .idea/dynamic.xml | ||
62 | # .idea/uiDesigner.xml | ||
63 | |||
64 | # Gradle: | ||
65 | # .idea/gradle.xml | ||
66 | # .idea/libraries | ||
67 | |||
68 | # Mongo Explorer plugin: | ||
69 | # .idea/mongoSettings.xml | ||
70 | |||
71 | ## File-based project format: | ||
72 | *.ipr | ||
73 | *.iws | ||
74 | |||
75 | ## Plugin-specific files: | ||
76 | |||
77 | # IntelliJ | ||
78 | /out/ | ||
79 | |||
80 | # mpeltonen/sbt-idea plugin | ||
81 | .idea_modules/ | ||
82 | |||
83 | # JIRA plugin | ||
84 | atlassian-ide-plugin.xml | ||
85 | |||
86 | # Crashlytics plugin (for Android Studio and IntelliJ) | ||
87 | com_crashlytics_export_strings.xml | ||
88 | crashlytics.properties | ||
89 | crashlytics-build.properties | ||
90 | |||
91 | |||
92 | ### Python template | ||
93 | # Byte-compiled / optimized / DLL files | ||
94 | __pycache__/ | ||
95 | *.py[cod] | ||
96 | |||
97 | # C extensions | ||
98 | *.so | ||
99 | |||
100 | # Distribution / packaging | ||
101 | .Python | ||
102 | env/ | ||
103 | build/ | ||
104 | develop-eggs/ | ||
105 | dist/ | ||
106 | downloads/ | ||
107 | eggs/ | ||
108 | .eggs/ | ||
109 | lib/ | ||
110 | lib64/ | ||
111 | parts/ | ||
112 | sdist/ | ||
113 | var/ | ||
114 | *.egg-info/ | ||
115 | .installed.cfg | ||
116 | *.egg | ||
117 | |||
118 | # PyInstaller | ||
119 | # Usually these files are written by a python script from a template | ||
120 | # before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
121 | *.manifest | ||
122 | *.spec | ||
123 | |||
124 | # Installer logs | ||
125 | pip-log.txt | ||
126 | pip-delete-this-directory.txt | ||
127 | |||
128 | # Unit test / coverage reports | ||
129 | htmlcov/ | ||
130 | .tox/ | ||
131 | .coverage | ||
132 | .coverage.* | ||
133 | .cache | ||
134 | nosetests.xml | ||
135 | coverage.xml | ||
136 | *,cover | ||
137 | |||
138 | # Translations | ||
139 | *.mo | ||
140 | *.pot | ||
141 | |||
142 | # Django stuff: | ||
143 | *.log | ||
144 | |||
145 | # Sphinx documentation | ||
146 | docs/_build/ | ||
147 | |||
148 | # PyBuilder | ||
149 | target/ | ||
150 | |||
151 | |||
152 | ### C template | ||
153 | # Object files | ||
154 | *.o | ||
155 | *.ko | ||
156 | *.obj | ||
157 | *.elf | ||
158 | |||
159 | # Precompiled Headers | ||
160 | *.gch | ||
161 | *.pch | ||
162 | |||
163 | # Libraries | ||
164 | *.lib | ||
165 | *.a | ||
166 | *.la | ||
167 | *.lo | ||
168 | |||
169 | # Shared objects (inc. Windows DLLs) | ||
170 | *.dll | ||
171 | *.so | ||
172 | *.so.* | ||
173 | *.dylib | ||
174 | |||
175 | # Executables | ||
176 | *.exe | ||
177 | *.out | ||
178 | *.app | ||
179 | *.i*86 | ||
180 | *.x86_64 | ||
181 | *.hex | ||
182 | |||
183 | # Debug files | ||
184 | *.dSYM/ | ||
185 | |||
186 | |||
diff --git a/arduino/fht_test.ino b/arduino/fht_test.ino new file mode 100644 index 0000000..0e2f83c --- /dev/null +++ b/arduino/fht_test.ino | |||
@@ -0,0 +1,68 @@ | |||
1 | |||
2 | // FHT Options | ||
3 | #define FHT_N 256 | ||
4 | #define SCALE 256 | ||
5 | #define WINDOW 1 | ||
6 | #define REORDER 1 | ||
7 | #define LOG_OUT 1 | ||
8 | #define LIN_OUT 0 | ||
9 | #define LIN_OUT8 0 | ||
10 | #define OCTAVE 0 | ||
11 | #define OCT_NORM 0 | ||
12 | |||
13 | #define BINS 128 | ||
14 | |||
15 | #include <FHT.h> | ||
16 | |||
17 | void aquire_data() { | ||
18 | noInterrupts(); | ||
19 | |||
20 | for (int i = 0; i < FHT_N; i++) { | ||
21 | while(!(ADCSRA & 0x10)); // wait for adc to be ready | ||
22 | ADCSRA = 0xf5; // restart adc | ||
23 | byte m = ADCL; // fetch adc data | ||
24 | byte j = ADCH; | ||
25 | int k = (j << 8) | m; // form into an int | ||
26 | k -= 0x0200; // form into a signed int | ||
27 | k <<= 6; // form into a 16b signed int | ||
28 | fht_input[i] = k; // put real data into bins | ||
29 | } | ||
30 | |||
31 | interrupts(); | ||
32 | } | ||
33 | |||
34 | void crunch_data() { | ||
35 | fht_window(); | ||
36 | fht_reorder(); | ||
37 | fht_run(); | ||
38 | //fht_mag_octave(); | ||
39 | fht_mag_log(); | ||
40 | } | ||
41 | |||
42 | void setup() { | ||
43 | |||
44 | Serial.begin(115200); | ||
45 | |||
46 | TIMSK0 = 0; // turn off timer0 for lower jitter | ||
47 | ADCSRA = 0xe5; // set the adc to free running mode | ||
48 | ADMUX = 0x40; // use adc0 | ||
49 | DIDR0 = 0x01; // turn off the digital input for adc0 | ||
50 | |||
51 | } | ||
52 | |||
53 | char buf[2550] = ""; | ||
54 | |||
55 | void loop() { | ||
56 | aquire_data(); | ||
57 | crunch_data(); | ||
58 | |||
59 | for (int i = 0; i < BINS; i++) { | ||
60 | Serial.print(fht_log_out[i]); | ||
61 | Serial.print(' '); | ||
62 | } | ||
63 | |||
64 | Serial.print('\n'); | ||
65 | |||
66 | delay(10000); | ||
67 | } | ||
68 | |||
diff --git a/visualizer/visualizer.py b/visualizer/visualizer.py new file mode 100644 index 0000000..ed65384 --- /dev/null +++ b/visualizer/visualizer.py | |||
@@ -0,0 +1,53 @@ | |||
1 | |||
2 | BINS = 128 | ||
3 | |||
4 | |||
5 | import serial | ||
6 | |||
7 | s = serial.Serial("/dev/ttyACM0", 115200) | ||
8 | |||
9 | |||
10 | def acquire_data(): | ||
11 | |||
12 | nb_val = 0 | ||
13 | while nb_val != BINS+1: | ||
14 | l = s.readline() | ||
15 | d = l.decode("utf8") | ||
16 | v = d.split(' ') | ||
17 | nb_val = len(v) | ||
18 | |||
19 | n = [0] * BINS | ||
20 | for i in range(BINS): | ||
21 | try: | ||
22 | n[i |