Add support for full-led revision of ghpad
This commit is contained in:
parent
91d22894b0
commit
5bc8b5dcb6
@ -50,7 +50,8 @@ TARGET_DIR = .
|
|||||||
# project specific files
|
# project specific files
|
||||||
SRC = keymap_common.c \
|
SRC = keymap_common.c \
|
||||||
matrix.c \
|
matrix.c \
|
||||||
led.c
|
led.c \
|
||||||
|
backlight.c
|
||||||
|
|
||||||
ifdef KEYMAP
|
ifdef KEYMAP
|
||||||
SRC := keymap_$(KEYMAP).c $(SRC)
|
SRC := keymap_$(KEYMAP).c $(SRC)
|
||||||
@ -123,7 +124,7 @@ 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 - not yet supported in LUFA
|
#NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
|
||||||
#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_EX_ENABLE = yes # External keymap in eeprom
|
||||||
KEYMAP_SECTION_ENABLE = yes # Fixed address keymap for keymap editor
|
KEYMAP_SECTION_ENABLE = yes # Fixed address keymap for keymap editor
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2013 Kai Ryu <kai1103@gmail.com>
|
Copyright 2013,2014 Kai Ryu <kai1103@gmail.com>
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -17,30 +17,66 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
|
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
#include <avr/interrupt.h>
|
#include <avr/interrupt.h>
|
||||||
|
#include <avr/pgmspace.h>
|
||||||
#include "backlight.h"
|
#include "backlight.h"
|
||||||
|
|
||||||
|
static const uint8_t backlight_table[] PROGMEM = {
|
||||||
|
0, 16, 128, 255
|
||||||
|
};
|
||||||
|
|
||||||
|
uint8_t softpwm_ocr = 0;
|
||||||
|
|
||||||
/* Backlight pin configuration
|
/* Backlight pin configuration
|
||||||
* PF7 PF6 PF5
|
* PWM: PB5 (RevRS)
|
||||||
|
* GPIO: PF7 PF6 PF5
|
||||||
*/
|
*/
|
||||||
void backlight_set(uint8_t level)
|
void backlight_set(uint8_t level)
|
||||||
{
|
{
|
||||||
switch (level) {
|
if (level > 0) {
|
||||||
case 0:
|
// Turn on PWM
|
||||||
DDRF &= ~(1<<PF7 | 1<<PF6 | 1<<PF5);
|
cli();
|
||||||
break;
|
// Hard PWM
|
||||||
case 1:
|
DDRB |= (1<<PB5);
|
||||||
DDRF &= ~(1<<PF6 | 1<<PF5);
|
PORTB |= (1<<PB5);
|
||||||
DDRF |= (1<<PF7);
|
TCCR1A |= ((1<<WGM10) | (1<<COM1A1));
|
||||||
PORTF &= ~(1<<PF7);
|
TCCR1B |= ((1<<CS11) | (1<<CS10));
|
||||||
break;
|
// Soft PWM
|
||||||
case 2:
|
DDRF |= ((1<<PF7) | (1<<PF6) | (1<<PF5));
|
||||||
DDRF &= ~(1<<PF5);
|
PORTF |= ((1<<PF7) | (1<<PF6) | (1<<PF5));
|
||||||
DDRF |= (1<<PF7 | 1<<PF6);
|
TIMSK1 |= ((1<<OCIE1A) | (1<<TOIE1));
|
||||||
PORTF &= ~(1<<PF7 | 1<<PF6);
|
TIFR1 |= (1<<TOV1);
|
||||||
break;
|
sei();
|
||||||
case 3:
|
// Set PWM
|
||||||
DDRF |= (1<<PF7 | 1<<PF6 | 1<<PF5);
|
OCR1A = pgm_read_byte(&backlight_table[level]);
|
||||||
PORTF &= ~(1<<PF7 | 1<<PF6 | 1<<PF5);
|
softpwm_ocr = pgm_read_byte(&backlight_table[level]);
|
||||||
break;
|
}
|
||||||
|
else {
|
||||||
|
// Turn off PWM
|
||||||
|
cli();
|
||||||
|
// Hard PWM
|
||||||
|
DDRB |= (1<<PB5);
|
||||||
|
PORTB &= ~(1<<PB5);
|
||||||
|
TCCR1A &= ~((1<<WGM10) | (1<<COM1A1));
|
||||||
|
TCCR1B &= ~((1<<CS11) | (1<<CS10));
|
||||||
|
// Soft PWM
|
||||||
|
DDRF |= ((1<<PF7) | (1<<PF6) | (1<<PF5));
|
||||||
|
PORTF |= ((1<<PF7) | (1<<PF6) | (1<<PF5));
|
||||||
|
TIMSK1 |= ((1<<OCIE1A) | (1<<TOIE1));
|
||||||
|
TIFR1 |= (1<<TOV1);
|
||||||
|
sei();
|
||||||
|
// Set PWM
|
||||||
|
OCR1A = 0;
|
||||||
|
softpwm_ocr = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ISR(TIMER1_COMPA_vect)
|
||||||
|
{
|
||||||
|
// LED off
|
||||||
|
PORTF |= ((1<<PF7) | (1<<PF6) | (1<<PF5));
|
||||||
|
}
|
||||||
|
ISR(TIMER1_OVF_vect)
|
||||||
|
{
|
||||||
|
// LED on
|
||||||
|
PORTF &= ~((1<<PF7) | (1<<PF6) | (1<<PF5));
|
||||||
|
}
|
||||||
|
54
keyboard/ghpad/keymap_4x6_backlight.c
Normal file
54
keyboard/ghpad/keymap_4x6_backlight.c
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
#include "keymap_common.h"
|
||||||
|
|
||||||
|
// 4x6 Keypad
|
||||||
|
#ifdef KEYMAP_SECTION_ENABLE
|
||||||
|
const uint8_t keymaps[KEYMAPS_COUNT][MATRIX_ROWS][MATRIX_COLS] __attribute__ ((section (".keymap.keymaps"))) = {
|
||||||
|
#else
|
||||||
|
const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
|
||||||
|
#endif
|
||||||
|
/* Keymap 0: Default Layer
|
||||||
|
* ,---------------.
|
||||||
|
* |Esc|Fn0|Fn1|Fn2|
|
||||||
|
* |---+---+---+---|
|
||||||
|
* |Num|/ |* |- |
|
||||||
|
* |---+---+---+---|
|
||||||
|
* |7 |8 |9 |+ |
|
||||||
|
* |---+---+---| |
|
||||||
|
* |4 |5 |6 | |
|
||||||
|
* |---+---+---+---|
|
||||||
|
* |1 |2 |3 |Ent|
|
||||||
|
* |---+---+---| |
|
||||||
|
* |0 |. | |
|
||||||
|
* `---------------'
|
||||||
|
*/
|
||||||
|
[0] = KEYMAP(
|
||||||
|
ESC, FN0, FN1, FN2, \
|
||||||
|
NLCK,PSLS,PAST,PMNS, \
|
||||||
|
P7, P8, P9, PPLS, \
|
||||||
|
P4, P5, P6, PENT, \
|
||||||
|
P1, P2, P3, PENT, \
|
||||||
|
P0, NO, PDOT,NO)
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Fn action definition
|
||||||
|
*/
|
||||||
|
#ifdef KEYMAP_SECTION_ENABLE
|
||||||
|
const uint16_t fn_actions[FN_ACTIONS_COUNT] __attribute__ ((section (".keymap.fn_actions"))) = {
|
||||||
|
#else
|
||||||
|
const uint16_t fn_actions[] PROGMEM = {
|
||||||
|
#endif
|
||||||
|
[0] = ACTION_BACKLIGHT_TOGGLE(),
|
||||||
|
[1] = ACTION_BACKLIGHT_DECREASE(),
|
||||||
|
[2] = ACTION_BACKLIGHT_INCREASE()
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef KEYMAP_EX_ENABLE
|
||||||
|
uint16_t keys_count(void) {
|
||||||
|
return sizeof(keymaps) / sizeof(keymaps[0]) * MATRIX_ROWS * MATRIX_COLS;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t fn_actions_count(void) {
|
||||||
|
return sizeof(fn_actions) / sizeof(fn_actions[0]);
|
||||||
|
}
|
||||||
|
#endif
|
@ -24,11 +24,11 @@ void led_set(uint8_t usb_led)
|
|||||||
{
|
{
|
||||||
if (usb_led & (1<<USB_LED_NUM_LOCK)) {
|
if (usb_led & (1<<USB_LED_NUM_LOCK)) {
|
||||||
// output low
|
// output low
|
||||||
DDRB |= (1<<2);
|
DDRB |= (1<<PB2);
|
||||||
PORTB &= ~(1<<2);
|
PORTB &= ~(1<<PB2);
|
||||||
} else {
|
} else {
|
||||||
// Hi-Z
|
// Hi-Z
|
||||||
DDRB &= ~(1<<2);
|
DDRB &= ~(1<<PB2);
|
||||||
PORTB &= ~(1<<2);
|
PORTB &= ~(1<<PB2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2013 Kai Ryu <kai1103@gmail.com>
|
Copyright 2013,2014 Kai Ryu <kai1103@gmail.com>
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
|
Reference in New Issue
Block a user