Selectable saving (manual save/button) and proper direct mode, code cleanup

This commit is contained in:
Adam Honse
2023-07-16 01:04:45 -05:00
parent b8519487f8
commit c092e96f66
4 changed files with 72 additions and 35 deletions

View File

@@ -29,9 +29,9 @@ RGBController_Seagate::RGBController_Seagate(SeagateController* controller_ptr)
location = controller->GetLocation();
mode Direct;
Direct.name = "Custom";
Direct.name = "Direct";
Direct.value = 0;
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_MANUAL_SAVE;
Direct.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Direct);
@@ -91,10 +91,21 @@ void RGBController_Seagate::UpdateSingleLED(int led)
unsigned char grn = RGBGetGValue(colors[led]);
unsigned char blu = RGBGetBValue(colors[led]);
controller->SetLED(led, red, grn, blu);
controller->SetLED(led, red, grn, blu, false);
}
void RGBController_Seagate::DeviceUpdateMode()
{
}
void RGBController_Seagate::DeviceSaveMode()
{
for(unsigned int led_idx = 0; led_idx < leds.size(); led_idx++)
{
unsigned char red = RGBGetRValue(colors[led_idx]);
unsigned char grn = RGBGetGValue(colors[led_idx]);
unsigned char blu = RGBGetBValue(colors[led_idx]);
controller->SetLED(led_idx, red, grn, blu, true);
}
}

View File

@@ -26,6 +26,8 @@ public:
void DeviceUpdateMode();
void DeviceSaveMode();
private:
SeagateController* controller;
};

View File

@@ -31,10 +31,46 @@ std::string SeagateController::GetLocation()
void SeagateController::SetLED
(
unsigned char led_id,
unsigned char r,
unsigned char g,
unsigned char b
unsigned char led_id,
unsigned char r,
unsigned char g,
unsigned char b,
bool save
)
{
/*-----------------------------------------------------------------------------*\
| Create buffer to hold RGB control data |
\*-----------------------------------------------------------------------------*/
unsigned char data[14] = {0};
data[0] = 0x0E; // size of data packet
data[1] = 0x00;
data[2] = 0x01;
data[3] = 0x09;
data[4] = 0x01;
data[5] = 0x06;
data[6] = led_id;
data[7] = 0x01;
if(save)
{
data[8] = 0x03; // 0x00 for no save, 0x03 for save
}
else
{
data[8] = 0x00;
}
data[9] = r;
data[10] = g;
data[11] = b;
data[12] = 0xFF;
data[13] = 0xFF;
SendPacket(data, 14);
}
void SeagateController::SendPacket
(
void * packet,
unsigned char packet_sz
)
{
/*-----------------------------------------------------------------------------*\
@@ -44,25 +80,6 @@ void SeagateController::SetLED
\*-----------------------------------------------------------------------------*/
unsigned char buffer[80] = {0};
/*-----------------------------------------------------------------------------*\
| Create buffer to hold RGB control data |
\*-----------------------------------------------------------------------------*/
unsigned char data[14] = {0};
data[0] = 0x0E;
data[1] = 0x00;
data[2] = 0x01;
data[3] = 0x09;
data[4] = 0x01;
data[5] = 0x06;
data[6] = led_id;
data[7] = 0x01;
data[8] = 0x03;
data[9] = r;
data[10] = g;
data[11] = b;
data[12] = 0x00;
data[13] = 0xFF;
/*-----------------------------------------------------------------------------*\
| Create PSCSI_PASS_THROUGH_DIRECT pointer and point it to the buffer |
\*-----------------------------------------------------------------------------*/
@@ -79,9 +96,9 @@ void SeagateController::SetLED
command->CdbLength = 0x0C;
command->SenseInfoLength = 0x20;
command->DataIn = SCSI_IOCTL_DATA_OUT;
command->DataTransferLength = 0x0000000E;
command->DataTransferLength = packet_sz;
command->TimeOutValue = 0x00000014;
command->DataBuffer = &data;
command->DataBuffer = packet;
command->SenseInfoOffset = 0x0000002E;
command->Cdb[0] = 0xD2;
@@ -94,11 +111,11 @@ void SeagateController::SetLED
command->Cdb[7] = 0x00;
command->Cdb[8] = 0x00;
command->Cdb[9] = 0x30;
command->Cdb[10] = 0x0E;
command->Cdb[10] = packet_sz;
command->Cdb[11] = 0x00;
/*-----------------------------------------------------------------------------*\
| Send pass through command |
\*-----------------------------------------------------------------------------*/
DeviceIoControl(fd, IOCTL_SCSI_PASS_THROUGH_DIRECT, command, 80, command, 80, NULL, NULL);
}
}

View File

@@ -24,13 +24,20 @@ public:
void SetLED
(
unsigned char led_id,
unsigned char r,
unsigned char g,
unsigned char b
unsigned char led_id,
unsigned char r,
unsigned char g,
unsigned char b,
bool save
);
private:
HANDLE fd;
std::wstring path;
void SeagateController::SendPacket
(
void * packet,
unsigned char packet_sz
);
};