| |
- pixtendv2core.PiXtendV2Core(__builtin__.object)
-
- PiXtendV2S
class PiXtendV2S(pixtendv2core.PiXtendV2Core) |
|
The PiXtendV2S class is based off of the PiXtendV2Core class, which provides basic and most common functions for
PiXtend V2. This class must implement the abstract methods _unpack_spi_data and _pack_spi_data otherwise there
can be no functioning data communication and no usable object at runtime. |
|
- Method resolution order:
- PiXtendV2S
- pixtendv2core.PiXtendV2Core
- __builtin__.object
Methods defined here:
- __init__(self, spi_speed=700000, com_interval=0.03, model=83)
- Constructor of the PixtendV2S class. Create needed variables to store the settings and values for the PiXtend V2
board which are transferred via SPI to the on-board microcontroller. The the core class (PiXtendV2Core) does
not provide all needed variables and functions, only the basic and most common functions of the PiXtend V2
system. This class has to build and supply the rest.
:param spi_speed: int
:param com_interval: float
:param model: int
- close(self)
- The 'close' function needs to be called to terminate the asynchronous SPI communication in the background and to
close the SPI driver. This function must be called before the PiXtendV2S object is destroyed in the program
it is used in.
Data descriptors defined here:
- analog_in0
- Get the value of analog input 0 as a float value converted to volts. The returned value is
based on the 5 volts / 10 volts jumper setting.
:return: Current value
:rtype: float
- analog_in0_raw
- Get the raw value of analog input 0.
:return: Current value
:rtype: int
- analog_in1
- Get the value of analog input 1 as a float value converted to volts. The returned value is
based on the 5 volts / 10 volts jumper setting.
:return: Current value
:rtype: float
- analog_in1_raw
- Get the raw value of analog input 1.
:return: Current value
:rtype: int
- crc_data_in_error
- Get the error state of the CRC check performed on the SPI data
:return: Current value, False means no error, True means the data is not correct, error
:rtype: bool
- digital_in0
- Get the state of digital input 0. A value of False means 'off' and a value of True means 'on'.
:return: Current value
:rtype: bool
- digital_in1
- Get the state of digital input 1. A value of False means 'off' and a value of True means 'on'.
:return: Current value
:rtype: bool
- digital_in2
- Get the state of digital input 2. A value of False means 'off' and a value of True means 'on'.
:return: Current value
:rtype: bool
- digital_in3
- Get the state of digital input 3. A value of False means 'off' and a value of True means 'on'.
:return: Current value
:rtype: bool
- digital_in4
- Get the state of digital input 4. A value of False means 'off' and a value of True means 'on'.
:return: Current value
:rtype: bool
- digital_in5
- Get the state of digital input 5. A value of False means 'off' and a value of True means 'on'.
:return: Current value
:rtype: bool
- digital_in6
- Get the state of digital input 6. A value of False means 'off' and a value of True means 'on'.
:return: Current value
:rtype: bool
- digital_in7
- Get the state of digital input 7. A value of False means 'off' and a value of True means 'on'.
:return: Current value
:rtype: bool
- digital_out0
- Get or Set the state of digital output 0. A value False means 'off' and a value of True means 'on'.
:return: Current value
:rtype: bool
- digital_out1
- Get or Set the state of digital output 1. A value False means 'off' and a value of True means 'on'.
:return: Current value
:rtype: bool
- digital_out2
- Get or Set the state of digital output 2. A value False means 'off' and a value of True means 'on'.
:return: Current value
:rtype: bool
- digital_out3
- Get or Set the state of digital output 3. A value False means 'off' and a value of True means 'on'.
:return: Current value
:rtype: bool
- jumper_setting_ai0
- Get or Set the 5 volts / 10 volts jumper setting, depending if the jumper was physically set on the
PiXtend V2 -S- board or not.
The library needs to know this setting to perform correct calculations of the raw analog
value of the analog input 0 when it is converted it's final float value.
The default setting is 10 volts (True), no jumper set.
:return: Current jumper setting
:rtype: bool
- jumper_setting_ai1
- Get or Set the 5 volts / 10 volts jumper setting, depending if the jumper was physically set on the
PiXtend V2 -S- board or not.
The library needs to know this setting to perform correct calculations of the raw analog
value of the analog input 1 when it is converted it's final float value.
The default setting is 10 volts (True), no jumper set.
:return: Current jumper setting
:rtype: bool
- pwm0_ctrl0
- Get or Set the PWM0Ctrl0 property. This int value controls the configuration of PWM0 channel A & B.
This property has the following bits which control PWM0:
Bit 0 - Mode0
Bit 1 - Mode1
Bit 3 - EnableA
Bit 4 - EnableB
Bit 5 - Prescaler0
Bit 6 - Prescaler1
Bit 7 - Prescaler2
See the software manual for more details on this property and it's bits.
The int value must be between 0 and 255.
:return: Current PWM0Ctrl0 value.
:rtype: int
- pwm0_ctrl1
- Get or Set the PWM0Ctrl1 property. It is used to set the frequency for PWM0 channels A & B, but only if the
selected PWM mode makes use of this value. See the software manual for more information on this topic.
The int value must be between 0 and 65535 (16 bits).
:return: Current PWM0Ctrl1 value
:rtype: int
- pwm0a
- Get or Set the value for PWM0 channel A. This property can be used to set the duty cycle of PWM0, however the
exact usage depends on the PWM mode selected through the property pwm0_ctrl0. The value must be between
0 and 65535, more information on the usage of PWM with PiXtend V2 -S- can be found in the software manual.
:return: Current PWM0 channel A value
:rtype: int
- pwm0b
- Get or Set the value for PWM0 channel B. This property can be used to set the duty cycle of PWM0, however the
exact usage depends on the PWM mode selected through the property pwm0_ctrl0. The value must be between
0 and 65535, more information on the usage of PWM with PiXtend V2 -S- can be found in the software manual.
:return: Current PWM0 channel B value
:rtype: int
- pwm1_ctrl0
- Get or Set the PWM1Ctrl0 property. This int value controls the configuration of PWM1 channel A & B.
This property has the following bits which control PWM1:
Bit 0 - Mode0
Bit 1 - Mode1
Bit 3 - EnableA
Bit 4 - EnableB
Bit 5 - Prescaler0
Bit 6 - Prescaler1
Bit 7 - Prescaler2
See the software manual for more details on this property and it's bits.
The int value must be between 0 and 255.
:return: Current PWM1Ctrl0 value.
:rtype: int
- pwm1_ctrl1
- Get or Set the PWM1Ctrl1 property. It is used to set the frequency for PWM1 channels A & B, but only if the
selected PWM mode makes use of this value. See the software manual for more information on this topic.
The int value must be between 0 and 255 (8 bits).
:return: Current PWM1Ctrl1 value
:rtype: int
- pwm1a
- Get or Set the value for PWM1 channel A. This property can be used to set the duty cycle of PWM1, however the
exact usage depends on the PWM mode selected through the property pwm1_ctrl0. The value must be between
0 and 255, more information on the usage of PWM with PiXtend V2 -S- can be found in the software manual.
:return: Current PWM1 channel A value
:rtype: int
- pwm1b
- Get or Set the value for PWM1 channel B. This property can be used to set the duty cycle of PWM1, however the
exact usage depends on the PWM mode selected through the property pwm1_ctrl0. The value must be between
0 and 255, more information on the usage of PWM with PiXtend V2 -S- can be found in the software manual.
:return: Current PWM1 channel B value
:rtype: int
- relay0
- Get or Set the state of relay 0. A value of False means 'off' and a value of True means 'on'.
:return: Current value
:rtype: bool
- relay1
- Get or Set the state of relay 1. A value of False means 'off' and a value of True means 'on'.
:return: Current value
:rtype: bool
- relay2
- Get or Set the state of relay 2. A value of False means 'off' and a value of True means 'on'.
:return: Current value
:rtype: bool
- relay3
- Get or Set the state of relay 3. A value of False means 'off' and a value of True means 'on'.
:return: Current value
:rtype: bool
- retain_data_in
- From RetainDataIn return a list of 32 int's, each list element has a value between 0 and 255 (byte value).
If the Retain functions was enabled, this list will contain the data previously stored in the microcontroller's
flash memory. The values will remain there even if the Retain Enable flag is not set.
:return: list[int]
- retain_data_out
- From RetainDataOut return a list of 32 int's, each list element has a value between 0 and 255 (byte value).
:return: list[int]
- servo0
- Get or Set the value for PWM 0 channel A in Servo Mode. Possible values are 0 to 16000.
:return: Current value
:rtype: int
- servo1
- Get or Set the value for PWM 0 channel B in Servo Mode. Possible values are 0 to 16000.
:return: Current value
:rtype: int
- servo2
- Get or Set the value for PWM 1 channel A in Servo Mode. Possible values are 0 to 125.
:return: Current value
:rtype: int
- servo3
- Get or Set the value for PWM 1 channel B in Servo Mode. Possible values are 0 to 125.
:return: Current value
:rtype: int
Data and other attributes defined here:
- __abstractmethods__ = frozenset([])
Methods inherited from pixtendv2core.PiXtendV2Core:
- __del__(self)
- Destructor of the Pixtend V2 class. Delete objects.
- set_dac_output(self, dac_channel=0, value=0)
- Set the analog output value for the chosen DAC. The value 0 or constant DAC_A selects DAC A and the value 1 or
constant DAC_B selects DAC B.
Example:
Selecting and setting DAC A:
p.set_dac_output (p.DAC_A, 512)
Selecting and setting DAC B:
p.set_dac_output (p.DAC_B, 256)
:param int dac_channel: Number of the DAC to set the new value to
:param int value: Output value for the chosen DAC.
:raises ValueError: If value is smaller then 0 or larger then 1023
Static methods inherited from pixtendv2core.PiXtendV2Core:
- clear_bit(int_type, offset)
- clear_bit() returns an integer with the bit at 'offset' cleared, set to 0.
:param int int_type: Integer value in which to clear one bit
:param int offset: Offset value which bit to clear
:return: Integer with bit cleared a 'offset'
:rtype: int
- set_bit(int_type, offset)
- set_bit() returns an integer with the bit at 'offset' set to 1.
:param int int_type: Integer value in which to set one bit
:param int offset: Offset value which bit to set
:return: Integer with bit set at 'offset'
:rtype: int
- test_bit(int_type, offset)
- test_bit() returns 1, if the bit at 'offset' is one else 0 if the bit is not set.
:param int int_type: Integer value to test
:param int offset: Offset value which bit to test
:return: Integer based value of 0 if bit at 'offset' is not set or 1 if bit is set
:rtype: int
- toggle_bit(int_type, offset)
- toggle_bit() returns an integer with the bit at 'offset' inverted, 0 -> 1 and 1 -> 0.
:param int int_type: Integer value to toggle one bit within
:param int offset: Offset value which bit to toggle
:return: integer with bit toggled at 'offset'
:rtype: int
Data descriptors inherited from pixtendv2core.PiXtendV2Core:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
- crc_header_in_error
- Get the error state of the CRC check performed on the SPI data header. If the CRC comparision is wrong
the value will be True, if the header of the SPI data is correct, the value will be False.
:return: Current value, False means no error, True means the header is not correct, error
:rtype: bool
- firmware
- Get the microcontroller's firmware version.
:return: Current value
:rtype: int
- gpio0
- Get or Set the state of GPIO 0. The value False means 'off' and a value of True means 'on'.
Example:
p.gpio0 = p.ON # Turns the GPIO on
p.gpio0 = p.OFF # Turns the GPIO off
or use
p.gpio0 = True # Turns the GPIO on
p.gpio0 = False # Turns the GPIO off
:return: Current value
:rtype: bool
- gpio0_ctrl
- Get or Set the configuration of GPIO 0. Possible values are 0 (Input), 1 (Output), 2 (DHT11) or 3 (DHT22).
:return: Current configuration
:rtype: int
:raises ValueError: If the passed value is not 0, 1, 2 or 3
- gpio1
- Get or Set the state of GPIO 1. The value False means 'off' and a value of True means 'on'.
Example:
p.gpio1 = p.ON # Turns the GPIO on
p.gpio1 = p.OFF # Turns the GPIO off
or use
p.gpio1 = True # Turns the GPIO on
p.gpio1 = False # Turns the GPIO off
:return: Current value
:rtype: bool
- gpio1_ctrl
- Get or Set the configuration of GPIO 1. Possible values are 0 (Input), 1 (Output), 2 (DHT11) or 3 (DHT22).
:return: Current configuration
:rtype: int
:raises ValueError: If the passed value is not 0, 1, 2 or 3
- gpio2
- Get or Set the state of GPIO 2. The value False means 'off' and a value of True means 'on'.
Example:
p.gpio2 = p.ON # Turns the GPIO on
p.gpio2 = p.OFF # Turns the GPIO off
or use
p.gpio2 = True # Turns the GPIO on
p.gpio2 = False # Turns the GPIO off
:return: Current value
:rtype: bool
- gpio2_ctrl
- Get or Set the configuration of GPIO 2. Possible values are 0 (Input), 1 (Output), 2 (DHT11) or 3 (DHT22).
:return: Current configuration
:rtype: int
:raises ValueError: If the passed value is not 0, 1, 2 or 3
- gpio3
- Get or Set the state of GPIO 3. The value False means 'off' and a value of True means 'on'.
Example:
p.gpio3 = p.ON # Turns the GPIO on
p.gpio3 = p.OFF # Turns the GPIO off
or use
p.gpio3 = True # Turns the GPIO on
p.gpio3 = False # Turns the GPIO off
:return: Current value
:rtype: bool
- gpio3_ctrl
- Get or Set the configuration of GPIO 3. Possible values are 0 (Input), 1 (Output), 2 (DHT11) or 3 (DHT22).
:return: Current configuration
:rtype: int
:raises ValueError: If the passed value is not 0, 1, 2 or 3
- gpio_pullups_enable
- Enable or Disable the GPIO 0-3 pullups if the GPIOs are configured as outputs and the pullups are needed.
Setting this property to True enables the pullups, if it is set to False the pullups remain off.
:return: Current value
:rtype: bool
- hardware
- Get the PiXtend V2 hardware revision.
:return: Current value
:rtype: int
- hum_input0_raw
- Get the humidity raw value from humidity input 0.
:return: Current value
:rtype: int
- hum_input1_raw
- Get the humidity raw value from humidity input 1.
:return: Current value
:rtype: int
- hum_input2_raw
- Get the humidity raw value from humidity input 2.
:return: Current value
:rtype: int
- hum_input3_raw
- Get the humidity raw value from humidity input 3.
:return: Current value
:rtype: int
- humid0
- Get the converted humidity value from humidity input 0 if a DHT11/DHT22 sensor is physically attached.
:return: Current value
:rtype: float
- humid1
- Get the converted humidity value from humidity input 1 if a DHT11/DHT22 sensor is physically attached.
:return: Current value
:rtype: float
- humid2
- Get the converted humidity value from humidity input 2 if a DHT11/DHT22 sensor is physically attached.
:return: Current value
:rtype: float
- humid3
- Get the converted humidity value from humidity input 3 if a DHT11/DHT22 sensor is physically attached.
:return: Current value
:rtype: float
- model_in
- Get the PiXtend V2 model information from the microcontroller.
:return: Current value
:rtype: int
- model_in_error
- Get the result of the comparison between the configured model, supplied by the child class through the init
function (constructor) when the object is created, and the reported model by the microcontroller.
If the configured model and the reported model match, the value will be False,
if they don't match, the value will be True and signifies an error.
:return: Current value, False means no error, True means the reported model does not match
:rtype: bool
- retain_copy
- Get or Set the microcontroller's Retain memory option to copy incoming data to the outgoing data
stream. This way the data which will be stored on the microcontroller, in the event of a sudden power loss,
can be verified that the data really reaches the microcontroller and that values are correct. This option is
mainly intended for debugging, but can be used by anyone.
:return: Current value
:rtype: bool
:raises ValueError: If the passed value is not True or False
- retain_enable
- Get or Set the microcontroller's Retain memory option to enabled. With this option active a specified amount of
data will be stored in the microcontroller's flash memory in the event of a sudden power loss. The exact amount
of int's/bytes which a PiXtend V2 board can store can be found in the SPI protocol specifications.
:return: Current value
:rtype: bool
:raises ValueError: If the passed value is not True or False
- save_state
- Get or Set the microcontroller's SaveState bit in case the computer has to shutdown or needs to reboot.
Settings this property to True will halt the microcontroller and a reset is needed in order to start any
communication again.
:return: Current value
:rtype: bool
:raises ValueError: If the passed value is not True or False
- state_led_off
- Get or Set if the State LED (L1) on the PiXtend V2 board is on or off.
True turns the LED off and False leave the State LED (L1) on.
:return: Current value
:rtype: bool
:raises ValueError: If the passed value is not True or False
- temp0
- Get the converted temperature value from temperature input 0 from a DHT11 or DHT22 sensor.
:return: Current value
:rtype: float
- temp1
- Get the converted temperature value from temperature input 1 from a DHT11 or DHT22 sensor.
:return: Current value
:rtype: float
- temp2
- Get the converted temperature value from temperature input 2 from a DHT11 or DHT22 sensor.
:return: Current value
:rtype: float
- temp3
- Get the converted temperature value from temperature input 3 from a DHT11 or DHT22 sensor.
:return: Current value
:rtype: float
- temp_input0_raw
- Get the temperature raw value from temperature input 0.
:return: Current value
:rtype: int
- temp_input1_raw
- Get the temperature raw value from temperature input 1.
:return: Current value
:rtype: int
- temp_input2_raw
- Get the temperature raw value from temperature input 2.
:return: Current value
:rtype: int
- temp_input3_raw
- Get the temperature raw value from temperature input 3.
:return: Current value
:rtype: int
- uc_state
- The UCState byte from the microcontroller contains information of the following internal states:
Bit 0: Run - The microcontroller is up and running, this is just a helper bit
Bit 4: Error0 - Bit 0 of the 4 bit error number from the microcontroller. Together with the next 3
Bit 5: Error1 - bits a 4 bit number can be formed which results in an error number which is
Bit 6: Error2 - listed in the SPI protocol specification or the software manual.
Bit 7: Error3
:return: Current value
:rtype: int
- uc_warnings
- The UCWarnings byte from the microcontroller contains information of the following internal errors:
Bit 1: RetainCRCError - Signals a CRC error in the retain data in the microcontroller
Bit 2: RetainVoltageError - The supply voltage is below 19 volts, the Retain memory option cannot be used.
:return: Current value
:rtype: int
- use_fahrenheit
- Get or Set if the conversion of the temperature raw value should be done in Fahrenheit.
Default is 'False', meaning by getting the temperature from temp0 to temp3
the value will be in degrees Celsius, if set to 'True' the values will be in Fahrenheit.
:returns: Bool value, 'False' for Celsius and 'True' for Fahrenheit
:rtype: bool
- watchdog
- Get or Set the PiXtend V2 watchdog option. WDT_OFF or 0 ms means the watchdog is disabled. One of the
following time values 16 ms, 32 ms, 64 ms, 125 ms, 250 ms, 500 ms, 1000 ms (1s), 2000 ms (2s), 4000 ms (4s)
and 8000 ms (8s) turns the watchdog function in the microcontroller on. If no SPI communication occurs within
this time frame, the microcontroller will stop working and goes into save state. Only a reset or power cycle
will bring it back to life once it has entered this stage.
:return: Current value
:rtype: int
:raises ValueError: If the passed value is not one of the following: 16, 32, 64, 125, 250, 500, 1000,
2000, 4000 or 8000
Data and other attributes inherited from pixtendv2core.PiXtendV2Core:
- BIT_0 = 0
- BIT_1 = 1
- BIT_10 = 10
- BIT_11 = 11
- BIT_12 = 12
- BIT_13 = 13
- BIT_14 = 14
- BIT_15 = 15
- BIT_2 = 2
- BIT_3 = 3
- BIT_4 = 4
- BIT_5 = 5
- BIT_6 = 6
- BIT_7 = 7
- BIT_8 = 8
- BIT_9 = 9
- COM_INTERVAL_DEFAULT = 0.03
- COM_INTERVAL_DHT = 0.03
- COM_INTERVAL_MINIMUM = 0.01
- DAC_A = 0
- DAC_B = 1
- DHT11 = 0
- DHT22 = 1
- GPIO_DHT11 = 2
- GPIO_DHT22 = 3
- GPIO_INPUT = 0
- GPIO_OUTPUT = 1
- JUMPER_10V = 1
- JUMPER_5V = 0
- MC_RESET_PIN = 23
- OFF = False
- ON = True
- PIXTENDV2S_MODEL = 83
- PWM_MODE = 1
- RS232 = 0
- RS485 = 0
- SERVO_MODE = 0
- SPI_ENABLE_PIN = 24
- SPI_NOT_FOUND = -1
- SPI_SPEED = 700000
- WDT_125MS = 125
- WDT_16MS = 16
- WDT_1S = 1000
- WDT_250MS = 250
- WDT_2S = 2000
- WDT_32MS = 32
- WDT_4S = 4000
- WDT_500MS = 500
- WDT_64MS = 64
- WDT_8S = 8000
- WDT_OFF = 0
- __metaclass__ = <class 'abc.ABCMeta'>
- Metaclass for defining Abstract Base Classes (ABCs).
Use this metaclass to create an ABC. An ABC can be subclassed
directly, and then acts as a mix-in class. You can also register
unrelated concrete classes (even built-in classes) and unrelated
ABCs as 'virtual subclasses' -- these and their descendants will
be considered subclasses of the registering ABC by the built-in
issubclass() function, but the registering ABC won't show up in
their MRO (Method Resolution Order) nor will method
implementations defined by the registering ABC be callable (not
even via super()).
| |