Add a simple backlight support for ghpad
This commit is contained in:
parent
e35fdfc5c7
commit
2a2c7b8333
46
keyboard/ghpad/backlight.c
Normal file
46
keyboard/ghpad/backlight.c
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
Copyright 2013 Kai Ryu <kai1103@gmail.com>
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <avr/io.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include "backlight.h"
|
||||
|
||||
/* Backlight pin configuration
|
||||
* PF7 PF6 PF5
|
||||
*/
|
||||
void backlight_set(uint8_t level)
|
||||
{
|
||||
switch (level) {
|
||||
case 0:
|
||||
DDRF &= ~(1<<PF7 | 1<<PF6 | 1<<PF5);
|
||||
break;
|
||||
case 1:
|
||||
DDRF &= ~(1<<PF6 | 1<<PF5);
|
||||
DDRF |= (1<<PF7);
|
||||
PORTF &= ~(1<<PF7);
|
||||
break;
|
||||
case 2:
|
||||
DDRF &= ~(1<<PF5);
|
||||
DDRF |= (1<<PF7 | 1<<PF6);
|
||||
PORTF &= ~(1<<PF7 | 1<<PF6);
|
||||
break;
|
||||
case 3:
|
||||
DDRF |= (1<<PF7 | 1<<PF6 | 1<<PF5);
|
||||
PORTF &= ~(1<<PF7 | 1<<PF6 | 1<<PF5);
|
||||
break;
|
||||
}
|
||||
}
|
@ -31,12 +31,19 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#define MATRIX_ROWS 6
|
||||
#define MATRIX_COLS 4
|
||||
|
||||
/* keymap in eeprom */
|
||||
#define FN_ACTIONS_COUNT 32
|
||||
#define KEYMAPS_COUNT 32
|
||||
|
||||
/* define if matrix has ghost */
|
||||
//#define MATRIX_HAS_GHOST
|
||||
|
||||
/* Set 0 if debouncing isn't needed */
|
||||
#define DEBOUNCE 5
|
||||
|
||||
/* number of backlight levels */
|
||||
#define BACKLIGHT_LEVELS 3
|
||||
|
||||
/* number of backlight levels */
|
||||
//#define BACKLIGHT_LEVELS 3
|
||||
|
||||
|
@ -35,7 +35,7 @@ const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
|
||||
TRNS,TRNS,TRNS,TRNS, \
|
||||
TRNS,TRNS,TRNS,TRNS, \
|
||||
TRNS,TRNS,TRNS,TRNS, \
|
||||
TRNS,TRNS,TRNS,TRNS),
|
||||
FN1, TRNS,FN2, TRNS),
|
||||
};
|
||||
|
||||
/*
|
||||
@ -46,7 +46,9 @@ const uint16_t fn_actions[FN_ACTIONS_COUNT] __attribute__ ((section (".keymap.fn
|
||||
#else
|
||||
const uint16_t fn_actions[] PROGMEM = {
|
||||
#endif
|
||||
[0] = ACTION_LAYER_MOMENTARY(1)
|
||||
[0] = ACTION_LAYER_MOMENTARY(1),
|
||||
[1] = ACTION_BACKLIGHT_DECREASE(),
|
||||
[2] = ACTION_BACKLIGHT_INCREASE()
|
||||
};
|
||||
|
||||
#ifdef KEYMAP_EX_ENABLE
|
||||
|
@ -57,6 +57,10 @@ uint8_t matrix_cols(void)
|
||||
|
||||
void matrix_init(void)
|
||||
{
|
||||
// disable JTAG
|
||||
MCUCR = (1<<JTD);
|
||||
MCUCR = (1<<JTD);
|
||||
|
||||
// initialize row and col
|
||||
unselect_rows();
|
||||
init_cols();
|
||||
|
Reference in New Issue
Block a user