File tree Expand file tree Collapse file tree 3 files changed +145
-61
lines changed
Expand file tree Collapse file tree 3 files changed +145
-61
lines changed Original file line number Diff line number Diff line change 6262class Sensor (Device ):
6363 """
6464 The sensor class provides a uniform interface for using most of the
65- sensors available for the EV3. The various underlying device drivers will
66- create a `lego-sensor` device for interacting with the sensors.
67-
68- Sensors are primarily controlled by setting the `mode` and monitored by
69- reading the `value<N>` attributes. Values can be converted to floating point
70- if needed by `value<N>` / 10.0 ^ `decimals`.
71-
72- Since the name of the `sensor<N>` device node does not correspond to the port
73- that a sensor is plugged in to, you must look at the `address` attribute if
74- you need to know which port a sensor is plugged in to. However, if you don't
75- have more than one sensor of each type, you can just look for a matching
76- `driver_name`. Then it will not matter which port a sensor is plugged in to - your
77- program will still work.
65+ sensors available for the EV3.
7866 """
7967
8068 SYSTEM_CLASS_NAME = 'lego-sensor'
@@ -286,7 +274,10 @@ def bin_data(self, fmt=None):
286274 if fmt is None : return raw
287275
288276 return unpack (fmt , raw )
289-
277+
278+ def _ensure_mode (self , mode ):
279+ if self .mode != mode :
280+ self .mode = mode
290281
291282def list_sensors (name_pattern = Sensor .SYSTEM_DEVICE_NAME_CONVENTION , ** kwargs ):
292283 """
You can’t perform that action at this time.
0 commit comments