Update features for GHPad
- USB 6KRO - SoftPWM LED - Breathing LED - Fading LED - Typing LED - Ledmap - Ledmap in EEPROM
This commit is contained in:
parent
24b533adca
commit
9414e34f5b
@ -51,7 +51,8 @@ TARGET_DIR = .
|
|||||||
SRC = keymap_common.c \
|
SRC = keymap_common.c \
|
||||||
matrix.c \
|
matrix.c \
|
||||||
led.c \
|
led.c \
|
||||||
backlight.c
|
backlight.c \
|
||||||
|
ledmap.c
|
||||||
|
|
||||||
ifdef KEYMAP
|
ifdef KEYMAP
|
||||||
SRC := keymap_$(KEYMAP).c $(SRC)
|
SRC := keymap_$(KEYMAP).c $(SRC)
|
||||||
@ -128,10 +129,16 @@ CONSOLE_ENABLE = yes # Console for debug(+400)
|
|||||||
COMMAND_ENABLE = yes # Commands for debug and configuration
|
COMMAND_ENABLE = yes # Commands for debug and configuration
|
||||||
#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
|
#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
|
||||||
NKRO_ENABLE = yes # USB Nkey Rollover
|
NKRO_ENABLE = yes # USB Nkey Rollover
|
||||||
|
USB_6KRO_ENABLE = yes # USB 6key Rollover
|
||||||
#PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support
|
#PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support
|
||||||
BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
|
BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
|
||||||
KEYMAP_EX_ENABLE = yes # External keymap in eeprom
|
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
|
||||||
|
FADING_LED_ENABLE = yes # Enable fading backlight
|
||||||
|
BREATHING_LED_ENABLE = yes # Enable breathing backlight
|
||||||
|
LEDMAP_ENABLE = yes # Enable LED mapping
|
||||||
|
LEDMAP_IN_EEPROM_ENABLE = yes # Read LED mapping from eeprom
|
||||||
|
|
||||||
|
|
||||||
# Optimize size but this may cause error "relocation truncated to fit"
|
# Optimize size but this may cause error "relocation truncated to fit"
|
||||||
|
@ -50,7 +50,16 @@ TARGET_DIR = .
|
|||||||
# project specific files
|
# project specific files
|
||||||
SRC = keymap.c \
|
SRC = keymap.c \
|
||||||
matrix.c \
|
matrix.c \
|
||||||
led.c
|
led.c \
|
||||||
|
backlight.c \
|
||||||
|
ledmap.c
|
||||||
|
|
||||||
|
ifdef KEYMAP
|
||||||
|
SRC := keymap_$(KEYMAP).c $(SRC)
|
||||||
|
else
|
||||||
|
SRC := keymap_4x6.c $(SRC)
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
CONFIG_H = config.h
|
CONFIG_H = config.h
|
||||||
|
|
||||||
@ -86,7 +95,16 @@ CONSOLE_ENABLE = yes # Console for debug
|
|||||||
COMMAND_ENABLE = yes # Commands for debug and configuration
|
COMMAND_ENABLE = yes # Commands for debug and configuration
|
||||||
SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
|
SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
|
||||||
NKRO_ENABLE = yes # USB Nkey Rollover(+500)
|
NKRO_ENABLE = yes # USB Nkey Rollover(+500)
|
||||||
|
USB_6KRO_ENABLE = yes # USB 6key Rollover
|
||||||
#PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support
|
#PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support
|
||||||
|
BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
|
||||||
|
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
|
||||||
|
FADING_LED_ENABLE = yes # Enable fading backlight
|
||||||
|
BREATHING_LED_ENABLE = yes # Enable breathing backlight
|
||||||
|
LEDMAP_ENABLE = yes # Enable LED mapping
|
||||||
|
LEDMAP_IN_EEPROM_ENABLE = yes # Read LED mapping from eeprom
|
||||||
|
|
||||||
|
|
||||||
# Search Path
|
# Search Path
|
||||||
|
@ -19,64 +19,96 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#include <avr/interrupt.h>
|
#include <avr/interrupt.h>
|
||||||
#include <avr/pgmspace.h>
|
#include <avr/pgmspace.h>
|
||||||
#include "backlight.h"
|
#include "backlight.h"
|
||||||
|
#include "softpwm_led.h"
|
||||||
|
#include "action.h"
|
||||||
|
|
||||||
|
#ifdef BACKLIGHT_ENABLE
|
||||||
|
|
||||||
|
static uint8_t backlight_mode;
|
||||||
|
|
||||||
static const uint8_t backlight_table[] PROGMEM = {
|
static const uint8_t backlight_table[] PROGMEM = {
|
||||||
0, 16, 128, 255
|
0, 16, 128, 255
|
||||||
};
|
};
|
||||||
|
|
||||||
uint8_t softpwm_ocr = 0;
|
|
||||||
|
|
||||||
/* Backlight pin configuration
|
/* Backlight pin configuration
|
||||||
* PWM: PB5 (RevRS)
|
* PWM: PB5 (RevRS)
|
||||||
* GPIO: PF7 PF6 PF5
|
* GPIO: PF7 PF6 PF5
|
||||||
*/
|
*/
|
||||||
void backlight_set(uint8_t level)
|
void backlight_set(uint8_t level)
|
||||||
{
|
{
|
||||||
if (level > 0) {
|
backlight_mode = level;
|
||||||
// Turn on PWM
|
switch (level) {
|
||||||
cli();
|
case 1:
|
||||||
// Hard PWM
|
case 2:
|
||||||
DDRB |= (1<<PB5);
|
case 3:
|
||||||
PORTB |= (1<<PB5);
|
softpwm_led_enable();
|
||||||
TCCR1A |= ((1<<WGM10) | (1<<COM1A1));
|
fading_led_disable_all();
|
||||||
TCCR1B |= ((1<<CS11) | (1<<CS10));
|
breathing_led_disable_all();
|
||||||
// Soft PWM
|
softpwm_led_set_all(pgm_read_byte(&backlight_table[level]));
|
||||||
DDRF |= ((1<<PF7) | (1<<PF6) | (1<<PF5));
|
break;
|
||||||
PORTF |= ((1<<PF7) | (1<<PF6) | (1<<PF5));
|
case 4:
|
||||||
TIMSK1 |= ((1<<OCIE1A) | (1<<TOIE1));
|
case 5:
|
||||||
TIFR1 |= (1<<TOV1);
|
case 6:
|
||||||
sei();
|
softpwm_led_enable();
|
||||||
// Set PWM
|
breathing_led_enable_all();
|
||||||
OCR1A = pgm_read_byte(&backlight_table[level]);
|
fading_led_disable_all();
|
||||||
softpwm_ocr = pgm_read_byte(&backlight_table[level]);
|
breathing_led_set_duration(6 - level);
|
||||||
}
|
break;
|
||||||
else {
|
case 7:
|
||||||
// Turn off PWM
|
softpwm_led_enable();
|
||||||
cli();
|
fading_led_enable_all();
|
||||||
// Hard PWM
|
breathing_led_disable_all();
|
||||||
DDRB |= (1<<PB5);
|
fading_led_set_direction(FADING_LED_FADE_IN);
|
||||||
PORTB &= ~(1<<PB5);
|
fading_led_set_duration(4);
|
||||||
TCCR1A &= ~((1<<WGM10) | (1<<COM1A1));
|
break;
|
||||||
TCCR1B &= ~((1<<CS11) | (1<<CS10));
|
case 8:
|
||||||
// Soft PWM
|
softpwm_led_enable();
|
||||||
DDRF |= ((1<<PF7) | (1<<PF6) | (1<<PF5));
|
fading_led_enable_all();
|
||||||
PORTF |= ((1<<PF7) | (1<<PF6) | (1<<PF5));
|
breathing_led_disable_all();
|
||||||
TIMSK1 |= ((1<<OCIE1A) | (1<<TOIE1));
|
fading_led_set_direction(FADING_LED_FADE_OUT);
|
||||||
TIFR1 |= (1<<TOV1);
|
fading_led_set_duration(2);
|
||||||
sei();
|
break;
|
||||||
// Set PWM
|
case 0:
|
||||||
OCR1A = 0;
|
default:
|
||||||
softpwm_ocr = 0;
|
fading_led_disable_all();
|
||||||
|
breathing_led_disable_all();
|
||||||
|
softpwm_led_enable();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ISR(TIMER1_COMPA_vect)
|
#ifndef LEDMAP_ENABLE
|
||||||
|
void softpwm_led_init(void)
|
||||||
{
|
{
|
||||||
// LED off
|
DDRB |= (1<<PB5);
|
||||||
PORTF |= ((1<<PF7) | (1<<PF6) | (1<<PF5));
|
DDRF |= (1<<PF7 | 1<<PF6 | 1<<PF5);
|
||||||
}
|
}
|
||||||
ISR(TIMER1_OVF_vect)
|
|
||||||
|
void softpwm_led_on(uint8_t index)
|
||||||
{
|
{
|
||||||
// LED on
|
PORTB |= (1<<PB5);
|
||||||
PORTF &= ~((1<<PF7) | (1<<PF6) | (1<<PF5));
|
PORTF &= ~(1<<PF7 | 1<<PF6 | 1<<PF5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void softpwm_led_off(uint8_t index)
|
||||||
|
{
|
||||||
|
PORTB &= ~(1<<PB5);
|
||||||
|
PORTF |= (1<<PF7 | 1<<PF6 | 1<<PF5);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void action_keyevent(keyevent_t event)
|
||||||
|
{
|
||||||
|
if (backlight_mode == 7) {
|
||||||
|
if (event.pressed) {
|
||||||
|
softpwm_led_decrease_all(32);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (backlight_mode == 8) {
|
||||||
|
if (event.pressed) {
|
||||||
|
softpwm_led_increase_all(32);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@ -42,7 +42,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#define DEBOUNCE 5
|
#define DEBOUNCE 5
|
||||||
|
|
||||||
/* number of backlight levels */
|
/* number of backlight levels */
|
||||||
#define BACKLIGHT_LEVELS 3
|
#define BACKLIGHT_LEVELS 8
|
||||||
|
|
||||||
|
#define LED_COUNT 5
|
||||||
|
|
||||||
/* number of backlight levels */
|
/* number of backlight levels */
|
||||||
//#define BACKLIGHT_LEVELS 3
|
//#define BACKLIGHT_LEVELS 3
|
||||||
|
@ -40,7 +40,7 @@ const uint16_t fn_actions[] PROGMEM = {
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef KEYMAP_EX_ENABLE
|
#ifdef KEYMAP_IN_EEPROM_ENABLE
|
||||||
uint16_t keys_count(void) {
|
uint16_t keys_count(void) {
|
||||||
return sizeof(keymaps) / sizeof(keymaps[0]) * MATRIX_ROWS * MATRIX_COLS;
|
return sizeof(keymaps) / sizeof(keymaps[0]) * MATRIX_ROWS * MATRIX_COLS;
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ const uint16_t fn_actions[] PROGMEM = {
|
|||||||
[2] = ACTION_BACKLIGHT_INCREASE()
|
[2] = ACTION_BACKLIGHT_INCREASE()
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef KEYMAP_EX_ENABLE
|
#ifdef KEYMAP_IN_EEPROM_ENABLE
|
||||||
uint16_t keys_count(void) {
|
uint16_t keys_count(void) {
|
||||||
return sizeof(keymaps) / sizeof(keymaps[0]) * MATRIX_ROWS * MATRIX_COLS;
|
return sizeof(keymaps) / sizeof(keymaps[0]) * MATRIX_ROWS * MATRIX_COLS;
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ const uint16_t fn_actions[] PROGMEM = {
|
|||||||
[2] = ACTION_BACKLIGHT_INCREASE()
|
[2] = ACTION_BACKLIGHT_INCREASE()
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef KEYMAP_EX_ENABLE
|
#ifdef KEYMAP_IN_EEPROM_ENABLE
|
||||||
uint16_t keys_count(void) {
|
uint16_t keys_count(void) {
|
||||||
return sizeof(keymaps) / sizeof(keymaps[0]) * MATRIX_ROWS * MATRIX_COLS;
|
return sizeof(keymaps) / sizeof(keymaps[0]) * MATRIX_ROWS * MATRIX_COLS;
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
/* translates key to keycode */
|
/* translates key to keycode */
|
||||||
uint8_t keymap_key_to_keycode(uint8_t layer, key_t key)
|
uint8_t keymap_key_to_keycode(uint8_t layer, key_t key)
|
||||||
{
|
{
|
||||||
#ifndef KEYMAP_EX_ENABLE
|
#ifndef KEYMAP_IN_EEPROM_ENABLE
|
||||||
return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]);
|
return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]);
|
||||||
#else
|
#else
|
||||||
return eeconfig_read_keymap_key(layer, key.row, key.col);
|
return eeconfig_read_keymap_key(layer, key.row, key.col);
|
||||||
@ -30,7 +30,7 @@ uint8_t keymap_key_to_keycode(uint8_t layer, key_t key)
|
|||||||
action_t keymap_fn_to_action(uint8_t keycode)
|
action_t keymap_fn_to_action(uint8_t keycode)
|
||||||
{
|
{
|
||||||
return (action_t) {
|
return (action_t) {
|
||||||
#ifndef KEYMAP_EX_ENABLE
|
#ifndef KEYMAP_IN_EEPROM_ENABLE
|
||||||
.code = pgm_read_word(&fn_actions[FN_INDEX(keycode)])
|
.code = pgm_read_word(&fn_actions[FN_INDEX(keycode)])
|
||||||
#else
|
#else
|
||||||
.code = eeconfig_read_keymap_fn_action(FN_INDEX(keycode))
|
.code = eeconfig_read_keymap_fn_action(FN_INDEX(keycode))
|
||||||
@ -38,7 +38,7 @@ action_t keymap_fn_to_action(uint8_t keycode)
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef KEYMAP_EX_ENABLE
|
#ifdef KEYMAP_IN_EEPROM_ENABLE
|
||||||
const uint8_t* keymaps_pointer(void) {
|
const uint8_t* keymaps_pointer(void) {
|
||||||
return (const uint8_t*)keymaps;
|
return (const uint8_t*)keymaps;
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#include "print.h"
|
#include "print.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "keymap.h"
|
#include "keymap.h"
|
||||||
#include "keymap_ex.h"
|
#include "keymap_in_eeprom.h"
|
||||||
|
|
||||||
extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
|
extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
|
||||||
extern const uint16_t fn_actions[];
|
extern const uint16_t fn_actions[];
|
||||||
|
@ -41,7 +41,7 @@ const uint16_t fn_actions[] PROGMEM = {
|
|||||||
[0] = ACTION_BACKLIGHT_STEP(),
|
[0] = ACTION_BACKLIGHT_STEP(),
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef KEYMAP_EX_ENABLE
|
#ifdef KEYMAP_IN_EEPROM_ENABLE
|
||||||
uint16_t keys_count(void) {
|
uint16_t keys_count(void) {
|
||||||
return sizeof(keymaps) / sizeof(keymaps[0]) * MATRIX_ROWS * MATRIX_COLS;
|
return sizeof(keymaps) / sizeof(keymaps[0]) * MATRIX_ROWS * MATRIX_COLS;
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#include "stdint.h"
|
#include "stdint.h"
|
||||||
#include "led.h"
|
#include "led.h"
|
||||||
|
|
||||||
|
#ifndef LEDMAP_ENABLE
|
||||||
|
|
||||||
void led_set(uint8_t usb_led)
|
void led_set(uint8_t usb_led)
|
||||||
{
|
{
|
||||||
@ -32,3 +33,5 @@ void led_set(uint8_t usb_led)
|
|||||||
PORTB &= ~(1<<PB2);
|
PORTB &= ~(1<<PB2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
73
keyboard/ghpad/ledmap.c
Normal file
73
keyboard/ghpad/ledmap.c
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
#include <avr/pgmspace.h>
|
||||||
|
#include "ledmap.h"
|
||||||
|
#include "debug.h"
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef LEDMAP_ENABLE
|
||||||
|
|
||||||
|
static const uint8_t ledmaps[LED_COUNT] PROGMEM = {
|
||||||
|
[0] = LEDMAP_NUM_LOCK | LEDMAP_BACKLIGHT, // LEDS1 - PB2
|
||||||
|
[1] = LEDMAP_BACKLIGHT, // LEDS6 - PF7
|
||||||
|
[2] = LEDMAP_BACKLIGHT, // LEDS11 - PF6
|
||||||
|
[3] = LEDMAP_BACKLIGHT, // LEDS16 - PF5
|
||||||
|
[4] = LEDMAP_BACKLIGHT, // PWM - PB5
|
||||||
|
};
|
||||||
|
|
||||||
|
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);
|
||||||
|
DDRF |= (1<<PF7 | 1<<PF6 | 1<<PF5);
|
||||||
|
PORTF |= (1<<PF7 | 1<<PF6 | 1<<PF5);
|
||||||
|
DDRB |= (1<<PB5);
|
||||||
|
PORTB &= ~(1<<PB5);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ledmap_led_on(uint8_t index)
|
||||||
|
{
|
||||||
|
switch (index) {
|
||||||
|
case 0:
|
||||||
|
PORTB &= ~(1<<PB2);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
PORTF &= ~(1<<PF7);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
PORTF &= ~(1<<PF6);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
PORTF &= ~(1<<PF5);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
PORTB |= (1<<PB5);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ledmap_led_off(uint8_t index)
|
||||||
|
{
|
||||||
|
switch (index) {
|
||||||
|
case 0:
|
||||||
|
PORTB |= (1<<PB2);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
PORTF |= (1<<PF7);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
PORTF |= (1<<PF6);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
PORTF |= (1<<PF5);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
PORTB &= ~(1<<PB5);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
Reference in New Issue
Block a user