blob: ec3b33a776f099d031c681be2de56a772a1af021 (
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
|
#ifndef BACKEND_BATTERY_H_
#define BACKEND_BATTERY_H_
#include "timer.h"
#include "api.h"
#include "probe.h"
struct battery {
const char *name;
/* Returns 1 if on AC; 0 if not. */
int (*on_ac)(struct battery *b);
/* Enable/disable charging. Returns 0 on success or negative error code. */
int (*charger_enable)(struct battery *b, int enable);
/* Returns 1 if charging the battery; 0 if not */
int (*charging)(struct battery *b);
/* Returns the minimum battery level constant value */
int (*min_level)(struct battery *b);
/* Returns the maximum battery level constant value */
int (*max_level)(struct battery *b);
/* Get the battery charge level value */
int (*charge_level)(struct battery *b);
/* Returns the battery capacity in mAh. 0 if no battery present.
* Negative if unknown */
int (*capacity_mAh)(struct battery *b);
/* Returns the measured battery current in mA.
* This is charge current if charging and drain current if draining.
* Negative value is returned on error */
int (*current_mA)(struct battery *b);
/* Returns the battery temperature in K. Negative is not supported. */
int (*temperature_K)(struct battery *b);
void (*destroy)(struct battery *b);
int (*update)(struct battery *b);
unsigned int poll_interval;
/* Internal */
struct sleeptimer timer;
int emergency_handled;
};
void battery_init(struct battery *b, const char *name);
struct battery * battery_probe(void);
void battery_destroy(struct battery *b);
int battery_fill_pt_message_stat(struct battery *b, struct pt_message *msg);
int battery_notify_state_change(struct battery *b);
DECLARE_PROBES(battery);
#define BATTERY_PROBE(_name, _func) DEFINE_PROBE(battery, _name, _func)
#endif /* BACKEND_BATTERY_H_ */
|