This change depends on the PlatformIO environment configuration to ensure that hardware dependencies and platform-specific settings are available for the proper execution of ADC reads and battery level processing.
What?
A function get_battery_value() was added to read the ADC value and convert it to a battery level percentage, interpreting a voltage range from 0 to 5V as a percentage between 0 and 100%. The function returns the battery level as an integer from 0 to 100, representing the battery charge state based on the input voltage.
Why?
This change enables flexible battery monitoring by providing a percentage-based reading. It is useful for applications that need to know the battery charge level in real-time, allowing decisions to be made based on battery level without needing to interpret the raw ADC value.
How?
The ADC is configured with a 12-bit resolution (maximum value of 4095) and a 5V reference voltage.
The function reads the ADC value and normalizes it to a value between 0 and 100%.
Dependencies
This change depends on the PlatformIO environment configuration to ensure that hardware dependencies and platform-specific settings are available for the proper execution of ADC reads and battery level processing.
What?
A function
get_battery_value()
was added to read the ADC value and convert it to a battery level percentage, interpreting a voltage range from 0 to 5V as a percentage between 0 and 100%. The function returns the battery level as an integer from 0 to 100, representing the battery charge state based on the input voltage.Why?
This change enables flexible battery monitoring by providing a percentage-based reading. It is useful for applications that need to know the battery charge level in real-time, allowing decisions to be made based on battery level without needing to interpret the raw ADC value.
How?