Corsair Lighting Protocol  0.15.0
Control LEDs connected to an Arduino with iCUE
CorsairLightingFirmware.h
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 
18 #include "Arduino.h"
19 #include "CorsairLightingProtocolConstants.h"
20 #include "CorsairLightingProtocolResponse.h"
21 
22 #define FIRMWARE_VERSION_SIZE 3
23 
24 const uint8_t corsairLightingNodePROFirmwareVersion[FIRMWARE_VERSION_SIZE] PROGMEM = {0x00, 0x0A, 0x04};
25 
26 #define corsairLightingNodeCOREFirmwareVersion corsairLightingNodePROFirmwareVersion
27 
28 #define corsairLS100FirmwareVersion corsairLightingNodePROFirmwareVersion
29 
30 const uint8_t corsairCommanderPROFirmwareVersion[FIRMWARE_VERSION_SIZE] PROGMEM = {0x00, 0x09, 0xD4};
31 
32 const uint8_t corsairLT100FirmwareVersion[FIRMWARE_VERSION_SIZE] PROGMEM = {0x01, 0x01, 0x38};
33 
34 const uint8_t corsairCommanderCOREFirmwareVersion[FIRMWARE_VERSION_SIZE] PROGMEM = {0x02, 0x06, 0xC9};
35 
36 const uint8_t* const firmwareVersions[] PROGMEM = {
37  corsairLightingNodePROFirmwareVersion, corsairCommanderPROFirmwareVersion, corsairLightingNodeCOREFirmwareVersion,
38  corsairLS100FirmwareVersion, corsairLT100FirmwareVersion, corsairCommanderCOREFirmwareVersion};
39 
40 struct DeviceID {
41  uint8_t data[4];
42 };
43 
48 public:
49  virtual void loadDeviceID(DeviceID& deviceID) const = 0;
50  virtual void saveDeviceID(const DeviceID& deviceID) = 0;
51 };
52 
54 public:
55  CorsairLightingFirmware(corsair_product_enum_t product, CorsairLightingFirmwareStorage* storage);
56  void handleFirmwareCommand(const Command& command, const CorsairLightingProtocolResponse* response);
57  void getDeviceID(DeviceID& deviceID) const;
58  void setDeviceID(const DeviceID& deviceID);
59  uint8_t getStatus();
60  void setStatus(uint8_t status);
61  uint8_t getProduct();
62 
63 protected:
64  CorsairLightingFirmwareStorage* const storage;
65  const corsair_product_enum_t product;
66  DeviceID deviceId;
67 
68 private:
69  uint8_t status = PROTOCOL_STATUS_OK;
70 };
Definition: CorsairLightingFirmware.h:47
Definition: CorsairLightingFirmware.h:53
Definition: CorsairLightingProtocolResponse.h:20
Definition: CorsairLightingProtocolConstants.h:110
Definition: CorsairLightingFirmware.h:40