Add more logging and exception
This commit is contained in:
parent
cb10bb3a4d
commit
ce1c82a192
8 changed files with 56 additions and 19 deletions
|
@ -1,4 +1,5 @@
|
|||
from compLib.ADC import ADC
|
||||
from compLib.LogstashLogging import Logging
|
||||
|
||||
BATTERY_CHANNEL = 2
|
||||
BATTERY_COUNT = 2
|
||||
|
@ -21,4 +22,6 @@ class Battery(object):
|
|||
:rtype: int
|
||||
"""
|
||||
voltage = adc.read(BATTERY_CHANNEL) * BATTERY_MULTIPLIER
|
||||
return int(((voltage / BATTERY_COUNT) - BATTERY_MIN_VOLTAGE) / (BATTERY_MAX_VOLTAGE - BATTERY_MIN_VOLTAGE) * 100)
|
||||
result = int(((voltage / BATTERY_COUNT) - BATTERY_MIN_VOLTAGE) / (BATTERY_MAX_VOLTAGE - BATTERY_MIN_VOLTAGE) * 100)
|
||||
Logging.get_logger().debug(f"Battery.percent = {result}")
|
||||
return result
|
||||
|
|
Reference in a new issue