Corsair Lighting Protocol  0.15.0
Control LEDs connected to an Arduino with iCUE
FanController.h
Go to the documentation of this file.
1 /*
2  Copyright 2019 Leon Kiefer
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 */
16 #pragma once
17 
23 #include "Arduino.h"
24 #include "IFanController.h"
25 
26 #define FAN_NUM 6
27 
33 enum class FanMask : byte {
35  Disconnected = 0x00,
37  ThreePin = 0x01,
39  FourPin = 0x02
40 };
41 
42 bool isValidFanMask(const FanMask fanMask);
43 
49 enum class FanDetectionType : byte {
51  Auto = 0x00,
53  ThreePin = 0x01,
55  FourPin = 0x02,
57  Disconnected = 0x03
58 };
59 
60 bool isValidFanDetectionType(const FanDetectionType type);
61 
62 #define FAN_FORCE_THREE_PIN_MODE_ON 0x01
63 #define FAN_FORCE_THREE_PIN_MODE_OFF 0x00
64 
65 #define FAN_CURVE_POINTS_NUM 6
66 
67 #define FAN_CURVE_TEMP_GROUP_EXTERNAL 255
68 
73 struct FanCurve {
77  uint16_t temperatures[FAN_CURVE_POINTS_NUM];
81  uint16_t rpms[FAN_CURVE_POINTS_NUM];
82 };
83 
88 class FanController : public IFanController {
89 public:
90  virtual void handleFanControl(const Command& command, const CorsairLightingProtocolResponse* response) override;
91 
92 protected:
99  virtual uint16_t getFanSpeed(uint8_t fan) = 0;
106  virtual void setFanSpeed(uint8_t fan, uint16_t speed) = 0;
113  virtual uint8_t getFanPower(uint8_t fan) = 0;
118  virtual void setFanPower(uint8_t fan, uint8_t percentage) = 0;
126  virtual void setFanCurve(uint8_t fan, uint8_t group, FanCurve& fanCurve) = 0;
133  virtual void setFanExternalTemperature(uint8_t fan, uint16_t temp) = 0;
139  virtual void setFanForce3PinMode(bool flag) = 0;
146  virtual FanDetectionType getFanDetectionType(uint8_t fan) = 0;
153  virtual void setFanDetectionType(uint8_t fan, FanDetectionType type) = 0;
154 };
FanDetectionType
Definition: FanController.h:49
FanMask
Definition: FanController.h:33
@ Disconnected
Definition: CorsairLightingProtocolResponse.h:20
Definition: FanController.h:88
virtual void setFanDetectionType(uint8_t fan, FanDetectionType type)=0
virtual uint8_t getFanPower(uint8_t fan)=0
virtual void setFanCurve(uint8_t fan, uint8_t group, FanCurve &fanCurve)=0
virtual void setFanExternalTemperature(uint8_t fan, uint16_t temp)=0
virtual uint16_t getFanSpeed(uint8_t fan)=0
virtual void setFanSpeed(uint8_t fan, uint16_t speed)=0
virtual void setFanForce3PinMode(bool flag)=0
virtual void handleFanControl(const Command &command, const CorsairLightingProtocolResponse *response) override
Definition: FanController.cpp:29
virtual void setFanPower(uint8_t fan, uint8_t percentage)=0
virtual FanDetectionType getFanDetectionType(uint8_t fan)=0
Definition: IFanController.h:25
Definition: CorsairLightingProtocolConstants.h:110
Definition: FanController.h:73
uint16_t rpms[FAN_CURVE_POINTS_NUM]
Definition: FanController.h:81
uint16_t temperatures[FAN_CURVE_POINTS_NUM]
Definition: FanController.h:77