update
This commit is contained in:
50
contr.c
50
contr.c
@@ -21,7 +21,16 @@
|
||||
|
||||
#include <contr.h>
|
||||
|
||||
button_t volume_button;
|
||||
|
||||
#include <button.h>
|
||||
#include <i2c.h>
|
||||
#include <adc.h>
|
||||
#include <disp.h>
|
||||
#include <timer.h>
|
||||
#include <radio.h>
|
||||
|
||||
button_t volplus_button;
|
||||
button_t volminus_button;
|
||||
|
||||
typedef struct {
|
||||
uint8_t volume;
|
||||
@@ -36,10 +45,31 @@ void contr_init(void) {
|
||||
}
|
||||
|
||||
void contr_setup(void) {
|
||||
i2c_init();
|
||||
disp_init();
|
||||
|
||||
button_init(&volplus_button, BTVOLPLUS_DDRADDR,
|
||||
BTVOLPLUS_PORTADDR, BTVOLPLUS_PINDADDR, BTVOLPLUS_OUTNUM);
|
||||
button_setup(&volplus_button);
|
||||
button_reset(&volplus_button);
|
||||
|
||||
button_init(&volminus_button, BTVOLMINUS_DDRADDR,
|
||||
BTVOLMINUS_PORTADDR, BTVOLMINUS_PINDADDR, BTVOLMINUS_OUTNUM);
|
||||
button_setup(&volminus_button);
|
||||
button_reset(&volminus_button);
|
||||
|
||||
adc_init();
|
||||
radio_init();
|
||||
radio_unmute();
|
||||
radio_volume();
|
||||
timer0_init();
|
||||
sei();
|
||||
|
||||
}
|
||||
|
||||
ISR(TIMER0_OVF_vect) {
|
||||
button_handle(&volume_button);
|
||||
button_handle(&volplus_button);
|
||||
button_handle(&volminus_button);
|
||||
}
|
||||
|
||||
|
||||
@@ -55,19 +85,25 @@ void contr_show_logo(void) {
|
||||
|
||||
void contr_show_volume(void) {
|
||||
char dispstr[CONTR_DISPSTR_SIZE];
|
||||
sprintf(dispstr, "%4d", contr.volume);
|
||||
disp_string(1, 1, dispstr);
|
||||
sprintf(dispstr, "%2d 0x%02X %02X", contr.volume, radio_get_status(), i2c_error);
|
||||
disp_string(7, 0, dispstr);
|
||||
}
|
||||
|
||||
#define MAX_VOLUME 64
|
||||
|
||||
void contr_calc_volume(void) {
|
||||
if (button_was_pressed(&volume_button) == true) {
|
||||
if (button_was_pressed(&volplus_button)) {
|
||||
if (contr.volume == MAX_VOLUME) {
|
||||
return;
|
||||
}
|
||||
contr.volume++;
|
||||
contr.volume_updated = true;
|
||||
}
|
||||
if (contr.volume > MAX_VOLUME) {
|
||||
contr.volume = 0;
|
||||
if (button_was_pressed(&volminus_button)) {
|
||||
if (contr.volume == 0) {
|
||||
return;
|
||||
}
|
||||
contr.volume--;
|
||||
contr.volume_updated = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user