43 lines
704 B
C++
43 lines
704 B
C++
|
|
#include "tone.hpp"
|
|
#include "tones.hpp"
|
|
#include "dac.hpp"
|
|
#include "timing.hpp"
|
|
#include "util.hpp"
|
|
#include "scheduler.hpp"
|
|
|
|
unsigned long int micros_at = 0;
|
|
|
|
inline unsigned long micros_diff() {
|
|
unsigned long now = micros();
|
|
unsigned long diff = now - micros_at;
|
|
micros_at = now;
|
|
return diff;
|
|
}
|
|
|
|
void setup() {
|
|
dac::init();
|
|
tones::init();
|
|
scheduler::init();
|
|
}
|
|
|
|
void loop() {
|
|
if(scheduler::running && timing::at >= scheduler::timestamp) {
|
|
scheduler::do_all();
|
|
}
|
|
|
|
timing::update();
|
|
|
|
float 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);
|
|
}
|
|
|