update
This commit is contained in:
2
Makefile
2
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)
|
||||
|
||||
27
contr.c
27
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);
|
||||
|
||||
Reference in New Issue
Block a user