Corsair Lighting Protocol  0.15.0
Control LEDs connected to an Arduino with iCUE
CLPUSBSerialBridge.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 <CorsairLightingProtocolConstants.h>
19 
20 #include "Arduino.h"
21 
22 #if (COMMAND_SIZE >= RESPONSE_SIZE)
23 #define RAWHID_AND_SERIAL_BUFFER_SIZE COMMAND_SIZE
24 #endif
25 
26 // Workaround for 16 byte responses don't work on 16U2 see https://github.com/Legion2/CorsairLightingProtocol/pull/152
27 #define RESPONSE_SIZE_16U2 64
28 
29 #define SERIAL_SYNCHRONIZATION_TIMEOUT 20
30 #define SERIAL_RESPONSE_TIMEOUT 10
31 #define SERIAL_BAUD 1000000
32 
33 #define RESET_PIN IO_MCU_RESET_PIN
34 
36 public:
46  CLPUSBSerialBridge(const char* serialNumber);
50  virtual void begin();
55  virtual void handleHID();
56 
57 private:
58  byte rawHIDAndSerialBuffer[RAWHID_AND_SERIAL_BUFFER_SIZE];
59 
60  void sendError();
61  void sendResponse();
62 };
Definition: CLPUSBSerialBridge.h:35
CLPUSBSerialBridge()
Definition: CLPUSBSerialBridge.h:40
virtual void begin()
Definition: CLPUSBSerialBridge.cpp:35
virtual void handleHID()
Definition: CLPUSBSerialBridge.cpp:66