59 lines
1020 B
C++
59 lines
1020 B
C++
|
|
#include "buttons.hpp"
|
|
#include "tone.hpp"
|
|
#include "tones.hpp"
|
|
#include "dac.hpp"
|
|
#include "timing.hpp"
|
|
#include "util.hpp"
|
|
#include "scheduler.hpp"
|
|
#include "indicator.hpp"
|
|
#include "serial.hpp"
|
|
#include "eeprom.hpp"
|
|
#include "data.hpp"
|
|
|
|
static unsigned long int micros_at = 0;
|
|
static bool led_state = true;
|
|
|
|
inline unsigned long micros_diff() {
|
|
unsigned long now = micros();
|
|
unsigned long diff = now - micros_at;
|
|
micros_at = now;
|
|
return diff;
|
|
}
|
|
|
|
void setup() {
|
|
dac::init();
|
|
serial::init();
|
|
tones::init();
|
|
indicator::init();
|
|
buttons::init();
|
|
scheduler::reset();
|
|
}
|
|
|
|
void loop() {
|
|
|
|
if(scheduler::is_running()) {
|
|
if(scheduler::should_update()) {
|
|
data::update();
|
|
scheduler::do_all();
|
|
indicator::update();
|
|
}
|
|
} else {
|
|
data::update();
|
|
}
|
|
|
|
timing::update();
|
|
|
|
int32_t value = 0;
|
|
uint32_t passed = timing::diff;
|
|
|
|
for(int i = 0; i < tones::active; i++) {
|
|
Tone& t = tones::all[i];
|
|
t.update(passed);
|
|
value += t.get();
|
|
}
|
|
|
|
dac::set((value >> 8) + 127);
|
|
}
|
|
|