Thanks for sharing your library!
in your code you hard code the inner array.
adc_key_val[0] = 30;
adc_key_val[1] = 160;
adc_key_val[2] = 360;
adc_key_val[3] = 550;
adc_key_val[4] = 780;
It would be nice if I could give an array of the resistor values and that the constructor calculated the internal key_values.
something like this ...
AnalogDebounce::AnalogDebounce(byte pin,button_callback f, int count, int * resistorArray) // assuming all values in same unit KOhm
{
uint16_t sum = 0;
for( int i=0; i< count; i++)
{
sum += resistorArray[i];
}
uint16_t partial = 0;
for(int i=0; i< count; i++)
{
partial += resistorArray[i];
adc_key_val[i] = (partial * 1024) / sum; // partial might need an initial correction factor
}
etc...
It is a bit more code but the user only has to fill in the resistors used. No magic numbers
What do you think of this idea?