Skip to content

Commit cadf0e8

Browse files
author
neil.hamilton
committed
Replace numbers with enums in ps6000aBlockExample.py
1 parent 35a58c0 commit cadf0e8

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

picosdk/PicoDeviceEnums.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def _define_coupling():
105105
# needs implementing still
106106

107107
def _define_bandwidth_limiter():
108-
PICO_BW_FULL = 0,
108+
PICO_BW_FULL = 0
109109
PICO_BW_100KHZ = 100000
110110
PICO_BW_20KHZ = 20000
111111
PICO_BW_1MHZ = 1000000
@@ -191,9 +191,9 @@ def _define_wave_type():
191191
])
192192

193193
def _define_threshold_direction():
194-
PICO_ABOVE= PICO_INSIDE = 0
194+
PICO_ABOVE = PICO_INSIDE = 0
195195
PICO_BELOW = PICO_OUTSIDE = 1
196-
PICO_RISING = PICO_ENTER = PICO_NONE = 2
196+
PICO_RISING = PICO_ENTER = PICO_NONE = 2
197197
PICO_FALLING = PICO_EXIT = 3
198198
PICO_RISING_OR_FALLING = PICO_ENTER_OR_EXIT = 4
199199
PICO_ABOVE_LOWER = 5

ps6000aExamples/ps6000aBlockExample.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import ctypes
99
import numpy as np
1010
from picosdk.ps6000a import ps6000a as ps
11-
#from picosdk.PicoDeviceEnums import PicoDeviceEnums as enums
11+
from picosdk.PicoDeviceEnums import picoEnum as enums
1212
import matplotlib.pyplot as plt
1313
from picosdk.functions import adc2mV, assert_pico_ok
1414

@@ -18,17 +18,17 @@
1818

1919
# Open 6000 A series PicoScope
2020
# returns handle to chandle for use in future API functions
21-
resolution = 0 # PICO_DEVICE_RESOLUTION["PICO_DR_8BIT"]
21+
resolution = enums.PICO_DEVICE_RESOLUTION["PICO_DR_8BIT"]
2222
status["openunit"] = ps.ps6000aOpenUnit(ctypes.byref(chandle), None, resolution)
2323
assert_pico_ok(status["openunit"])
2424

2525
# Set channel A on
2626
# handle = chandle
27-
channelA = 0 #enums.PICO_CHANNEL["PICO_CHANNEL_A"]
28-
coupling = 0 #enums.PICO_COUPLING["PICO_DC"]
27+
channelA = enums.PICO_CHANNEL["PICO_CHANNEL_A"]
28+
coupling = enums.PICO_COUPLING["PICO_DC"]
2929
channelRange = 7
3030
# analogueOffset = 0 V
31-
bandwidth = 0 #enums.PICO_CHANNEL["PICO_BW_FULL"]
31+
bandwidth = enums.PICO_BANDWIDTH_LIMITER["PICO_BW_FULL"]
3232
status["setChannelA"] = ps.ps6000aSetChannelOn(chandle, channelA, coupling, channelRange, 0, bandwidth)
3333
assert_pico_ok(status["setChannelA"])
3434

@@ -43,15 +43,15 @@
4343
# enable = 1
4444
source = channelA
4545
# threshold = 1000 mV
46-
direction = 2 # PICO_THRESHOLD_DIRECTION["PICO_RISING"]
46+
direction = enums.PICO_THRESHOLD_DIRECTION["PICO_RISING"]
4747
# delay = 0 s
4848
# autoTriggerMicroSeconds = 1000000 us
4949
status["setSimpleTrigger"] = ps.ps6000aSetSimpleTrigger(chandle, 1, source, 1000, direction, 0, 1000000)
5050
assert_pico_ok(status["setSimpleTrigger"])
5151

5252
# Get fastest available timebase
5353
# handle = chandle
54-
enabledChannelFlags = 1 #PICO_CHANNEL_FLAGS["PICOCHANNEL_A_FLAGS"]
54+
enabledChannelFlags = enums.PICO_CHANNEL_FLAGS["PICO_CHANNEL_A_FLAGS"]
5555
timebase = ctypes.c_uint32(0)
5656
timeInterval = ctypes.c_double(0)
5757
# resolution = resolution
@@ -74,12 +74,12 @@
7474
# bufferMax = bufferAMax
7575
# bufferMin = bufferAMin
7676
# nSamples = nSamples
77-
dataType = 1 # PICO_DATA_TYPE["PICO_INT16_T"]
77+
dataType = enums.PICO_DATA_TYPE["PICO_INT16_T"]
7878
waveform = 0
79-
downSampleMode = 0x80000000 # PICO_RATIO_MODE["PICO_RATIO_MODE_RAW"]
80-
clear = 0x00000001 # PICO_ACTION["PICO_CLEAR_ALL"]
81-
add = 0x00000002 # PICO_ACTION["PICO_ADD"]
82-
action = clear|add # PICO_ACTION["PICO_CLEAR_WAVEFORM_CLEAR_ALL"] + PICO_ACTION["PICO_ADD"]
79+
downSampleMode = enums.PICO_RATIO_MODE["PICO_RATIO_MODE_RAW"]
80+
clear = enums.PICO_ACTION["PICO_CLEAR_ALL"]
81+
add = enums.PICO_ACTION["PICO_ADD"]
82+
action = clear|add # PICO_ACTION["PICO_CLEAR_WAVEFORM_CLEAR_ALL"] | PICO_ACTION["PICO_ADD"]
8383
status["setDataBuffers"] = ps.ps6000aSetDataBuffers(chandle, channelA, ctypes.byref(bufferAMax), ctypes.byref(bufferAMin), nSamples, dataType, waveform, downSampleMode, action)
8484
assert_pico_ok(status["setDataBuffers"])
8585

0 commit comments

Comments
 (0)