From 91d22894b0ccf7657592bbda840f7ab1bfc0a6b4 Mon Sep 17 00:00:00 2001 From: Kai Ryu Date: Tue, 14 Jan 2014 16:13:01 +0900 Subject: [PATCH] Impement led matrix for GH60 rev.CNY --- keyboard/gh60/Makefile | 3 +- keyboard/gh60/backlight.c | 22 ++++++++++- keyboard/gh60/config.h | 10 ++--- keyboard/gh60/led_matrix.c | 75 ++++++++++++++++++++++++++++++++++++++ keyboard/gh60/matrix.c | 3 ++ 5 files changed, 106 insertions(+), 7 deletions(-) diff --git a/keyboard/gh60/Makefile b/keyboard/gh60/Makefile index 99b62f1f..8da7908d 100644 --- a/keyboard/gh60/Makefile +++ b/keyboard/gh60/Makefile @@ -51,7 +51,8 @@ TARGET_DIR = . SRC = keymap_common.c \ matrix.c \ led.c \ - backlight.c + backlight.c \ + led_matrix.c ifdef KEYMAP SRC := keymap_$(KEYMAP).c $(SRC) diff --git a/keyboard/gh60/backlight.c b/keyboard/gh60/backlight.c index 3d8f6279..25fbc833 100644 --- a/keyboard/gh60/backlight.c +++ b/keyboard/gh60/backlight.c @@ -20,7 +20,7 @@ along with this program. If not, see . #include #include "backlight.h" -#ifdef GH60_REV_CHN +#if defined(GH60_REV_CHN) static const uint8_t backlight_table[] PROGMEM = { 0, 16, 128, 255 }; @@ -51,6 +51,26 @@ void backlight_set(uint8_t level) OCR1B = 0; } } +#elif #defined(GH60_REV_CNY) +static const uint8_t backlight_table[] PROGMEM = { + 0, 16, 128, 255 +}; + +void backlight_set(uint8_t level) +{ + if (level > 0) { + led_matrix_disable(); + for (uint8_t row = 0; row < LED_MATRIX_ROWS; row++) { + for (uint8_t col = 0; col < LED_MATRIX_COLS; col++) { + led_matrix_set_value(row, col, pgm_read_byte(&backlight_table[level])); + } + } + led_matrix_enable(); + } + else { + led_matrix_disable(); + } +} #else void backlight_set(uint8_t level) { diff --git a/keyboard/gh60/config.h b/keyboard/gh60/config.h index 6bb2e4ee..dd9d21ae 100644 --- a/keyboard/gh60/config.h +++ b/keyboard/gh60/config.h @@ -43,16 +43,16 @@ along with this program. If not, see . /* number of backlight levels */ #if defined(GH60_REV_CHN) -#define BACKLIGHT_LEVELS 3 +# define BACKLIGHT_LEVELS 3 #elif defined(GH60_REV_CNY) -#define BACKLIGHT_LEVELS 3 +# define BACKLIGHT_LEVELS 3 #else -#define BACKLIGHT_LEVELS 1 +# define BACKLIGHT_LEVELS 1 #endif #ifdef GH60_REV_CNY -#define LED_MATRIX_ROWS 6 -#define LED_MATRIX_COLS 14 +# define LED_MATRIX_ROWS 6 +# define LED_MATRIX_COLS 14 #endif /* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ diff --git a/keyboard/gh60/led_matrix.c b/keyboard/gh60/led_matrix.c index a3525cc3..bcd94218 100644 --- a/keyboard/gh60/led_matrix.c +++ b/keyboard/gh60/led_matrix.c @@ -15,3 +15,78 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +#include +#include "led_matrix.h" + +#if defined(GH60_REV_CNY) + +/* LED Column pin configuration + * pin: F0 F1 E6 C7 C6 B7 D4 B0 B1 B5 B4 D7 D6 B3 (Rev.CNY) + */ +void led_matrix_write_cols(led_matrix_row_t cols) +{ + (cols & (1<<0)) ? (PORTF |= (1<