mirror of https://github.com/nealey/proton
Button more responsive, sorta
This commit is contained in:
parent
c3f635e1f9
commit
059eda4c8d
|
@ -28,6 +28,12 @@ MusicPlayer::startPlayingFile(const char *trackname)
|
|||
return musicPlayer->startPlayingFile(trackname);
|
||||
}
|
||||
|
||||
boolean
|
||||
MusicPlayer::isPlaying()
|
||||
{
|
||||
return musicPlayer->playingMusic;
|
||||
}
|
||||
|
||||
void
|
||||
MusicPlayer::stopPlaying()
|
||||
{
|
||||
|
|
|
@ -9,6 +9,7 @@ public:
|
|||
MusicPlayer(int8_t cs, int8_t dcs, int8_t dreq, int8_t cardcs);
|
||||
boolean startPlayingFile(const char *trackname);
|
||||
void setVolume(uint8_t left, uint8_t right);
|
||||
boolean isPlaying();
|
||||
void stopPlaying();
|
||||
void poll(unsigned long jiffies); // Call this once per loop()
|
||||
};
|
||||
|
|
|
@ -25,7 +25,7 @@ Synchrotron *sync1;
|
|||
#define DEBUG 13
|
||||
|
||||
// Inputs
|
||||
#define TRIGGER 9
|
||||
#define TRIGGER 8
|
||||
|
||||
// global time counter
|
||||
unsigned long jiffies = 0;
|
||||
|
@ -63,18 +63,34 @@ void loop() {
|
|||
|
||||
music->poll(jiffies);
|
||||
|
||||
if (state == 0) {
|
||||
if (new_jiffies > jiffies) {
|
||||
switch (state) {
|
||||
case 0:
|
||||
if (trigger) {
|
||||
if (music->startPlayingFile("track001.mp3")) {
|
||||
state = 1;
|
||||
music->startPlayingFile("track001.mp3");
|
||||
sync1->charge();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (! music->isPlaying()) {
|
||||
if (music->startPlayingFile("track002.mp3")) {
|
||||
state = 4;
|
||||
sync1->standby();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
if (! music->isPlaying()) {
|
||||
state = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (new_jiffies > jiffies) {
|
||||
jiffies = new_jiffies;
|
||||
sync1->tick(jiffies);
|
||||
flashDebug();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,10 +37,9 @@ Synchrotron::discharge() {
|
|||
}
|
||||
|
||||
Synchrotron::tick(unsigned long jiffies) {
|
||||
float adj = (float)ticks / (float)tickrate;
|
||||
byte raa = r * adj;
|
||||
byte gaa = g * adj;
|
||||
byte baa = b * adj;
|
||||
byte raa = r * ticks / tickrate;
|
||||
byte gaa = g * ticks / tickrate;
|
||||
byte baa = b * ticks / tickrate;
|
||||
byte ra = r - raa;
|
||||
byte ga = g - gaa;
|
||||
byte ba = b - baa;
|
||||
|
|
Loading…
Reference in New Issue