diff --git a/Makefile b/Makefile index 9b26a76..5981e88 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ F_CPU = 16000000UL MCU = atmega328p CFLAGS += -DF_CPU=$(F_CPU) -mmcu=$(MCU) -CFLAGS += -I. -O2 --std=c99 +CFLAGS += -I. -O2 --std=c11 CFLAGS += -ffunction-sections -fdata-sections LDFLAGS += -s -mmcu=$(MCU) diff --git a/contr.c b/contr.c index be3385c..bb6f6d0 100644 --- a/contr.c +++ b/contr.c @@ -31,11 +31,7 @@ typedef struct { uint8_t band; - bool button_was_pressed; - uint16_t button_time_counter; - uint16_t button_time_untap; - uint16_t button_tap_counter; - bool button_strokes_ended; + uint16_t vcc; } contr_t; contr_t contr; @@ -57,6 +53,17 @@ void contr_setup(void) { contr_read_band(); } +void contr_measure_vcc() { + contr.vcc = adc_read(ACD_CHANELL3); +} + + +#define CONTR_VCC_SCALE 2700.0F +float contr_get_vcc() { + return (float)contr.vcc / CONTR_VCC_SCALE; +} + + void contr_switch_band(void) { switch (contr.band) { case CONTR_BAND_10M: @@ -157,12 +164,20 @@ void contr_show_band(void) { disp_string(0, 12, contr_get_bandname(contr.band)); } +void contr_show_vcc(void) { + char buffer[12] = { '\0' }; + sprintf(buffer, "#%4.1fV", contr_get_vcc()); + disp_string(0, 0, buffer); +} + + void contr_main(void) { contr_show_logo(); - uint16_t counter = 0; while (true) { contr_button_eval(); + contr_measure_vcc(); + contr_show_vcc(); contr_show_band(); counter++; _delay_ms(100); diff --git a/main.c b/main.c index 415a014..e65f317 100644 --- a/main.c +++ b/main.c @@ -37,7 +37,9 @@ int main(void) { relay80m_init(); buzzer_init(); fan_init(); + button_init(); + button_reset(); relaytx_off(); atten_off();