37 lines
894 B
C++
37 lines
894 B
C++
#include <Arduino.h>
|
|
|
|
|
|
extern uint8_t run_rgb_program;
|
|
|
|
|
|
// TCB0 general interrupt
|
|
ISR(TCB0_INT_vect)
|
|
{
|
|
// reset the INTFLAGS - necessary on this series
|
|
uint8_t intflags = TCB0.INTFLAGS;
|
|
TCB0.INTFLAGS = intflags;
|
|
|
|
// in this program, this interrupt is only used for timing.
|
|
// we'll now return to executing loop()
|
|
}
|
|
|
|
// button interrupt
|
|
ISR(PORTA_PORT_vect)
|
|
{
|
|
// reset the INTFLAGS - necessary on this series
|
|
uint8_t intflags = PORTA.INTFLAGS;
|
|
PORTA.INTFLAGS = intflags;
|
|
|
|
// was our pin changed?
|
|
if (intflags & PIN3_bm) {
|
|
// is the pin low?
|
|
if (!digitalRead(PIN_PA3)) {
|
|
// start running a program if one isn't running already
|
|
if (!run_rgb_program) run_rgb_program = 1;
|
|
} else if (run_rgb_program == 2) {
|
|
// if we're running a program when the button is released (likely),
|
|
// then skip this interrupt
|
|
run_rgb_program++;
|
|
}
|
|
}
|
|
} |