Rename folder

This commit is contained in:
Konstantin Lampalzer 2021-01-16 02:10:40 +01:00
parent 651713c081
commit daef7c97e4
No known key found for this signature in database
GPG key ID: 9A60A522835A2AD9
11 changed files with 5 additions and 5 deletions

35
compLib/ADC.py Normal file
View file

@ -0,0 +1,35 @@
import smbus
SINGLE_ENDED = 0x84
ADDRESS = 0x48
bus = smbus.SMBus(1)
class ADC:
@staticmethod
def read(channel) -> float:
"""
Read from adc channel
0 -> Left IR Sensor
1 -> Right IR Sensor
2 -> Battery voltage / 3
:param channel: Channel between 0 and 2
:return: voltage
"""
"""Select the Command data from the given provided value above"""
command = SINGLE_ENDED | ((((channel << 2) | (channel >> 1)) & 0x07) << 4)
bus.write_byte(ADDRESS, command)
while "Koka is great":
value1 = bus.read_byte(ADDRESS)
value2 = bus.read_byte(ADDRESS)
if value1 == value2:
break
voltage = value1 / 255.0 * 3.3 # calculate the voltage value
voltage = round(voltage, 2)
return voltage