mirror of
				https://github.com/KevinMidboe/python-gpiozero.git
				synced 2025-10-29 17:50:37 +00:00 
			
		
		
		
	Move the API to the end, recipes all grouped together up-front (with remote GPIO setup just before the remote GPIO recipes). Tweak some headings so everything looks a little more consistent in the (now shorter) ToC. Also added module index tags.
		
			
				
	
	
		
			139 lines
		
	
	
		
			2.8 KiB
		
	
	
	
		
			ReStructuredText
		
	
	
	
	
	
			
		
		
	
	
			139 lines
		
	
	
		
			2.8 KiB
		
	
	
	
		
			ReStructuredText
		
	
	
	
	
	
| ================
 | |
| API - Exceptions
 | |
| ================
 | |
| 
 | |
| .. currentmodule:: gpiozero
 | |
| 
 | |
| The following exceptions are defined by GPIO Zero. Please note that multiple
 | |
| inheritance is heavily used in the exception hierarchy to make testing for
 | |
| exceptions easier. For example, to capture any exception generated by GPIO
 | |
| Zero's code::
 | |
| 
 | |
|     from gpiozero import *
 | |
| 
 | |
|     led = PWMLED(17)
 | |
|     try:
 | |
|         led.value = 2
 | |
|     except GPIOZeroError:
 | |
|         print('A GPIO Zero error occurred')
 | |
| 
 | |
| Since all GPIO Zero's exceptions descend from :exc:`GPIOZeroError`, this will
 | |
| work. However, certain specific errors have multiple parents. For example, in
 | |
| the case that an out of range value is passed to :attr:`OutputDevice.value` you
 | |
| would expect a :exc:`ValueError` to be raised. In fact, a
 | |
| :exc:`OutputDeviceBadValue` error will be raised. However, note that this
 | |
| descends from both :exc:`GPIOZeroError` (indirectly) and from :exc:`ValueError`
 | |
| so you can still do::
 | |
| 
 | |
|     from gpiozero import *
 | |
| 
 | |
|     led = PWMLED(17)
 | |
|     try:
 | |
|         led.value = 2
 | |
|     except ValueError:
 | |
|         print('Bad value specified')
 | |
| 
 | |
| 
 | |
| Errors
 | |
| ======
 | |
| 
 | |
| .. autoexception:: GPIOZeroError
 | |
| 
 | |
| .. autoexception:: DeviceClosed
 | |
| 
 | |
| .. autoexception:: BadEventHandler
 | |
| 
 | |
| .. autoexception:: BadQueueLen
 | |
| 
 | |
| .. autoexception:: BadWaitTime
 | |
| 
 | |
| .. autoexception:: CompositeDeviceError
 | |
| 
 | |
| .. autoexception:: CompositeDeviceBadName
 | |
| 
 | |
| .. autoexception:: EnergenieSocketMissing
 | |
| 
 | |
| .. autoexception:: EnergenieBadSocket
 | |
| 
 | |
| .. autoexception:: SPIError
 | |
| 
 | |
| .. autoexception:: SPIBadArgs
 | |
| 
 | |
| .. autoexception:: SPIBadChannel
 | |
| 
 | |
| .. autoexception:: SPIFixedClockMode
 | |
| 
 | |
| .. autoexception:: SPIInvalidClockMode
 | |
| 
 | |
| .. autoexception:: SPIFixedBitOrder
 | |
| 
 | |
| .. autoexception:: SPIFixedSelect
 | |
| 
 | |
| .. autoexception:: SPIFixedWordSize
 | |
| 
 | |
| .. autoexception:: SPIInvalidWordSize
 | |
| 
 | |
| .. autoexception:: GPIODeviceError
 | |
| 
 | |
| .. autoexception:: GPIODeviceClosed
 | |
| 
 | |
| .. autoexception:: GPIOPinInUse
 | |
| 
 | |
| .. autoexception:: GPIOPinMissing
 | |
| 
 | |
| .. autoexception:: InputDeviceError
 | |
| 
 | |
| .. autoexception:: OutputDeviceError
 | |
| 
 | |
| .. autoexception:: OutputDeviceBadValue
 | |
| 
 | |
| .. autoexception:: PinError
 | |
| 
 | |
| .. autoexception:: PinInvalidFunction
 | |
| 
 | |
| .. autoexception:: PinInvalidState
 | |
| 
 | |
| .. autoexception:: PinInvalidPull
 | |
| 
 | |
| .. autoexception:: PinInvalidEdges
 | |
| 
 | |
| .. autoexception:: PinInvalidBounce
 | |
| 
 | |
| .. autoexception:: PinSetInput
 | |
| 
 | |
| .. autoexception:: PinFixedPull
 | |
| 
 | |
| .. autoexception:: PinEdgeDetectUnsupported
 | |
| 
 | |
| .. autoexception:: PinUnsupported
 | |
| 
 | |
| .. autoexception:: PinSPIUnsupported
 | |
| 
 | |
| .. autoexception:: PinPWMError
 | |
| 
 | |
| .. autoexception:: PinPWMUnsupported
 | |
| 
 | |
| .. autoexception:: PinPWMFixedValue
 | |
| 
 | |
| .. autoexception:: PinUnknownPi
 | |
| 
 | |
| .. autoexception:: PinMultiplePins
 | |
| 
 | |
| .. autoexception:: PinNoPins
 | |
| 
 | |
| .. autoexception:: PinInvalidPin
 | |
| 
 | |
| Warnings
 | |
| ========
 | |
| 
 | |
| .. autoexception:: GPIOZeroWarning
 | |
| 
 | |
| .. autoexception:: SPIWarning
 | |
| 
 | |
| .. autoexception:: SPISoftwareFallback
 | |
| 
 | |
| .. autoexception:: PinFactoryFallback
 | |
| 
 | |
| .. autoexception:: PinNonPhysical
 | |
| 
 |