Finished up all the modes

This commit is contained in:
crashniels 2020-06-04 03:07:09 +02:00 committed by Adam Honse
parent e086ecd0bb
commit b1de039f21
4 changed files with 121 additions and 47 deletions

View file

@ -10,6 +10,17 @@
#include "GloriousModelOController.h"
#include <cstring>
#ifdef WIN32
#include <Windows.h>
#else
#include <unistd.h>
static void Sleep(unsigned int milliseconds)
{
usleep(1000 * milliseconds);
}
#endif
GloriousModelOController::GloriousModelOController(hid_device* dev_handle)
{
dev = dev_handle;
@ -20,6 +31,7 @@ GloriousModelOController::GloriousModelOController(hid_device* dev_handle)
current_mode = GLORIOUS_MODE_STATIC;
current_speed = GLORIOUS_SPEED_NORMAL;
current_direction = GLORIOUS_DIRECTION_UP;
}
GloriousModelOController::~GloriousModelOController()
@ -39,7 +51,7 @@ unsigned int GloriousModelOController::GetLEDCount()
return(led_count);
}
void GloriousModelOController::SetLEDColor(unsigned char red, unsigned char green, unsigned char blue)
void GloriousModelOController::SetLEDColor(RGBColor* color_buf)
{
unsigned char usb_buf[520] =
{
@ -114,9 +126,9 @@ void GloriousModelOController::SetLEDColor(unsigned char red, unsigned char gree
usb_buf[0x0B] = 0x24;
usb_buf[0x35] = GLORIOUS_MODE_STATIC;
usb_buf[0x38] = 0x40; //max brightness
usb_buf[0x39] = red;
usb_buf[0x3A] = blue;
usb_buf[0x3B] = green;
usb_buf[0x39] = RGBGetRValue(color_buf[0]);
usb_buf[0x3A] = RGBGetBValue(color_buf[0]);
usb_buf[0x3B] = RGBGetGValue(color_buf[0]);
//DPI Button
/*
@ -127,9 +139,13 @@ void GloriousModelOController::SetLEDColor(unsigned char red, unsigned char gree
*/
hid_send_feature_report(dev, usb_buf, sizeof(usb_buf));
Sleep(1);
}
void GloriousModelOController::SetMode(unsigned char mode, unsigned char speed, unsigned char direction)
void GloriousModelOController::SetMode(unsigned char mode,
unsigned char speed,
unsigned char direction,
RGBColor* color_buf)
{
unsigned char usb_buf[520] =
{
@ -214,33 +230,58 @@ void GloriousModelOController::SetMode(unsigned char mode, unsigned char speed,
break;
case GLORIOUS_MODE_SPECTRUM_BREATING:
//colours not yet researched
usb_buf[0x3C] = speed; //speed for mode 3
usb_buf[0x3D] = 0x07; //maybe some kind of bank change?+
//usb_buf[0x3D] = 0x06;
usb_buf[0x3E] = RGBGetRValue(color_buf[0]); //mode 3 red 1
usb_buf[0x3F] = RGBGetBValue(color_buf[0]); //mode 3 blue 1
usb_buf[0x40] = RGBGetGValue(color_buf[0]); //mode 3 green 1
usb_buf[0x41] = RGBGetRValue(color_buf[1]); //mode 3 red 2
usb_buf[0x42] = RGBGetBValue(color_buf[1]); //mode 3 blue 2
usb_buf[0x43] = RGBGetGValue(color_buf[1]); //mode 3 green 2
usb_buf[0x44] = RGBGetRValue(color_buf[2]); //mode 3 red 3
usb_buf[0x45] = RGBGetBValue(color_buf[2]); //mode 3 blue 3
usb_buf[0x46] = RGBGetGValue(color_buf[2]); //mode 3 green 3
usb_buf[0x47] = RGBGetRValue(color_buf[3]); //mode 3 red 4
usb_buf[0x48] = RGBGetBValue(color_buf[3]); //mode 3 blue 4
usb_buf[0x49] = RGBGetGValue(color_buf[3]); //mode 3 green 4
usb_buf[0x4A] = RGBGetRValue(color_buf[4]); //mode 3 red 5
usb_buf[0x4B] = RGBGetBValue(color_buf[4]); //mode 3 blue 5
usb_buf[0x4C] = RGBGetGValue(color_buf[4]); //mode 3 green 5
usb_buf[0x4D] = RGBGetRValue(color_buf[5]); //mode 3 red 6
usb_buf[0x4E] = RGBGetBValue(color_buf[5]); //mode 3 blue 6
usb_buf[0x4F] = RGBGetGValue(color_buf[5]); //mode 3 green 6
usb_buf[0x50] = RGBGetRValue(color_buf[6]); //mode 3 red 7
usb_buf[0x51] = RGBGetBValue(color_buf[6]); //mode 3 blue 7
usb_buf[0x52] = RGBGetGValue(color_buf[6]); //mode 3 green 7
break;
case GLORIOUS_MODE_CHASE:
case GLORIOUS_MODE_TAIL:
usb_buf[0x53] = speed; //Speed for mode 4
break;
case GLORIOUS_MODE_SPECTRUM_CYCLE:
usb_buf[0x54] = speed; //Speed for mode 1,2,5
break;
case GLORIOUS_MODE_FLASHING:
case GLORIOUS_MODE_RAVE:
usb_buf[0x74] = speed; //Speed for mode 7
usb_buf[0x75] = 0xff; //mode 7 red 1
usb_buf[0x76] = 0x00; //mode 7 blue 1
usb_buf[0x77] = 0x00; //mode 7 green 1
usb_buf[0x78] = 0x00; //mode 7 red 2
usb_buf[0x79] = 0x00; //mode 7 blue 2
usb_buf[0x7A] = 0xff; //mode 7 green 2
usb_buf[0x75] = RGBGetRValue(color_buf[0]); //mode 7 red 1
usb_buf[0x76] = RGBGetBValue(color_buf[0]); //mode 7 blue 1
usb_buf[0x77] = RGBGetGValue(color_buf[0]); //mode 7 green 1
usb_buf[0x78] = RGBGetRValue(color_buf[1]); //mode 7 red 2
usb_buf[0x79] = RGBGetBValue(color_buf[1]); //mode 7 blue 2
usb_buf[0x7A] = RGBGetGValue(color_buf[1]); //mode 7 green 2
break;
case GLORIOUS_MODE_SLOW_RAINBOW:
case GLORIOUS_MODE_WAVE:
usb_buf[0x7C] = speed; //Speed for mode 9
break;
case GLORIOUS_MODE_BREATHING:
usb_buf[0x7D] = speed;
usb_buf[0x7E] = 0x00; //mode 0a red
usb_buf[0x7F] = 0x00; //mode 0a blue
usb_buf[0x80] = 0xff; //mode 0a green
usb_buf[0x7E] = RGBGetRValue(color_buf[0]); //mode 0a red
usb_buf[0x7F] = RGBGetBValue(color_buf[0]); //mode 0a blue
usb_buf[0x80] = RGBGetGValue(color_buf[0]); //mode 0a green
default:
break;
}
hid_send_feature_report(dev, usb_buf, sizeof(usb_buf));
Sleep(1);
}

View file

@ -19,11 +19,11 @@ enum
GLORIOUS_MODE_RAINBOW = 0x01,
GLORIOUS_MODE_STATIC = 0x02,
GLORIOUS_MODE_SPECTRUM_BREATING = 0x03,
GLORIOUS_MODE_CHASE = 0x04,
GLORIOUS_MODE_TAIL = 0x04,
GLORIOUS_MODE_SPECTRUM_CYCLE = 0x05,
GLORIOUS_MODE_FLASHING = 0x07,
GLORIOUS_MODE_RAVE = 0x07,
GLORIOUS_MODE_EPILEPSY = 0x08, //not in the official software
GLORIOUS_MODE_SLOW_RAINBOW = 0x09,
GLORIOUS_MODE_WAVE = 0x09,
GLORIOUS_MODE_BREATHING = 0x0a,
};
@ -56,8 +56,8 @@ public:
std::string GetDeviceName();
unsigned int GetLEDCount();
void SetLEDColor(unsigned char red, unsigned char green, unsigned char blue);
void SetMode(unsigned char mode, unsigned char speed, unsigned char direction);
void SetLEDColor(RGBColor* color_buf);
void SetMode(unsigned char mode, unsigned char speed, unsigned char direction, RGBColor* color_buf);
private:
hid_device* dev;
@ -67,4 +67,5 @@ private:
unsigned char current_mode;
unsigned char current_speed;
unsigned char current_direction;
};

View file

@ -44,21 +44,25 @@ RGBController_GloriousModelO::RGBController_GloriousModelO(GloriousModelOControl
mode SpectrumBreathing;
SpectrumBreathing.name = "Seemless Breathing";
SpectrumBreathing.flags = MODE_FLAG_HAS_SPEED;
SpectrumBreathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
SpectrumBreathing.speed_min = GLORIOUS_SPEED_SLOW;
SpectrumBreathing.speed = GLORIOUS_SPEED_NORMAL;
SpectrumBreathing.speed_max = GLORIOUS_SPEED_FAST;
SpectrumBreathing.colors_min = 7;
SpectrumBreathing.colors_max = 7;
SpectrumBreathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
SpectrumBreathing.value = GLORIOUS_MODE_SPECTRUM_BREATING;
SpectrumBreathing.colors.resize(7);
modes.push_back(SpectrumBreathing);
mode Chase;
Chase.name = "Chase";
Chase.name = "Tail";
Chase.flags = MODE_FLAG_HAS_SPEED;
Chase.speed_min = GLORIOUS_SPEED_SLOW;
Chase.speed = GLORIOUS_SPEED_NORMAL;
Chase.speed_max = GLORIOUS_SPEED_FAST;
Chase.color_mode = MODE_COLORS_NONE;
Chase.value = GLORIOUS_MODE_CHASE;
Chase.value = GLORIOUS_MODE_TAIL;
modes.push_back(Chase);
mode SpectrumCycle;
@ -72,13 +76,16 @@ RGBController_GloriousModelO::RGBController_GloriousModelO(GloriousModelOControl
modes.push_back(SpectrumCycle);
mode Flashing;
Flashing.name = "Flashing";
Flashing.flags = MODE_FLAG_HAS_SPEED;
Flashing.name = "Rave";
Flashing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
Flashing.speed_min = GLORIOUS_SPEED_SLOW;
Flashing.speed = GLORIOUS_SPEED_NORMAL;
Flashing.speed_max = GLORIOUS_SPEED_FAST;
Flashing.color_mode = MODE_COLORS_NONE;
Flashing.value = GLORIOUS_MODE_FLASHING;
Flashing.colors_min = 2;
Flashing.colors_max = 2;
Flashing.color_mode = MODE_COLORS_MODE_SPECIFIC;
Flashing.value = GLORIOUS_MODE_RAVE;
Flashing.colors.resize(2);
modes.push_back(Flashing);
mode Epilepsy;
@ -89,23 +96,26 @@ RGBController_GloriousModelO::RGBController_GloriousModelO(GloriousModelOControl
modes.push_back(Epilepsy);
mode RainbowSlow;
RainbowSlow.name = "Random";
RainbowSlow.name = "Wave";
RainbowSlow.flags = MODE_FLAG_HAS_SPEED;
RainbowSlow.speed_min = GLORIOUS_SPEED_SLOW;
RainbowSlow.speed = GLORIOUS_SPEED_NORMAL;
RainbowSlow.speed_max = GLORIOUS_SPEED_FAST;
RainbowSlow.color_mode = MODE_COLORS_NONE;
RainbowSlow.value = GLORIOUS_MODE_SLOW_RAINBOW;
RainbowSlow.value = GLORIOUS_MODE_WAVE;
modes.push_back(RainbowSlow);
mode Breathing;
Breathing.name = "Breathing";
Breathing.flags = MODE_FLAG_HAS_SPEED;
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
Breathing.speed_min = GLORIOUS_MODE_BREATING_SLOW;
Breathing.speed = GLORIOUS_MODE_BREATING_NORMAL;
Breathing.speed_max = GLORIOUS_MODE_BREATING_FAST;
Breathing.color_mode = MODE_COLORS_NONE;
Breathing.colors_min = 1;
Breathing.colors_max = 1;
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
Breathing.value = GLORIOUS_MODE_BREATHING;
Breathing.colors.resize(1);
modes.push_back(Breathing);
SetupZones();
@ -147,12 +157,7 @@ void RGBController_GloriousModelO::ResizeZone(int /*zone*/, int /*new_size*/)
void RGBController_GloriousModelO::DeviceUpdateLEDs()
{
RGBColor color = colors[0];
unsigned char red = RGBGetRValue(color);
unsigned char grn = RGBGetGValue(color);
unsigned char blu = RGBGetBValue(color);
gmo->SetLEDColor(red, grn, blu);
gmo->SetLEDColor(&colors[0]);
}
void RGBController_GloriousModelO::UpdateZoneLEDs(int /*zone*/)
@ -171,7 +176,8 @@ void RGBController_GloriousModelO::SetCustomMode()
void RGBController_GloriousModelO::UpdateMode()
{
unsigned int direction;
unsigned int direction = 0;
unsigned int speed = GLORIOUS_SPEED_NORMAL;
if (modes[active_mode].value == GLORIOUS_MODE_STATIC)
{
@ -181,18 +187,43 @@ void RGBController_GloriousModelO::UpdateMode()
{
if (modes[active_mode].direction == MODE_DIRECTION_UP)
{
direction = GLORIOUS_DIRECTION_UP;
direction = GLORIOUS_DIRECTION_DOWN;
}
else
{
direction = GLORIOUS_DIRECTION_DOWN;
direction = GLORIOUS_DIRECTION_UP;
}
if ((modes[active_mode].speed == GLORIOUS_SPEED_FAST) ||
(modes[active_mode].speed == GLORIOUS_SPEED_SLOW) ||
(modes[active_mode].speed == GLORIOUS_SPEED_NORMAL))
{
speed = modes[active_mode].speed;
}
else
{
if ((modes[active_mode].speed == GLORIOUS_MODE_BREATING_FAST) ||
(modes[active_mode].speed == GLORIOUS_MODE_BREATING_SLOW) ||
(modes[active_mode].speed == GLORIOUS_MODE_BREATING_NORMAL))
{
speed = modes[active_mode].speed;
}
else
{
speed = GLORIOUS_SPEED_NORMAL;
}
}
if (modes[active_mode].color_mode == MODE_COLORS_NONE)
{
gmo->SetMode(modes[active_mode].value, speed, direction, 0);
}
else
{
gmo->SetMode(modes[active_mode].value, speed, direction, &modes[active_mode].colors[0]);
}
gmo->SetMode(modes[active_mode].value, modes[active_mode].speed, direction);
}
}
//wave, epilepsy, spectrum cycle, tail, glorious mode, off

View file

@ -8,6 +8,7 @@
\*-----------------------------------------*/
#pragma once
#include "RGBController.h"
#include "GloriousModelOController.h"