Skip to content

Commit 75b27b7

Browse files
authored
Merge branch 'picotech:master' into setuptools
2 parents 5d95888 + 45aa22a commit 75b27b7

File tree

65 files changed

+3905
-97
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+3905
-97
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@
1414
build/
1515

1616
# venv directory
17-
venv/
17+
venv/
18+
19+
.bak/

picosdk/PicoDeviceEnums.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ def _define_action():
236236

237237
picoEnum.PICO_ACTION = _define_action()
238238

239-
picoEnum.Pico_TRIGGER_STATE = make_enum([
239+
picoEnum.PICO_TRIGGER_STATE = make_enum([
240240
"PICO_CONDITION_DONT_CARE",
241241
"PICO_CONDITION_TRUE",
242242
"PICO_CONDITION_FALSE"

picosdk/PicoDeviceStructs.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"""
99

1010
from ctypes import *
11+
from picosdk.library import Library
1112

1213
class PicoStructlib(Library):
1314
def __init__(self):

picosdk/discover.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from picosdk.ps4000a import ps4000a
1111
from picosdk.ps5000a import ps5000a
1212
from picosdk.ps6000 import ps6000
13+
from picosdk.ps6000a import ps6000a
1314

1415

1516
# the A drivers are faster to enumerate devices, so search them first.
@@ -18,6 +19,7 @@
1819
ps3000a,
1920
ps4000a,
2021
ps5000a,
22+
ps6000a,
2123
ps6000,
2224
ps2000,
2325
ps3000,
@@ -47,4 +49,4 @@ def find_all_units():
4749
devices.append(device)
4850
if not devices:
4951
raise DeviceNotFoundError("Could not find any devices on any drivers.")
50-
return devices
52+
return devices

picosdk/picosynth.py

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
#
2+
# Copyright (C) 2022 Pico Technology Ltd. See LICENSE file for terms.
3+
#
4+
"""
5+
This is a Python module defining the functions from the picosynth.h C header file
6+
for the PicoSource AS108 Agile Synthesizer using the picosynth driver API functions.
7+
"""
8+
9+
from ctypes import *
10+
from picosdk.library import Library
11+
from picosdk.errors import ArgumentOutOfRangeError
12+
from picosdk.constants import make_enum
13+
14+
class Picosynthlib(library):
15+
def __init__(self):
16+
super(Picosynthlib, self).__init__("picosynth")
17+
18+
picosynth = Picosynthlib()
19+
20+
picosynth.PICO_SOURCE_MODEL = make_enum([
21+
"PICO_NONE_SPECIFIED",
22+
"PICO_SYNTH",
23+
])
24+
25+
doc = """ PICO_STATUS picosynthOpenUnit
26+
(
27+
PICO_SOURCE_MODEL model,
28+
uint32_t *handle,
29+
unit8_t *serialNumber
30+
);"""
31+
picosynth.make_symbol("_OpenUnit","picosynthOpenUnit",c_uint32,[c_uint32, c_void_p, c_void_p],doc)
32+
33+
doc = """ PICO_STATUS picosynthEnumerateUnits
34+
(
35+
PICO_SOURCE_MODEL model,
36+
uint8_t *serials,
37+
unit16_t *serialLth
38+
);"""
39+
picosynth.make_symbol("_EnumerateUnits","picosynthEnumerateUnits",c_uint32,[c_uint32, c_void_p, c_void_p],doc)
40+
41+
doc = """ PICO_STATUS picosynthGetUnitInfo
42+
(
43+
int8_t *string,
44+
unit16_t stringLength,
45+
uint16_t *requiredSize,
46+
PICO_INFO deviceInfo
47+
);"""
48+
picosynth.make_symbol("_GetUnitInfo","picosynthGetUnitInfo",c_uint32,[c_uint32, c_void_p, c_uint16, c_void_p, c_uint32],doc)
49+
50+
doc = """ PICO_STATUS picosynthPingUnit
51+
(
52+
uint32_t *handle,
53+
);"""
54+
picosynth.make_symbol("_PingUnit","picosynthPingUnit",c_uint32,[c_uint32],doc)
55+
56+
doc = """ PICO_STATUS picosynthCloseUnit
57+
(
58+
uint32_t *handle,
59+
);"""
60+
picosynth.make_symbol("_CloseUnit","picosynthCloseUnit",c_uint32,[c_uint32],doc)
61+
62+
doc = """ PICO_STATUS picosynthSetOutputOff
63+
(
64+
uint32_t *handle,
65+
);"""
66+
picosynth.make_symbol("_SetOutputOff","picosynthSetOutputOff",c_uint32,[c_uint32],doc)
67+
68+
doc = """ PICO_STATUS picosynthSetFrequency
69+
(
70+
uint32_t *handle,
71+
double frequencyHz,
72+
double powerLeveldBm
73+
);"""
74+
picosynth.make_symbol("_SetFrequency","picosynthSetFrequency",c_uint32,[c_uint32, c_double, c_double],doc)
75+
76+
doc = """ PICO_STATUS picosynthSetPhase
77+
(
78+
uint32_t handle,
79+
double phaseDeg
80+
);"""
81+
picosynth.make_symbol("_SetPhase", "picosynthSetPhase", c_uint32,[c_uint32, c_double], doc)
82+
83+
doc = """ PICO_STATUS picosynthSetAmplitudeModulation
84+
(
85+
uint32_t handle,
86+
double frequencyHz,
87+
double powerLeveldBm,
88+
double modulationDepthPercent,
89+
double modulationRateHz,
90+
MODULATION_SOURCE modulationSource,
91+
int16_t enabled
92+
);"""
93+
picosynth.make_symbol("_SetAmplitudeModulation","picosynthSetAmplitudeModulation", c_uint32,[c_uint32,c_double,c_double,c_double,c_double,c_uint32,c_int16],doc)
94+
95+
doc = """ PICO_STATUS picosynthSetFrequencyModulation
96+
(
97+
uint32_t handle,
98+
double frequencyHz,
99+
double powerLeveldBm,
100+
double modulationDeviationHz,
101+
double modulationRateHz,
102+
MODULATION_SOURCE modulationSource,
103+
int16_t enabled
104+
);"""
105+
picosynth.make_symbol("_SetFrequencyModulation","picosynthSetFrequencyModulation",c_uint32,[c_uint32,c_double,c_double,c_double,c_double,c_uint32,c_int16],doc)
106+
107+
doc = """ PICO_STATUS picosynthSetPhaseModulation
108+
(
109+
uint32_t handle,
110+
double frequencyHz,
111+
double powerLeveldBm,
112+
double modulationDeviationHz,
113+
double modulationRateHz,
114+
MODULATION_SOURCE modulationSource,
115+
int16_t enabled
116+
);"""
117+
picosynth.make_symbol("_SetPhaseModulation","picosynthSetPhaseModulation",c_uint32,[c_uint32,c_double,c_double,c_double,c_double,c_uint32,c_int16],doc)
118+
119+
doc = """ PICO_STATUS picosynthSetFrequencyAndLevelSweep
120+
(
121+
uint32_t handle,
122+
double startFrequencyHz,
123+
double stopFrequencyHz,
124+
double startLevel,
125+
double stopLevel,
126+
LEVEL_UNIT levelUnit,
127+
double dwellTimeUs,
128+
int32_t pointsInSweep,
129+
SWEEP_HOP_MODE mode,
130+
TRIGGER_MODE triggerMode
131+
);"""
132+
picosynth.make_symbol("_SetFrequencyAndLevelSweep","picosynthSetFrequencyAndLevelSweep", c_uint32,[c_uint32,c_double,c_double,c_double,c_double,c_uint32,c_double,c_int32,c_uint32,c_uint32],doc)
133+
134+
doc = """ PICO_STATUS picosynthSetPhaseAndLevelSweep
135+
(
136+
uint32_t handle,
137+
double frequencyHz,
138+
double startPhaseDeg,
139+
double stopPhaseDeg,
140+
double startLevel,
141+
double stopLevel,
142+
LEVEL_UNIT levelUnit,
143+
double dwellTimeUs,
144+
int32_t pointsInSweep,
145+
SWEEP_HOP_MODE mode,
146+
TRIGGER_MODE triggerMode
147+
);"""
148+
picosynth.make_symbol("_SetPhaseAndLevelSweep","picosynthSetPhaseAndLevelSweep", c_uint32,[c_uint32,c_double,c_double,c_double,c_double,c_double,c_uint32,c_double,c_int32,c_uint32,c_uint32],doc)
149+
150+
doc = """ PICO_STATUS picosynthSetArbitraryPhaseAndLevel
151+
(
152+
uint32_t handle,
153+
double frequencyHz,
154+
double *arbitraryPhaseDeg,
155+
double *arbitraryPowerLeveldBm,
156+
int32_t numberOfPoints,
157+
double dwellTimeUs,
158+
TRIGGER_MODE triggerMode
159+
);"""
160+
picosynth.make_symbol("_SetArbitraryPhaseAndLevel","picosynthSetArbitraryPhaseAndLevel",c_uint32,[c_uint32,c_double,c_double,c_double,c_int32,c_double,c_uint32],doc)
161+
162+
doc = """ PICO_STATUS picosynthSetArbitraryFrequencyAndLevel
163+
(
164+
uint32_t handle,
165+
double *arbitraryFrequencyHz,
166+
double *arbitraryPowerLeveldBm,
167+
int32_t numberOfPoints,
168+
double dwellTimeUs,
169+
TRIGGER_MODE triggerMode
170+
);"""
171+
picosynth.make_symbol("_SetArbitraryFrequencyAndLevel","picosynthSetArbitraryFrequencyAndLevel",c_uint32,[c_uint32,c_double,c_double,c_int32,c_double,c_uint32],doc)

picosdk/ps2000a.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,3 +846,19 @@ class PS2000A_TRIGGER_CHANNEL_PROPERTIES(Structure):
846846
ps2000a.make_symbol("_GetMaxSegments", "ps2000aGetMaxSegments", c_uint32, [c_int16, c_void_p], doc)
847847

848848
ps2000a.INI_LOGIC_VOLTS = 1.5
849+
850+
doc = """ void *ps2000aBlockReady
851+
(
852+
int16_t handle,
853+
PICO_STATUS status,
854+
void *pParameter
855+
);
856+
define a python function which accepts the correct arguments, and pass it to the constructor of this type.
857+
"""
858+
859+
ps2000a.BlockReadyType = C_CALLBACK_FUNCTION_FACTORY(None,
860+
c_int16,
861+
c_uint32,
862+
c_void_p)
863+
864+
ps2000a.BlockReadyType.__doc__ = doc

picosdk/ps3000a.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def _define_digital_port():
146146

147147
ps3000a.PS3000A_THRESHOLD_DIRECTION = make_enum([
148148
("PS3000A_ABOVE", "PS3000A_INSIDE"),
149-
("PS3000A_BELOW", "PS3000A_OUTSIDE"),
149+
("PS3000A_BELOW", "PS3000A_OUTSIDE","PS3000A_NONE"),
150150
("PS3000A_RISING", "PS3000A_ENTER"),
151151
("PS3000A_FALLING", "PS3000A_EXIT"),
152152
("PS3000A_RISING_OR_FALLING", "PS3000A_ENTER_OR_EXIT"),
@@ -155,8 +155,7 @@ def _define_digital_port():
155155
"PS3000A_RISING_LOWER",
156156
"PS3000A_FALLING_LOWER"
157157
"PS3000A_POSITIVE_RUNT",
158-
"PS3000A_NEGATIVE_RUNT",
159-
"PS3000A_NONE"
158+
"PS3000A_NEGATIVE_RUNT"
160159
])
161160

162161
ps3000a.PS3000A_THRESHOLD_MODE = make_enum([

picosdk/ps4000a.py

Lines changed: 80 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,23 @@ def __init__(self):
2828
ps4000a.PICO_COUPLING = {k[-2:]: v for k, v in ps4000a.PS4000A_COUPLING.items()}
2929

3030
# A tuple in an enum like this is 2 names for the same value.
31-
ps4000a.PS4000A_CHANNEL = make_enum([
32-
"PS4000A_CHANNEL_A",
33-
"PS4000A_CHANNEL_B",
34-
"PS4000A_CHANNEL_C",
35-
"PS4000A_CHANNEL_D",
36-
("PS4000A_CHANNEL_E", "PS4000A_MAX_4_CHANNELS"),
37-
"PS4000A_CHANNEL_F",
38-
"PS4000A_CHANNEL_G",
39-
"PS4000A_CHANNEL_H",
40-
("PS4000A_MAX_CHANNELS", "PS4000A_EXTERNAL"),
41-
"PS4000A_TRIGGER_AUX",
42-
"PS4000A_MAX_TRIGGER_SOURCES",
43-
])
31+
ps4000a.PS4000A_CHANNEL = {
32+
"PS4000A_CHANNEL_A" : 0,
33+
"PS4000A_CHANNEL_B" : 1,
34+
"PS4000A_CHANNEL_C" : 2,
35+
"PS4000A_CHANNEL_D" : 3,
36+
("PS4000A_CHANNEL_E", "PS4000A_MAX_4_CHANNELS") : 4,
37+
"PS4000A_CHANNEL_F" : 5,
38+
"PS4000A_CHANNEL_G" : 6 ,
39+
"PS4000A_CHANNEL_H" : 7,
40+
("PS4000A_MAX_CHANNELS", "PS4000A_EXTERNAL") : 8,
41+
"PS4000A_TRIGGER_AUX" : 9,
42+
"PS4000A_MAX_TRIGGER_SOURCES" : 10,
43+
"PS4000A_PULSE_WIDTH_SOURCE" : 0x10000000
44+
}
4445

45-
ps4000a.PS4000A_CHANNEL["PS4000A_PULSE_WIDTH_SOURCE"] = 0x10000000
46+
ps4000a.PICO_CHANNEL = {k[19:]: v for k, v in ps4000a.PS4000A_CHANNEL.items()}
4647

47-
# only include the normal analog channels for now:
48-
ps4000a.PICO_CHANNEL = {k[-1]: v for k, v in ps4000a.PS4000A_CHANNEL.items() if "PS4000A_CHANNEL_" in k}
4948

5049

5150
# The voltage ranges for this driver are so oddly defined, that it is easier to describe them as a literal than trying
@@ -257,6 +256,70 @@ def process_enum(enum):
257256
'PS4000A_PRBS',
258257
])
259258

259+
ps4000a.PS4000A_CONDITIONS_INFO = make_enum([
260+
'PS4000A_CLEAR',
261+
'PS4000A_ADD',
262+
])
263+
264+
ps4000a.PS4000A_THRESHOLD_DIRECTION = make_enum([
265+
("PS4000A_ABOVE", "PS4000A_INSIDE"),
266+
("PS4000A_BELOW", "PS4000A_OUTSIDE"),
267+
("PS4000A_RISING", "PS4000A_ENTER", "PS4000A_NONE"),
268+
("PS4000A_FALLING", "PS4000A_EXIT"),
269+
("PS4000A_RISING_OR_FALLING", "PS4000A_ENTER_OR_EXIT"),
270+
"PS4000A_ABOVE_LOWER",
271+
"PS4000A_BELOW_LOWER",
272+
"PS4000A_RISING_LOWER",
273+
"PS4000A_FALLING_LOWER",
274+
"PS4000A_POSITIVE_RUNT",
275+
"PS4000A_NEGATIVE_RUNT",
276+
])
277+
278+
ps4000a.PS4000A_THRESHOLD_MODE = make_enum([
279+
"PS4000A_LEVEL",
280+
"PS4000A_WINDOW"
281+
])
282+
283+
ps4000a.PS4000A_TRIGGER_STATE = make_enum([
284+
"PS4000A_DONT_CARE",
285+
"PS4000A_TRUE",
286+
"PS4000A_FALSE"
287+
])
288+
289+
ps4000a.PS4000A_PULSE_WIDTH_TYPE = make_enum([
290+
"PW_TYPE NONE",
291+
"PW_TYPE_LESS_THAN",
292+
"PW_TYPE_GREATER_THAN",
293+
"PW_TYPE_IN_RANGE",
294+
"PW_TYPE_OUT_OF_RANGE"
295+
])
296+
297+
class PS4000A_CONDITION (Structure):
298+
_pack_ = 1
299+
_fields_ = [("source", c_int32),
300+
("condition", c_int16)]
301+
302+
ps4000a.PS4000A_CONDITION = PS4000A_CONDITION
303+
304+
class PS4000A_DIRECTION(Structure):
305+
_pack_ = 1
306+
_fields_ = [("channel", c_int32),
307+
("direction", c_int32),
308+
("mode", c_int32)]
309+
310+
ps4000a.PS4000A_DIRECTION = PS4000A_DIRECTION
311+
312+
class PS4000A_TRIGGER_CHANNEL_PROPERTIES(Structure):
313+
_pack_ = 1
314+
_fields_ = [("thresholdUpper", c_int16),
315+
("thresholdUpperHysteresis", c_uint16),
316+
("thresholdLower", c_int16),
317+
("thresholdLowerHysteresis", c_uint16),
318+
("channel", c_int32),
319+
("thresholdMode", c_int32)]
320+
321+
ps4000a.PS4000A_TRIGGER_CHANNEL_PROPERTIES = PS4000A_TRIGGER_CHANNEL_PROPERTIES
322+
260323
doc = """ PICO_STATUS ps4000aOpenUnit
261324
(
262325
int16_t *handle,
@@ -994,4 +1057,4 @@ def process_enum(enum):
9941057
int16_t handle,
9951058
PS4000A_DEVICE_RESOLUTION resolution
9961059
); """
997-
ps4000a.make_symbol("_SetResolution", "ps4000aSetDeviceResolution", c_uint32, [c_int16, c_int32], doc)
1060+
ps4000a.make_symbol("_SetResolution", "ps4000aSetDeviceResolution", c_uint32, [c_int16, c_int32], doc)

0 commit comments

Comments
 (0)