Ok, if it is not supported, then I will remove the brightness code, for Vdd=3.3V using VREF = 3 introduces an error of 9-10%, a better fix would be
that would give an error less than 2% and should be fine for this (not using x10 to avoid divisions). I will also update the schematics to rename Vref to ADC offset for not to confuse with this VREF which is the ADC Vref+. The battery scale can be done in the menu and/or in the eeprom if R1 and R2 are known. Using current values R1 = 20K, R2 = 6.8K the maximum battery voltage would be 13V (vs. 20V in the case of 5V) so it might be safer to use a value lower than 6.8K e.g. 5.1K that would allow a maximum battery voltage of ~16V. I didn't find any replacement for the MCP1525, which should give 3.3V/2 = 1.65V, so the resistor divider might work well. MCP1525 is very stable and always gives 2.5V = 5V/2
Code:
#define VREF 26 // 3.3V x 8 #define adc_to_volts(x) ((VREF*((int16_t)(x)-(int16_t)g_adc_offset))>>3) #define volts(x) ((VREF*(x))>>3)
Comment