fix: hall music_player

This commit is contained in:
2021-10-11 12:22:29 +02:00
parent 820117d871
commit 3767c02ad3
6 changed files with 16 additions and 4 deletions

View File

@@ -8,6 +8,8 @@ AudioOutputI2S *out;
uint8_t audio_current_Song = 0; uint8_t audio_current_Song = 0;
uint8_t n = 0; uint8_t n = 0;
bool audio_start = false;
const char *waveFile[] = const char *waveFile[] =
{"/ringoffire.mp3", {"/ringoffire.mp3",
"/Let_it_be.mp3", "/Let_it_be.mp3",
@@ -83,10 +85,17 @@ void handleAudio()
{ {
Serial.println("Audio: stop playback"); Serial.println("Audio: stop playback");
mp3->stop(); mp3->stop();
audio_start = false;
} }
} }
else else
{ {
if(!audio_start)
{
playSong(audio_current_Song);
audio_start = true;
}
if (mp3->isRunning()) if (mp3->isRunning())
{ {
if (!mp3->loop()) if (!mp3->loop())

View File

@@ -9,7 +9,7 @@
#include "game.h" #include "game.h"
#define AUDIOGAIN 0.25 #define AUDIOGAIN 0.5
#define AUDIONSONGS 3 #define AUDIONSONGS 3
#define AUDIOREPEATS 3 #define AUDIOREPEATS 3

View File

@@ -11,6 +11,8 @@ bool hall_is_Idle = true;
void initGame(void) void initGame(void)
{ {
pinMode(HALL_INPUT, ANALOG); pinMode(HALL_INPUT, ANALOG);
//analogReadResolution(10);
analogSetAttenuation(ADC_11db);
} }
@@ -26,6 +28,7 @@ void handleGame(void)
if(hall_idle_count > HALLIDLESAMPLES) if(hall_idle_count > HALLIDLESAMPLES)
{ {
hall_is_Idle = false; hall_is_Idle = false;
hall_idle_count = 8;
} }
else else
{ {

View File

@@ -4,8 +4,8 @@
#include "board.h" #include "board.h"
#define HALLINTERVAL 200 #define HALLINTERVAL 200
#define HALLIDLETHRESHOLD 11 #define HALLIDLETHRESHOLD 6
#define HALLIDLESAMPLES 4 #define HALLIDLESAMPLES 2
void initGame(void); void initGame(void);
void handleGame(void); void handleGame(void);