Last active
November 18, 2017 16:55
-
-
Save pabloariasmora/7993d24d69313952c9a4203e9bd2160a to your computer and use it in GitHub Desktop.
test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
int raw_data[1024]; | |
int filt_data[1024]; | |
int out_data[1024]; | |
int idx = 0; | |
//P1 grab samples | |
for (i=0; i<1023; i++){ | |
raw_data[i] = ReadADC(); | |
} | |
//P2 digital filtering | |
for (i=1; i<1023; i++){ | |
filt_data[i] = (raw_data[i] + raw_data[i-1])/2; | |
} | |
filt_data[0] = raw_data[0]; | |
//P3 maximum detection | |
out = filt_data[0]; | |
for (i=1; i<1023; i++){ | |
if(filt_data[i] > filt_data[i-1]) | |
out = filt_data[i]; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from queue import Queue | |
from threading import Thread | |
ak = Queue() | |
bk = Queue() | |
ck = Queue() | |
dk = Queue() | |
ek = Queue() | |
fk = Queue() | |
out = [] | |
def sort(): | |
while True: | |
a = ak.get() | |
if not a == 0: | |
ck.put(a) | |
bk.put(a) | |
ak.task_done() | |
def acc(): | |
acc = 0 | |
while True: | |
b = bk.get() | |
if b == 0: | |
acc += 1 | |
else: | |
dk.put(acc) | |
acc = 0 | |
bk.task_done() | |
def join(): | |
while True: | |
d = dk.get() | |
c = ck.get() | |
ek.put(d) | |
ek.put(c) | |
dk.task_done() | |
ck.task_done() | |
def show(): | |
while True: | |
e = ek.get() | |
out.append(e) | |
print (e) | |
ek.task_done() | |
#in_list = [0,0,0,-1,255,3] | |
in_list = [1,2,3] | |
# in_list = [0,0,1,0,3] | |
print ("in={}".format(in_list)) | |
for data in in_list: | |
ak.put(data) | |
t = Thread(target=sort) | |
t.daemon = True | |
t.start() | |
t2 = Thread(target=acc) | |
t2.daemon = True | |
t2.start() | |
t3 = Thread(target=join) | |
t3.daemon = True | |
t3.start() | |
t4 = Thread(target=show) | |
t4.daemon = True | |
t4.start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment