1
0

Experimental implement of led mapping for GH60

This commit is contained in:
Kai Ryu 2014-07-20 12:53:25 +09:00
parent aa7182e87c
commit 872c619cdf
5 changed files with 117 additions and 0 deletions

View File

@ -52,6 +52,7 @@ SRC = keymap_common.c \
matrix.c \ matrix.c \
led.c \ led.c \
backlight.c \ backlight.c \
ledmap.c \
led_matrix.c led_matrix.c
ifdef KEYMAP ifdef KEYMAP
@ -141,6 +142,7 @@ KEYMAP_IN_EEPROM_ENABLE = yes # Read keymap from eeprom
KEYMAP_SECTION_ENABLE = yes # Fixed address keymap for keymap editor KEYMAP_SECTION_ENABLE = yes # Fixed address keymap for keymap editor
SOFTPWM_LED_ENABLE = yes # Enable SoftPWM to drive backlight SOFTPWM_LED_ENABLE = yes # Enable SoftPWM to drive backlight
BREATHING_LED_ENABLE = yes # Enable breathing backlight BREATHING_LED_ENABLE = yes # Enable breathing backlight
LEDMAP_ENABLE = yes # Enable LED mapping
# Optimize size but this may cause error "relocation truncated to fit" # Optimize size but this may cause error "relocation truncated to fit"

View File

@ -169,6 +169,7 @@ inline void backlight_set_raw(uint8_t raw)
} }
#ifdef SOFTPWM_LED_ENABLE #ifdef SOFTPWM_LED_ENABLE
#ifndef LEDMAP_ENABLE
void softpwm_led_on(void) void softpwm_led_on(void)
{ {
@ -189,6 +190,7 @@ void softpwm_led_off(void)
} }
#endif #endif
#endif
#ifndef SOFTPWM_LED_ENABLE #ifndef SOFTPWM_LED_ENABLE

View File

@ -53,6 +53,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define LED_MATRIX_COLS 14 #define LED_MATRIX_COLS 14
#endif #endif
/* LED mapping */
#ifdef LEDMAP_ENABLE
#if defined(GH60_REV_CHN)
#define LED_COUNT 2
#else
#define LED_COUNT 5
#endif
#endif
/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ /* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
#define LOCKING_SUPPORT_ENABLE #define LOCKING_SUPPORT_ENABLE

View File

@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "led.h" #include "led.h"
#ifndef LEDMAP_ENABLE
void led_set(uint8_t usb_led) void led_set(uint8_t usb_led)
{ {
if (usb_led & (1<<USB_LED_CAPS_LOCK)) { if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
@ -32,3 +33,4 @@ void led_set(uint8_t usb_led)
PORTB &= ~(1<<2); PORTB &= ~(1<<2);
} }
} }
#endif

102
keyboard/gh60/ledmap.c Normal file
View File

@ -0,0 +1,102 @@
#include "ledmap.h"
#include <avr/pgmspace.h>
#ifdef LEDMAP_ENABLE
static const uint8_t ledmaps[LED_COUNT] PROGMEM = {
#if defined(GH60_REV_CHN)
[0] = LEDMAP_CAPS_LOCK, // CapsLock - PB2
[1] = LEDMAP_BACKLIGHT, // PWM - PB6
#else
[0] = LEDMAP_CAPS_LOCK, // CapsLock - PB2
[1] = LEDMAP_BACKLIGHT, // Esc - GPIO1 - PF6
[2] = LEDMAP_LAYER(1), // WASD - GPIO0 - PF7
[3] = LEDMAP_LAYER(2), // Sh/Al/Ct - GPIO3 - PF4
[4] = LEDMAP_LAYER(1), // Fn - GPIO2 - PF5
#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