Skip to content

Commit 308e4b5

Browse files
author
Dilawar Singh
committedJun 24, 2019
Merge branch 'master' into devel
2 parents 356dd47 + 111c3f0 commit 308e4b5

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed
 

‎SerialScope/arduino.py

+18-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,20 @@
2020
import logging
2121
logger = logging.getLogger("arduino")
2222

23+
def interalFun(t):
24+
return (math.sin(2*math.pi*100*t))*128, (math.cos(2*math.pi*50*t))*64
25+
26+
def idealDelayForInteral():
27+
# In one second, I need to generate 5k samples. Usually most computer will
28+
# generate is way to fast; so I need to add delay. Some computers are slow
29+
# so this number can not be fixed.
30+
t0 = time.time()
31+
data = []
32+
while len(data) < 5e3:
33+
t = time.time() - t0
34+
data.append(interalFun(t))
35+
return max(0, (1-t)/5e3)
36+
2337
class SerialReader():
2438
"""docstring for SerialReader"""
2539
def __init__(self, port, baud, debug = False):
@@ -31,6 +45,8 @@ def __init__(self, port, baud, debug = False):
3145
self.debug = debug
3246
self.devname = ''
3347
self.lock = threading.Lock()
48+
self.internalDelay = idealDelayForInteral()
49+
print( self.internalDelay )
3450
try:
3551
self.s = serial.Serial(port, baud)
3652
except Exception as e:
@@ -49,9 +65,9 @@ def Read(self, N, startT):
4965
data = []
5066
for i in range(N):
5167
t = time.time() - startT
52-
a, b = (1+math.sin(2*math.pi*100*t))*128, (1+math.cos(2*math.pi*50*t))*64
68+
a, b = interalFun(t)
5369
data.append((t, int(a), int(b)))
54-
time.sleep(1e-4)
70+
time.sleep( self.internalDelay )
5571
return data
5672
# Arduino
5773
t0 = time.time() - startT

‎SerialScope/config.py

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
logger.warning("module screeninfo is not available: %s" % e)
3636
pass
3737

38-
3938
def log(msg, level=1):
4039
logger.log(level, msg)
4140

‎setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
setup(
1010
name = "SerialScope",
11-
version = "0.1.1",
11+
version = "0.1.2",
1212
description = "A serial-port based oscilloscope",
1313
long_description = readme,
1414
long_description_content_type='text/markdown',

0 commit comments

Comments
 (0)