This repository has been archived on 2025-02-01. You can view files and clone it, but cannot push or open issues or pull requests.
tmk_keyboard/keyboard/valkey/backlight.c

66 lines
1.6 KiB
C

/*
Copyright 2014 Ralf Schmitt <ralf@bunkertor.net>
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
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <avr/io.h>
#include "backlight.h"
/* Backlight pin configuration
*
* HOME_ROW : PD1
* FUNCTIONS: PD0
*/
void backlight_init_ports() {
DDRD |= (1<<0) | (1<<1);
//PORTD |= (1<<0) | (1<<1);
DDRD |= (1<<6);
PORTD |= (1<<6);
}
void backlight_set(uint8_t level) {
(level & BACKLIGHT_FNCT) ? backlight_enable_fn() : backlight_disable_fn();
(level & BACKLIGHT_HOME) ? backlight_enable_home() : backlight_disable_home();
}
void backlight_enable_fn() {
DDRD |= (1<<0) | (1<<1);
PORTD |= (1<<0);
}
void backlight_disable_fn() {
DDRD |= (1<<0) | (1<<1);
PORTD &= ~(1<<0);
}
void backlight_invert_fn() {
DDRD |= (1<<0) | (1<<1);
PORTD ^= (1<<0);
}
void backlight_enable_home() {
DDRD |= (1<<0) | (1<<1);
PORTD |= (1<<1);
}
void backlight_disable_home() {
DDRD |= (1<<0) | (1<<1);
PORTD &= ~(1<<1);
}
void backlight_invert_home() {
DDRD |= (1<<0) | (1<<1);
PORTD ^= (1<<1);
}