Fixed SDCard / RFID on off
This commit is contained in:
parent
dfea791a2f
commit
5cbe653063
|
|
@ -9,7 +9,7 @@
|
|||
; https://docs.platformio.org/page/projectconf.html
|
||||
|
||||
[env:d1_mini32]
|
||||
platform = espressif32
|
||||
platform = platformio/espressif32@~6.8.0
|
||||
board = wemos_d1_mini32
|
||||
framework = arduino
|
||||
lib_deps =
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ const String startup_sound = "start.mp3";
|
|||
|
||||
const String mapping_file = "/mapping.txt";
|
||||
|
||||
const String progress_file = "/progress.txt";
|
||||
const String progress_file = "progress.txt";
|
||||
|
||||
std::map<String, String> rfid_map;
|
||||
|
||||
|
|
|
|||
42
src/main.cpp
42
src/main.cpp
|
|
@ -108,33 +108,35 @@ void activateSD()
|
|||
{
|
||||
if (SDActive)
|
||||
return;
|
||||
digitalWrite(CS_SDCARD, LOW);
|
||||
|
||||
if (!SD.begin(CS_SDCARD))
|
||||
{
|
||||
Serial.println("SD initialization failed!");
|
||||
while (1)
|
||||
;
|
||||
}
|
||||
SDActive = true;
|
||||
}
|
||||
|
||||
void deactivateSD()
|
||||
{
|
||||
//SD.end();
|
||||
digitalWrite(CS_SDCARD, HIGH);
|
||||
SDActive = false;
|
||||
if (SDActive) {
|
||||
digitalWrite(CS_SDCARD, HIGH);
|
||||
SDActive = false;
|
||||
}
|
||||
}
|
||||
|
||||
void activateRFID()
|
||||
{
|
||||
digitalWrite(CS_RFID, LOW);
|
||||
SPI.begin(-1, -1, -1, CS_RFID);
|
||||
rfid.PCD_Init(CS_RFID, RST_RFID);
|
||||
RFIDActive = true;
|
||||
}
|
||||
|
||||
void deactivateRFID()
|
||||
{
|
||||
digitalWrite(CS_RFID, HIGH);
|
||||
RFIDActive = false;
|
||||
if (RFIDActive) {
|
||||
digitalWrite(CS_RFID, HIGH);
|
||||
RFIDActive = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Make size of files human readable
|
||||
|
|
@ -219,8 +221,6 @@ void playSongByName(String song)
|
|||
deactivateRFID();
|
||||
activateSD();
|
||||
playFile(mp3File.c_str());
|
||||
activateRFID();
|
||||
deactivateSD();
|
||||
}
|
||||
|
||||
void playSongByPath(String path)
|
||||
|
|
@ -524,7 +524,10 @@ void setup()
|
|||
pinMode(CS_RFID, OUTPUT);
|
||||
pinMode(CS_SDCARD, OUTPUT);
|
||||
|
||||
deactivateRFID();
|
||||
digitalWrite(CS_RFID,HIGH);
|
||||
digitalWrite(CS_SDCARD,HIGH);
|
||||
RFIDActive = false;
|
||||
SDActive = false;
|
||||
|
||||
|
||||
Serial.print("Initializing SD card...");
|
||||
|
|
@ -555,14 +558,14 @@ void setup()
|
|||
}
|
||||
|
||||
|
||||
deactivateSD();
|
||||
activateRFID();
|
||||
Serial.println("RFID");
|
||||
//deactivateSD();
|
||||
//activateRFID();
|
||||
//Serial.println("RFID");
|
||||
|
||||
// Init MFRC522
|
||||
// Init SPI bus
|
||||
SPI.begin(-1, -1, -1, CS_RFID);
|
||||
rfid.PCD_Init(CS_RFID, RST_RFID);
|
||||
//SPI.begin(-1, -1, -1, CS_RFID);
|
||||
//rfid.PCD_Init(CS_RFID, RST_RFID);
|
||||
|
||||
/* somehow this test stops rfid from working!
|
||||
if (rfid.PCD_PerformSelfTest())
|
||||
|
|
@ -726,9 +729,6 @@ String getStartupSoundDir() {
|
|||
|
||||
void loop()
|
||||
{
|
||||
deactivateRFID();
|
||||
activateSD();
|
||||
|
||||
if (audio.isRunning())
|
||||
{
|
||||
if (asyncStop)
|
||||
|
|
@ -830,6 +830,8 @@ void loop()
|
|||
{
|
||||
readRFID();
|
||||
}
|
||||
deactivateRFID();
|
||||
activateSD();
|
||||
}
|
||||
|
||||
if (loopCounter % VOLTAGE_LOOP_INTERVAL == 0)
|
||||
|
|
|
|||
Loading…
Reference in New Issue