From 2a2c7b83334db0e2cd9b2647033bb0188a1061db Mon Sep 17 00:00:00 2001 From: Kai Ryu Date: Fri, 10 Jan 2014 09:18:52 +0900 Subject: [PATCH] Add a simple backlight support for ghpad --- keyboard/ghpad/backlight.c | 46 +++++++++++++++++++++++++++++++++++ keyboard/ghpad/config.h | 7 ++++++ keyboard/ghpad/keymap_arrow.c | 6 +++-- keyboard/ghpad/matrix.c | 4 +++ 4 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 keyboard/ghpad/backlight.c diff --git a/keyboard/ghpad/backlight.c b/keyboard/ghpad/backlight.c new file mode 100644 index 00000000..61282adb --- /dev/null +++ b/keyboard/ghpad/backlight.c @@ -0,0 +1,46 @@ +/* +Copyright 2013 Kai Ryu + +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 . +*/ + +#include +#include +#include "backlight.h" + +/* Backlight pin configuration + * PF7 PF6 PF5 + */ +void backlight_set(uint8_t level) +{ + switch (level) { + case 0: + DDRF &= ~(1<. #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 diff --git a/keyboard/ghpad/keymap_arrow.c b/keyboard/ghpad/keymap_arrow.c index 5e00ace3..0bf98ed6 100644 --- a/keyboard/ghpad/keymap_arrow.c +++ b/keyboard/ghpad/keymap_arrow.c @@ -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 diff --git a/keyboard/ghpad/matrix.c b/keyboard/ghpad/matrix.c index b259d253..32cf4b6a 100644 --- a/keyboard/ghpad/matrix.c +++ b/keyboard/ghpad/matrix.c @@ -57,6 +57,10 @@ uint8_t matrix_cols(void) void matrix_init(void) { + // disable JTAG + MCUCR = (1<