Experimental implement of led mapping for GH60
This commit is contained in:
parent
aa7182e87c
commit
872c619cdf
@ -52,6 +52,7 @@ SRC = keymap_common.c \
|
||||
matrix.c \
|
||||
led.c \
|
||||
backlight.c \
|
||||
ledmap.c \
|
||||
led_matrix.c
|
||||
|
||||
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
|
||||
SOFTPWM_LED_ENABLE = yes # Enable SoftPWM to drive 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"
|
||||
|
@ -169,6 +169,7 @@ inline void backlight_set_raw(uint8_t raw)
|
||||
}
|
||||
|
||||
#ifdef SOFTPWM_LED_ENABLE
|
||||
#ifndef LEDMAP_ENABLE
|
||||
|
||||
void softpwm_led_on(void)
|
||||
{
|
||||
@ -189,6 +190,7 @@ void softpwm_led_off(void)
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef SOFTPWM_LED_ENABLE
|
||||
|
@ -53,6 +53,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#define LED_MATRIX_COLS 14
|
||||
#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 */
|
||||
#define LOCKING_SUPPORT_ENABLE
|
||||
|
||||
|
@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#include "led.h"
|
||||
|
||||
|
||||
#ifndef LEDMAP_ENABLE
|
||||
void led_set(uint8_t usb_led)
|
||||
{
|
||||
if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
|
||||
@ -32,3 +33,4 @@ void led_set(uint8_t usb_led)
|
||||
PORTB &= ~(1<<2);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
102
keyboard/gh60/ledmap.c
Normal file
102
keyboard/gh60/ledmap.c
Normal 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
|
Reference in New Issue
Block a user