Skip to content

Commit

Permalink
Alpha AW768 and APIv5 global effect rework
Browse files Browse the repository at this point in the history
  • Loading branch information
T-Troll committed Feb 14, 2022
1 parent bbdf835 commit 5d36024
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
8 changes: 2 additions & 6 deletions AlienFX Sample App/AlienFX Sample App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,12 @@ int main()
if (afx_dev.AlienFXInitialize(0x04f2) != -1) { // keyboard
cout << hex << "VID: 0x" << afx_dev.GetVid() << ", PID: 0x" << afx_dev.GetPID() << ", API v" << afx_dev.GetVersion() << endl;
cout << "Now try light 2 to blue... ";
res = afx_dev.SetColor(2, {255});
cout << "Result " << res << ", ";
res = afx_dev.UpdateColors();
cout << "Update result " << res << endl;
afx_dev.SetColor(2, {255});
afx_dev.UpdateColors();
cin.get();
cout << "Now try light 3 to mixed... ";
res = afx_dev.SetColor(3, {255, 255});
cout << "Result " << res << ", ";
res = afx_dev.UpdateColors();
cout << "Update result " << res << endl;
cin.get();
/*cout << "Ok, now lights off...";
afx_dev.ToggleState(0, NULL, false);
Expand Down
20 changes: 14 additions & 6 deletions AlienFX_SDK/AlienFX_SDK.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ namespace AlienFX_SDK {
buffer[0] = reportID;
buffer[1] = 0x1;
int res = HidD_SetFeature(devHandle, buffer, length);
printf(" Pre-init result %d ", res);
}

memcpy(&buffer[1], command, size);
Expand Down Expand Up @@ -316,7 +315,7 @@ namespace AlienFX_SDK {
PrepareAndSend(COMMV8.control, sizeof(COMMV8.control), {{15, 0x20}});
PrepareAndSend(COMMV8.control, sizeof(COMMV8.control), {{14, 0x10}});
PrepareAndSend(COMMV8.control, sizeof(COMMV8.control), {{15, 0x80}});
PrepareAndSend(COMMV8.control, sizeof(COMMV8.control), {{15, 0x4d}});
res = PrepareAndSend(COMMV8.control, sizeof(COMMV8.control), {{15, 0x4d}});
} break;
//case API_L_V7:
//{
Expand Down Expand Up @@ -889,13 +888,22 @@ namespace AlienFX_SDK {
switch (version) {
case API_L_V5:
{
if (!inSet) Reset();
PrepareAndSend(COMMV5.setEffect, sizeof(COMMV5.setEffect), {
if (inSet)
UpdateColors();
Reset();
if (effType < 2)
PrepareAndSend(COMMV5.setEffect, sizeof(COMMV5.setEffect), {
{2,1}, {11,0xff}, {12,0xff}, {14,0xff}, {15,0xff}});
else
PrepareAndSend(COMMV5.setEffect, sizeof(COMMV5.setEffect), {
{2,effType}, {3,tempo},
{10,act1.r}, {11,act1.g}, {12,act1.b},
{13,act2.r}, {14,act2.g}, {15,act2.b},
{16,1}});
UpdateColors();
{16,5}});
if (effType < 2)
PrepareAndSend(COMMV5.update, sizeof(COMMV5.update), { {3,0xfe}, {6,0xff}, {7,0xff} });
else
UpdateColors();
return true;
} break;
default: return true;
Expand Down
6 changes: 4 additions & 2 deletions AlienFX_SDK/alienfx-controls.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,10 @@ namespace AlienFX_SDK {

static struct COMMV8 {
const byte status[1]{0x1};
const byte control[13]{0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x0a,0x00,0x01,0x01};
const byte colorSet[13]{0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x0a,0x00,0x01,0x01};
//const byte control[13]{0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x0a,0x00,0x01,0x01};
const byte control[13]{0x01,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x0a,0x00,0x02,0x01};
//const byte colorSet[13]{0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x0a,0x00,0x01,0x01};
const byte colorSet[13]{0x01,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x0a,0x00,0x02,0x01};
// [2] - store byte, [3-5] - RGB1, [6-8] - RGB2, [12] - 1 set, 2 store, [15] - lightID
} COMMV8;
}

0 comments on commit 5d36024

Please sign in to comment.