Skip to content

Commit 89256ee

Browse files
committed
First attempt at getting distance
1 parent 9443434 commit 89256ee

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

buildhat/colordistance.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,17 @@ def get_reflected_light(self):
115115
readings.append(self.get()[0])
116116
return int(sum(readings) / len(readings))
117117

118+
def get_distance(self):
119+
"""Return the reflected light
120+
121+
:return: Reflected light
122+
:rtype: int
123+
"""
124+
self.mode(6)
125+
distance = self.get()
126+
print("distance", distance)
127+
return
128+
118129
def _clamp(self, val, small, large):
119130
return max(small, min(val, large))
120131

0 commit comments

Comments
 (0)