Rename folder
This commit is contained in:
parent
651713c081
commit
daef7c97e4
11 changed files with 5 additions and 5 deletions
24
compLib/Battery.py
Normal file
24
compLib/Battery.py
Normal file
|
@ -0,0 +1,24 @@
|
|||
from compLib.ADC import ADC
|
||||
|
||||
BATTERY_CHANNEL = 2
|
||||
BATTERY_COUNT = 2
|
||||
BATTERY_MULTIPLIER = 3
|
||||
BATTERY_MIN_VOLTAGE = 3.6
|
||||
BATTERY_MAX_VOLTAGE = 4.1
|
||||
|
||||
adc = ADC()
|
||||
|
||||
|
||||
class Battery(object):
|
||||
"""Used to interact with the battery
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def percent() -> int:
|
||||
"""Get battery percentage
|
||||
|
||||
:return: Percentage between 0 and 100
|
||||
:rtype: int
|
||||
"""
|
||||
voltage = adc.read(BATTERY_CHANNEL) * BATTERY_MULTIPLIER
|
||||
return int((voltage - BATTERY_MIN_VOLTAGE) / BATTERY_MAX_VOLTAGE * 100)
|
Reference in a new issue