openlifu.io.LIFUHVController.HVController

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

Bases: object

__init__(uart: LIFUUart = None)[source]

Initialize the HVController.

Parameters:

uart (LIFUUart) – The LIFUUart instance for communication.

close()[source]

Close Uart

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.

enter_dfu() bool[source]

Perform a soft reset to enter DFU mode on TX 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.

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_vmon_values() list[dict][source]

Retrieve the voltage monitor readings from the console device.

Returns:

A list of 8 dictionaries, one for each channel, containing:
  • channel (int): Channel number (0-7)

  • raw_adc (int): Raw ADC reading (uint16)

  • reserved (int): Reserved value (uint16)

  • voltage (float): Voltage reading in volts

  • converted_voltage (float): Converted voltage value

Return type:

list[dict]

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

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

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.

hv_enable(enable: bool = False) bool[source]

Enable or disable high voltage output.

Parameters:

enable (bool) – True to enable HV, False to disable.

Returns:

True if the operation was successful, False otherwise.

Return type:

bool

Raises:

ValueError – If the controller is not connected.

if not self.uart.is_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_raw_dac(dac_id: int = 0, dac_value: int = 0) int[source]

Set Raw DAC value.

Parameters:
  • dac_id (int) – The desired DAC to set (default is 0). Valid IDs are 0, 1, 2, and 3.

  • dac_value (int) – The desired DAC value (default is 0). Must be between 0 and 4095.

Returns:

The current output DAC value.

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.