Some minor fixes for RedScarfII
This commit is contained in:
parent
430e15e0ba
commit
b08054dba1
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2013,2014 Kai Ryu <kai1103@gmail.com>
|
Copyright 2014 Kai Ryu <kai1103@gmail.com>
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -28,64 +28,61 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
|
|
||||||
#ifdef BACKLIGHT_ENABLE
|
#ifdef BACKLIGHT_ENABLE
|
||||||
|
|
||||||
static uint8_t backlight_mode;
|
|
||||||
|
|
||||||
static const uint8_t backlight_table[] PROGMEM = {
|
static const uint8_t backlight_table[] PROGMEM = {
|
||||||
0, 16, 128, 255
|
0, 16, 128, 255
|
||||||
};
|
};
|
||||||
|
|
||||||
void backlight_enable(void);
|
|
||||||
void backlight_disable(void);
|
|
||||||
inline void backlight_set_raw(uint8_t raw);
|
inline void backlight_set_raw(uint8_t raw);
|
||||||
|
|
||||||
|
#ifdef SOFTPWM_LED_ENABLE
|
||||||
|
#ifdef FADING_LED_ENABLE
|
||||||
|
static uint8_t backlight_mode;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Backlight pin configuration
|
/* Backlight pin configuration
|
||||||
* PWM: PB7(OC1C)
|
* PWM: PB7(OC1C)
|
||||||
*/
|
*/
|
||||||
|
#ifndef SOFTPWM_LED_ENABLE
|
||||||
void backlight_enable(void)
|
void backlight_enable(void)
|
||||||
{
|
{
|
||||||
#ifdef SOFTPWM_LED_ENABLE
|
|
||||||
DDRB |= (1<<PB7);
|
|
||||||
softpwm_led_enable();
|
|
||||||
#else
|
|
||||||
// Turn on PWM
|
// Turn on PWM
|
||||||
DDRB |= (1<<PB7);
|
|
||||||
cli();
|
cli();
|
||||||
TCCR1A |= ((1<<WGM10) | (1<<COM1C1));
|
DDRB |= (1<<PB7);
|
||||||
TCCR1B |= ((1<<CS11) | (1<<CS10));
|
TCCR1A |= ( (1<<WGM10) | (1<<COM1C1) );
|
||||||
|
TCCR1B |= ( (1<<CS11) | (1<<CS10) );
|
||||||
sei();
|
sei();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void backlight_disable(void)
|
void backlight_disable(void)
|
||||||
{
|
{
|
||||||
#ifdef SOFTPWM_LED_ENABLE
|
|
||||||
DDRB &= ~(1<<PB7);
|
|
||||||
softpwm_led_disable();
|
|
||||||
#else
|
|
||||||
// Turn off PWM
|
// Turn off PWM
|
||||||
cli();
|
cli();
|
||||||
DDRB &= ~(1<<PB7);
|
DDRB &= ~(1<<PB7);
|
||||||
TCCR1A &= ~( (1<<WGM10) | (1<<COM1C1) );
|
TCCR1A &= ~( (1<<WGM10) | (1<<COM1C1) );
|
||||||
TCCR1B &= ~( (1<<CS11) | (1<<CS10) );
|
TCCR1B &= ~( (1<<CS11) | (1<<CS10) );
|
||||||
sei();
|
sei();
|
||||||
OCR1C = 0;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void backlight_set(uint8_t level)
|
void backlight_set(uint8_t level)
|
||||||
{
|
{
|
||||||
|
#ifdef FADING_LED_ENABLE
|
||||||
|
backlight_mode = level;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef BREATHING_LED_ENABLE
|
#ifdef BREATHING_LED_ENABLE
|
||||||
switch (level) {
|
switch (level) {
|
||||||
case 1:
|
case 1:
|
||||||
case 2:
|
case 2:
|
||||||
case 3:
|
case 3:
|
||||||
backlight_enable();
|
|
||||||
#ifdef SOFTPWM_LED_ENABLE
|
#ifdef SOFTPWM_LED_ENABLE
|
||||||
|
softpwm_led_enable();
|
||||||
#ifdef FADING_LED_ENABLE
|
#ifdef FADING_LED_ENABLE
|
||||||
fading_led_disable_all();
|
fading_led_disable_all();
|
||||||
#endif
|
#endif
|
||||||
breathing_led_disable_all();
|
breathing_led_disable_all();
|
||||||
#else
|
#else
|
||||||
|
backlight_enable();
|
||||||
breathing_led_disable();
|
breathing_led_disable();
|
||||||
#endif
|
#endif
|
||||||
backlight_set_raw(pgm_read_byte(&backlight_table[level]));
|
backlight_set_raw(pgm_read_byte(&backlight_table[level]));
|
||||||
@ -93,30 +90,35 @@ void backlight_set(uint8_t level)
|
|||||||
case 4:
|
case 4:
|
||||||
case 5:
|
case 5:
|
||||||
case 6:
|
case 6:
|
||||||
backlight_enable();
|
|
||||||
#ifdef SOFTPWM_LED_ENABLE
|
#ifdef SOFTPWM_LED_ENABLE
|
||||||
|
softpwm_led_enable();
|
||||||
#ifdef FADING_LED_ENABLE
|
#ifdef FADING_LED_ENABLE
|
||||||
fading_led_disable_all();
|
fading_led_disable_all();
|
||||||
#endif
|
#endif
|
||||||
breathing_led_enable_all();
|
breathing_led_enable_all();
|
||||||
#else
|
#else
|
||||||
|
backlight_enable();
|
||||||
breathing_led_enable();
|
breathing_led_enable();
|
||||||
#endif
|
#endif
|
||||||
breathing_led_set_duration(6 - level);
|
breathing_led_set_duration(6 - level);
|
||||||
break;
|
break;
|
||||||
|
#ifdef SOFTPWM_LED_ENABLE
|
||||||
#ifdef FADING_LED_ENABLE
|
#ifdef FADING_LED_ENABLE
|
||||||
case 7:
|
case 7:
|
||||||
backlight_enable();
|
softpwm_led_enable();
|
||||||
fading_led_enable_all();
|
fading_led_enable_all();
|
||||||
breathing_led_disable_all();
|
breathing_led_disable_all();
|
||||||
fading_led_set_direction(FADING_LED_FADE_IN);
|
fading_led_set_direction(FADING_LED_FADE_IN);
|
||||||
fading_led_set_duration(3);
|
fading_led_set_duration(3);
|
||||||
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
backlight_enable();
|
softpwm_led_enable();
|
||||||
fading_led_enable_all();
|
fading_led_enable_all();
|
||||||
breathing_led_disable_all();
|
breathing_led_disable_all();
|
||||||
fading_led_set_direction(FADING_LED_FADE_OUT);
|
fading_led_set_direction(FADING_LED_FADE_OUT);
|
||||||
fading_led_set_duration(3);
|
fading_led_set_duration(3);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
case 0:
|
case 0:
|
||||||
default:
|
default:
|
||||||
@ -125,10 +127,11 @@ void backlight_set(uint8_t level)
|
|||||||
fading_led_disable_all();
|
fading_led_disable_all();
|
||||||
#endif
|
#endif
|
||||||
breathing_led_disable_all();
|
breathing_led_disable_all();
|
||||||
|
softpwm_led_disable();
|
||||||
#else
|
#else
|
||||||
breathing_led_disable();
|
breathing_led_disable();
|
||||||
#endif
|
|
||||||
backlight_disable();
|
backlight_disable();
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@ -140,6 +143,7 @@ void backlight_set(uint8_t level)
|
|||||||
backlight_disable();
|
backlight_disable();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef SOFTPWM_LED_ENABLE
|
#ifndef SOFTPWM_LED_ENABLE
|
||||||
@ -162,9 +166,14 @@ inline void backlight_set_raw(uint8_t raw)
|
|||||||
|
|
||||||
#ifndef LEDMAP_ENABLE
|
#ifndef LEDMAP_ENABLE
|
||||||
#ifdef SOFTPWM_LED_ENABLE
|
#ifdef SOFTPWM_LED_ENABLE
|
||||||
|
void softpwm_led_init(void)
|
||||||
|
{
|
||||||
|
DDRB |= (1<<PB7);
|
||||||
|
}
|
||||||
|
|
||||||
void softpwm_led_on(uint8_t index)
|
void softpwm_led_on(uint8_t index)
|
||||||
{
|
{
|
||||||
PORTB |= (1<<PB7);
|
PORTB |= (1<<PB7);
|
||||||
}
|
}
|
||||||
|
|
||||||
void softpwm_led_off(uint8_t index)
|
void softpwm_led_off(uint8_t index)
|
||||||
|
@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#include "keymap_common.h"
|
#include "keymap_common.h"
|
||||||
|
|
||||||
/* translates key to keycode */
|
/* translates key to keycode */
|
||||||
uint8_t keymap_key_to_keycode(uint8_t layer, key_t key)
|
uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key)
|
||||||
{
|
{
|
||||||
#ifndef KEYMAP_IN_EEPROM_ENABLE
|
#ifndef KEYMAP_IN_EEPROM_ENABLE
|
||||||
return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]);
|
return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]);
|
||||||
|
@ -20,16 +20,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
|
|
||||||
#ifdef LEDMAP_ENABLE
|
#ifdef LEDMAP_ENABLE
|
||||||
|
|
||||||
static const uint8_t ledmaps[LED_COUNT] PROGMEM = {
|
static const uint16_t ledmaps[LED_COUNT] PROGMEM = {
|
||||||
[0] = LEDMAP_CAPS_LOCK | LEDMAP_BACKLIGHT, // CapsLock
|
[0] = LEDMAP_CAPS_LOCK | LEDMAP_BACKLIGHT, // CapsLock
|
||||||
[1] = LEDMAP_NUM_LOCK | LEDMAP_BACKLIGHT, // NumLock
|
[1] = LEDMAP_NUM_LOCK | LEDMAP_BACKLIGHT, // NumLock
|
||||||
[2] = LEDMAP_SCROLL_LOCK | LEDMAP_BACKLIGHT, // Logo
|
[2] = LEDMAP_SCROLL_LOCK | LEDMAP_BACKLIGHT, // Logo
|
||||||
[3] = LEDMAP_BACKLIGHT, // Backlight
|
[3] = LEDMAP_BACKLIGHT, // Backlight
|
||||||
};
|
};
|
||||||
|
|
||||||
uint8_t ledmap_get_code(uint8_t index)
|
ledmap_t ledmap_get_code(uint8_t index)
|
||||||
{
|
{
|
||||||
return pgm_read_byte(&ledmaps[index]);
|
return (ledmap_t) { .code = pgm_read_word(&ledmaps[index]) };
|
||||||
}
|
}
|
||||||
|
|
||||||
/* LED pin configration
|
/* LED pin configration
|
||||||
@ -64,6 +64,7 @@ void ledmap_led_on(uint8_t index)
|
|||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
PORTB |= (1<<PB7);
|
PORTB |= (1<<PB7);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user