31 lines
494 B
C++
31 lines
494 B
C++
|
|
#include <Arduino.h>
|
|
#include "indicator.hpp"
|
|
#include "tones.hpp"
|
|
#include "util.hpp"
|
|
|
|
constexpr int PINS[] = {9, 10};
|
|
|
|
void indicator::init() {
|
|
for(int pin : PINS) {
|
|
pinMode(pin, 1);
|
|
}
|
|
}
|
|
|
|
void indicator::reset() {
|
|
for(int pin : PINS) {
|
|
analogWrite(pin, 0);
|
|
}
|
|
}
|
|
|
|
void indicator::update() {
|
|
int v[size(PINS)] = {0};
|
|
for(int i = 0; i < tones::active; i++) {
|
|
v[i % size(PINS)] += tones::all[i].amplitude;
|
|
}
|
|
for(int i = 0; i < size(PINS); i++) {
|
|
analogWrite(PINS[i], v[i]);
|
|
}
|
|
}
|
|
|