From e26869d70ac3e78d3c07d312c8f07b190b0c3325 Mon Sep 17 00:00:00 2001 From: Kai Ryu Date: Fri, 18 Apr 2014 12:12:59 +0900 Subject: [PATCH] Change software pwm method to fix blink issue --- common/breathing_led.c | 2 +- keyboard/gh60/backlight.c | 58 +++++++++++++++++++++++++++++---------- 2 files changed, 44 insertions(+), 16 deletions(-) diff --git a/common/breathing_led.c b/common/breathing_led.c index 80bb9d59..497f9a6d 100644 --- a/common/breathing_led.c +++ b/common/breathing_led.c @@ -97,7 +97,7 @@ ISR(TIMER3_COMPA_vect) step++; if (step >= BREATHING_LED_LEVELS - breathing_led_config.level) { step = 0; - index++; backlight_set_raw(pgm_read_byte(&breathing_table[index])); + index++; } } diff --git a/keyboard/gh60/backlight.c b/keyboard/gh60/backlight.c index 62a6e2ca..9b9c190b 100644 --- a/keyboard/gh60/backlight.c +++ b/keyboard/gh60/backlight.c @@ -21,6 +21,12 @@ along with this program. If not, see . #include "backlight.h" #include "debug.h" +#ifndef GH60_REV_CHN +#define SOFTPWM_TIMER_TOP F_CPU/(256*64) +uint8_t softpwm_ocr = 0; +uint8_t softpwm_ocr_buff = 0; +#endif + #if defined(BREATHING_LED_ENABLE) || defined(BACKLIGHT_CUSTOM) static const uint8_t backlight_table[] PROGMEM = { 0, 16, 128, 255 @@ -33,19 +39,20 @@ void backlight_enable(void) { #if defined(GH60_REV_CHN) // Turn on PWM - cli(); DDRB |= (1<>8)&0xff; + OCR1AL = SOFTPWM_TIMER_TOP&0xff; + TIMSK1 |= (1< 15) { + PORTF &= ~(1<