used incorrect sensor mode for getbrightness() method

This commit is contained in:
d3rped 2018-03-18 16:19:12 +01:00
parent bfd00d33ed
commit 48dfc2a03b

View file

@ -8,7 +8,7 @@ import ev3dev.ev3 as ev3
class Sensor: class Sensor:
def __init__(self): def __init__(self):
self._sensor = ev3.ColorSensor() self._sensor = ev3.ColorSensor()
self._sensor.mode = 'REF-RAW' self._sensor.mode = 'COL-REFLECT'
def iscolor(self, color): def iscolor(self, color):
curcol = self._sensor.bin_data("hhh") curcol = self._sensor.bin_data("hhh")
@ -19,7 +19,7 @@ class Sensor:
# see https://stackoverflow.com/questions/687261/converting-rgb-to-grayscale-intensity # see https://stackoverflow.com/questions/687261/converting-rgb-to-grayscale-intensity
def getbrightness(self): def getbrightness(self):
if(self._sensor.mode == 'REF-RAW'): if(self._sensor.mode == 'COL-REFLECT'):
return self._sensor.value return self._sensor.value
else: else:
print("ERROR: incorrect sensor mode.") print("ERROR: incorrect sensor mode.")