summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--liboctopus/python/.gitignore1
-rw-r--r--liboctopus/python/demos/adc.py10
-rw-r--r--liboctopus/python/demos/reader/test.py27
-rw-r--r--liboctopus/python/demos/reader/test.py~0
4 files changed, 35 insertions, 3 deletions
diff --git a/liboctopus/python/.gitignore b/liboctopus/python/.gitignore
index 5b2c896..0a2eedb 100644
--- a/liboctopus/python/.gitignore
+++ b/liboctopus/python/.gitignore
@@ -1,2 +1,3 @@
octopus.py
octopus_wrap.c
+*.pyc
diff --git a/liboctopus/python/demos/adc.py b/liboctopus/python/demos/adc.py
index 5e55ab7..338eea9 100644
--- a/liboctopus/python/demos/adc.py
+++ b/liboctopus/python/demos/adc.py
@@ -10,10 +10,14 @@ octopus_open(op)
octopus_adc_init(op, 33)
octopus_adc_ref(op, 2)
+
+ADC_REV_MV = 5000
while 1:
value = octopus_adc_get(op, 33)
- callin = "Value %i" % value
- print callin
- time.sleep(1)
+ value_mv = ((ADC_REV_MV/1024.0) * value) / 4.0
+ value_dba = value_mv / 10
+ print "value={0}, {1}mV, {2}dbA".format(value, value_mv, value_dba)
+
+ time.sleep(0.4)
diff --git a/liboctopus/python/demos/reader/test.py b/liboctopus/python/demos/reader/test.py
new file mode 100644
index 0000000..7ecdec0
--- /dev/null
+++ b/liboctopus/python/demos/reader/test.py
@@ -0,0 +1,27 @@
+#!/usr/bin/env python
+import time
+import numpy as np
+from octopus import *
+
+
+op=octopus_context()
+octopus_init(op)
+octopus_open(op)
+octopus_adc_init(op, 33)
+octopus_adc_ref(op, 2)
+
+
+
+buf = []
+for i in range(200):
+ buf.append( octopus_adc_get(op, 33) )
+ time.sleep(0.01)
+ print i, buf[-1]
+
+signal = np.array(buf)
+fourier = np.fft.fft(signal)
+n = signal.size
+freq = np.fft.fftfreq(n, 0.1)
+print fourier
+print freq
+
diff --git a/liboctopus/python/demos/reader/test.py~ b/liboctopus/python/demos/reader/test.py~
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/liboctopus/python/demos/reader/test.py~