diff --git a/firmware/keyboard.c b/firmware/keyboard.c index 19739f7..651eb6d 100644 --- a/firmware/keyboard.c +++ b/firmware/keyboard.c @@ -21,11 +21,17 @@ #define CMD_IEEREAD 8 // int. eep. #define CMD_SETBLOCK 9 #define CMD_SETLED 10 +#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, @@ -103,6 +109,14 @@ 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]; @@ -126,7 +140,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 +190,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;