本文整理汇总了Python中PyHT6022.LibUsbScope.Oscilloscope.set_interface方法的典型用法代码示例。如果您正苦于以下问题:Python Oscilloscope.set_interface方法的具体用法?Python Oscilloscope.set_interface怎么用?Python Oscilloscope.set_interface使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyHT6022.LibUsbScope.Oscilloscope
的用法示例。
在下文中一共展示了Oscilloscope.set_interface方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ScopeInterface
# 需要导入模块: from PyHT6022.LibUsbScope import Oscilloscope [as 别名]
# 或者: from PyHT6022.LibUsbScope.Oscilloscope import set_interface [as 别名]
class ScopeInterface(QObject):
new_data = pyqtSignal(list)
def __init__(self, parent=None):
super(ScopeInterface, self).__init__(parent)
self.inprogress = False
def initialize(self):
self.sample_rate_index = 8
self.voltage_range = 0x01
self.data_points = 3 * 1024
self.trigger_level = 150
self.trigger_type = +1
self.scope = Oscilloscope()
self.scope.setup()
self.scope.open_handle()
if (not self.scope.is_device_firmware_present):
self.scope.flash_firmware()
self.scope.set_interface(1); # choose ISO
self.scope.set_num_channels(1)
self.scope.set_sample_rate(self.sample_rate_index)
self.scope.set_ch1_voltage_range(self.voltage_range)
time.sleep(0.1)
return None
def capture(self):
if not self.inprogress:
self.inprogress = True
self.scope.start_capture()
shutdown_event = self.scope.read_async(self.data_callback, self.data_points, outstanding_transfers=25)
print("Clearing FIFO and starting data transfer...")
def data_callback(self, ch1_data, _):
d = list(ch1_data)
i = 0
#print("got new data ", time.time(), " : ", len(d))
if self.trigger_type > 0:
while (i < len(d) - 1) and not (d[i+1] > self.trigger_level and d[i] < self.trigger_level):
i += 1
#print("Trigger at ", i)
if (i != len(d) - 1):
self.new_data.emit(d[i:])
def stop(self):
self.scope.stop_capture()
print("Stopping new transfers.")
shutdown_event.set()
print("Snooze 1")
time.sleep(1)
print("Closing handle")
self.scope.close_handle()
print("Handle closed.")
self.inprogress = False
示例2: Oscilloscope
# 需要导入模块: from PyHT6022.LibUsbScope import Oscilloscope [as 别名]
# 或者: from PyHT6022.LibUsbScope.Oscilloscope import set_interface [as 别名]
elif entry < threshold and running:
stability.append(current)
running = False
else:
continue
return stability[1:-1]
sample_rate_index = 24
voltage_range = 0x01
data_points = 3 * 1024
scope = Oscilloscope()
scope.setup()
scope.open_handle()
scope.flash_firmware()
scope.set_interface(1) # choose ISO
scope.set_num_channels(1)
scope.set_sample_rate(sample_rate_index)
scope.set_ch1_voltage_range(voltage_range)
time.sleep(1)
data = deque(maxlen=2*1024*1024)
data_extend = data.extend
def extend_callback(ch1_data, _):
global data_extend
data_extend(ch1_data)
start_time = time.time()
print("Clearing FIFO and starting data transfer...")
示例3: Oscilloscope
# 需要导入模块: from PyHT6022.LibUsbScope import Oscilloscope [as 别名]
# 或者: from PyHT6022.LibUsbScope.Oscilloscope import set_interface [as 别名]
numchannels = 1
numseconds = 8 # number of seconds to sample
blocksize = 6*1024 # should be divisible by 6*1024
alternative = 1 # choose ISO 3072 bytes per 125 us
scope = Oscilloscope()
scope.setup()
scope.open_handle()
scope.flash_firmware()
if (not scope.is_device_firmware_present):
scope.flash_firmware()
else:
scope.supports_single_channel = True;
print "Setting up scope!"
scope.set_interface(alternative);
print "ISO" if scope.is_iso else "BULK", "packet size:", scope.packetsize
print scope.set_num_channels(numchannels)
# set voltage range
scope.set_ch1_voltage_range(voltagerange)
# set sample rate
scope.set_sample_rate(samplerate)
# we divide by 100 because otherwise audacity lets us not zoom into it
samplerate = samplerate * 1000 * 10
print "Reading data from scope! in ",
for x in range(0, 3):
print 3-x,"..",
sys.stdout.flush()
time.sleep(1)
print "now"