2024-08-25 18:22:48 +10:00
|
|
|
|
|
|
|
#include <Arduino.h>
|
|
|
|
#include "indicator.hpp"
|
|
|
|
#include "tones.hpp"
|
2024-08-31 16:31:19 +10:00
|
|
|
#include "util.hpp"
|
2024-08-25 18:22:48 +10:00
|
|
|
|
2024-08-31 16:31:19 +10:00
|
|
|
constexpr int PINS[] = {9, 10};
|
2024-08-25 18:22:48 +10:00
|
|
|
|
|
|
|
void indicator::init() {
|
2024-08-31 16:31:19 +10:00
|
|
|
for(int pin : PINS) {
|
|
|
|
pinMode(pin, 1);
|
|
|
|
}
|
2024-08-28 13:10:57 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
void indicator::reset() {
|
2024-08-31 16:31:19 +10:00
|
|
|
for(int pin : PINS) {
|
|
|
|
analogWrite(pin, 0);
|
|
|
|
}
|
2024-08-25 18:22:48 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
void indicator::update() {
|
2024-08-31 16:31:19 +10:00
|
|
|
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]);
|
|
|
|
}
|
2024-08-25 18:22:48 +10:00
|
|
|
}
|
|
|
|
|