From 5bc8b5dcb6a4e03a1ad7bceba2c22bb9f6eb81fb Mon Sep 17 00:00:00 2001 From: Kai Ryu Date: Fri, 4 Apr 2014 12:22:22 +0900 Subject: [PATCH] Add support for full-led revision of ghpad --- keyboard/ghpad/Makefile | 5 +- keyboard/ghpad/backlight.c | 76 ++++++++++++++++++++------- keyboard/ghpad/keymap_4x6_backlight.c | 54 +++++++++++++++++++ keyboard/ghpad/led.c | 8 +-- keyboard/ghpad/matrix.c | 2 +- 5 files changed, 118 insertions(+), 27 deletions(-) create mode 100644 keyboard/ghpad/keymap_4x6_backlight.c diff --git a/keyboard/ghpad/Makefile b/keyboard/ghpad/Makefile index 4b76788c..f1cecfb0 100644 --- a/keyboard/ghpad/Makefile +++ b/keyboard/ghpad/Makefile @@ -50,7 +50,8 @@ TARGET_DIR = . # project specific files SRC = keymap_common.c \ matrix.c \ - led.c + led.c \ + backlight.c ifdef KEYMAP 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 #NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA #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_SECTION_ENABLE = yes # Fixed address keymap for keymap editor diff --git a/keyboard/ghpad/backlight.c b/keyboard/ghpad/backlight.c index 61282adb..f6b00317 100644 --- a/keyboard/ghpad/backlight.c +++ b/keyboard/ghpad/backlight.c @@ -1,5 +1,5 @@ /* -Copyright 2013 Kai Ryu +Copyright 2013,2014 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 @@ -17,30 +17,66 @@ along with this program. If not, see . #include #include +#include #include "backlight.h" +static const uint8_t backlight_table[] PROGMEM = { + 0, 16, 128, 255 +}; + +uint8_t softpwm_ocr = 0; + /* Backlight pin configuration - * PF7 PF6 PF5 + * PWM: PB5 (RevRS) + * GPIO: PF7 PF6 PF5 */ void backlight_set(uint8_t level) { - switch (level) { - case 0: - DDRF &= ~(1< 0) { + // Turn on PWM + cli(); + // Hard PWM + DDRB |= (1< +Copyright 2013,2014 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