-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.py
More file actions
32 lines (26 loc) · 1.03 KB
/
test.py
File metadata and controls
32 lines (26 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import time
import statistics
import math
import emlib
import spidev
# Settings
ADC_SAMPLESPERWAVE = 16 # If set to more then 400 with one channel, the code can't keep up, so that is about the max samples per wave
ADC_ACWAVESTOREAD = 50
AC_FREQUENCY = 50
CHANNELS = [7]
# Create the reader
reader = emlib.AdcReader()
while(True):
print(time.perf_counter())
### Read the channels
data = reader.readSineWave(CHANNELS, ADC_SAMPLESPERWAVE, ADC_ACWAVESTOREAD, AC_FREQUENCY)
for i in range(len(data[0])):
line = []
for channeldataidx in range(len(data)):
line.append(data[channeldataidx][i])
print(';'.join(str(x) for x in line))
### Normalize the captured data
for i in range(len(data)):
#print("Channel {} before normalize: Reads: {}, Min: {}, Max: {}".format(i,len(data[i]),min(data[i]),max(data[i])))
data[i] = emlib.normalize(data[i])
#print("Channel {} after normalize: Reads: {}, Min: {}, Max: {}".format(i,len(data[i]),min(data[i]),max(data[i])))