Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _set_fan_control_mode(self, mode):
"""Set hardware/software fan control mode."""
return self._exec(WriteBit.WRITE, _CORSAIR_FAN_CONTROL_MODE, [mode.value])
def initialize(self, single_12v_ocp=False, **kwargs):
"""Initialize the device.
Necessary to receive non-zero value responses from the device.
Note: replies before calling this function appear to follow the
pattern <address> .
"""
self._write([0xfe, 0x03]) # not well understood
self._read()
mode = OCPMode.SINGLE_RAIL if single_12v_ocp else OCPMode.MULTI_RAIL
if mode != self._get_12v_ocp_mode():
# TODO replace log level with info once this has been confimed to work
LOGGER.warning('(experimental feature) changing +12V OCP mode to %s', mode)
self._exec(WriteBit.WRITE, _CORSAIR_12V_OCP_MODE, [mode.value])
if self._get_fan_control_mode() != FanControlMode.HARDWARE:
LOGGER.info('resetting fan control to hardware mode')
self._set_fan_control_mode(FanControlMode.HARDWARE)
self.device.release()
</address>
def set_fixed_speed(self, channel, duty, **kwargs):
"""Set channel to a fixed speed duty."""
duty = clamp(duty, _MIN_FAN_DUTY, 100)
LOGGER.info('ensuring fan control is in software mode')
self._set_fan_control_mode(FanControlMode.SOFTWARE)
LOGGER.info('setting fan PWM duty to %i%%', duty)
self._exec(WriteBit.WRITE, CMD.FAN_COMMAND_1, [duty])
self.device.release()