OpenRGB/Controllers/CorsairHydroPlatinumController/CorsairHydroPlatinumController.h
Kasper 9b2296b0bc Fix sequence number having the wrong value
* I'm really not sure what it is, but for some reason with the ternary operator the sequence number was ending up wrong - it would end up being 1 twice in a row, at startup it would be 0 when it should have been 1 and other issues. This fixes that
* Also made it atomic

Commit amended for code style by Adam Honse <calcprogrammer1@gmail.com>
2021-04-14 15:27:19 -05:00

52 lines
1.7 KiB
C++

/*-------------------------------------------------------------------*\
| CorsairHydroPlatinumController.h |
| |
| Driver for Corsair Hydro Platinum AIO Coolers |
| |
| Kasper 28th March 2021 |
| |
\*-------------------------------------------------------------------*/
#pragma once
#include "RGBController.h"
#include <vector>
#include <string>
#include <hidapi/hidapi.h>
#define CORSAIR_HYDRO_PLATINUM_PACKET_SIZE 65
#define CORSAIR_HYDRO_PLATINUM_PACKET_DELAY 3
enum
{
CORSAIR_HYDRO_PLATINUM_MAGIC_1 = 0b001,
CORSAIR_HYDRO_PLATINUM_MAGIC_2 = 0b010,
CORSAIR_HYDRO_PLATINUM_MAGIC_3 = 0b011,
CORSAIR_HYDRO_PLATINUM_SET_LIGHTING_1 = 0b100,
CORSAIR_HYDRO_PLATINUM_SET_LIGHTING_2 = 0b101,
CORSAIR_HYDRO_PLATINUM_SET_LIGHTING_3 = 0b110,
};
class CorsairHydroPlatinumController
{
public:
CorsairHydroPlatinumController(hid_device* dev_handle, const char* path);
~CorsairHydroPlatinumController();
std::string GetLocation();
std::string GetFirmwareString();
void SetupColors(std::vector<RGBColor> colors);
private:
hid_device* dev;
std::string location;
std::string firmware_version;
std::atomic<unsigned int> sequence_number;
void SendMagic(const uint8_t* magic, unsigned int command);
void SendColors(std::vector<RGBColor> colors, unsigned int start, unsigned int end, unsigned int command);
unsigned int GetSequenceNumber();
uint8_t ComputePEC(const void * data, size_t size);
};