Add suport for brightness to Glorious Model O

master
Kosta A 5 months ago committed by Adam Honse
parent 6e3271fe95
commit 6672b53542

@ -34,8 +34,11 @@ RGBController_Sinowealth::RGBController_Sinowealth(SinowealthController* control
version = controller->GetFirmwareVersion();
mode Static;
Static.name = "Static";
Static.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_AUTOMATIC_SAVE;
Static.name = "Custom";
Static.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_AUTOMATIC_SAVE;
Static.brightness_min = GLORIOUS_BRIGHTNESS_LOW;
Static.brightness = GLORIOUS_BRIGHTNESS_NORMAL;
Static.brightness_max = GLORIOUS_BRIGHTNESS_HIGH;
Static.color_mode = MODE_COLORS_PER_LED;
Static.value = GLORIOUS_MODE_STATIC;
modes.push_back(Static);
@ -48,7 +51,7 @@ RGBController_Sinowealth::RGBController_Sinowealth(SinowealthController* control
modes.push_back(Off);
mode Rainbow;
Rainbow.name = "Glorious Mode";
Rainbow.name = "Rainbow";
Rainbow.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_UD | MODE_FLAG_AUTOMATIC_SAVE;
Rainbow.speed_min = GLORIOUS_SPEED_SLOW;
Rainbow.speed = GLORIOUS_SPEED_NORMAL;
@ -73,10 +76,13 @@ RGBController_Sinowealth::RGBController_Sinowealth(SinowealthController* control
mode Chase;
Chase.name = "Tail";
Chase.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_AUTOMATIC_SAVE;
Chase.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_AUTOMATIC_SAVE;
Chase.speed_min = GLORIOUS_SPEED_SLOW;
Chase.speed = GLORIOUS_SPEED_NORMAL;
Chase.speed_max = GLORIOUS_SPEED_FAST;
Chase.brightness_min = GLORIOUS_BRIGHTNESS_LOW;
Chase.brightness = GLORIOUS_BRIGHTNESS_NORMAL;
Chase.brightness_max = GLORIOUS_BRIGHTNESS_HIGH;
Chase.color_mode = MODE_COLORS_NONE;
Chase.value = GLORIOUS_MODE_TAIL;
modes.push_back(Chase);
@ -93,10 +99,13 @@ RGBController_Sinowealth::RGBController_Sinowealth(SinowealthController* control
mode Flashing;
Flashing.name = "Rave";
Flashing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_AUTOMATIC_SAVE;
Flashing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_AUTOMATIC_SAVE;
Flashing.speed_min = GLORIOUS_SPEED_SLOW;
Flashing.speed = GLORIOUS_SPEED_NORMAL;
Flashing.speed_max = GLORIOUS_SPEED_FAST;
Flashing.brightness_min = GLORIOUS_BRIGHTNESS_LOW;
Flashing.brightness = GLORIOUS_BRIGHTNESS_NORMAL;
Flashing.brightness_max = GLORIOUS_BRIGHTNESS_HIGH;
Flashing.colors_min = 2;
Flashing.colors_max = 2;
Flashing.color_mode = MODE_COLORS_MODE_SPECIFIC;
@ -111,22 +120,25 @@ RGBController_Sinowealth::RGBController_Sinowealth(SinowealthController* control
Epilepsy.value = GLORIOUS_MODE_EPILEPSY;
modes.push_back(Epilepsy);
mode RainbowSlow;
RainbowSlow.name = "Wave";
RainbowSlow.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_AUTOMATIC_SAVE;
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_WAVE;
modes.push_back(RainbowSlow);
mode Wave;
Wave.name = "Wave";
Wave.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_AUTOMATIC_SAVE;
Wave.speed_min = GLORIOUS_SPEED_SLOW;
Wave.speed = GLORIOUS_SPEED_NORMAL;
Wave.speed_max = GLORIOUS_SPEED_FAST;
Wave.brightness_min = GLORIOUS_BRIGHTNESS_LOW;
Wave.brightness = GLORIOUS_BRIGHTNESS_NORMAL;
Wave.brightness_max = GLORIOUS_BRIGHTNESS_HIGH;
Wave.color_mode = MODE_COLORS_NONE;
Wave.value = GLORIOUS_MODE_WAVE;
modes.push_back(Wave);
mode Breathing;
Breathing.name = "Breathing";
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_AUTOMATIC_SAVE;
Breathing.speed_min = GLORIOUS_MODE_BREATING_SLOW;
Breathing.speed = GLORIOUS_MODE_BREATING_NORMAL;
Breathing.speed_max = GLORIOUS_MODE_BREATING_FAST;
Breathing.speed_min = GLORIOUS_SPEED_SLOW;
Breathing.speed = GLORIOUS_SPEED_NORMAL;
Breathing.speed_max = GLORIOUS_SPEED_FAST;
Breathing.colors_min = 1;
Breathing.colors_max = 1;
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
@ -178,7 +190,7 @@ void RGBController_Sinowealth::ResizeZone(int /*zone*/, int /*new_size*/)
void RGBController_Sinowealth::DeviceUpdateLEDs()
{
controller->SetLEDColor(&colors[0]);
DeviceUpdateMode();
}
void RGBController_Sinowealth::UpdateZoneLEDs(int /*zone*/)
@ -194,51 +206,44 @@ void RGBController_Sinowealth::UpdateSingleLED(int /*led*/)
void RGBController_Sinowealth::DeviceUpdateMode()
{
unsigned int direction = 0;
unsigned int speed = GLORIOUS_SPEED_NORMAL;
unsigned int speed = GLORIOUS_SPEED_FAST;
unsigned int brightness = GLORIOUS_BRIGHTNESS_HIGH;
if (modes[active_mode].value == GLORIOUS_MODE_STATIC)
if (modes[active_mode].flags & MODE_FLAG_HAS_SPEED)
{
speed = modes[active_mode].speed;
}
if (modes[active_mode].flags & MODE_FLAG_HAS_BRIGHTNESS)
{
brightness = modes[active_mode].brightness;
}
else
if ((modes[active_mode].flags & MODE_FLAG_HAS_DIRECTION_LR) ||
(modes[active_mode].flags & MODE_FLAG_HAS_DIRECTION_UD) ||
(modes[active_mode].flags & MODE_FLAG_HAS_DIRECTION_HV))
{
if (modes[active_mode].direction == MODE_DIRECTION_UP)
{
direction = GLORIOUS_DIRECTION_DOWN;
}
else
{
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;
}
direction = GLORIOUS_DIRECTION_DOWN;
}
}
if (modes[active_mode].color_mode == MODE_COLORS_NONE)
{
controller->SetMode(modes[active_mode].value, speed, direction, 0);
}
else
{
controller->SetMode(modes[active_mode].value, speed, direction, &modes[active_mode].colors[0]);
}
if (modes[active_mode].color_mode == MODE_COLORS_NONE)
{
controller->SetMode(modes[active_mode].value, speed, brightness, direction, 0);
}
else if (modes[active_mode].color_mode == MODE_COLORS_PER_LED)
{
controller->SetMode(modes[active_mode].value, speed, brightness, direction, &colors[0]);
}
else
{
controller->SetMode(modes[active_mode].value, speed, brightness, direction, &modes[active_mode].colors[0]);
}
}

@ -22,10 +22,6 @@ SinowealthController::SinowealthController(hid_device* dev_data_handle, hid_devi
name = dev_name;
led_count = 1;
current_mode = GLORIOUS_MODE_STATIC;
current_speed = GLORIOUS_SPEED_NORMAL;
current_direction = GLORIOUS_DIRECTION_UP;
}
SinowealthController::~SinowealthController()
@ -88,32 +84,11 @@ std::string SinowealthController::GetFirmwareVersion()
return std::string(reinterpret_cast<char*>(usb_buf) + 2); // Skip report and command byte
}
void SinowealthController::SetLEDColor
(
RGBColor* color_buf
)
{
if (GetProfile() < SINOWEALTH_CONFIG_SIZE_MIN) return;
unsigned char usb_buf[SINOWEALTH_CONFIG_REPORT_SIZE];
memcpy(usb_buf, device_configuration, SINOWEALTH_CONFIG_SIZE); // Yes, we only copy 167 bytes back, for now - if anything weird starts happening use SINOWEALTH_CONFIG_REPORT_SIZE
usb_buf[0x03] = 0x7B; //write to device
usb_buf[0x06] = 0x00;
usb_buf[0x35] = GLORIOUS_MODE_STATIC;
usb_buf[0x38] = 0x40; //max brightness
usb_buf[0x39] = RGBGetRValue(color_buf[0]);
usb_buf[0x3A] = RGBGetBValue(color_buf[0]);
usb_buf[0x3B] = RGBGetGValue(color_buf[0]);
hid_send_feature_report(dev_data, usb_buf, SINOWEALTH_CONFIG_REPORT_SIZE);
}
void SinowealthController::SetMode
(
unsigned char mode,
unsigned char speed,
unsigned char brightness,
unsigned char direction,
RGBColor* color_buf
)
@ -130,16 +105,19 @@ void SinowealthController::SetMode
switch (mode)
{
case GLORIOUS_MODE_OFF:
usb_buf[0x81] = 0x00; //mode 0 either 0x00 or 0x03
break;
case GLORIOUS_MODE_RAINBOW:
usb_buf[0x36] = speed;
usb_buf[0x36] = ((brightness & 0xF) << 4) | (speed & 0xF);
usb_buf[0x37] = direction;
break;
case GLORIOUS_MODE_STATIC:
usb_buf[0x38] = ((brightness & 0xF) << 4);
usb_buf[0x39] = RGBGetRValue(color_buf[0]);
usb_buf[0x3A] = RGBGetBValue(color_buf[0]);
usb_buf[0x3B] = RGBGetGValue(color_buf[0]);
break;
case GLORIOUS_MODE_SPECTRUM_BREATING:
//colours not yet researched
usb_buf[0x3C] = speed; //speed for mode 3
usb_buf[0x3C] = ((brightness & 0xF) << 4) | (speed & 0xF);
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
@ -165,13 +143,13 @@ void SinowealthController::SetMode
usb_buf[0x52] = RGBGetGValue(color_buf[6]); //mode 3 green 7
break;
case GLORIOUS_MODE_TAIL:
usb_buf[0x53] = speed; //Speed for mode 4
usb_buf[0x53] = ((brightness & 0xF) << 4) | (speed & 0xF);
break;
case GLORIOUS_MODE_SPECTRUM_CYCLE:
usb_buf[0x54] = speed; //Speed for mode 1,2,5
usb_buf[0x54] = ((brightness & 0xF) << 4) | (speed & 0xF);
break;
case GLORIOUS_MODE_RAVE:
usb_buf[0x74] = speed; //Speed for mode 7
usb_buf[0x74] = ((brightness & 0xF) << 4) | (speed & 0xF);
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
@ -180,13 +158,16 @@ void SinowealthController::SetMode
usb_buf[0x7A] = RGBGetGValue(color_buf[1]); //mode 7 green 2
break;
case GLORIOUS_MODE_WAVE:
usb_buf[0x7C] = speed; //Speed for mode 9
usb_buf[0x7C] = ((brightness & 0xF) << 4) | (speed & 0xF);
break;
case GLORIOUS_MODE_BREATHING:
usb_buf[0x7D] = speed;
usb_buf[0x7D] = ((brightness & 0xF) << 4) | (speed & 0xF);
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
case GLORIOUS_MODE_OFF:
usb_buf[0x81] = 0x00; //mode 0 either 0x00 or 0x03
break;
default:
break;
}

@ -31,27 +31,27 @@ enum
GLORIOUS_MODE_RAVE = 0x07,
GLORIOUS_MODE_EPILEPSY = 0x08, //not in the official software
GLORIOUS_MODE_WAVE = 0x09,
GLORIOUS_MODE_BREATHING = 0x0a,
GLORIOUS_MODE_BREATHING = 0x0A,
};
enum
{
GLORIOUS_SPEED_SLOW = 0x41,
GLORIOUS_SPEED_NORMAL = 0x42,
GLORIOUS_SPEED_FAST = 0x43,
GLORIOUS_SPEED_SLOW = 0x01,
GLORIOUS_SPEED_NORMAL = 0x02,
GLORIOUS_SPEED_FAST = 0x03,
};
enum
{
GLORIOUS_DIRECTION_UP = 0x00,
GLORIOUS_DIRECTION_DOWN = 0x01,
GLORIOUS_BRIGHTNESS_LOW = 0x01,
GLORIOUS_BRIGHTNESS_NORMAL = 0x02,
GLORIOUS_BRIGHTNESS_HIGH = 0x04,
};
enum
{
GLORIOUS_MODE_BREATING_SLOW = 0x01,
GLORIOUS_MODE_BREATING_NORMAL = 0x02,
GLORIOUS_MODE_BREATING_FAST = 0x03,
GLORIOUS_DIRECTION_DOWN = 0x00,
GLORIOUS_DIRECTION_UP = 0x01,
};
class SinowealthController
@ -66,16 +66,13 @@ public:
std::string GetSerialString();
std::string GetFirmwareVersion();
void SetLEDColor(RGBColor* color_buf);
void SetMode(unsigned char mode, unsigned char speed, unsigned char direction, RGBColor* color_buf);
void SetMode(unsigned char mode, unsigned char speed, unsigned char brightness, unsigned char direction, RGBColor* color_buf);
int GetProfile();
private:
hid_device* dev_cmd;
hid_device* dev_data;
unsigned int led_count;
unsigned char current_mode;
unsigned char current_speed;
unsigned char current_direction;
unsigned char device_configuration[SINOWEALTH_CONFIG_REPORT_SIZE];
std::string location;
std::string name;

Loading…
Cancel
Save