class
#include <pros/adi.hpp>
DigitalIn
Constructors, destructors, conversion operators
- DigitalIn(std::uint8_t adi_port) explicit
- Configures an ADI port to act as a Digital Input.
-
DigitalIn(ext_
adi_ port_ pair_ t port_pair) explicit - Configures an ADI port on an adi_expander to act as a Digital Input.
Public functions
- std::int32_t get_new_press() const
- Gets a rising-edge case for a digital button press.
- std::int32_t get_value() const
- Gets the digital value (1 or 0) of a pin.
-
ext_
adi_ port_ tuple_ t get_port() const - Gets the port of the sensor.
Friends
-
std::ostream& operator<<(std::ostream& os,
pros::
adi:: DigitalIn& digital_in) - This is the overload for the << operator for printing to streams.
Function documentation
std::int32_t pros:: adi:: DigitalIn:: get_value() const
Gets the digital value (1 or 0) of a pin.
Returns | The value stored for the given port |
---|
Inherited from ADIPort::get_value.
This function uses the following values of errno when an error state is reached:
EADDRINUSE - The port is not configured as a digital input (e.g. the port has been reconfigured)
Analogous to adi_digital_read.
Example
#define DIGITAL_SENSOR_PORT 1 void opcontrol() { pros::adi::DigitalIn sensor (DIGITAL_SENSOR_PORT); while (true) { std::cout << "Sensor Value:" << sensor.get_value(); pros::delay(10); } }
ext_ adi_ port_ tuple_ t pros:: adi:: DigitalIn:: get_port() const
Gets the port of the sensor.
Returns | returns a tuple of integer ports. |
---|
Example
#define DIGITAL_SENSOR_PORT 1 // 'A' void initialize() { pros::adi::AnalogIn sensor (DIGITAL_SENSOR_PORT); // Getting values from the tuple using std::get<index> int sensorSmartPort = std::get<0>(sensor.get_port()); // First value int sensorAdiPort = std::get<1>(sensor.get_port()); // Second value // Prints the first and second value from the port tuple (The Adi Port. The first value is the Smart Port) printf("Sensor Smart Port: %d\n", sensorSmartPort); printf("Sensor Adi Port: %d\n", sensorAdiPort); }