update
This commit is contained in:
@@ -7,7 +7,7 @@ F_CPU = 16000000UL
|
|||||||
MCU = atmega328p
|
MCU = atmega328p
|
||||||
|
|
||||||
CFLAGS += -DF_CPU=$(F_CPU) -mmcu=$(MCU)
|
CFLAGS += -DF_CPU=$(F_CPU) -mmcu=$(MCU)
|
||||||
CFLAGS += -I. -O2 --std=c99
|
CFLAGS += -I. -O2 --std=c11
|
||||||
CFLAGS += -ffunction-sections -fdata-sections
|
CFLAGS += -ffunction-sections -fdata-sections
|
||||||
|
|
||||||
LDFLAGS += -s -mmcu=$(MCU)
|
LDFLAGS += -s -mmcu=$(MCU)
|
||||||
|
|||||||
@@ -31,11 +31,7 @@
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t band;
|
uint8_t band;
|
||||||
bool button_was_pressed;
|
uint16_t vcc;
|
||||||
uint16_t button_time_counter;
|
|
||||||
uint16_t button_time_untap;
|
|
||||||
uint16_t button_tap_counter;
|
|
||||||
bool button_strokes_ended;
|
|
||||||
} contr_t;
|
} contr_t;
|
||||||
|
|
||||||
contr_t contr;
|
contr_t contr;
|
||||||
@@ -57,6 +53,17 @@ void contr_setup(void) {
|
|||||||
contr_read_band();
|
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) {
|
void contr_switch_band(void) {
|
||||||
switch (contr.band) {
|
switch (contr.band) {
|
||||||
case CONTR_BAND_10M:
|
case CONTR_BAND_10M:
|
||||||
@@ -157,12 +164,20 @@ void contr_show_band(void) {
|
|||||||
disp_string(0, 12, contr_get_bandname(contr.band));
|
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) {
|
void contr_main(void) {
|
||||||
contr_show_logo();
|
contr_show_logo();
|
||||||
|
|
||||||
uint16_t counter = 0;
|
uint16_t counter = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
contr_button_eval();
|
contr_button_eval();
|
||||||
|
contr_measure_vcc();
|
||||||
|
contr_show_vcc();
|
||||||
contr_show_band();
|
contr_show_band();
|
||||||
counter++;
|
counter++;
|
||||||
_delay_ms(100);
|
_delay_ms(100);
|
||||||
|
|||||||
Reference in New Issue
Block a user