openlifu.io.LIFUHVController.HVController

class openlifu.io.LIFUHVController.HVController(uart: LIFUUart | None = None)[source]

Bases: object

__init__(uart: LIFUUart | None = None)[source]

Initialize the HVController.

Parameters:

uart (LIFUUart) – The LIFUUart instance for communication.

echo(echo_data=None) tuple[bytes, int][source]

Send an echo command to the device with data and receive the same data in response.

Parameters:

echo_data (bytes) – The data to send (must be a byte array).

Returns:

The echoed data and its length.

Return type:

tuple[bytes, int]

Raises:
  • ValueError – If the UART is not connected.

  • TypeError – If the echo_data is not a byte array.

  • Exception – If an error occurs during the echo process.

get_fan_speed(fan_id: int = 0) int[source]

Get the current output fan percentage.

Parameters:

fan_id (int) – The desired fan to read (default is 0). bottom fans (0), and top fans (1).

Returns:

The current output fan percentage.

Return type:

int

Raises:

ValueError – If the controller is not connected.

get_hardware_id() str[source]

Retrieve the hardware ID of the Console device.

Returns:

Hardware ID in hexadecimal format.

Return type:

str

Raises:
  • ValueError – If the UART is not connected.

  • Exception – If an error occurs while retrieving the hardware ID.

get_rgb_led() int[source]

Get the current RGB LED state.

Returns:

The current RGB state (0 = OFF, 1 = RED, 2 = BLUE, 3 = GREEN).

Return type:

int

Raises:

ValueError – If the controller is not connected.

get_temperature1() float[source]

Retrieve the temperature reading from the TX device.

Returns:

Temperature value in Celsius.

Return type:

float

Raises:
  • ValueError – If the UART is not connected.

  • Exception – If an error occurs or the received data length is invalid.

get_temperature2() float[source]

Retrieve the temperature reading from the TX device.

Returns:

Temperature value in Celsius.

Return type:

float

Raises:
  • ValueError – If the UART is not connected.

  • Exception – If an error occurs or the received data length is invalid.

get_version() str[source]

Retrieve the firmware version of the Console device.

Returns:

Firmware version in the format ‘vX.Y.Z’.

Return type:

str

Raises:
  • ValueError – If the UART is not connected.

  • Exception – If an error occurs while fetching the version.

get_voltage() float[source]

Get the current output voltage setting.

Returns:

The current output voltage.

Return type:

float

Raises:

ValueError – If the controller is not connected.

ping() bool[source]

Send a ping command to the Console device to verify connectivity.

Raises:
  • ValueError – If the UART is not connected.

  • Exception – If an error occurs during the ping process.

set_dacs(hvp: int, hvm: int, hrp: int, hrm: int) bool[source]

Set the output voltage.

Parameters:

voltage (float) – The desired output voltage.

Raises:

ValueError – If the controller is not connected or voltage exceeds supply voltage.

set_fan_speed(fan_id: int = 0, fan_speed: int = 50) int[source]

Get the current output fan percentage.

Parameters:
  • fan_id (int) – The desired fan to set (default is 0). bottom fans (0), and top fans (1).

  • fan_speed (int) – The desired fan speed (default is 50).

Returns:

The current output fan percentage.

Return type:

int

Raises:

ValueError – If the controller is not connected.

set_rgb_led(rgb_state: int) int[source]

Set the RGB LED state.

Parameters:

rgb_state (int) – The desired RGB state (0 = OFF, 1 = RED, 2 = BLUE, 3 = GREEN).

Returns:

The current RGB state after setting.

Return type:

int

Raises:

ValueError – If the controller is not connected or the RGB state is invalid.

set_voltage(voltage: float) bool[source]

Set the output voltage.

Parameters:

voltage (float) – The desired output voltage.

Raises:

ValueError – If the controller is not connected or voltage exceeds supply voltage.

soft_reset() bool[source]

Perform a soft reset on the Console device.

Returns:

True if the reset was successful, False otherwise.

Return type:

bool

Raises:
  • ValueError – If the UART is not connected.

  • Exception – If an error occurs while resetting the device.

toggle_led() bool[source]

Toggle the LED on the Console device.

Raises:
  • ValueError – If the UART is not connected.

  • Exception – If an error occurs while toggling the LED.

turn_hv_off()[source]

Turn off the high voltage.

turn_hv_on()[source]

Turn on the high voltage.