led brightness in menu and save in eeprom

master
Eggert Jung 6 years ago
parent f48f18ac64
commit 5ed19b564c

@ -5,11 +5,13 @@ extern int8_t menu_val_timezone;
extern int8_t menu_val_timezone_ee EEMEM; 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; extern uint8_t menu_val_format_ee EEMEM;
extern uint8_t menu_val_leds_ee EEMEM;
typedef enum { typedef enum {
OFF, OFF,
TIMEZONE, TIMEZONE,
FORMAT, FORMAT,
LEDS,
EXIT EXIT
} menu_state_t; } menu_state_t;

@ -42,17 +42,12 @@ int8_t parse_nmea_gps(char input_string[RX_INPUT_BUFFER_SIZE], uint8_t output_bu
} }
void encoder_action(uint8_t dir){ void encoder_action(uint8_t dir){
if (dir) { if(get_menu_active())
if(get_menu_active()) if (dir) {
menu_up_down(1); menu_up_down(1);
else } else {
OCR2A++;
} else {
if(get_menu_active())
menu_up_down(-1); menu_up_down(-1);
else }
OCR2A--;
}
} }
int main(void){ int main(void){
@ -109,6 +104,7 @@ void setup(){
menu_val_format = 24; menu_val_format = 24;
eeprom_write_byte(&menu_val_format_ee, menu_val_format); eeprom_write_byte(&menu_val_format_ee, menu_val_format);
} }
OCR2A = eeprom_read_byte(&menu_val_leds_ee);
DDRA = ENABLE_TUBE_SUPPLY; DDRA = ENABLE_TUBE_SUPPLY;
@ -176,7 +172,6 @@ void setup(){
TCCR2B = (1 << CS22) TCCR2B = (1 << CS22)
|(0 << CS21) |(0 << CS21)
|(0 << CS20); |(0 << CS20);
OCR2A = 0; // Compare value 125
uart_init(); uart_init();
i2c_init(); i2c_init();

@ -9,6 +9,7 @@ int8_t menu_val_timezone_ee EEMEM;
int8_t menu_val_timezone; int8_t menu_val_timezone;
uint8_t menu_val_format_ee EEMEM; uint8_t menu_val_format_ee EEMEM;
uint8_t menu_val_format; uint8_t menu_val_format;
uint8_t menu_val_leds_ee EEMEM;
uint8_t get_menu_active(){ uint8_t get_menu_active(){
if(state != OFF) if(state != OFF)
@ -52,8 +53,13 @@ const char* get_menu_text(){
res[3] = (menu_val_format % 10) + 0x30; res[3] = (menu_val_format % 10) + 0x30;
res[4] = 'H'; res[4] = 'H';
break; break;
case LEDS:
res[3] = (OCR2A / 100) + 0x30;
res[4] = (OCR2A / 10 % 10) + 0x30;
res[5] = (OCR2A % 10) + 0x30;
break;
default: default:
res = "ERROR"; res = "ERROR ";
break; break;
} }
else else
@ -64,6 +70,10 @@ const char* get_menu_text(){
case FORMAT: case FORMAT:
res = "FORMAT"; res = "FORMAT";
break; break;
case LEDS:
res = "LED ";
eeprom_write_byte(&menu_val_leds_ee, OCR2A);
break;
case EXIT: case EXIT:
res = "ZURUEK"; res = "ZURUEK";
break; break;
@ -91,15 +101,18 @@ void menu_up_down(uint8_t up_down){
else if(menu_val_format == 24) else if(menu_val_format == 24)
menu_val_format = 12; menu_val_format = 12;
break; break;
case LEDS:
OCR2A += up_down;
break;
default: default:
break; break;
} }
else{ else{
state += up_down; state += up_down;
if(state < 1) if(state < 1)
state = EXIT; state = 1;
if(state > 3) if(state > EXIT)
state = TIMEZONE; state = EXIT;//TIMEZONE;
} }
//debug_menu(); //debug_menu();
} }

Loading…
Cancel
Save