| Conditions | 2 |
| Total Lines | 14 |
| Code Lines | 8 |
| Lines | 14 |
| Ratio | 100 % |
| Changes | 0 | ||
| 1 | import logging |
||
| 12 | View Code Duplication | async def train_sensor_change(self): |
|
|
|
|||
| 13 | self.message_info(f'Train sensor value change {self.train_sensor.value}') |
||
| 14 | distance = self.train_sensor.value[VisionSensor.capability.sense_distance] |
||
| 15 | count = self.train_sensor.value[VisionSensor.capability.sense_count] |
||
| 16 | |||
| 17 | if count > 3: |
||
| 18 | # Wave your hand more than three times in front of the sensor and the program ends |
||
| 19 | self.keep_running = False |
||
| 20 | |||
| 21 | # The closer your hand gets to the sensor, the faster the motor runs |
||
| 22 | self.motor_speed = (10-distance)*10 |
||
| 23 | |||
| 24 | # Flag a change |
||
| 25 | self.sensor_change = True |
||
| 26 | |||
| 45 |