mirror of
				https://github.com/KevinMidboe/python-gpiozero.git
				synced 2025-10-29 17:50:37 +00:00 
			
		
		
		
	Merge pull request #177 from waveform80/misc-11
Miscellaneous minor changes for 1.1
This commit is contained in:
		
							
								
								
									
										2
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								Makefile
									
									
									
									
									
								
							| @@ -159,7 +159,7 @@ release: $(PY_SOURCES) $(DOC_SOURCES) $(DEB_SOURCES) | ||||
| 	dch --newversion $(VER)$(DEB_SUFFIX) --controlmaint | ||||
| 	# commit the changes and add a new tag | ||||
| 	git commit debian/changelog -m "Updated changelog for release $(VER)" | ||||
| 	git tag -s release-$(VER) -m "Release $(VER)" | ||||
| 	git tag -s v$(VER) -m "Release v$(VER)" | ||||
| 	# update the package's registration on PyPI (in case any metadata's changed) | ||||
| 	$(PYTHON) $(PYFLAGS) setup.py register | ||||
|  | ||||
|   | ||||
| @@ -35,7 +35,7 @@ RGBLED | ||||
| ====== | ||||
|  | ||||
| .. autoclass:: RGBLED(red, green, blue, active_high=True) | ||||
|     :members: on, off, blink, red, green, blue, value | ||||
|     :members: on, off, toggle, blink, red, green, blue, color | ||||
|  | ||||
| Motor | ||||
| ===== | ||||
|   | ||||
| @@ -520,17 +520,22 @@ class RGBLED(SourceMixin, CompositeDevice): | ||||
|         The GPIO pin that controls the blue component of the RGB LED. | ||||
|  | ||||
|     :param bool active_high: | ||||
|         If ``True`` (the default), the :meth:`on` method will set the GPIOs to | ||||
|         HIGH. If ``False``, the :meth:`on` method will set the GPIOs to LOW | ||||
|         (the :meth:`off` method always does the opposite). | ||||
|         Set to ``True`` (the default) for common cathode RGB LEDs. If you are | ||||
|         using a common anode RGB LED, set this to ``False``. | ||||
|  | ||||
|     :param bool initial_value: | ||||
|         The initial color for the LED. Defaults to black ``(0, 0, 0)``. | ||||
|     """ | ||||
|     def __init__(self, red=None, green=None, blue=None, active_high=True): | ||||
|     def __init__( | ||||
|             self, red=None, green=None, blue=None, active_high=True, | ||||
|             initial_value=(0, 0, 0)): | ||||
|         self._leds = () | ||||
|         self._blink_thread = None | ||||
|         if not all([red, green, blue]): | ||||
|             raise OutputDeviceError('red, green, and blue pins must be provided') | ||||
|         super(RGBLED, self).__init__() | ||||
|         self._leds = tuple(PWMLED(pin, active_high) for pin in (red, green, blue)) | ||||
|         self.value = initial_value | ||||
|  | ||||
|     red = _led_property(0) | ||||
|     green = _led_property(1) | ||||
| @@ -563,18 +568,28 @@ class RGBLED(SourceMixin, CompositeDevice): | ||||
|  | ||||
|     def on(self): | ||||
|         """ | ||||
|         Turn the device on. This equivalent to setting the device color to | ||||
|         white ``(1, 1, 1)``. | ||||
|         Turn the LED on. This equivalent to setting the LED color to white | ||||
|         ``(1, 1, 1)``. | ||||
|         """ | ||||
|         self.value = (1, 1, 1) | ||||
|  | ||||
|     def off(self): | ||||
|         """ | ||||
|         Turn the device off. This is equivalent to setting the device color | ||||
|         to black ``(0, 0, 0)``. | ||||
|         Turn the LED off. This is equivalent to setting the LED color to black | ||||
|         ``(0, 0, 0)``. | ||||
|         """ | ||||
|         self.value = (0, 0, 0) | ||||
|  | ||||
|     def toggle(self): | ||||
|         """ | ||||
|         Toggle the state of the device. If the device is currently off | ||||
|         (:attr:`value` is ``(0, 0, 0)``), this changes it to "fully" on | ||||
|         (:attr:`value` is ``(1, 1, 1)``).  If the device has a specific color, | ||||
|         this method inverts the color. | ||||
|         """ | ||||
|         r, g, b = self.value | ||||
|         self.value = (1 - r, 1 - g, 1 - b) | ||||
|  | ||||
|     def close(self): | ||||
|         self._stop_blink() | ||||
|         for led in self._leds: | ||||
|   | ||||
		Reference in New Issue
	
	Block a user