Module GenericAnalogSensor
[frames] | no frames]

Source Code for Module GenericAnalogSensor

 1  # GenericAnalogSensor.py 
 2   
 3  ''' 
 4   This software is part of the EV3BrickPi library. 
 5   It is Open Source Free Software, so you may 
 6   - run the code for any purpose 
 7   - study how the code works and adapt it to your needs 
 8   - integrate all or parts of the code in your own programs 
 9   - redistribute copies of the code 
10   - improve the code and release your improvements to the public 
11   However the use of the code is entirely your responsibility. 
12  ''' 
13   
14  from LegoRobot import LegoRobot 
15   
16 -class GenericAnalogSensor():
17 ''' 18 Creates an abstraction of a generic analog sensor attached at given port. 19 '''
20 - def __init__(self, port):
21 self.port = port 22 LegoRobot._lock.acquire() 23 BrickPi.SensorType[self.port] = TYPE_SENSOR_RAW 24 LegoRobot._lock.release()
25
26 - def getValue(self):
27 ''' 28 Returns the current value. 29 ''' 30 LegoRobot._lock.acquire() 31 value = BrickPi.Sensor[self.port] 32 LegoRobot._lock.release() 33 return value
34