[battery] Tie into the periodic function to update APM info

Tie into the periodic function so we can get the APM info.

For now it's not checking that some time has elapsed, the hope
is that it'll just be driven by md_main_loop() / 5 second select
timeout.
This commit is contained in:
Adrian Chadd
2022-05-14 22:08:55 -07:00
parent 4bd5a665db
commit 030f55fa2e

View File

@@ -11,6 +11,9 @@
#include "libami.h" #include "libami.h"
/* XXX should be an md method */
extern void (*md_periodic_func)(void);
/* /*
* Test battery module for FreeBSD, using APM. * Test battery module for FreeBSD, using APM.
*/ */
@@ -45,21 +48,29 @@ get_apm_info(void)
return true; return true;
} }
static void
periodic_func(void)
{
fprintf(stderr, "Ha!\n");
get_apm_info();
}
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
char *arg=md_init(argc, argv); char *arg;
arg = md_init(argc, argv);
progname=argv[0]; progname=argv[0];
md_periodic_func = periodic_func;
apm_fd = open(APM_DEV, O_RDONLY); apm_fd = open(APM_DEV, O_RDONLY);
if (apm_fd < 0) { if (apm_fd < 0) {
err(127, "open"); err(127, "open");
} }
/* /* initial battery info */
* XXX TODO: how do I actually get this to run once
* a second in the main loop?
*/
get_apm_info(); get_apm_info();
md_main_loop(); md_main_loop();