Digital¶
- class brainstem.entity.Digital(module, index)[source]¶
The DigitalClass is the interface to digital entities on BrainStem modules.
Digital entities have the following 5 possabilities: Digital Input, Digital Output, RCServo Input, RCServo Output, and HighZ. Other capabilities may be available and not all pins support all configurations. Please see the product datasheet.
- Useful Constants:
VALUE_LOW (0)
VALUE_HIGH (1)
CONFIGURATION_INPUT (0)
CONFIGURATION_OUTPUT (1)
CONFIGURATION_RCSERVO_INPUT (2)
CONFIGURATION_RCSERVO_OUTPUT (3)
CONFIGURATION_HIGHZ (4)
CONFIGURATION_INPUT_PULL_UP (0)
CONFIGURATION_INPUT_NO_PULL (4)
CONFIGURATION_INPUT_PULL_DOWN (5)
CONFIGURATION_SIGNAL_OUTPUT (6)
CONFIGURATION_SIGNAL_INPUT (7)
- getConfiguration()[source]¶
Get the digital configuration.
If the configuration is 1 the digital is configured as an output, if the configuration is 0, the digital is set as an input.
- Returns:
Result object, containing NO_ERROR and digital configuration or a non zero Error code.
- Return type:
- getState()[source]¶
Get the digital state.
A return of 1 indicates the digitial is above the logic high threshold. A return of 0 indicates the digital is below the logic low threshold.
- Returns:
Result object, containing NO_ERROR and digital state or a non zero Error code.
- Return type:
- getStateAll()[source]¶
Gets the digital state of all digitals in a bit mapped representation. Number of digitals varies across BrainStem modules. Refer to then datasheet for the capabilities of your module.
- Returns:
Result object, containing NO_ERROR and the digital state of all digitals where bit 0 = digital 0 and bit 1 = digital 1 etc. 0 = logic low and 1 = logic high. A non zero Error code is returned on error.
- Return type:
- setConfiguration(configuration)[source]¶
Set the digital configuration.
- Param:
- configuration (int):
Digital Input: CONFIGURATION_INPUT = 0
Digital Output: CONFIGURATION_OUTPUT = 1
RCServo Input: CONFIGURATION_RCSERVO_INPUT = 2
RCServo Output: CONFIGURATION_RCSERVO_OUTPUT = 3
High Z State: CONFIGURATION_HIGHZ = 4
Digital Input with pull up: CONFIGURATION_INPUT_PULL_UP = 0 (Default)
Digital Input with no pull up or pull down: CONFIGURATION_INPUT_NO_PULL = 4
Digital Input with pull down: CONFIGURATION_INPUT_PULL_DOWN = 5
Digital Signal Output: CONFIGURATION_SIGNAL_OUTPUT = 6
Digital Signal Input: CONFIGURATION_SIGNAL_INPUT = 7
- Returns:
Return NO_ERROR on success, or one of the common sets of return error codes on failure.
- Return type:
Result.error
- setState(state)[source]¶
Set the digital state.
- Param:
- state (int):
Set 1 for logic high, set 0 for logic low. configuration must be set to output.
- Returns:
Return NO_ERROR on success, or one of the common sets of return error codes on failure.
- Return type:
Result.error
- setStateAll(state)[source]¶
Sets the digital state of all digitals based on the bit mapping. Number of digitals varies across BrainStem modules. Refer to then datasheet for the capabilities of your module.
- Param:
- state (uint):
The state to be set for all digitals in a bit mapped representation. 0 is logic low, 1 is logic high. Where bit 0 = digital 0, bit 1 = digital 1 etc. Configuration must be set to output.
- Returns:
Return NO_ERROR on success, or one of the common sets of return error codes on failure.
- Return type:
Result.error