Case statement error

Oh, yes, you're correct, you did post that bit.
Sorry.
But you've changed the code since then.

Still, it's only warning.

All i did was go into my variables.h file and changed the following variable,, added the word state_ before them so it wasn't conflicting.

bool state_warn_low = false;
bool state_alarm_high = false;
bool state_alarm_low = false;
bool state_error = false;
bool state_no_readings = false;
bool state_normal_range = false;

And i did change one more thing sorry, to get it to build i changed

printf("enum value: %d\n", i);
        playWav(i, 50);

to

printf("enum value: %d\n", i);
        //playWav(i, 50);

so I was able to build. However im now in a loop cycle as my device is trying to figure out how to play the file in the enum....

The warning message is simply telling you that it's wrong to consider an enum and an int as equivalent.

thank you for that clarification. so im no longer in a boot loop, but also have no audio now.

Maybe because it appears all you're doing is to print a pathname.

oh sorry! i took the // out of each case so it resembles this now

case general_alarm:
            file = new AudioFileSourceSD("/wav/alarm.wav");
            printf("/wav/alarm.wav\n");
            break;

What about all the I2S and volume and begin stuff?

I moved the function for begin and volume directly under the last case inside the enum...

...but I can't see that in the code you posted last.

Oh yea, sorry I keep forgetting to send the code after a change. Guess I'm expecting you to pull out your all seeing globe. I'll post. In just a minute.

enum soundEffects {
    alarm,
    alarm_high,
    alarm_low,
    Dev_startup,
    error,
    error1,
    noread,
    noreadings,
    normalrange,
    startup,
    startup_dev,
    update,
    warning,
    warning_high,
    warning_low,
};

void playWAV (enum soundEffects effect, int volume)
{
    //Serial.println("Entered paciplay_day");
    //printf("Entered paciplay_day\n");

    switch (effect)
    {
        case alarm:
            file = new AudioFileSourceSD("/wav/alarm.wav");
            printf("/wav/alarm.wav\n");
            break;

        case alarm_high:
            file = new AudioFileSourceSD("/wav/alarmhigh.wav");
            printf("/wav/alarmhigh.wav\n");
            break;

        case alarm_low:
            file = new AudioFileSourceSD("/wav/alarmlow.wav");
            printf("/wav/alarmlow.wav\n");
            break;

        case error:
            file = new AudioFileSourceSD("/wav/error.wav");
            printf("/wav/error.wav\n");
            break;

        case error1:
            file = new AudioFileSourceSD("/wav/error1.wav");
            printf("/wav/error1.wav\n");
            break;

        case noread:
            file = new AudioFileSourceSD("/wav/noread.wav");
            printf("/wav/noread.wav\n");
            break;

        case noreadings:
            file = new AudioFileSourceSD("/wav/noreadings.wav");
            printf("/wav/noreadings.wav\n");
            break;

        case normalrange:
            file = new AudioFileSourceSD("/wav/normalrange.wav");
            printf("/wav/normalrange.wav\n");
            break;

        case warning:
            file = new AudioFileSourceSD("/wav/warning.wav");
            printf("/wav/warning.wav\n");
            break;

        case warning_high:
            file = new AudioFileSourceSD("/wav/warninghigh.wav");
            printf("/wav/warninghigh.wav\n");
            break;

        case warning_low:
            file = new AudioFileSourceSD("/wav/warninglow.wav");
            printf("/wav/warninglow.wav\n");
            break;

        case startup:
            file = new AudioFileSourceSD("/wav/startup.wav");
            printf("/wav/startup.wav\n");
            break;

        case startup_dev:
            file = new AudioFileSourceSD("/wav/startup_dev.wav");
            printf("/wav/startup_dev.wav\n");
            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 main()
{
    //using direct numbers
    for (int i = 0; i<14; i++)
    {
        printf("enum value: %d\n", i);
        //playWAV(i, 50);
    }

    //directly calling
    playWAV(startup, 100);

    // Other way of calling the value
    enum soundEffects sound;
    sound = error;
    playWAV(sound, 100);
    return 0;
}

Can you see where the "switch" ends?

hmm...with this code, it is now in a reboot cycle again (from the code i just posted) i ran a decoder on the guru meditation error i was able to pull out of the serial log.......

0x400d39b4: finalizeWAVInstance() at C:/Users/Administrator.MYTDS/Documents/PlatformIO/Projects/bg1248/src/BG1248.ino line 3026
0x400d9b34: loop() at C:/Users/Administrator.MYTDS/Documents/PlatformIO/Projects/bg1248/src/BG1248.ino line 3406
0x400fadfc: loopTask(void*) at C:/Users/Administrator.MYTDS/.platformio/packages/framework-arduinoespressif32/cores/esp32/main.cpp line 23
0x40091b6a: vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c line 143
PC: 0x400d39b4: finalizeWAVInstance() at C:/Users/Administrator.MYTDS/Documents/PlatformIO/Projects/bg1248/src/BG1248.ino line 3026
EXCVADDR: 0x00000000

Decoding stack results
0x400d39b4: finalizeWAVInstance() at C:/Users/Administrator.MYTDS/Documents/PlatformIO/Projects/bg1248/src/BG1248.ino line 3026
0x400d9b34: loop() at C:/Users/Administrator.MYTDS/Documents/PlatformIO/Projects/bg1248/src/BG1248.ino line 3406
0x400fadfc: loopTask(void*) at C:/Users/Administrator.MYTDS/.platformio/packages/framework-arduinoespressif32/cores/esp32/main.cpp line 23
0x40091b6a: vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c line 143

im assuming its either a null object or i messed up something....

Ends?

Yes, ends
Where the switch's closing brace is.

Oops. Ita below the begin line ':slight_smile: should I move the begin section below the switch bracket

just moved it



enum soundEffects {
    general_alarm,
    alarm_high,
    alarm_low,
    Dev_startup,
    error,
    error1,
    noread,
    noreadings,
    normalrange,
    startup,
    startup_dev,
    update,
    warning,
    warning_high,
    warning_low,
};

void playWAV (enum soundEffects effect, int volume)
{
    //Serial.println("Entered paciplay_day");
    //printf("Entered paciplay_day\n");

    switch (effect)
    {
        case general_alarm:
            file = new AudioFileSourceSD("/wav/alarm.wav");
            printf("/wav/alarm.wav\n");
            break;

        case alarm_high:
            file = new AudioFileSourceSD("/wav/alarmhigh.wav");
            printf("/wav/alarmhigh.wav\n");
            break;

        case alarm_low:
            file = new AudioFileSourceSD("/wav/alarmlow.wav");
            printf("/wav/alarmlow.wav\n");
            break;

        case error:
            file = new AudioFileSourceSD("/wav/error.wav");
            printf("/wav/error.wav\n");
            break;

        case error1:
            file = new AudioFileSourceSD("/wav/error1.wav");
            printf("/wav/error1.wav\n");
            break;

        case noread:
            file = new AudioFileSourceSD("/wav/noread.wav");
            printf("/wav/noread.wav\n");
            break;

        case noreadings:
            file = new AudioFileSourceSD("/wav/noreadings.wav");
            printf("/wav/noreadings.wav\n");
            break;

        case normalrange:
            file = new AudioFileSourceSD("/wav/normalrange.wav");
            printf("/wav/normalrange.wav\n");
            break;

        case warning:
            file = new AudioFileSourceSD("/wav/warning.wav");
            printf("/wav/warning.wav\n");
            break;

        case warning_high:
            file = new AudioFileSourceSD("/wav/warninghigh.wav");
            printf("/wav/warninghigh.wav\n");
            break;

        case warning_low:
            file = new AudioFileSourceSD("/wav/warninglow.wav");
            printf("/wav/warninglow.wav\n");
            break;

        case startup:
            file = new AudioFileSourceSD("/wav/startup.wav");
            printf("/wav/startup.wav\n");
            break;

        case startup_dev:
            file = new AudioFileSourceSD("/wav/startup_dev.wav");
            printf("/wav/startup_dev.wav\n");
            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 main()
{
    //using direct numbers
    for (int i = 0; i<14; i++)
    {
        printf("enum value: %d\n", i);
        //playWAV(i, 50);
    }

    //directly calling
    playWAV(startup, 100);

    // Other way of calling the value
    enum soundEffects sound;
    sound = error;
    playWAV(sound, 100);
    return 0;
}

And . . ?

(You should really have a default case)

it took flashing it twice (don't know why the first one did nothing, the screen wouldnt even turn on) but now it is working as expected.

in this scenerio every condition has a set of files, im not even sure what i would put a default file as...maybe a blank audio file or maybe just a simple beep?