From 228d62dd18906eaef814ec63cf888b30a94cd1c8 Mon Sep 17 00:00:00 2001 From: Jonathan Gordon Date: Wed, 24 Jan 2007 02:19:22 +0000 Subject: Split the system status variables out of global_settings and put them into a new struct global_status. Use status_save() if these need saving. Added car_adapter_mode to the nvram settings, so nvram settings will be reset. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12101 a1c6a512-1295-4272-9138-f99709370657 --- apps/settings.c | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) (limited to 'apps/settings.c') diff --git a/apps/settings.c b/apps/settings.c index 1a7d159666..4280ff9f7a 100644 --- a/apps/settings.c +++ b/apps/settings.c @@ -86,6 +86,7 @@ void dac_line_in(bool enable); #endif struct user_settings global_settings; +struct system_status global_status; #ifdef HAVE_RECORDING const char rec_base_directory[] = REC_BASE_DIR; #endif @@ -346,6 +347,12 @@ bool settings_write_config(char* filename) close(fd); return true; } +#ifndef HAVE_RTC_RAM +static bool flush_global_status_callback(void) +{ + return write_nvram_data(nvram_buffer,NVRAM_BLOCK_SIZE); +} +#endif static bool flush_config_block_callback(void) { bool r1, r2; @@ -357,16 +364,33 @@ static bool flush_config_block_callback(void) /* * persist all runtime user settings to disk or RTC RAM */ -int settings_save( void ) +static void update_runtime(void) { int elapsed_secs; elapsed_secs = (current_tick - lasttime) / HZ; - global_settings.runtime += elapsed_secs; + global_status.runtime += elapsed_secs; lasttime += (elapsed_secs * HZ); - if ( global_settings.runtime > global_settings.topruntime ) - global_settings.topruntime = global_settings.runtime; + if ( global_status.runtime > global_status.topruntime ) + global_status.topruntime = global_status.runtime; +} + +void status_save( void ) +{ + update_runtime(); +#ifdef HAVE_RTC_RAM + /* this will be done in the ata_callback if + target doesnt have rtc ram */ + write_nvram_data(nvram_buffer,NVRAM_BLOCK_SIZE); +#else + register_ata_idle_func(flush_global_status_callback); +#endif +} + +int settings_save( void ) +{ + update_runtime(); #ifdef HAVE_RTC_RAM /* this will be done in the ata_callback if target doesnt have rtc ram */ -- cgit v1.2.3