Subversion Repositories Projects

Compare Revisions

Regard whitespace Rev 1198 → Rev 1199

/C-OSD/C-Epilepsy/eeprom.c
0,0 → 1,57
/****************************************************************************
* Copyright (C) 2011 by Claas Anders "CaScAdE" Rathje *
* admiralcascade@gmail.com *
* Project-URL: http://www.mylifesucks.de/oss/c-epilepsy/ *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
****************************************************************************/
 
#include "eeprom.h"
 
uint8_t EEMEM ee_checkbyte1 = CHECKBYTE1;
uint8_t EEMEM ee_checkbyte2 = CHECKBYTE2;
uint8_t EEMEM ee_main_mode = 0;
uint8_t EEMEM ee_nc_handler_state = 0;
uint8_t EEMEM ee_player_current_animation = 0;
 
void load_eeprom(void) {
if (eeprom_read_byte(&ee_checkbyte1) == CHECKBYTE1 && eeprom_read_byte(&ee_checkbyte2) == CHECKBYTE2) {
main_mode = eeprom_read_byte(&ee_main_mode);
nc_handler_state = eeprom_read_byte(&ee_nc_handler_state);
player_current_animation = eeprom_read_byte(&ee_player_current_animation);
player_changeanim(0);
}
}
 
void save_eeprom(void) {
eeprom_write_byte(&ee_checkbyte1, CHECKBYTE1);
eeprom_write_byte(&ee_checkbyte2, CHECKBYTE2);
eeprom_write_byte(&ee_main_mode, main_mode);
eeprom_write_byte(&ee_nc_handler_state, nc_handler_state);
eeprom_write_byte(&ee_player_current_animation, player_current_animation);
}
 
uint8_t eeprom_delay = 0;
 
void eeprom_timer_callback(void) {
eeprom_delay++;
if (eeprom_delay > 10) { // every 10sec check for dirty (mode change)
if (CEPILEPSYFLAGS & CEPI_DIRTYEEPROM) {
CEPILEPSYFLAGS &= ~(CEPI_DIRTYEEPROM);
save_eeprom();
}
eeprom_delay = 0;
}
}