Skip to content

Commit fc79540

Browse files
committed
picam: remove unused imports and avoid importing deprecated microscope.devices.
1 parent aaaf813 commit fc79540

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

microscope/cameras/picam.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,28 +27,29 @@
2727

2828
import numpy as np
2929

30-
import microscope
30+
import microscope.abc
3131

3232
# import raspberry pi specific modules
3333
import picamera
3434
import picamera.array
3535

3636
# to allow hardware trigger.
3737
import RPi.GPIO as GPIO
38-
from microscope import devices
39-
from microscope.devices import ROI, Binning, keep_acquiring
38+
from microscope import ROI, Binning, TriggerType, TriggerMode
39+
from microscope.abc import keep_acquiring
4040

4141

4242
GPIO_Trigger = 21
4343
GPIO_CAMLED = 5
4444

4545
_logger = logging.getLogger(__name__)
4646

47+
4748
# Trigger types.
4849
@enum.unique
4950
class TrgSourceMap(enum.Enum):
50-
SOFTWARE = microscope.TriggerType.SOFTWARE
51-
EDGE_RISING = microscope.TriggerType.RISING_EDGE
51+
SOFTWARE = TriggerType.SOFTWARE
52+
EDGE_RISING = TriggerType.RISING_EDGE
5253

5354

5455
class PiCamera(microscope.abc.Camera):
@@ -69,7 +70,7 @@ def __init__(self, *args, **kwargs):
6970
self.exposure_time = 0.001 # in seconds
7071
self.cycle_time = self.exposure_time
7172
# initialise in soft trigger mode
72-
self._trigger_type = microscope.TriggerType.SOFTWARE
73+
self._trigger_type = TriggerType.SOFTWARE
7374
# setup hardware triggerline
7475
GPIO.setmode(GPIO.BCM)
7576
# GPIO trigger line is an input
@@ -193,32 +194,32 @@ def abort(self):
193194
self._acquiring = False
194195

195196
def set_trigger(
196-
self, ttype: microscope.TriggerType, tmode: microscope.TriggerMode
197+
self, ttype: TriggerType, tmode: TriggerMode
197198
) -> None:
198199
if ttype == self._trigger_type:
199200
return
200-
elif ttype == microscope.TriggerType.SOFTWARE:
201+
elif ttype == TriggerType.SOFTWARE:
201202
GPIO.remove_event_detect(GPIO_Trigger)
202-
self._trigger_type = microscope.TriggerType.SOFTWARE
203-
elif ttype == microscope.TriggerType.RISING_EDGE:
203+
self._trigger_type = TriggerType.SOFTWARE
204+
elif ttype == TriggerType.RISING_EDGE:
204205
GPIO.add_event_detect(
205206
GPIO_Trigger,
206207
GPIO.RISING,
207208
callback=self.HW_trigger,
208209
bouncetime=10,
209210
)
210-
self._trigger_type = microscope.TriggerType.RISING_EDGE
211+
self._trigger_type = TriggerType.RISING_EDGE
211212

212213
@property
213-
def trigger_mode(self) -> microscope.TriggerMode:
214+
def trigger_mode(self) -> TriggerMode:
214215
# if self._trigger_type==devices.TRIGGER_BEFORE:
215-
return microscope.TriggerMode.ONCE
216+
return TriggerMode.ONCE
216217

217218
# else:
218-
# return microscope.TriggerMode.ONCE
219+
# return TriggerMode.ONCE
219220

220221
@property
221-
def trigger_type(self) -> microscope.TriggerType:
222+
def trigger_type(self) -> TriggerType:
222223
return self._trigger_type
223224

224225
def _get_roi(self):

0 commit comments

Comments
 (0)