This commit is contained in:
Олег Бородин
2024-08-21 13:30:04 +02:00
parent c8f1609cf0
commit cd8da763c2
3 changed files with 24 additions and 7 deletions

27
contr.c
View File

@@ -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);