/* | |||||
Copyright 2013 Kai Ryu <[email protected]> | |||||
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; | |||||
} | |||||
} |
#define MATRIX_ROWS 6 | #define MATRIX_ROWS 6 | ||||
#define MATRIX_COLS 4 | #define MATRIX_COLS 4 | ||||
/* keymap in eeprom */ | |||||
#define FN_ACTIONS_COUNT 32 | |||||
#define KEYMAPS_COUNT 32 | |||||
/* define if matrix has ghost */ | /* define if matrix has ghost */ | ||||
//#define MATRIX_HAS_GHOST | //#define MATRIX_HAS_GHOST | ||||
/* Set 0 if debouncing isn't needed */ | /* Set 0 if debouncing isn't needed */ | ||||
#define DEBOUNCE 5 | #define DEBOUNCE 5 | ||||
/* number of backlight levels */ | |||||
#define BACKLIGHT_LEVELS 3 | |||||
/* number of backlight levels */ | /* number of backlight levels */ | ||||
//#define BACKLIGHT_LEVELS 3 | //#define BACKLIGHT_LEVELS 3 | ||||
TRNS,TRNS,TRNS,TRNS, \ | TRNS,TRNS,TRNS,TRNS, \ | ||||
TRNS,TRNS,TRNS,TRNS, \ | TRNS,TRNS,TRNS,TRNS, \ | ||||
TRNS,TRNS,TRNS,TRNS, \ | TRNS,TRNS,TRNS,TRNS, \ | ||||
TRNS,TRNS,TRNS,TRNS), | |||||
FN1, TRNS,FN2, TRNS), | |||||
}; | }; | ||||
/* | /* | ||||
#else | #else | ||||
const uint16_t fn_actions[] PROGMEM = { | const uint16_t fn_actions[] PROGMEM = { | ||||
#endif | #endif | ||||
[0] = ACTION_LAYER_MOMENTARY(1) | |||||
[0] = ACTION_LAYER_MOMENTARY(1), | |||||
[1] = ACTION_BACKLIGHT_DECREASE(), | |||||
[2] = ACTION_BACKLIGHT_INCREASE() | |||||
}; | }; | ||||
#ifdef KEYMAP_EX_ENABLE | #ifdef KEYMAP_EX_ENABLE |
void matrix_init(void) | void matrix_init(void) | ||||
{ | { | ||||
// disable JTAG | |||||
MCUCR = (1<<JTD); | |||||
MCUCR = (1<<JTD); | |||||
// initialize row and col | // initialize row and col | ||||
unselect_rows(); | unselect_rows(); | ||||
init_cols(); | init_cols(); |