j5.backends.console.sr.v4 package¶
Submodules¶
Module contents¶
Backends for Student Robotics version 4 boards in the console environment.
-
class
j5.backends.console.sr.v4.
SRV4MotorBoardConsoleBackend
(serial: str, console_class: Type[j5.backends.console.console.Console] = <class 'j5.backends.console.console.Console'>)[source]¶ Bases:
j5.components.motor.MotorInterface
,j5.backends.backend.Backend
The console implementation of the SR v4 motor board.
-
board
¶
-
classmethod
discover
() → Set[j5.boards.board.Board][source]¶ Discover boards that this backend can control.
Returns: set of boards that this backend can control.
-
firmware_version
¶ The firmware version reported by the board.
Returns: firmware version reported by the board, if any.
-
get_motor_state
(identifier: int) → Union[float, j5.components.motor.MotorSpecialState][source]¶ Get the current motor state.
Parameters: identifier – identifier of the motor Returns: state of the motor.
-
serial
¶ The serial number reported by the board.
Returns: serial number reported by the board.
-
set_motor_state
(identifier: int, power: Union[float, j5.components.motor.MotorSpecialState]) → None[source]¶ Set the state of a motor.
Parameters: - identifier – identifier of the motor
- power – state of the motor.
Raises: ValueError – invalid motor identifier.
-
-
class
j5.backends.console.sr.v4.
SRV4PowerBoardConsoleBackend
(serial: str, console_class: Type[j5.backends.console.console.Console] = <class 'j5.backends.console.console.Console'>)[source]¶ Bases:
j5.components.power_output.PowerOutputInterface
,j5.components.piezo.PiezoInterface
,j5.components.button.ButtonInterface
,j5.components.battery_sensor.BatterySensorInterface
,j5.components.led.LEDInterface
,j5.backends.backend.Backend
The console implementation of the SR V4 power board.
-
board
¶
-
buzz
(identifier: int, duration: datetime.timedelta, pitch: float) → None[source]¶ Queue a pitch to be played.
Parameters: - identifier – piezo identifier to play pitch on.
- duration – duration of the tone.
- pitch – Pitch of the tone in Hz.
Raises: ValueError – invalid value for parameter.
-
classmethod
discover
() → Set[j5.boards.board.Board][source]¶ Discover boards that this backend can control.
Returns: set of boards that this backend can control.
-
firmware_version
¶ The firmware version reported by the board.
Returns: firmware version reported by the board, if any.
-
get_battery_sensor_current
(identifier: int) → float[source]¶ Get the current of a battery sensor.
Parameters: identifier – Identifier of battery sensor. Returns: current measured by the sensor. Raises: ValueError – invalid battery sensor identifier.
-
get_battery_sensor_voltage
(identifier: int) → float[source]¶ Get the voltage of a battery sensor.
Parameters: identifier – Identifier of battery sensor. Returns: voltage measured by the sensor. Raises: ValueError – invalid battery sensor identifier.
Get the state of a button.
Parameters: identifier – Button identifier to fetch state of. Returns: state of the button. Raises: ValueError – invalid button identifier.
-
get_led_state
(identifier: int) → bool[source]¶ Get the state of an LED.
Parameters: identifier – identifier of the LED. Returns: current state of the LED.
-
get_power_output_current
(identifier: int) → float[source]¶ Get the current being drawn on a power output, in amperes.
Parameters: identifier – power output to fetch current of. Returns: measured current of the output. Raises: ValueError – Invalid power output identifier.
-
get_power_output_enabled
(identifier: int) → bool[source]¶ Get whether a power output is enabled.
Parameters: identifier – power output to fetch status of. Returns: status of the power output. Raises: ValueError – Invalid power output identifier.
-
serial
¶ The serial number reported by the board.
Returns: serial number reported by the board.
-
set_led_state
(identifier: int, state: bool) → None[source]¶ Set the state of an LED.
Parameters: - identifier – identifier of the LED.
- state – desired state of the LED.
Raises: ValueError – invalid LED identifer.
-
set_power_output_enabled
(identifier: int, enabled: bool) → None[source]¶ Set whether a power output is enabled.
Parameters: - identifier – power output to enable / disable
- enabled – status of the power output.
Raises: ValueError – Invalid power output identifier.
Halt the program until this button is pushed.
Parameters: identifier – Button identifier to wait for.
-
-
class
j5.backends.console.sr.v4.
SRV4RuggeduinoConsoleBackend
(serial: str, console_class: Type[j5.backends.console.console.Console] = <class 'j5.backends.console.console.Console'>)[source]¶ Bases:
j5.components.string_command.StringCommandComponentInterface
,j5.backends.console.j5.arduino.ArduinoConsoleBackend
Console Backend for the SR v4 Ruggeduino.
-
board
¶
-
classmethod
discover
() → Set[j5.boards.board.Board][source]¶ Discover boards that this backend can control.
Returns: set of boards that this backend can control.
-
execute_string_command
(command: str) → str[source]¶ Execute the string command and return the result.
This function can be synchronous and blocking.
Parameters: command – command to send. Returns: result from the command.
-
get_gpio_pin_digital_state
(identifier: int) → bool¶ Get the last written state of a given GPIO pin.
Parameters: identifier – pin number Returns: Last known digital state of the pin. Raises: ValueError – pin is not in correct mode.
-
get_gpio_pin_mode
(identifier: int) → j5.components.gpio_pin.GPIOPinMode¶ Get the hardware mode of a GPIO pin.
Parameters: identifier – pin number. Returns: mode of the pin.
-
get_led_state
(identifier: int) → bool¶ Get the state of an LED.
Parameters: identifier – LED identifier. Returns: current state of the LED. Raises: ValueError – invalid LED identifier.
-
read_gpio_pin_analogue_value
(identifier: int) → float¶ Read the scaled analogue value of a given GPIO pin.
Parameters: identifier – pin number Returns: scaled analogue value of the pin. Raises: ValueError – pin is not in correct mode.
-
read_gpio_pin_digital_state
(identifier: int) → bool¶ Read the digital state of a given GPIO pin.
Parameters: identifier – pin number Returns: digital state of the pin. Raises: ValueError – pin is not in correct mode.
-
set_gpio_pin_mode
(identifier: int, pin_mode: j5.components.gpio_pin.GPIOPinMode) → None¶ Set the hardware mode of a GPIO pin.
Parameters: - identifier – pin number to set.
- pin_mode – mode to set the pin to.
-
set_led_state
(identifier: int, state: bool) → None¶ Set the state of an LED.
Parameters: - identifier – LED identifier.
- state – desired state of the LED.
Raises: ValueError – invalid LED identifier.
-
write_gpio_pin_dac_value
(identifier: int, scaled_value: float) → None¶ Write a scaled analogue value to the DAC on a given GPIO pin.
Parameters: - identifier – pin number
- scaled_value – scaled analogue value to write
Raises: NotImplementedError – Arduino Uno does not have a DAC.
-
write_gpio_pin_digital_state
(identifier: int, state: bool) → None¶ Write to the digital state of a GPIO pin.
Parameters: - identifier – pin number
- state – desired digital state.
Raises: ValueError – pin is not in correct mode.
-
write_gpio_pin_pwm_value
(identifier: int, duty_cycle: float) → None¶ Write a scaled analogue value to the PWM on a given GPIO pin.
Parameters: - identifier – pin number
- duty_cycle – duty cycle to write
Raises: NotImplementedError – Not implemented in any supported firmware yet.
-
-
class
j5.backends.console.sr.v4.
SRV4ServoBoardConsoleBackend
(serial: str, console_class: Type[j5.backends.console.console.Console] = <class 'j5.backends.console.console.Console'>)[source]¶ Bases:
j5.components.servo.ServoInterface
,j5.backends.backend.Backend
The console implementation of the SR v4 Servo board.
-
board
¶
-
classmethod
discover
() → Set[j5.boards.board.Board][source]¶ Discover boards that this backend can control.
Returns: set of boards that this backend can control.
-
firmware_version
¶ The firmware version reported by the board.
Returns: firmware version reported by the board, if any.
-
get_servo_position
(identifier: int) → Optional[float][source]¶ Get the servo position.
Parameters: identifier – Port of servo to check. Returns: Position of servo.
-
serial
¶ The serial number reported by the board.
Returns: serial number reported by the board.
-
set_servo_position
(identifier: int, position: Optional[float]) → None[source]¶ Set the servo position.
Parameters: - identifier – Port of servo to set position.
- position – Position to set the servo to.
Raises: ValueError – Unknown servo identifier.
-