コード例 #1
0
ファイル: commander_pro.py プロジェクト: Shane4STER/liquidctl
    def set_speed_profile(self,
                          channel,
                          profile,
                          temperature_sensor=1,
                          **kwargs):
        """Set fan or fans to follow a speed duty profile.

        Valid channel values are 'fanN', where N >= 1 is the fan number, and
        'fan', to simultaneously configure all fans.  Unconfigured fan channels
        may default to 100% duty.

        Up to six (temperature, duty) pairs can be supplied in `profile`,
        with temperatures in Celsius and duty values in percentage.  The last
        point should set the fan to 100% duty cycle, or be omitted; in the
        latter case the fan will be set to max out at 60°C.
        """

        # send fan num, temp sensor, check to make sure it is actually enabled, and do not let the user send external sensor
        # 6 2-byte big endian temps (celsius * 100), then 6 2-byte big endian rpms
        # need to figure out how to find out what the max rpm is for the given fan

        if self._fan_count == 0:
            raise NotSupportedByDevice()

        profile = list(profile)

        criticalTemp = _CRITICAL_TEMPERATURE_HIGH if check_unsafe(
            'high_tempature', **kwargs) else _CRITICAL_TEMPERATURE
        profile = _prepare_profile(profile, criticalTemp)

        # fan_type = kwargs['fan_type'] # need to make sure this is set
        temp_sensor = clamp(temperature_sensor, 1, self._temp_probs)

        sensors = self._data.load('temp_sensors_connected',
                                  default=[0] * self._temp_probs)

        if sensors[temp_sensor - 1] != 1:
            raise ValueError('the specified tempature sensor is not connected')

        buf = bytearray(26)
        buf[1] = temp_sensor - 1  # 0  # use temp sensor 1

        for i, entry in enumerate(profile):
            temp = entry[0] * 100
            rpm = entry[1]

            # convert both values to 2 byte big endian values
            buf[2 + i * 2] = temp.to_bytes(2, byteorder='big')[0]
            buf[3 + i * 2] = temp.to_bytes(2, byteorder='big')[1]
            buf[14 + i * 2] = rpm.to_bytes(2, byteorder='big')[0]
            buf[15 + i * 2] = rpm.to_bytes(2, byteorder='big')[1]

        fan_channels = self._get_hw_fan_channels(channel)
        fan_modes = self._data.load('fan_modes', default=[0] * self._fan_count)

        for fan in fan_channels:
            mode = fan_modes[fan]
            if mode == _FAN_MODE_DC or mode == _FAN_MODE_PWM:
                buf[0] = fan
                self._send_command(_CMD_SET_FAN_PROFILE, buf)
コード例 #2
0
ファイル: kraken2.py プロジェクト: mrudisel/liquidctl
    def set_color(self, channel, mode, colors, speed='normal', direction='forward', **kwargs):
        """Set the color mode for a specific channel."""
        if not self.supports_lighting:
            raise NotSupportedByDevice()

        if mode == 'super':
            _LOGGER.warning('deprecated mode, move to super-fixed, super-breathing or super-wave')
            mode = 'super-fixed'
        if 'backwards' in mode:
            _LOGGER.warning('deprecated mode, move to direction=backwards option')
            mode = mode.replace('backwards-', '')
            direction = 'backward'

        mval, mod2, mod4, mincolors, maxcolors, ringonly = _COLOR_MODES[mode]

        if direction == 'backward':
            mod2 += 0x10

        if ringonly and channel != 'ring':
            _LOGGER.warning('mode=%s unsupported with channel=%s, dropping to ring',
                            mode, channel)
            channel = 'ring'

        steps = self._generate_steps(colors, mincolors, maxcolors, mode, ringonly)
        sval = _ANIMATION_SPEEDS[speed]
        byte2 = mod2 | _COLOR_CHANNELS[channel]
        for i, leds in enumerate(steps):
            seq = i << 5
            byte4 = sval | seq | mod4
            logo = [leds[0][1], leds[0][0], leds[0][2]]
            ring = list(itertools.chain(*leds[1:]))
            self._write([0x2, 0x4c, byte2, mval, byte4] + logo + ring)
コード例 #3
0
    def set_color(self, channel, mode, colors, speed='normal', **kwargs):
        """Set the color mode.

        Only supported by Smart Device V1/V2 and HUE 2 controllers.
        """

        if not self._color_channels:
            raise NotSupportedByDevice()
        cid = self._color_channels[channel]
        _, _, _, mincolors, maxcolors = self._COLOR_MODES[mode]
        colors = [[g, r, b] for [r, g, b] in colors]
        if len(colors) < mincolors:
            raise ValueError(
                'Not enough colors for mode={}, at least {} required'.format(
                    mode, mincolors))
        elif maxcolors == 0:
            if colors:
                LOGGER.warning('too many colors for mode=%s, none needed',
                               mode)
            colors = [[0, 0,
                       0]]  # discard the input but ensure at least one step
        elif len(colors) > maxcolors:
            LOGGER.warning('too many colors for mode=%s, dropping to %i', mode,
                           maxcolors)
            colors = colors[:maxcolors]
        sval = _ANIMATION_SPEEDS[speed]
        self._write_colors(cid, mode, colors, sval)
コード例 #4
0
ファイル: smart_device.py プロジェクト: swiknaba/liquidctl
    def set_color(self, channel, mode, colors, speed='normal', direction='forward', **kwargs):
        """Set the color mode.

        Only supported by Smart Device V1/V2 and HUE 2 controllers.
        """

        if not self._color_channels:
            raise NotSupportedByDevice()

        if 'backwards' in mode:
            _LOGGER.warning('deprecated mode, move to direction=backwards option')
            mode = mode.replace('backwards-', '')
            direction = 'backward'

        cid = self._color_channels[channel]
        _, _, _, mincolors, maxcolors = self._COLOR_MODES[mode]
        colors = [[g, r, b] for [r, g, b] in colors]
        if len(colors) < mincolors:
            raise ValueError(f'not enough colors for mode={mode}, at least {mincolors} required')
        elif maxcolors == 0:
            if colors:
                _LOGGER.warning('too many colors for mode=%s, none needed', mode)
            colors = [[0, 0, 0]]  # discard the input but ensure at least one step
        elif len(colors) > maxcolors:
            _LOGGER.warning('too many colors for mode=%s, dropping to %d',
                            mode, maxcolors)
            colors = colors[:maxcolors]

        sval = _ANIMATION_SPEEDS[speed]
        self._write_colors(cid, mode, colors, sval, direction)
コード例 #5
0
ファイル: kraken2.py プロジェクト: kalufinnle/liquidctl
 def set_instantaneous_speed(self, channel, duty, **kwargs):
     """Set channel to speed, but do not ensure persistence."""
     if not self.supports_cooling:
         raise NotSupportedByDevice()
     cbase, dmin, dmax = _SPEED_CHANNELS[channel]
     duty = clamp(duty, dmin, dmax)
     LOGGER.info('setting %s PWM duty to %i%%', channel, duty)
     self._write([0x2, 0x4d, cbase & 0x70, 0, duty])
コード例 #6
0
ファイル: kraken2.py プロジェクト: kalufinnle/liquidctl
 def set_fixed_speed(self, channel, duty, **kwargs):
     """Set channel to a fixed speed."""
     if not self.supports_cooling:
          raise NotSupportedByDevice()
     elif self.supports_cooling_profiles:
         self.set_speed_profile(channel, [(0, duty), (59, duty), (60, 100), (100, 100)])
     else:
         self.set_instantaneous_speed(channel, duty)
コード例 #7
0
ファイル: asetek_pro.py プロジェクト: CaseySJ/liquidctl
 def _fan_indexes(self, channel):
     if channel.startswith('fan'):
         if len(channel) > 3:
             channel_num = int(channel[3:]) - 1
             if channel_num >= self._fan_count:
                 raise ValueError(f'unknown channel: {channel}')
             return [channel_num]
         return range(self._fan_count)
     elif channel == 'pump':
         raise NotSupportedByDevice()
     else:
         raise ValueError(f'unknown channel: {channel}')
コード例 #8
0
ファイル: asetek_pro.py プロジェクト: andytank123/liquidctl
 def set_fixed_speed(self, channel, duty, **kwargs):
     """Set channel to a fixed speed duty."""
     channel = channel.lower()
     if channel.startswith('fan'):
         duty = clamp(duty, 0, 100)
         # Need to write curve for each fan in channel
         for i in self._get_fan_indexes(channel):
             _LOGGER.info('setting speed for fan %d to %d', i + 1, duty)
             self._write([_CMD_WRITE_FAN_SPEED, i, duty])
             self._end_transaction_and_read(32)
     elif channel == 'pump':
         raise NotSupportedByDevice()
     else:
         raise KeyError(f'Unknow channel: {channel}')
コード例 #9
0
ファイル: kraken2.py プロジェクト: kalufinnle/liquidctl
 def set_speed_profile(self, channel, profile, **kwargs):
     """Set channel to use a speed profile."""
     if not self.supports_cooling_profiles:
         raise NotSupportedByDevice()
     norm = normalize_profile(profile, _CRITICAL_TEMPERATURE)
     # due to a firmware limitation the same set of temperatures must be
     # used on both channels; we reduce the number of writes by trimming the
     # interval and/or resolution to the most useful range
     stdtemps = list(range(20, 50)) + list(range(50, 60, 2)) + [60]
     interp = [(t, interpolate_profile(norm, t)) for t in stdtemps]
     cbase, dmin, dmax = _SPEED_CHANNELS[channel]
     for i, (temp, duty) in enumerate(interp):
         duty = clamp(duty, dmin, dmax)
         LOGGER.info('setting %s PWM duty to %i%% for liquid temperature >= %i°C',
                      channel, duty, temp)
         self._write([0x2, 0x4d, cbase + i, temp, duty])
コード例 #10
0
ファイル: asetek_pro.py プロジェクト: joaqim/liquidctl
 def set_speed_profile(self, channel, profile, **kwargs):
     """Set channel to follow a speed duty profile."""
     channel = channel.lower()
     if channel == 'pump':
         raise NotSupportedByDevice()
     if not channel.startswith('fan'):
         raise KeyError(f'Unknown channel: {channel}')
     adjusted = self._prepare_profile(profile, 0, 100, _MAX_PROFILE_POINTS)
     for temp, duty in adjusted:
         _LOGGER.info(
             'setting %s PWM point: (%i°C, %i%%), device interpolated',
             channel, temp, duty)
     temps, duties = map(list, zip(*adjusted))
     # Need to write curve for each fan in channel
     for i in self._get_fan_indexes(channel):
         _LOGGER.info('setting speed for fan %d', i + 1)
         self._write([_PRO_CMD_WRITE_FAN_CURVE, i] + temps + duties)
         self._end_transaction_and_read(32)
コード例 #11
0
    def set_fixed_speed(self, channel, duty, **kwargs):
        """Set fan or fans to a fixed speed duty.

        Valid channel values are 'fanN', where N >= 1 is the fan number, and
        'fan', to simultaneously configure all fans.  Unconfigured fan channels
        may default to 100% duty.

        Different commands for sending fixed percent (0x23) and fixed rpm (0x24)
        Probably want to use fixed percent for this untill the rpm flag is enabled.
        Can only send one fan command at a time, if fan mode is unset will need to send 6?
        messages (or 1 per enabled fan)
        """

        if self._fan_count == 0:
            raise NotSupportedByDevice()

        duty = clamp(duty, 0, 100)
        fan_channels = self._get_hw_fan_channels(channel)
        fan_modes = self._data.load('fan_modes', default=[0] * self._fan_count)

        for fan in fan_channels:
            mode = fan_modes[fan]
            if mode == _FAN_MODE_DC or mode == _FAN_MODE_PWM:
                self._send_command(_CMD_SET_FAN_DUTY, [fan, duty])
コード例 #12
0
 def set_speed_profile(self, channel, profile, **kwargs):
     """Not supported by this device."""
     raise NotSupportedByDevice()
コード例 #13
0
 def set_color(self, channel, mode, colors, **kwargs):
     """Not supported by this device."""
     raise NotSupportedByDevice()
コード例 #14
0
 def set_fixed_speed(self, channel, duty, **kwargs):
     """Not supported by this device."""
     raise NotSupportedByDevice()
コード例 #15
0
ファイル: smart_device.py プロジェクト: liquidctl/liquidctl
 def set_speed_profile(self, channel, profile, **kwargs):
     raise NotSupportedByDevice()