added USB commands for brightness
This commit is contained in:
		
							parent
							
								
									9172fe3d78
								
							
						
					
					
						commit
						116d402b94
					
				| @ -21,11 +21,17 @@ | |||||||
| #define CMD_IEEREAD 8 // int. eep.
 | #define CMD_IEEREAD 8 // int. eep.
 | ||||||
| #define CMD_SETBLOCK 9 | #define CMD_SETBLOCK 9 | ||||||
| #define CMD_SETLED 10 | #define CMD_SETLED 10 | ||||||
|  | #define CMD_SETBRIGHTNESS 12 | ||||||
|  | #define CMD_GETBRIGHTNESS 13 | ||||||
| 
 | 
 | ||||||
| #define IEE_ADDR_DEFAULT_BRIGHTNESS 0 | #define IEE_ADDR_DEFAULT_BRIGHTNESS 0 | ||||||
| #define IEE_ADDR_DEFAULT_BLOCK 4 | #define IEE_ADDR_DEFAULT_BLOCK 4 | ||||||
| 
 | 
 | ||||||
|  | #define BLOCKCODE_RERENDER 254 | ||||||
|  | #define BLOCKCODE_RELOAD 253 | ||||||
|  | 
 | ||||||
| volatile int change_block = 255; | volatile int change_block = 255; | ||||||
|  | volatile uint8_t brightness = 1; | ||||||
| 
 | 
 | ||||||
| const uint8_t PROGMEM gamma8[] = { | const uint8_t PROGMEM gamma8[] = { | ||||||
|         0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, |         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]; | 		change_block = rq->wValue.bytes[0]; | ||||||
| 		return 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) { | 	else if (rq->bRequest == CMD_SETLED) { | ||||||
| 		led[rq->wValue.bytes[0]].r = rq->wValue.bytes[1]; | 		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]].g = rq->wIndex.bytes[0]; | ||||||
| @ -126,7 +140,6 @@ void keyboard(void) { | |||||||
| 	enum enum_state next_state = IDLE; | 	enum enum_state next_state = IDLE; | ||||||
| 	uint8_t i; | 	uint8_t i; | ||||||
| 	uint16_t factor = 1; | 	uint16_t factor = 1; | ||||||
| 	uint8_t brightness = 1; |  | ||||||
| 	uint8_t key = 0; | 	uint8_t key = 0; | ||||||
| 	uint16_t loadAddress; | 	uint16_t loadAddress; | ||||||
| 	uint16_t loadCount; | 	uint16_t loadCount; | ||||||
| @ -177,10 +190,12 @@ void keyboard(void) { | |||||||
| 		switch (state) { | 		switch (state) { | ||||||
| 		case IDLE: | 		case IDLE: | ||||||
| 			if (change_block != 255) { | 			if (change_block != 255) { | ||||||
| 				if (change_block == 254) { | 				if (change_block == BLOCKCODE_RERENDER) { | ||||||
| 					state = RENDER; | 					state = RENDER; | ||||||
| 					next_state = IDLE; | 					next_state = IDLE; | ||||||
| 				} else { | 				} else { | ||||||
|  | 					if (change_block = BLOCKCODE_RELOAD) | ||||||
|  | 						change_block = current_block; | ||||||
| 					loadAddress_ld = (change_block) * LEDS_PER_SLOT * 3; | 					loadAddress_ld = (change_block) * LEDS_PER_SLOT * 3; | ||||||
| 					state = PREP_LOAD; | 					state = PREP_LOAD; | ||||||
| 					next_state = IDLE; | 					next_state = IDLE; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user