RieqyNS13 icon

c++ custom led lightning

RieqyNS13 | PRO | 02/13/18 03:41:57 PM UTC | 0 ⭐ | 1289 👁️ | Never ⏰ | []
C++ |

2.12 KB

|

None

|

0 👍

/

0 👎

// Author : RieqyNS13
 
 
#include "stdafx.h"
#include <Windows.h>
#include <stdlib.h>
#include <windef.h>
#include "SDKDLL.h"
#include <iostream>
#define MAX_ASU 6
using namespace std;
 
COLOR_MATRIX cm;
void setWarnaUtama(int row,int col, KEY_COLOR kolor) {
    
    cm.KeyColor[row][col].r = kolor.r;
    cm.KeyColor[row][col].g = kolor.g;
    cm.KeyColor[row][col].b = kolor.b;
}
int jancuk = 105;
bool kntl = true;
void setWarnaBackground() {
    for (int i = 0;i < 22;i++) {
        for (int j = 0;j < 6;j++) {
            //printf("row %d col %d\n", j, i);
            cm.KeyColor[j][i].r = jancuk;
            cm.KeyColor[j][i].g = jancuk;
            cm.KeyColor[j][i].b = jancuk;
            
        }
    }
    if (jancuk == 195)kntl = false;
    else if (jancuk == 105)kntl = true;
 
    if (kntl)jancuk += 30;
    else jancuk -= 30;
}
int main()
{
    bool a = IsDevicePlug();
    if (a) {
        printf("Written by RieqyNS13");
        SetControlDevice(DEV_MKeys_L);
        EnableLedControl(true);
        SetFullLedColor(255, 255, 255);
 
        KEY_COLOR asu[MAX_ASU];
        asu[0].r = 255;
        asu[0].g = 0;
        asu[0].b = 255;
 
        asu[1].r = 255;
        asu[1].g = 255;
        asu[1].b = 0;
 
        asu[2].r = 255;
        asu[2].g = 100;
        asu[2].b = 50;
 
        asu[3].r = 100;
        asu[3].g = 250;
        asu[3].b = 10;
 
        asu[4].r = 0;
        asu[4].g = 255;
        asu[4].b = 200;
 
        asu[5].r = 60;
        asu[5].g = 120;
        asu[5].b = 240;
 
        int col = 0,row = 0;
        int col_begin = 0, row_begin = 0;
        int p = 6,c=0;
        while (true) { 
            int i = 0;
            setWarnaBackground();
            SetAllLedColor(cm);
            c = 0;
            row = row_begin;
            col = col_begin;
            while (i < MAX_ASU) {
                setWarnaUtama(row, col, asu[i]);
                int mod = col % 2;
                if ((row == 5 && i < row && mod == 0) || (row == 0 && i < 5 - row && mod == 1))
                    col++;
                else {
                    if(mod==0)row++;
                    else row--;
                }
                i++;    
            }
            SetAllLedColor(cm);
            Sleep(50);
 
            int mod = col_begin % 2;
            if ((row_begin == 5 && mod== 0) || (row_begin == 0 && mod == 1)) {
                col_begin++;
            }
            else {
                if (mod == 0)row_begin++;
                else row_begin--;
            }
            if (col_begin == 22) {
                row_begin = 0;
                col_begin = 0;
            }
        }
        
    }
    return 0;
}

Comments