something like this?
#include <M5Stack.h>
#include "utility/M5Timer.h"
char currentCharEffect = '\0'; // none
int currentVolume = 0; // OFF
M5Timer M5timer;
void playWAV (char effect, int volume)
{
...
}
void playCallback() {
playWAV(currentCharEffect, currentVolume);
}
void setup() {
M5.begin();
M5timer.setTimeout(5000, playCallback);
}
void loop() {
M5timer.run();
// here some code modifying currentCharEffect and currentVolume
}