save timezone setting in eeprom

master
Eggert Jung 6 years ago
parent 9e934015e0
commit c151a7bb67

@ -1,7 +1,10 @@
#include <stdint.h> #include <stdint.h>
#include <avr/eeprom.h>
extern int8_t menu_val_timezone; extern int8_t menu_val_timezone;
extern int8_t menu_val_timezone_ee EEMEM;
extern uint8_t menu_val_format; extern uint8_t menu_val_format;
extern uint8_t menu_val_format_ee EEMEM;
typedef enum { typedef enum {
OFF, OFF,

@ -1,6 +1,7 @@
#include <avr/io.h> #include <avr/io.h>
#include <util/delay.h> #include <avr/eeprom.h>
#include <avr/interrupt.h> #include <avr/interrupt.h>
#include <util/delay.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "pinout.h" #include "pinout.h"
@ -88,6 +89,13 @@ void check_dip_switches() {
} }
void setup(){ void setup(){
menu_val_timezone = eeprom_read_byte((uint8_t*)&menu_val_timezone_ee);
menu_val_format = eeprom_read_byte(&menu_val_format_ee);
if(menu_val_format != 24 && menu_val_format != 12){
menu_val_format = 24;
eeprom_write_byte(&menu_val_format_ee, menu_val_format);
}
DDRA = ENABLE_TUBE_SUPPLY; DDRA = ENABLE_TUBE_SUPPLY;
DDRB = STATUS_LED_B DDRB = STATUS_LED_B

@ -5,8 +5,10 @@
menu_state_t state = OFF; menu_state_t state = OFF;
uint8_t selected = 0; uint8_t selected = 0;
int8_t menu_val_timezone = -1; int8_t menu_val_timezone_ee EEMEM;
uint8_t menu_val_format = 24; int8_t menu_val_timezone;
uint8_t menu_val_format_ee EEMEM;
uint8_t menu_val_format;
//void debug_menu(){ //void debug_menu(){
// printf("state: %d\r\n", state); // printf("state: %d\r\n", state);
@ -21,11 +23,6 @@ uint8_t get_menu_active(){
return 0; return 0;
} }
const char *text[] = {
"test ",
" test"
};
void enter_menu(){ void enter_menu(){
switch(state){ switch(state){
case OFF: case OFF:
@ -49,6 +46,7 @@ const char* get_menu_text(){
switch(state){ switch(state){
case TIMEZONE: case TIMEZONE:
res = " "; res = " ";
menu_val_timezone = eeprom_read_byte((uint8_t*)&menu_val_timezone_ee);
if(menu_val_timezone < 0) if(menu_val_timezone < 0)
res[3] = '-'; res[3] = '-';
else else
@ -92,6 +90,7 @@ void menu_up_down(uint8_t up_down){
menu_val_timezone = 12; menu_val_timezone = 12;
if(menu_val_timezone > 12) if(menu_val_timezone > 12)
menu_val_timezone = -12; menu_val_timezone = -12;
eeprom_write_byte((uint8_t*)&menu_val_timezone_ee, menu_val_timezone);
break; break;
case FORMAT: case FORMAT:
if(menu_val_format == 12) if(menu_val_format == 12)

Loading…
Cancel
Save