add timer to check battery level every 30 seconds

This commit is contained in:
Brad Parker 2016-12-19 15:49:11 -05:00
parent 1e5c675702
commit 51b9886586
1 changed files with 12 additions and 1 deletions

View File

@ -29,6 +29,7 @@
#include <lists/string_list.h> #include <lists/string_list.h>
#include <gfx/math/matrix_4x4.h> #include <gfx/math/matrix_4x4.h>
#include <encodings/utf.h> #include <encodings/utf.h>
#include <features/features_cpu.h>
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include "../../config.h" #include "../../config.h"
@ -68,6 +69,8 @@
#define XMB_DELAY 10 #define XMB_DELAY 10
#endif #endif
#define BATTERY_LEVEL_CHECK_INTERVAL (30 * 1000000)
#if 0 #if 0
#define XMB_DEBUG #define XMB_DEBUG
#endif #endif
@ -2635,8 +2638,14 @@ static void xmb_frame(void *data)
if (settings->menu.battery_level_enable) if (settings->menu.battery_level_enable)
{ {
const frontend_ctx_driver_t *frontend = frontend_get_ptr(); const frontend_ctx_driver_t *frontend = frontend_get_ptr();
static retro_time_t last_time = 0;
retro_time_t current_time = cpu_features_get_time_usec();
bool time_to_update = false;
if (frontend && frontend->get_powerstate) if (current_time - last_time >= BATTERY_LEVEL_CHECK_INTERVAL)
time_to_update = true;
if (time_to_update && frontend && frontend->get_powerstate)
{ {
char msg[12]; char msg[12];
int seconds = 0, percent = 0; int seconds = 0, percent = 0;
@ -2646,6 +2655,8 @@ static void xmb_frame(void *data)
*msg = '\0'; *msg = '\0';
last_time = current_time;
if (percent > 0) if (percent > 0)
{ {
size_t x_pos = 0; size_t x_pos = 0;