added indicator LED
This commit is contained in:
parent
9263b619a1
commit
31aa8beefb
|
@ -0,0 +1,19 @@
|
|||
|
||||
#include <Arduino.h>
|
||||
#include "indicator.hpp"
|
||||
#include "tones.hpp"
|
||||
|
||||
#define LED_INDICATOR 10
|
||||
|
||||
void indicator::init() {
|
||||
pinMode(LED_INDICATOR, OUTPUT);
|
||||
}
|
||||
|
||||
void indicator::update() {
|
||||
float v = 0;
|
||||
for(int i = 0; i < tones::active; i++) {
|
||||
v += tones::all[i].amplitude;
|
||||
}
|
||||
analogWrite(LED_INDICATOR, min((int)(v * 256), 255));
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
namespace indicator {
|
||||
|
||||
void init();
|
||||
void update();
|
||||
};
|
||||
|
|
@ -5,8 +5,10 @@
|
|||
#include "timing.hpp"
|
||||
#include "util.hpp"
|
||||
#include "scheduler.hpp"
|
||||
#include "indicator.hpp"
|
||||
|
||||
unsigned long int micros_at = 0;
|
||||
static unsigned long int micros_at = 0;
|
||||
static bool led_state = true;
|
||||
|
||||
inline unsigned long micros_diff() {
|
||||
unsigned long now = micros();
|
||||
|
@ -19,11 +21,13 @@ void setup() {
|
|||
dac::init();
|
||||
tones::init();
|
||||
scheduler::init();
|
||||
indicator::init();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if(scheduler::running && timing::at >= scheduler::timestamp) {
|
||||
scheduler::do_all();
|
||||
indicator::update();
|
||||
}
|
||||
|
||||
timing::update();
|
||||
|
|
Loading…
Reference in New Issue