Open softhack007 opened 1 year ago
Great idea and for sure will eliminate some of the guess work . I do hope you could also consider analog as that would be helpful for line-in as some are still on the DIY listed in the wiki ( works really well when it does )
It would not be possible to do this for analog @dosipod as the value read this way will never be exactly 0 or freeze if a connection comes loose.
The idea here was to help uses get better feedback when trying to wire up I2S devices, but using the wrong pins etc. Better to indicate some form of error rather than just say "silence"
development note for a future feature
Is your feature request related to a problem? Please describe.
To help diagnose wrong configuration, it would be useful to make a difference between "silence" (some signal but below thresholds) and "frozen" signal (constantly at the same value for long time).
Describe the solution you'd like
Implementation should be straight forward, with some potential for optimizations as we only need to consider "sample batches" that are all at the same value.
static unsigned long timeOfLastChange=0;
that stores the millis() from the last changing sample batch (special case "0" = never changed since startup)static float previous_sample =0;
for comparing with new samples. If all samples in the batch == previous_sample, we are stuck at a value. If at least one is different, update timeOfLastChange to indicate "not stuck". And update previous_sample to a randomly picked sample, like the 16th in a batch (does not matter which one we use).timeOfLastChange - now() > 5 seconds
--> show "frozen".Additional context
I2S is basically single-direction from programming perspective, so you set pins, then start reading values. There is no feedback available about bad configuration, for example missing/broken MCLK signal.
Thanks @netmindz and a few other discord users who suggested a detection scheme for "frozen" signals.