2014-07-20 03:53:25 +00:00
|
|
|
#include <avr/pgmspace.h>
|
2014-07-24 06:03:58 +00:00
|
|
|
#include "ledmap.h"
|
|
|
|
#include "debug.h"
|
2014-07-20 03:53:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
#ifdef LEDMAP_ENABLE
|
|
|
|
|
|
|
|
static const uint8_t ledmaps[LED_COUNT] PROGMEM = {
|
|
|
|
#if defined(GH60_REV_CHN)
|
2014-07-25 05:24:57 +00:00
|
|
|
[0] = LEDMAP_CAPS_LOCK | LEDMAP_BACKLIGHT, // CapsLock - PB2
|
2014-08-25 05:03:23 +00:00
|
|
|
[1] = LEDMAP_LAYER(1), // PWM - PB6
|
2014-07-20 03:53:25 +00:00
|
|
|
#else
|
2014-07-25 05:24:57 +00:00
|
|
|
[0] = LEDMAP_CAPS_LOCK | LEDMAP_BACKLIGHT, // CapsLock - PB2
|
|
|
|
[1] = LEDMAP_BACKLIGHT, // Esc - GPIO1 - PF6
|
|
|
|
[2] = LEDMAP_LAYER(1) | LEDMAP_BACKLIGHT, // WASD - GPIO0 - PF7
|
|
|
|
[3] = LEDMAP_LAYER(2) | LEDMAP_BACKLIGHT, // Sh/Al/Ct - GPIO3 - PF4
|
|
|
|
[4] = LEDMAP_LAYER(1) | LEDMAP_BACKLIGHT, // Fn - GPIO2 - PF5
|
2014-07-20 03:53:25 +00:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
uint8_t ledmap_get_code(uint8_t index)
|
|
|
|
{
|
|
|
|
return pgm_read_byte(&ledmaps[index]);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ledmap_led_init(void)
|
|
|
|
{
|
|
|
|
DDRB |= (1<<PB2);
|
|
|
|
PORTB |= (1<<PB2);
|
|
|
|
#if defined(GH60_REV_CHN)
|
|
|
|
DDRB |= (1<<PB6);
|
|
|
|
PORTB &= ~(1<<PB6);
|
|
|
|
#else
|
|
|
|
DDRF |= (1<<PF7 | 1<<PF6 | 1<<PF5 | 1<<PF4);
|
|
|
|
PORTF |= (1<<PF7 | 1<<PF6 | 1<<PF5 | 1<<PF4);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void ledmap_led_on(uint8_t index)
|
|
|
|
{
|
|
|
|
#if defined(GH60_REV_CHN)
|
|
|
|
switch (index) {
|
|
|
|
case 0:
|
|
|
|
PORTB &= ~(1<<PB2);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
PORTB |= (1<<PB6);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
switch (index) {
|
|
|
|
case 0:
|
|
|
|
PORTB &= ~(1<<PB2);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
PORTF &= ~(1<<PF6);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
PORTF &= ~(1<<PF7);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
PORTF &= ~(1<<PF4);
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
PORTF &= ~(1<<PF5);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void ledmap_led_off(uint8_t index)
|
|
|
|
{
|
|
|
|
#if defined(GH60_REV_CHN)
|
|
|
|
switch (index) {
|
|
|
|
case 0:
|
|
|
|
PORTB |= (1<<PB2);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
PORTB &= ~(1<<PB6);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
switch (index) {
|
|
|
|
case 0:
|
|
|
|
PORTB |= (1<<PB2);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
PORTF |= (1<<PF6);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
PORTF |= (1<<PF7);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
PORTF |= (1<<PF4);
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
PORTF |= (1<<PF5);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|