mirror of
https://github.com/KevinMidboe/python-gpiozero.git
synced 2025-10-29 17:50:37 +00:00
Change RGBLED interface from 0-100 to 0-255, close #40
This commit is contained in:
@@ -130,14 +130,14 @@ led = RGBLED(2, 3, 4)
|
||||
|
||||
| Property | Description | Type |
|
||||
| -------- | ----------- | ---- |
|
||||
| `red` | The brightness value of the red LED (0 to 100). | Integer |
|
||||
| `green` | The brightness value of the green LED (0 to 100). | Integer |
|
||||
| `blue` | The brightness value of the blue LED (0 to 100). | Integer |
|
||||
| `rgb` | The brightness values of the three LEDs (0 to 100). | Tuple |
|
||||
| `red` | The brightness value of the red LED (0 to 255). | Integer |
|
||||
| `green` | The brightness value of the green LED (0 to 255). | Integer |
|
||||
| `blue` | The brightness value of the blue LED (0 to 255). | Integer |
|
||||
| `rgb` | The brightness values of the three LEDs (0 to 255). | Tuple |
|
||||
|
||||
## Motor
|
||||
|
||||
Generic single-direction motor.
|
||||
Generic bi-directional motor.
|
||||
|
||||
### Wiring
|
||||
|
||||
|
||||
@@ -266,20 +266,20 @@ from time import sleep
|
||||
|
||||
led = RGBLED(red=9, green=10, blue=11)
|
||||
|
||||
led.red = 100 # full red
|
||||
led.red = 50 # half red
|
||||
led.red = 255 # full red
|
||||
led.red = 128 # half red
|
||||
|
||||
led.rgb = (0, 100, 0) # full green
|
||||
led.rgb = (0, 255, 0) # full green
|
||||
|
||||
led.rgb = (100, 0, 100) # magenta
|
||||
led.rgb = (100, 100, 0) # yellow
|
||||
led.rgb = (0, 100, 100) # cyan
|
||||
led.rgb = (100, 100, 100) # white
|
||||
led.rgb = (255, 0, 255) # magenta
|
||||
led.rgb = (255, 255, 0) # yellow
|
||||
led.rgb = (0, 255, 100) # cyan
|
||||
led.rgb = (255, 255, 255) # white
|
||||
|
||||
led.rgb = (0, 0, 0) # off
|
||||
|
||||
# slowly increase intensity of blue
|
||||
for n in range(100):
|
||||
for n in range(256):
|
||||
led.blue += 1
|
||||
sleep(0.1)
|
||||
```
|
||||
@@ -365,7 +365,7 @@ from gpiozero import RGBLED, MCP3008
|
||||
|
||||
def read_pot(channel):
|
||||
with MCP3008(channel=channel) as pot:
|
||||
return 100 * pot.read() / 1023
|
||||
return 255 * pot.read() / 1023
|
||||
|
||||
led = RGBLED(red=2, green=3, blue=4)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user