Commit 36af0087 authored by Cédric Bonhomme's avatar Cédric Bonhomme

Added support of the color sensor.

parent 29d90ab4
...@@ -16,6 +16,7 @@ from flask import Flask ...@@ -16,6 +16,7 @@ from flask import Flask
from ev3.ev3dev import Motor from ev3.ev3dev import Motor
#from ev3.lego import LargeMotor #from ev3.lego import LargeMotor
from ev3.lego import TouchSensor from ev3.lego import TouchSensor
from ev3.lego import ColorSensor
from ev3.lego import InfraredSensor from ev3.lego import InfraredSensor
import conf import conf
...@@ -32,11 +33,13 @@ right_wheel = None ...@@ -32,11 +33,13 @@ right_wheel = None
left_wheel = None left_wheel = None
button = None button = None
ir_sensor = None ir_sensor = None
color_sensor = None
try: try:
right_wheel = Motor(port=Motor.PORT.B) right_wheel = Motor(port=Motor.PORT.B)
left_wheel = Motor(port=Motor.PORT.C) left_wheel = Motor(port=Motor.PORT.C)
button = TouchSensor() button = TouchSensor()
ir_sensor = InfraredSensor() ir_sensor = InfraredSensor()
color_sensor = ColorSensor()
except Exception as e: except Exception as e:
pass#raise Exception('You must run the application on the EV3.') pass#raise Exception('You must run the application on the EV3.')
......
...@@ -11,9 +11,9 @@ ...@@ -11,9 +11,9 @@
# ***** END LICENSE BLOCK ***** # ***** END LICENSE BLOCK *****
__author__ = "Cedric Bonhomme" __author__ = "Cedric Bonhomme"
__version__ = "$Revision: 0.3 $" __version__ = "$Revision: 0.4 $"
__date__ = "$Date: 2014/12/15$" __date__ = "$Date: 2014/12/15$"
__revision__ = "$Date: 2015/10/31 $" __revision__ = "$Date: 2015/11/04 $"
__copyright__ = "Copyright (c) 2014-2015 Cédric BOnhomme" __copyright__ = "Copyright (c) 2014-2015 Cédric BOnhomme"
__license__ = "" __license__ = ""
...@@ -27,7 +27,7 @@ from ev3.ev3dev import Motor ...@@ -27,7 +27,7 @@ from ev3.ev3dev import Motor
import conf import conf
from web.decorators import to_response from web.decorators import to_response
from web import app from web import app
from web import right_wheel, left_wheel, button, ir_sensor from web import right_wheel, left_wheel, button, ir_sensor, color_sensor
login_manager = LoginManager(app) login_manager = LoginManager(app)
login_manager.login_view = 'index' login_manager.login_view = 'index'
...@@ -123,6 +123,11 @@ def sensor(sensor_name=""): ...@@ -123,6 +123,11 @@ def sensor(sensor_name=""):
""" """
if sensor_name == "ir_sensor": if sensor_name == "ir_sensor":
return {"distance": ir_sensor.prox} return {"distance": ir_sensor.prox}
elif sensor_name == "color_sensor":
return {"rgb": color_sensor.rgb,
"ambiant": color_sensor.ambiant,
"reflect": color_sensor.reflect,
"mode": color_sensor.mode}
elif sensor_name == "button": elif sensor_name == "button":
pass pass
else: else:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment