Working on a unique project with a tea5767 and am trying to have it build a list of "strong" frequencies during setup, then have it tune to each for 5 seconds (looping the list indefinitely) when done.
The best method I can think of would be to perform a scan using tea5767's library and for frequencies where printSignalStrength() is greater than x, append the frequency to an array. In the loop, I could have it simply tune to each array variable for 5 seconds each.
My questions are...
Would an array be the best method (or even work) for setting up something like this?
If so, the number of variables in the array may be dynamic each startup. Without knowing this, how could I ensure each frequency is accessed when tuning to each in the loop?
I couldn't find existing code which did something similar to this, but if you do or have other suggestions; please share:)
It has to be big enough to hold as many frequencies as you are interested in ever having in the list. And an array of an appropriate type (integer, long, float whatever) to represent the frequency.
Keep a variable that just counts how many you found during the scan, and only refer to or use later that number of entries.
How many frequencies are you expecting ? Since memory is anyway not infinite, you may as well declare an array with a finite number of entries. If you do decide to declare variables dynamically you run the risk of running out, causing unexpected behavior.
Another thing would be that if you have more frequencies that are strong enough, you could just delete the weakest from the list.