We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
electricity
1 parent 898735d commit 6e9d02aCopy full SHA for 6e9d02a
āsrc/components/module/battery.cpp
@@ -20,7 +20,6 @@ void setup_battery(Battery_conf *conf) {
20
*/
21
uint8_t get_electricity() {
22
uint16_t electricity = analogRead(_battery_conf->pin);
23
- uint32_t batter_value = (_battery_conf->max - _battery_conf->min) * 100;
24
25
if(electricity < _battery_conf->min) {
26
return 0;
@@ -31,7 +30,7 @@ uint8_t get_electricity() {
31
30
}
32
33
// Scale the analog input value to a percentage between 0 and 100
34
- return ( (electricity - _battery_conf->min) / batter_value );
+ return ( ( (electricity - _battery_conf->min) * 100 ) / (_battery_conf->max - _battery_conf->min) );
35
36
37
uint16_t get_electricity_value() {
0 commit comments