Subversion Repositories Projects

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1199 - 1
/****************************************************************************
2
 *   Copyright (C) 2011 by Claas Anders "CaScAdE" Rathje                    *
3
 *   admiralcascade@gmail.com                                               *
4
 *   Project-URL: http://www.mylifesucks.de/oss/c-epilepsy/                 *
5
 *                                                                          *
6
 *   This program is free software; you can redistribute it and/or modify   *
7
 *   it under the terms of the GNU General Public License as published by   *
8
 *   the Free Software Foundation; either version 2 of the License.         *
9
 *                                                                          *
10
 *   This program is distributed in the hope that it will be useful,        *
11
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
12
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
13
 *   GNU General Public License for more details.                           *
14
 *                                                                          *
15
 *   You should have received a copy of the GNU General Public License      *
16
 *   along with this program; if not, write to the                          *
17
 *   Free Software Foundation, Inc.,                                        *
18
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.              *
19
 ****************************************************************************/
20
 
21
#include "eeprom.h"
22
 
23
uint8_t EEMEM ee_checkbyte1 = CHECKBYTE1;
24
uint8_t EEMEM ee_checkbyte2 = CHECKBYTE2;
25
uint8_t EEMEM ee_main_mode = 0;
26
uint8_t EEMEM ee_nc_handler_state = 0;
27
uint8_t EEMEM ee_player_current_animation = 0;
28
 
29
void load_eeprom(void) {
30
    if (eeprom_read_byte(&ee_checkbyte1) == CHECKBYTE1 && eeprom_read_byte(&ee_checkbyte2) == CHECKBYTE2) {
31
        main_mode = eeprom_read_byte(&ee_main_mode);
32
        nc_handler_state = eeprom_read_byte(&ee_nc_handler_state);
33
        player_current_animation = eeprom_read_byte(&ee_player_current_animation);
34
        player_changeanim(0);
35
    }
36
}
37
 
38
void save_eeprom(void) {
39
    eeprom_write_byte(&ee_checkbyte1, CHECKBYTE1);
40
    eeprom_write_byte(&ee_checkbyte2, CHECKBYTE2);
41
    eeprom_write_byte(&ee_main_mode, main_mode);
42
    eeprom_write_byte(&ee_nc_handler_state, nc_handler_state);
43
    eeprom_write_byte(&ee_player_current_animation, player_current_animation);
44
}
45
 
46
uint8_t eeprom_delay = 0;
47
 
48
void eeprom_timer_callback(void) {
49
    eeprom_delay++;
50
    if (eeprom_delay > 10) { // every 10sec check for dirty (mode change)
51
        if (CEPILEPSYFLAGS & CEPI_DIRTYEEPROM) {
52
            CEPILEPSYFLAGS &= ~(CEPI_DIRTYEEPROM);
53
            save_eeprom();
54
        }
55
        eeprom_delay = 0;
56
    }
57
}