From e5c22c533e7d9ec06036d45e9894ad82d792cc75 Mon Sep 17 00:00:00 2001 From: ysard Date: Tue, 21 Dec 2021 21:00:53 +0100 Subject: [PATCH] Add doc & example for headlight support --- README.md | 1 + docs/Headlight.md | 20 ++++++++++++++++++++ docs/Peripherals.md | 3 ++- 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 docs/Headlight.md diff --git a/README.md b/README.md index ac1e6d8..d4faae3 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ If you have Vernie assembled, you might run scripts from [`examples/vernie`](exa - [vision sensor](docs/VisionSensor.md): several modes to measure distance, color and luminosity - [tilt sensor](docs/TiltSensor.md) subscription: 2 axis, 3 axis, bump detect modes - [RGB LED](docs/LED.md) color change +- [Headlight](docs/Headlight.md) brightness change - [push button](docs/MoveHub.md#push-button) status subscription - [battery voltage and current](docs/VoltageCurrent.md) subscription available diff --git a/docs/Headlight.md b/docs/Headlight.md new file mode 100644 index 0000000..afee041 --- /dev/null +++ b/docs/Headlight.md @@ -0,0 +1,20 @@ +### Headlight + +You can set the brightness of the LEDs of this set using the `LEDLight` class and its +`set_brightness` method. Accepted values are between 0 and 100%. + +Example to make the LEDs blink: + +```python +import time +from pylgbst.hub import MoveHub + +hub = MoveHub() +# Blink forever +while True: + # Headlight is on port D; set its brightness to 100% + hub.port_D.set_brightness(100) + time.sleep(1) + # Shutdown the ligth + hub.port_D.set_brightness(0) +``` diff --git a/docs/Peripherals.md b/docs/Peripherals.md index 8ed90f9..acf8015 100644 --- a/docs/Peripherals.md +++ b/docs/Peripherals.md @@ -4,6 +4,7 @@ Here is the list of peripheral devices that have dedicated classes in library: - [Motors](Motor.md) - [RGB LED](LED.md) +- [Headlight](Headlight.md) - [Tilt Sensor](TiltSensor.md) - [Vision Sensor](VisionSensor.md) (color and/or distance) - [Voltage and Current Sensors](VoltageCurrent.md) @@ -19,6 +20,6 @@ It is possible to subscribe with multiple times for the same sensor. Only one, v Good practice for any program is to unsubscribe from all sensor subscriptions before exiting, especially when used with `DebugServer`. -## Generic Perihpheral +## Generic Peripheral In case you have used a peripheral that is not recognized by the library, it will be detected as generic `Peripheral` class. You still can use subscription and sensor info getting commands for it. \ No newline at end of file