diff --git a/main.c b/main.c index 85abab2..ccc9715 100644 --- a/main.c +++ b/main.c @@ -1,5 +1,28 @@ /* - LedController + ledcontroller-3bit + + This file is a fork of the LedController code. You will find + the original copyright notice below. + + Copyright (C) 2013 andmarios - http://www.andmarios.com + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + + + Original Copyright Notice: + + LedController Copyright (C) 2011 jmrobles - http://robleshermoso.wordpress.com This program is free software: you can redistribute it and/or modify @@ -34,11 +57,35 @@ int main(int argc,char** argv) unsigned char code = 0; if (argc != 2 ) { - printf("syntax: %s red | green | blue | off\n",argv[0]); + printf("syntax: %s blue | red | green | aqua | purple | yellow | white | off\n",argv[0]); return -1; } - if ( strcmp(argv[1],"red") == 0 ) + +/* + The device has a RGB LED, which has two states for each "sub-LED", + on and off. + The "sub-LEDs" are red, green and blue. + + Obviously there are 8 possible combinations for their state. + It seems there aren't bits mapped to each sub-LED, but instead + 3-bit values mapped to the 8 combinations. + + R G B Color Value + 0 0 0 off 0x0 + 0 0 1 blue 0x1 + 1 0 0 red 0x2 + 0 1 0 green 0x3 + 0 1 1 aqua 0x4 + 1 0 1 purple 0x5 + 1 1 0 yellow 0x6 + 1 1 1 white 0x7 +*/ + if ( strcmp(argv[1],"blue") == 0 ) + { + code = 1; + } + else if ( strcmp(argv[1],"red") == 0 ) { code = 2; } @@ -46,9 +93,21 @@ int main(int argc,char** argv) { code = 3; } - else if ( strcmp(argv[1],"blue") == 0 ) + else if ( strcmp(argv[1],"aqua") == 0 ) { - code = 1; + code = 4; + } + else if ( strcmp(argv[1],"purple") == 0 ) + { + code = 5; + } + else if ( strcmp(argv[1],"yellow") == 0 ) + { + code = 6; + } + else if ( strcmp(argv[1],"white") == 0 ) + { + code = 7; } libusb_init(NULL);