Merge pull request #25 from orcinus/master
Fixed brightness control; Reduced number of brightness levels to 4.daktil_thumb_popravljen
commit
0aa0f75432
|
@ -36,14 +36,26 @@ void backlight_set(uint8_t level)
|
||||||
{
|
{
|
||||||
// Turn off PWM control on PB7, revert to output low.
|
// Turn off PWM control on PB7, revert to output low.
|
||||||
TCCR1A &= ~(_BV(COM1C1));
|
TCCR1A &= ~(_BV(COM1C1));
|
||||||
// CHANNEL = level << OFFSET | 0x0FFF;
|
CHANNEL = 0x0;
|
||||||
CHANNEL = ((1 << level) - 1);
|
// Prevent backlight blink on lowest level
|
||||||
|
PORTB &= ~(_BV(PORTB7));
|
||||||
|
}
|
||||||
|
else if ( level == BACKLIGHT_LEVELS )
|
||||||
|
{
|
||||||
|
// Prevent backlight blink on lowest level
|
||||||
|
PORTB &= ~(_BV(PORTB7));
|
||||||
|
// Turn on PWM control of PB7
|
||||||
|
TCCR1A |= _BV(COM1C1);
|
||||||
|
// Set the brightness
|
||||||
|
CHANNEL = 0xFFFF;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// Prevent backlight blink on lowest level
|
||||||
|
PORTB &= ~(_BV(PORTB7));
|
||||||
// Turn on PWM control of PB7
|
// Turn on PWM control of PB7
|
||||||
TCCR1A |= _BV(COM1C1);
|
TCCR1A |= _BV(COM1C1);
|
||||||
// CHANNEL = level << OFFSET | 0x0FFF;
|
// Set the brightness
|
||||||
CHANNEL = ((1 << level) - 1);
|
CHANNEL = 0xFFFF >> ((BACKLIGHT_LEVELS - level) * ((BACKLIGHT_LEVELS + 1) / 2));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -35,8 +35,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
//#define MATRIX_HAS_GHOST
|
//#define MATRIX_HAS_GHOST
|
||||||
|
|
||||||
/* number of backlight levels */
|
/* number of backlight levels */
|
||||||
/* NOTE: this is the max value of 0..BACKLIGHT_LEVELS so really 16 levels. */
|
#define BACKLIGHT_LEVELS 3
|
||||||
#define BACKLIGHT_LEVELS 15
|
|
||||||
|
|
||||||
/* Set 0 if debouncing isn't needed */
|
/* Set 0 if debouncing isn't needed */
|
||||||
#define DEBOUNCE 5
|
#define DEBOUNCE 5
|
||||||
|
@ -51,18 +50,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
|
keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Feature disable options
|
* Feature disable options
|
||||||
* These options are also useful to firmware size reduction.
|
* These options are also useful to firmware size reduction.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* disable debug print */
|
/* disable debug print */
|
||||||
//#define NO_DEBUG
|
#define NO_DEBUG
|
||||||
|
|
||||||
/* disable print */
|
/* disable print */
|
||||||
//#define NO_PRINT
|
#define NO_PRINT
|
||||||
|
|
||||||
/* disable action features */
|
/* disable action features */
|
||||||
//#define NO_ACTION_LAYER
|
//#define NO_ACTION_LAYER
|
||||||
|
|
Loading…
Reference in New Issue