I keep having a problem with my m5core2. I know what is causing it but not the reason why or how to remedy the situation. If I for example change my playwav volume from having to type it every time to having a variable that way you can change the volume on all of them together. So i assigned a variable. (int vol_con) however once I upload the code it works until it trys to find the wav file then gets stuck in a reboot cycle. I found it is being returned a null value. How and why is that happening??
decoder log:
PC: 0x401ac4bd: AudioFileSourceUnsync::getByte() at C:/Users/Administrator.MYTDS/Documents/Arduino/libraries/ESP8266Audio/src/AudioFileSourceID3.cpp line 76
EXCVADDR: 0x00000000
Decoding stack results
0x401ac4bd: AudioFileSourceUnsync::getByte() at C:/Users/Administrator.MYTDS/Documents/Arduino/libraries/ESP8266Audio/src/AudioFileSourceID3.cpp line 76
0x400f5c03: AudioGeneratorWAV::begin(AudioFileSource*, AudioOutput*) at C:/Users/Administrator.MYTDS/Documents/Arduino/libraries/ESP8266Audio/src/AudioGeneratorWAV.cpp line 296
0x400e0801: handleAlarmsInfoLine(NSinfo*) at C:/Users/Administrator.MYTDS/Documents/PlatformIO/Projects/paci_1248/src/goodnites.ino line 1739
0x400e3a62: MicroDot::setBrightness(unsigned char) at src/microdot.cpp line 158
0x400fbbd6: _GLOBAL__sub_I_loopTaskHandle() at C:/Users/Administrator.MYTDS/.platformio/packages/framework-arduinoespressif32/cores/esp32/IPAddress.h line 94
0x40091d0a: vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c line 143
which part? the area i declaired the variable? where im using them? I cant post the whole code as the sketch is about 3000 lines and i wont subject anyone to that torture
////////////////AUDIO/////////////
void playWAV (char effect, vol_con)
{
Serial.println("Entered playWAV");
switch (effect)
{
case 'a':
file = new AudioFileSourceSD("/wav/alarm.wav");
break;
case 'b':
file = new AudioFileSourceSD("/wav/alarmhigh.wav");
break;
case 'c':
file = new AudioFileSourceSD("/wav/alarmlow.wav");
break;
case 'd':
file = new AudioFileSourceSD("/wav/error.wav");
break;
case 'e':
file = new AudioFileSourceSD("/wav/error1.wav");
break;
case 'f':
file = new AudioFileSourceSD("/wav/noread.wav");
break;
case 'g':
file = new AudioFileSourceSD("/wav/noreadings.wav");
break;
case 'h':
file = new AudioFileSourceSD("/wav/normalrange.wav");
break;
case 'i':
file = new AudioFileSourceSD("/wav/warning.wav");
break;
case 'j':
file = new AudioFileSourceSD("/wav/warninghigh.wav");
break;
case 'k':
file = new AudioFileSourceSD("/wav/warninglow.wav");
break;
case 'l':
file = new AudioFileSourceSD("/wav/startup.wav");
break;
case 'm':
file = new AudioFileSourceSD("/wav/startup.wav");
break;
case 'n':
file = new AudioFileSourceSD("/wav/update.wav");
break;
}
float volumeGain = ((float)volume / 100.0) * 39.0;
Serial.print("volumeGain:");
Serial.println(volumeGain);
id3 = new AudioFileSourceID3(file);
out = new AudioOutputI2S(0, 0); // Output to builtInDAC
out->SetPinout(12, 0, 2);
out->SetOutputModeMono(true);
out->SetGain(volumeGain);
wav = new AudioGeneratorWAV();
wav->begin(id3, out);
}
int vol_con = 3;
Is it possible you can simplify the code, eliminating the non related procedures? It would be best if you could boil the code down to just showing the issue.
Even if you had to put dummy functions in place
what i posted is where the problem is. its inside the void playwav function. I have specified the variable directly below the function. you can see i have the value set but if i push it to the device it crashes and goes into a boot loop.
I think your onto somethjng. I thought I was putting, them global buy I didn't close the PlayWAV command fully... Maybe that is it... Wait another thing. The volume that I'm trying to control, it's listed in the function as char effect, int volume... However volume is a part of a float. Within the lower half of the code for that function
Could that be it?
This is also a 100% stupid question but I have to wear the dunce cap and ask, because I'm trying to is set up day night modes using. Localtimeinfo.tm_hour >= 20.blah blah
.
Can there be two sets of variables for the same function? As the way its constructed is using that line above if before 20 00 hours it's false skips it completly if equal or greater than 20 00 its true so use xyz
Basically its a if true else skip.
Would this be possible? I'm asking because const variables work fine
ok, this is different, I took a change because I seperate things into header files sometime if they have a lot of different void functions (like my led effects). I decided to try putting all my variables into a variables.h file, and #include "variables.h" right after include arduino. magically it is working. the variables stay after a reboot.