Reads analog value of the sensor that's connected to our `GoPiGo3`_ robot as a percentage. :returns: Percentage mapped to 0V-5V range. :rtype: int
(self)
| 452 | return self.value |
| 453 | |
| 454 | def percent_read(self): |
| 455 | """ |
| 456 | Reads analog value of the sensor that's connected to our `GoPiGo3`_ robot as a percentage. |
| 457 | |
| 458 | :returns: Percentage mapped to 0V-5V range. |
| 459 | :rtype: int |
| 460 | |
| 461 | """ |
| 462 | reading_percent = round(self.read() * 100 // self._max_value) |
| 463 | |
| 464 | # Some sensors - like the loudness_sensor - |
| 465 | # can actually return higher than 100% so let's clip it |
| 466 | # and keep classrooms within an acceptable noise level |
| 467 | if reading_percent > 100: |
| 468 | reading_percent = 100 |
| 469 | return reading_percent |
| 470 | |
| 471 | def write(self, power): |
| 472 | """ |
no test coverage detected