text: #!/usr/bin/env python
  """ Set a single laser in camera mode (active trigger).
  
  A camera trigger signal must be used as input to the FPGA. The
  first laser trigger signal (laser0) is then generated by the
  FPGA and follows the camera trigger input.
  """
  
  import time
  import microfpga.controller as cl
  import microfpga.signals as sig
  from microfpga.signals import LaserTriggerMode
  
  
  with cl.MicroFPGA(n_laser=1, use_camera=True) as mufpga:
  
      # check if successful
      if mufpga.is_connected():
  
          if mufpga.is_active_sync():
              camera = {
                  'pulse': 1.5,  # ms
                  'delay': 0,
                  'exposure': 9,
                  'readout': 1
              }
              mufpga.set_camera_state_ms(**camera)
  
              # print state
              print(mufpga.get_camera_state_ms())
  
              # set laser state
              laser = {
                  'channel': 0,
                  'mode': LaserTriggerMode.MODE_FOLLOW,
                  'duration': 65535,
                  'sequence': sig.MAX_SEQUENCE
              }
              mufpga.set_laser_state(**laser)
  
              # read laser state
              print(f'Current Laser 0 state: {mufpga.get_laser_state(0)}')
  
              # run camera for 1 s
              mufpga.start_camera()
              print('Camera running')
  
              time.sleep(1)  # in s
  
              mufpga.stop_camera()
              print('Camera stopped')
  
      else:
          print('Failed to connect')
  