This commit is contained in:
Олег Бородин
2024-08-21 17:58:42 +02:00
parent 30b04a8ba2
commit 5e922d155e
6 changed files with 108 additions and 10 deletions

61
contr.c
View File

@@ -32,6 +32,7 @@
typedef struct {
uint8_t band;
uint16_t vcc;
uint16_t cnt;
} contr_t;
contr_t contr;
@@ -41,11 +42,6 @@ void contr_set_band(uint8_t band);
void contr_write_band(void);
void contr_read_band(void);
ISR(TIMER0_OVF_vect) {
button_handle();
uart_handle();
}
void contr_init(void) {
contr.band = CONTR_BAND_OFF;
}
@@ -109,7 +105,7 @@ void contr_set_band(uint8_t band) {
break;
}
contr_write_band();
atten_on();
atten_off();
}
char* contr_get_bandname() {
@@ -161,24 +157,71 @@ void contr_show_logo(void) {
}
void contr_show_band(void) {
disp_string(0, 12, contr_get_bandname(contr.band));
disp_string(0, 13, 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);
sprintf(buffer, "%03.1fv", contr_get_vcc());
disp_string(3, 11, buffer);
}
void contr_show_ptt(void) {
if (ptt_is_pressed()) {
disp_string(3, 0, "TX");
} else {
disp_string(3, 0, " ");
}
}
ISR(TIMER0_OVF_vect) {
//button_handle();
//uart_handle();
}
ISR(TIMER1_OVF_vect) {
contr.cnt++;
}
void xxtimer0_init(void) {
/* Disable comparators */
REG_SETDOWN_BIT(TCCR0A, COM0A1);
REG_SETDOWN_BIT(TCCR0A, COM0A0);
REG_SETDOWN_BIT(TCCR0A, COM0B1);
REG_SETDOWN_BIT(TCCR0A, COM0B0);
/* Set normal mode */
REG_SETDOWN_BIT(TCCR0A, WGM01);
REG_SETDOWN_BIT(TCCR0A, WGM00);
/* Set clock to 1/64 */
REG_SETDOWN_BIT(TCCR0B, CS02);
REG_SETUP_BIT(TCCR0B, CS01);
REG_SETUP_BIT(TCCR0B, CS00);
/* Enable timer interrupt */
REG_SETUP_BIT(TIMSK0, TOIE0);
}
void contr_show_cnt(void) {
char buffer[12] = { '\0' };
sprintf(buffer, "%8u", contr.cnt);
disp_string(2, 0, buffer);
}
void contr_main(void) {
contr_show_logo();
uint16_t counter = 0;
sei();
while (true) {
contr_show_ptt();
contr_button_eval();
contr_measure_vcc();
contr_show_vcc();
contr_show_band();
contr_show_cnt();
counter++;
_delay_ms(100);
}