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
|
|
|
|
|
2014-11-25 09:23:16 +00:00
|
|
|
static const uint16_t ledmaps[LED_COUNT] PROGMEM = {
|
2014-07-20 03:53:25 +00:00
|
|
|
#if defined(GH60_REV_CHN)
|
2014-07-25 05:24:57 +00:00
|
|
|
[0] = LEDMAP_CAPS_LOCK | LEDMAP_BACKLIGHT, // CapsLock - PB2
|
2014-09-02 03:21:36 +00:00
|
|
|
[1] = LEDMAP_BACKLIGHT, // 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
|
|
|
|
};
|
|
|
|
|
2014-11-25 09:23:16 +00:00
|
|
|
ledmap_t ledmap_get_code(uint8_t index)
|
2014-07-20 03:53:25 +00:00
|
|
|
{
|
2014-11-25 09:23:16 +00:00
|
|
|
return (ledmap_t) { .code = pgm_read_word(&ledmaps[index]) };
|
2014-07-20 03:53:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|