2024-09-27 22:46:51 +10:00
|
|
|
|
|
|
|
#include <Arduino.h>
|
|
|
|
#include "buttons.hpp"
|
|
|
|
#include "scheduler.hpp"
|
|
|
|
#include "data.hpp"
|
|
|
|
#include "tones.hpp"
|
|
|
|
#include "dac.hpp"
|
|
|
|
#include "indicator.hpp"
|
|
|
|
|
|
|
|
const int PIN_NEXT = 8;
|
2024-09-29 18:07:58 +10:00
|
|
|
|
|
|
|
static uint32_t addr_next = 0;
|
2024-09-27 22:46:51 +10:00
|
|
|
|
|
|
|
void buttons::init() {
|
|
|
|
pinMode(PIN_NEXT, INPUT_PULLUP);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void on_next() {
|
|
|
|
switch(scheduler::state) {
|
|
|
|
case scheduler::State::play:
|
|
|
|
scheduler::state = scheduler::State::skip;
|
|
|
|
indicator::reset();
|
2024-09-29 18:07:58 +10:00
|
|
|
data::jump(addr_next);
|
2024-09-27 22:46:51 +10:00
|
|
|
tones::clear_all();
|
|
|
|
dac::reset();
|
|
|
|
break;
|
|
|
|
case scheduler::State::pause:
|
|
|
|
scheduler::state = scheduler::State::play;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void buttons::update() {
|
2024-09-30 23:25:16 +10:00
|
|
|
if(!digitalRead(PIN_NEXT)) {
|
2024-09-27 22:46:51 +10:00
|
|
|
delay(1);
|
2024-09-30 23:25:16 +10:00
|
|
|
while(!digitalRead(PIN_NEXT)) {}
|
2024-09-27 22:46:51 +10:00
|
|
|
delay(1);
|
|
|
|
on_next();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-09-29 18:07:58 +10:00
|
|
|
void buttons::set_addr_next(uint32_t addr) {
|
|
|
|
addr_next = addr;
|
|
|
|
}
|
|
|
|
|