Move tube to separate file
This commit is contained in:
22
metronom.ino
22
metronom.ino
@@ -1,6 +1,5 @@
|
|||||||
#include "SAMDTimerInterrupt.h"
|
#include "SAMDTimerInterrupt.h"
|
||||||
#include "SAMD_ISR_Timer.h"
|
#include "SAMD_ISR_Timer.h"
|
||||||
#include "grove_alphanumeric_display.h"
|
|
||||||
|
|
||||||
#define HW_TIMER_INTERVAL_MS 10
|
#define HW_TIMER_INTERVAL_MS 10
|
||||||
SAMDTimer ITimer(TIMER_TC3);
|
SAMDTimer ITimer(TIMER_TC3);
|
||||||
@@ -8,7 +7,6 @@ SAMD_ISR_Timer ISR_Timer;
|
|||||||
|
|
||||||
void TimerHandler(void) { ISR_Timer.run(); }
|
void TimerHandler(void) { ISR_Timer.run(); }
|
||||||
|
|
||||||
Seeed_Digital_Tube tube;
|
|
||||||
|
|
||||||
const int COUNTDOWN = 240;
|
const int COUNTDOWN = 240;
|
||||||
const int PERIOD_MS = 1000;
|
const int PERIOD_MS = 1000;
|
||||||
@@ -28,12 +26,7 @@ volatile float temperature = 0.0;
|
|||||||
void setup() {
|
void setup() {
|
||||||
initButton();
|
initButton();
|
||||||
initTemperature();
|
initTemperature();
|
||||||
|
initTube();
|
||||||
// Wire initialized by temperature sensor
|
|
||||||
tube.setTubeType(TYPE_4, TYPE_4_DEFAULT_I2C_ADDR);
|
|
||||||
tube.setBrightness(15);
|
|
||||||
tube.setBlinkRate(BLINK_OFF);
|
|
||||||
tube.setPoint(true,true);
|
|
||||||
|
|
||||||
ITimer.attachInterruptInterval_MS(10, TimerHandler);
|
ITimer.attachInterruptInterval_MS(10, TimerHandler);
|
||||||
ISR_Timer.setInterval(PERIOD_MS, runMetronome);
|
ISR_Timer.setInterval(PERIOD_MS, runMetronome);
|
||||||
@@ -47,19 +40,8 @@ void runMetronome() {
|
|||||||
|
|
||||||
digitalWrite(BUTTON_LED_PIN, countdown % 2 ? HIGH : LOW);
|
digitalWrite(BUTTON_LED_PIN, countdown % 2 ? HIGH : LOW);
|
||||||
} else if (countdown == 0) {
|
} else if (countdown == 0) {
|
||||||
//tone(BUZZER_PIN, 1000, 100);
|
//tone(BUZZER_PIN, 300, 100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateTube() {
|
|
||||||
char tube_str[5];
|
|
||||||
|
|
||||||
if (countdown <= 0)
|
|
||||||
sprintf(tube_str, "%4u", (unsigned int) (temperature * 100.0));
|
|
||||||
else
|
|
||||||
sprintf(tube_str, "%4u", countdown);
|
|
||||||
|
|
||||||
tube.displayString(tube_str);
|
|
||||||
}
|
|
||||||
|
|
||||||
void loop() {}
|
void loop() {}
|
||||||
|
|||||||
22
tube.ino
Normal file
22
tube.ino
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
#include "grove_alphanumeric_display.h"
|
||||||
|
|
||||||
|
Seeed_Digital_Tube tube;
|
||||||
|
|
||||||
|
void initTube() {
|
||||||
|
// Wire initialized by temperature sensor
|
||||||
|
tube.setTubeType(TYPE_4, TYPE_4_DEFAULT_I2C_ADDR);
|
||||||
|
tube.setBrightness(15);
|
||||||
|
tube.setBlinkRate(BLINK_OFF);
|
||||||
|
tube.setPoint(true,true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateTube() {
|
||||||
|
char tube_str[5];
|
||||||
|
|
||||||
|
if (countdown <= 0)
|
||||||
|
sprintf(tube_str, "%4u", (unsigned int) (temperature * 100.0));
|
||||||
|
else
|
||||||
|
sprintf(tube_str, "%4u", countdown);
|
||||||
|
|
||||||
|
tube.displayString(tube_str);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user