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