qmk_firmware

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

battery.md (1432B)


      1 # Battery
      2 
      3 This feature provides the high level abstraction for sampling battery level.
      4 
      5 ## Usage
      6 
      7 To use this driver, add the following to your `rules.mk`:
      8 
      9 ```make
     10 BATTERY_ENABLE = yes
     11 ```
     12 
     13 ## Basic Configuration {#basic-configuration}
     14 
     15 Add the following to your `config.h`:
     16 
     17 |Define                    |Default |Description                                       |
     18 |--------------------------|--------|--------------------------------------------------|
     19 |`BATTERY_SAMPLE_INTERVAL` |`30000` |The time between battery samples in milliseconds. |
     20 
     21 ## Driver Configuration {#driver-configuration}
     22 
     23 See the [Battery Driver](../drivers/battery) documentation for more information.
     24 
     25 ## Functions
     26 
     27 ### `uint8_t battery_get_percent(void)` {#api-battery-get-percent}
     28 
     29 Sample battery level.
     30 
     31 #### Return Value {#api-battery-get-percent-return}
     32 
     33 The battery percentage, in the range 0-100.
     34 
     35 ## Callbacks
     36 
     37 ### `void battery_percent_changed_user(uint8_t level)` {#api-battery-percent-changed-user}
     38 
     39 User hook called when battery level changed.
     40 
     41 ### Arguments {#api-battery-percent-changed-user-arguments}
     42 
     43  - `uint8_t level`  
     44    The battery percentage, in the range 0-100.
     45 
     46 ---
     47 
     48 ### `void battery_percent_changed_kb(uint8_t level)` {#api-battery-percent-changed-kb}
     49 
     50 Keyboard hook called when battery level changed.
     51 
     52 ### Arguments {#api-battery-percent-changed-kb-arguments}
     53 
     54  - `uint8_t level`  
     55    The battery percentage, in the range 0-100.