This repository has been archived by the owner on Jul 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
CommanderPro.h
89 lines (73 loc) · 2.48 KB
/
CommanderPro.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#pragma once
#include <FastLEDController.h>
#include <CorsairLightingProtocol.h>
#include <CorsairLightingProtocolHID.h>
#include "FakeTemperatureController.h"
#include "SimpleFanController.h"
#include "DCFan.h"
#include "PWMFan.h"
constexpr uint8_t DEFAULT_FAN_UPDATE_RATE = 500;
constexpr uint8_t DEFAULT_FIRMWARE_VERSION[FIRMWARE_VERSION_SIZE] PROGMEM = { 0x00, 0x08, 0x00 };
template <size_t CHANNEL_LED_COUNT>
class CommanderPro {
public:
/*
* Creates a commander pro
*
* @param useEEPROM use EEPROM to save settings
* Uses default fan update rate
*/
CommanderPro(bool useEEPROM);
/*
* Creates a commander pro
*
* @param useEEPROM use EEPROM to save settings
* @param fanUpdateRate update rate to change fans
*/
CommanderPro(bool useEEPROM, uint8_t fanUpdateRate);
/*
* Adds a fan to the commander pro
*
* @param index location of fan to add
* @param fan Fan to add
*/
virtual void addFan(uint8_t index, IFan* fan);
/*
* Reads latest data, translates it to LED colors, and updates buffers
*
* @return True if there is a change to the LEDs, False if there is no change
*/
virtual bool update();
CRGB channel1[CHANNEL_LED_COUNT];
CRGB channel2[CHANNEL_LED_COUNT];
private:
Command cmd;
FastLEDController<CHANNEL_LED_COUNT>* ledController;
FakeTemperatureController* tempController;
SimpleFanController* fanController;
CorsairLightingProtocol* clp;
CorsairLightingProtocolHID* cHID;
};
template<size_t CHANNEL_LED_COUNT>
CommanderPro<CHANNEL_LED_COUNT>::CommanderPro(bool useEEPROM) : CommanderPro(useEEPROM, DEFAULT_FAN_UPDATE_RATE) {
}
template<size_t CHANNEL_LED_COUNT>
CommanderPro<CHANNEL_LED_COUNT>::CommanderPro(bool useEEPROM, uint8_t fanUpdateRate) {
ledController = new FastLEDController<CHANNEL_LED_COUNT>(tempController, useEEPROM);
tempController = new FakeTemperatureController();
fanController = new SimpleFanController(tempController, fanUpdateRate, EEPROM_ADDRESS + ledController->getEEPROMSize());
clp = new CorsairLightingProtocol(ledController, tempController, fanController, DEFAULT_FIRMWARE_VERSION);
cHID = new CorsairLightingProtocolHID(clp);
ledController->addLeds(0, channel1);
ledController->addLeds(1, channel2);
}
template<size_t CHANNEL_LED_COUNT>
void CommanderPro<CHANNEL_LED_COUNT>::addFan(uint8_t index, IFan* fan) {
fanController->addFan(index, fan);
}
template<size_t CHANNEL_LED_COUNT>
bool CommanderPro<CHANNEL_LED_COUNT>::update() {
cHID->update();
fanController->updateFans();
return ledController->updateLEDs();
}