raspberry
This commit is contained in:
1 parent
84dfdf5210
commit
be436085b3
55 files changed
+2195
No files matched your search
@@ -0,0 +1,29 @@
|
||||
from RPi import GPIO
|
||||
import time, argparse
|
||||
import numpy as np
|
||||
parser = argparse.ArgumentParser(description='Analyze RF signal for Nexa codes')
|
||||
parser.add_argument('-g', dest='gpio', type=int, default=27, help='GPIO pin (Default: 27)')
|
||||
parser.add_argument('-s', dest='secs', type=int, default=3, help='Seconds to record (Default: 3)')
|
||||
parser.add_argument('--raw', dest='raw', action='store_true', default=False, help='Output raw samples')
|
||||
parser.add_argument('-f', dest='file',default="data.npy", help='Data file (Default: data.npy)')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
times = []
|
||||
|
||||
GPIO.setmode(GPIO.BCM)
|
||||
GPIO.setup(args.gpio, GPIO.IN)
|
||||
GPIO.add_event_detect(args.gpio, GPIO.BOTH,
|
||||
callback=lambda ch: times.append(time.perf_counter_ns()//1000))
|
||||
|
||||
time.sleep(args.secs)
|
||||
GPIO.remove_event_detect(args.gpio)
|
||||
GPIO.cleanup()
|
||||
|
||||
# Calculate difference between consecutive times
|
||||
diff = [b-a for a,b in zip(times, times[1:])]
|
||||
|
||||
|
||||
np.save(args.file, diff)
|
||||
if args.raw: # Print a raw dump
|
||||
for d in diff: print(d, end='\n' if d>5e3 else ' ')
|
||||
Reference in new issue
Block a user