Compare commits

...

3 Commits

View File

@ -21,11 +21,18 @@
#define CMD_IEEREAD 8 // int. eep.
#define CMD_SETBLOCK 9
#define CMD_SETLED 10
#define CMD_GETLED 11
#define CMD_SETBRIGHTNESS 12
#define CMD_GETBRIGHTNESS 13
#define IEE_ADDR_DEFAULT_BRIGHTNESS 0
#define IEE_ADDR_DEFAULT_BLOCK 4
#define BLOCKCODE_RERENDER 254
#define BLOCKCODE_RELOAD 253
volatile int change_block = 255;
volatile uint8_t brightness = 1;
const uint8_t PROGMEM gamma8[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@ -49,7 +56,7 @@ const uint8_t PROGMEM gammaBright[] = {
0, 1, 2, 3, 6, 10, 14,
18, 26, 31, 38, 46, 54, 66,
76, 89, 104, 128, 150, 180, 240,
250, 280, 340};
290, 400, 500};
struct cRGB led[LEDS_PER_SLOT];
@ -103,12 +110,26 @@ USB_PUBLIC uchar usbFunctionSetup(uchar data[8])
change_block = rq->wValue.bytes[0];
return 0;
}
else if (rq->bRequest == CMD_SETBRIGHTNESS) {
brightness = rq->wValue.bytes[0];
return 0;
}
else if(rq->bRequest == CMD_GETBRIGHTNESS) {
reportBuffer[0] = brightness;
return 1;
}
else if (rq->bRequest == CMD_SETLED) {
led[rq->wValue.bytes[0]].r = rq->wValue.bytes[1];
led[rq->wValue.bytes[0]].g = rq->wIndex.bytes[0];
led[rq->wValue.bytes[0]].b = rq->wIndex.bytes[1];
return 0;
}
else if (rq->bRequest == CMD_GETLED) {
reportBuffer[0] = led[rq->wValue.bytes[0]].r;
reportBuffer[1] = led[rq->wValue.bytes[0]].g;
reportBuffer[2] = led[rq->wValue.bytes[0]].b;
return 3;
}
return 0;
}
@ -126,7 +147,6 @@ void keyboard(void) {
enum enum_state next_state = IDLE;
uint8_t i;
uint16_t factor = 1;
uint8_t brightness = 1;
uint8_t key = 0;
uint16_t loadAddress;
uint16_t loadCount;
@ -177,10 +197,12 @@ void keyboard(void) {
switch (state) {
case IDLE:
if (change_block != 255) {
if (change_block == 254) {
if (change_block == BLOCKCODE_RERENDER) {
state = RENDER;
next_state = IDLE;
} else {
if (change_block = BLOCKCODE_RELOAD)
change_block = current_block;
loadAddress_ld = (change_block) * LEDS_PER_SLOT * 3;
state = PREP_LOAD;
next_state = IDLE;
@ -194,7 +216,8 @@ void keyboard(void) {
brightness = (brightness <= 0 ? 0 : brightness - 1);
break;
case KEY_BRIGHTNESS_DOWN:
brightness = (brightness >= 21 ? 21 : brightness + 1);
brightness = (brightness >= sizeof(gammaBright) - 3 ? /* No idea why -3... */
sizeof(gammaBright) - 3 : brightness + 1);
break;
case KEY_SF_1:
break;