qmk_firmware

QMK firmware for my keyboards (Corne, Sweep Ferris) and trackball (Ploopy Adept)
Log | Files | Refs | Submodules | LICENSE

promethium.c (560B)


      1 #include "keyboard.h"
      2 #include "timer.h"
      3 #include "battery.h"
      4 
      5 #ifndef BATTERY_POLL
      6 #    define BATTERY_POLL 30000
      7 #endif
      8 
      9 uint8_t battery_level(void) {
     10     // maintain legacy behaviour and scale 0-100 percent to 0-255
     11     uint16_t percent = battery_get_percent();
     12     return  (percent * 255) / 100;
     13 }
     14 
     15 __attribute__ ((weak))
     16 void battery_poll(uint8_t level) {
     17 }
     18 
     19 void housekeeping_task_kb(void) {
     20     static uint16_t counter = BATTERY_POLL;
     21     counter++;
     22 
     23     if (counter > BATTERY_POLL) {
     24         counter = 0;
     25         battery_poll(battery_level());
     26     }
     27 }