2017-10-21 22:51:02 +02:00
|
|
|
#include "17.h"
|
2016-03-28 01:17:40 +02:00
|
|
|
|
2016-06-29 22:21:41 +02:00
|
|
|
int pwm_level;
|
|
|
|
|
2016-04-06 05:27:40 +02:00
|
|
|
void matrix_init_kb(void) {
|
2016-03-28 01:17:40 +02:00
|
|
|
// put your keyboard start-up code here
|
|
|
|
// runs once when the firmware starts up
|
2016-06-24 04:18:20 +02:00
|
|
|
matrix_init_user();
|
2016-03-28 01:17:40 +02:00
|
|
|
};
|
2016-06-29 22:21:41 +02:00
|
|
|
|
2019-01-23 18:25:32 +01:00
|
|
|
void led_set_kb(uint8_t usb_led) {
|
2016-06-29 22:21:41 +02:00
|
|
|
print("led_set\n");
|
|
|
|
}
|
|
|
|
|
2019-01-23 18:25:32 +01:00
|
|
|
void backlight_init_ports(void) {
|
2016-06-29 22:21:41 +02:00
|
|
|
// Set C7 to output
|
|
|
|
DDRC |= (1<<7);
|
|
|
|
|
|
|
|
// Initialize the timer
|
|
|
|
TC4H = 0x03;
|
|
|
|
OCR4C = 0xFF;
|
|
|
|
TCCR4A = 0b10000010;
|
|
|
|
TCCR4B = 0b00000001;
|
|
|
|
}
|
|
|
|
|
2019-01-23 18:25:32 +01:00
|
|
|
void backlight_set(uint8_t level) {
|
2016-06-29 22:21:41 +02:00
|
|
|
// Determine the PWM level
|
|
|
|
switch (level)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
// 33%
|
|
|
|
pwm_level = 0x54;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
// 66%
|
|
|
|
pwm_level = 0xA8;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
// 100%
|
|
|
|
pwm_level = 0xFF;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
// 0%
|
|
|
|
pwm_level = 0x00;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
xprintf("Unknown level: %d\n", level);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Write the PWM level to the timer
|
|
|
|
TC4H = pwm_level >> 8;
|
|
|
|
OCR4A = 0xFF & pwm_level;
|
|
|
|
}
|