API Reference
commons
- class pympcam.commons.MpcamGpio(chip: int, pin: int, direction: str = 'out')
Data class for MPCam GPIO.
- Todo
Verify which periphery version has inverted gpio
- Parameters
chip – Chip number for the GPIO.
pin – Pin number for the GPIO chip.
direction – Pin direction. Valid values are ‘in’ and ‘out’.
- init() periphery.gpio.GPIO
Initializes periphery’s GPIO.
- Returns
GPIO type from periphery.
coralManager
- class pympcam.coralManager.CoralManager
Controls Coral (TPU) power state on MPCam board.
Sequences for the power up (USB) procedure are extracted from Coral Accelerator Module Datasheet
- TIMEOUT_PGOOD_SEC = 0.002
Timeout for PGOOD4: Power OK signal, in seconds
- TIMEOUT_PWR_EN_SEC = 0.01
Timeout for PWR_EN: Power enable input, in seconds
- TIMEOUT_RST_SEC = 0.01
Timeout for RST_L: System reset, in seconds
- turnOff()
Turns off internal Coral device in MPCam.
- turnOn() bool
Turns on internal Coral device in MPCam.
- Returns
PGOOD4 state, should be True to indicate proper turn on.
headerIo
- class pympcam.headerIo.HeadersIo
Controls Headers Input/Output on MPCam board.
- get(label: str) int
Gets GPIO current state.
- Parameters
label – Header DIO to get (do0, do1, do2, do3).
- Returns
DIO current state: 1 if active, 0 if not.
- set(label: str, value: Optional[bool] = None) int
Sets (or toggles) GPIO current state. If value is provided, is set as current.
- Parameters
label – Header DIO to get (do0, do1, do2, do3).
value – Forces a state to selected DIO.
- Returns
DIO current state: 1 if active, 0 if not.
headerPwm
- class pympcam.headerPwm.HeaderPwm
Controls Headers PWM on MPCam board.
Available PWM:
PWM1
PWM2
- close(label: str)
Closes a PWM device.
- Parameters
label – PWM to be closed (pwm1, pwm2).
- get(label: str)
Gets PWM parameters.
- Parameters
label – PWM to be get (pwm1, pwm2).
- Returns
Tuple with duty cycle and frequency.
- set(label: str, duty_cycle=0.5, frequency=1)
Sets specified PWM to start.
- Warning
Some combinations of duty_cycle and frequency may cause errors.
- Parameters
label – PWM to be used (pwm1, pwm2).
duty_cycle – Duty cycle for the PWM, as % between 0 and 1.
frequency – Frequency for the PWM, as Hz.
irLed
userButtons
- class pympcam.userButtons.UserButtons
Controls User buttons on MPCam board.
Available buttons are:
SW1
SW2
- getState(button: Optional[str] = None)
Gets current button state.
- Parameters
button – button to get state.
- Returns
True if button was pressed.
- pollState(button: periphery.gpio.GPIO, timeoutSeconds=10) bool
Polls button state during a period of time (timeout). Button change is detected either by faling or raising edge.
- Parameters
button – button to get state.
timeoutSeconds – time to wait for button state change, in seconds.
- Returns
True if button was pressed.
userLed
- class pympcam.userLed.UserLed
Controls User LEDs on MPCam board.
Avaible LEDs:
LED1: Blue
LED2: Red
- LED1 = MpcamGpio(chip=9, pin=2, direction='out')
GPIO instance of LED1, Blue.
- LED2 = MpcamGpio(chip=7, pin=13, direction='out')
GPIO instance of LED2, Red.
- getState(label: Optional[str] = None) bool
Gets current state of a user LED.
- Parameters
label – LED to get state (LED1, LED2).
- Returns
True if LED is on.
- turnOff(label: Optional[str] = None) None
Turns off user LEDs.
- Parameters
label – LED to be turn off (LED1, LED2) or empty for all.
- turnOn(label: Optional[str] = None) None
Turns on user LEDs.
- Parameters
label – LED to be turn on (LED1, LED2) or empty for all.