aboutsummaryrefslogtreecommitdiffstats
path: root/docs/features/battery.md
blob: f5c725efb9bdd8440d7f8ff2f99feff810cc9080 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# Battery

This feature provides the high level abstraction for sampling battery level.

## Usage

To use this driver, add the following to your `rules.mk`:

```make
BATTERY_ENABLE = yes
```

## Basic Configuration {#basic-configuration}

Add the following to your `config.h`:

|Define                    |Default |Description                                       |
|--------------------------|--------|--------------------------------------------------|
|`BATTERY_SAMPLE_INTERVAL` |`30000` |The time between battery samples in milliseconds. |

## Driver Configuration {#driver-configuration}

See the [Battery Driver](../drivers/battery) documentation for more information.

## Functions

### `uint8_t battery_get_percent(void)` {#api-battery-get-percent}

Sample battery level.

#### Return Value {#api-battery-get-percent-return}

The battery percentage, in the range 0-100.

## Callbacks

### `void battery_percent_changed_user(uint8_t level)` {#api-battery-percent-changed-user}

User hook called when battery level changed.

### Arguments {#api-battery-percent-changed-user-arguments}

 - `uint8_t level`  
   The battery percentage, in the range 0-100.

---

### `void battery_percent_changed_kb(uint8_t level)` {#api-battery-percent-changed-kb}

Keyboard hook called when battery level changed.

### Arguments {#api-battery-percent-changed-kb-arguments}

 - `uint8_t level`  
   The battery percentage, in the range 0-100.