uint8_t buffer[BUFFERSIZE];
uint8_t pointer = 0;
-uint8_t red[NUM_LEDS] = {0xff};
-uint8_t green[NUM_LEDS] = {0xff};
-uint8_t blue[NUM_LEDS] = {0xff};
+uint8_t red[NUM_LEDS] = {0x06,0x06,0x06,0x06,0x06};
+uint8_t green[NUM_LEDS] = {0x09,0x09,0x09,0x09,0x09};
+uint8_t blue[NUM_LEDS] = {0x10,0x10,0x10,0x10,0x10};
void init(void) {
LED_RGB_OUT();
LED_RGB_LOW();
+ DDRD |= (1<<PD5);
}
void led_update(void) {
uint8_t col[3];
uint8_t cc;
- DDRD |= (1<<PD5);
+ PORTD &= ~(1<<PD5);
+
cli();
for(uint8_t k = 0; k<NUM_LEDS;k++) {
col[0] = green[k];
}
else {
LED_RGB_HIGH();
+ _delay_us(0.1);
LED_RGB_LOW();
_delay_us(0.5);
}
}
}
sei();
- DDRD &= ~(1<<PD5);
+ PORTD |= (1<<PD5);
}
-uint8_t hex2int(char c) {
+uint8_t hex2int(uint8_t c) {
if(c >= '0' && c<='9') return c-'0';
if(c >= 'a' && c<='f') return c-'a'+10;
if(c >= 'A' && c<='F') return c-'A'+10;
return -1;
}
-uint8_t configuration_led(char* h) {
+uint8_t configuration_led(uint8_t* h) {
uint8_t l = hex2int(*h);
red[l] = hex2int(*(h+1))*16+hex2int(*(h+2));
green[l] = hex2int(*(h+3))*16+hex2int(*(h+4));
__attribute__((naked)) int main(void) {
init();
usb_init();
+ led_update();
while (1) {
int n = usb_serial_getchar();
if (n >= 0) {
buffer[pointer++] = n;
+ usb_serial_putchar_nowait(n);
if(pointer>BUFFERSIZE) {
pointer = 0;
}
- if(n == 10) {
- if(pointer >= 9 && buffer[0] == '#') {
- configuration_led(buffer+1);
- }
+ if(pointer >= 8 && buffer[0] == '#') {
+ configuration_led(buffer+1);
pointer = 0;
}
}
+ if (n == 0x0a || n == 0x0d || buffer[0] != '#') {
+ pointer = 0;
+ }
}
}
// Udev rules (in /etc/udev/rules.d) can define persistent device
// names linked to this serial number, as well as permissions, owner
// and group settings.
-#define STR_SERIAL_NUMBER L"00001"
+#define STR_SERIAL_NUMBER L"00002"
// Mac OS-X and Linux automatically load the correct drivers. On
// Windows, even though the driver is supplied by Microsoft, an