ICOMP-UNC / Bit-Masters

MIT License
0 stars 0 forks source link

[FEATURE][#2] Read battery ADC value #12

Closed sofiavalos closed 2 weeks ago

sofiavalos commented 2 weeks ago

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?