Card Reader WIP
This commit is contained in:
parent
35d62e9bf0
commit
1258a23dc4
|
|
@ -27,7 +27,7 @@ MISO -> D6
|
||||||
```
|
```
|
||||||
|
|
||||||
## TODOs
|
## TODOs
|
||||||
* Card Reader with SPI. Configure hspi, second SPI channel?
|
* Card Reader with SPI. Configure hspi, second SPI channel? Or does SD Card + RFID run at the same channel?
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,5 +17,6 @@ lib_deps =
|
||||||
me-no-dev/AsyncTCP@^1.1.1
|
me-no-dev/AsyncTCP@^1.1.1
|
||||||
me-no-dev/ESP Async WebServer@^1.2.3
|
me-no-dev/ESP Async WebServer@^1.2.3
|
||||||
alanswx/ESPAsyncWiFiManager@^0.31
|
alanswx/ESPAsyncWiFiManager@^0.31
|
||||||
|
miguelbalboa/MFRC522@^1.4.10
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
board_build.partitions = huge_app.csv
|
board_build.partitions = huge_app.csv
|
||||||
|
|
|
||||||
|
|
@ -5,5 +5,11 @@ void stop();
|
||||||
|
|
||||||
void start();
|
void start();
|
||||||
|
|
||||||
|
boolean buttonPressed(const uint8_t pin);
|
||||||
|
|
||||||
|
unsigned long lastStart = 0;
|
||||||
|
|
||||||
|
const int startDelay = 250;
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
#define HELPER_H_
|
#define HELPER_H_
|
||||||
|
|
||||||
#include <SD.h>
|
#include <SD.h>
|
||||||
|
#include "globals.h"
|
||||||
|
|
||||||
|
|
||||||
struct DirectoryNode {
|
struct DirectoryNode {
|
||||||
|
|
@ -89,4 +90,6 @@ DirectoryNode* findFirstMP3Node(DirectoryNode* currentNode) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* HELPER_H_ */
|
#endif /* HELPER_H_ */
|
||||||
41
src/main.cpp
41
src/main.cpp
|
|
@ -9,12 +9,24 @@
|
||||||
|
|
||||||
#include "Audio.h"
|
#include "Audio.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#include <SPI.h>
|
||||||
|
#include <SD.h>
|
||||||
|
#include <MFRC522.h>//RFID Reader
|
||||||
|
|
||||||
|
// define pins for RFID
|
||||||
|
#define CS_RFID 32
|
||||||
|
#define RST_RFID 33
|
||||||
|
|
||||||
|
// Audio DAC
|
||||||
#define I2S_DOUT 26 // connect to DAC pin DIN
|
#define I2S_DOUT 26 // connect to DAC pin DIN
|
||||||
#define I2S_BCLK 27 // connect to DAC pin BCK
|
#define I2S_BCLK 27 // connect to DAC pin BCK
|
||||||
#define I2S_LRC 25 // connect to DAC pin LCK
|
#define I2S_LRC 25 // connect to DAC pin LCK
|
||||||
|
|
||||||
#include <SPI.h>
|
#define BTN_START_STOP 17 // Button on D3 and GND
|
||||||
#include <SD.h>
|
|
||||||
|
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
#include "WebContent.h"
|
#include "WebContent.h"
|
||||||
|
|
@ -24,9 +36,7 @@
|
||||||
File root;
|
File root;
|
||||||
File mp3File;
|
File mp3File;
|
||||||
|
|
||||||
unsigned long lastStart = 0;
|
|
||||||
|
|
||||||
const int startDelay = 250;
|
|
||||||
|
|
||||||
Audio audio;
|
Audio audio;
|
||||||
|
|
||||||
|
|
@ -42,6 +52,8 @@ boolean blockState = false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void playNextMp3()
|
void playNextMp3()
|
||||||
{
|
{
|
||||||
blockState = true;
|
blockState = true;
|
||||||
|
|
@ -161,7 +173,7 @@ void setup()
|
||||||
// put your setup code here, to run once:
|
// put your setup code here, to run once:
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
|
|
||||||
pinMode(D3, INPUT_PULLUP);
|
pinMode(BTN_START_STOP, INPUT_PULLUP);
|
||||||
|
|
||||||
// first parameter is name of access point, second is the password
|
// first parameter is name of access point, second is the password
|
||||||
AsyncWiFiManager wifiManager(&server, &dns);
|
AsyncWiFiManager wifiManager(&server, &dns);
|
||||||
|
|
@ -219,13 +231,28 @@ void loop()
|
||||||
{
|
{
|
||||||
|
|
||||||
audio.loop();
|
audio.loop();
|
||||||
if (digitalRead(D3) == LOW)
|
|
||||||
|
if (buttonPressed(BTN_START_STOP)) {
|
||||||
|
if (audio.isRunning()) {
|
||||||
|
stop();
|
||||||
|
} else {
|
||||||
|
start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean buttonPressed(const uint8_t pin) {
|
||||||
|
if (digitalRead(pin) == LOW)
|
||||||
{
|
{
|
||||||
unsigned long now = millis();
|
unsigned long now = millis();
|
||||||
if (now - lastStart > startDelay)
|
if (now - lastStart > startDelay)
|
||||||
{
|
{
|
||||||
playNextMp3();
|
|
||||||
lastStart = now;
|
lastStart = now;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue