interesting thought to make it voltage independant!
static const long cachedMaxValue = 1023; probably int works well enough saves 2 bytes
float percentage = (((float) ADValue) / cachedMaxValue);
float percentage = ( ADValue * (1.0/cachedMaxValue); // will become a compile time calculated value which is faster @ runtime + no casting need.
rewrote function as I think there is a bug if only v2 was NO_VOLTAGE, please check
AnalogVoltage(int _inPin = -1, float minV = NO_VOLTAGE, float maxV = NO_VOLTAGE): AnalogIn(_inPin)
voltage = 0;
minVoltage = (minV == NO_VOLTAGE) ? 0.0 : minV;
maxVoltage = (maxV == NO_VOLTAGE) ? defaultAnalogReference : maxV;
Think you can save some bytes more if you use integers representing milliVolts for the voltages, also the math will be faster.