2016-11-26 12:11:40 +06:00
|
|
|
#include "promethium.h"
|
2017-02-10 20:28:46 +06:00
|
|
|
#include "analog.h"
|
|
|
|
#include "timer.h"
|
|
|
|
#include "matrix.h"
|
2017-04-19 00:38:08 +06:00
|
|
|
#include "musical_notes.h"
|
|
|
|
|
2017-04-19 11:35:05 +06:00
|
|
|
float fauxclicky_pressed_note[2] = MUSICAL_NOTE(_C5, 0.25);
|
|
|
|
float fauxclicky_released_note[2] = MUSICAL_NOTE(_C4, 0.25);
|
|
|
|
float fauxclicky_beep_note[2] = MUSICAL_NOTE(_C6, 0.25);
|
2016-11-26 12:11:40 +06:00
|
|
|
|
2017-02-11 13:50:43 +06:00
|
|
|
// cubic fit {3.3, 0}, {3.5, 2.9}, {3.6, 5}, {3.7, 8.6}, {3.8, 36}, {3.9, 62}, {4.0, 73}, {4.05, 83}, {4.1, 89}, {4.15, 94}, {4.2, 100}
|
|
|
|
|
|
|
|
uint8_t battery_level(void) {
|
2017-02-10 20:28:46 +06:00
|
|
|
float voltage = analogRead(BATTERY_PIN) * 2 * 3.3 / 1024;
|
2017-02-11 13:50:43 +06:00
|
|
|
if (voltage < MIN_VOLTAGE) return 0;
|
|
|
|
if (voltage > MAX_VOLTAGE) return 255;
|
|
|
|
return (voltage - MIN_VOLTAGE) / (MAX_VOLTAGE - MIN_VOLTAGE) * 255;
|
2017-02-10 20:28:46 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
__attribute__ ((weak))
|
2017-02-11 13:50:43 +06:00
|
|
|
void battery_poll(uint8_t level) {
|
2017-02-10 20:28:46 +06:00
|
|
|
}
|
2016-11-26 12:11:40 +06:00
|
|
|
|
2017-02-10 20:28:46 +06:00
|
|
|
void matrix_init_kb(void) {
|
2016-11-26 12:11:40 +06:00
|
|
|
matrix_init_user();
|
2017-02-10 20:28:46 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
void matrix_scan_kb(void) {
|
|
|
|
static uint16_t counter = BATTERY_POLL;
|
|
|
|
counter++;
|
|
|
|
|
|
|
|
if (counter > BATTERY_POLL) {
|
|
|
|
counter = 0;
|
2017-02-11 13:50:43 +06:00
|
|
|
battery_poll(battery_level());
|
2017-02-10 20:28:46 +06:00
|
|
|
}
|
2017-02-10 23:07:10 +06:00
|
|
|
|
|
|
|
matrix_scan_user();
|
2017-02-10 20:28:46 +06:00
|
|
|
}
|
|
|
|
|
2017-02-11 18:03:18 +06:00
|
|
|
void led_set_kb(uint8_t usb_led) {
|
|
|
|
led_set_user(usb_led);
|
|
|
|
}
|
2017-02-10 20:28:46 +06:00
|
|
|
|
2017-02-15 18:22:58 +06:00
|
|
|
__attribute__ ((weak))
|
|
|
|
void led_set_user(uint8_t usb_led) {
|
|
|
|
}
|
|
|
|
|