Skip to content

Commit

Permalink
🔖 Release/4.1.0 (#668)
Browse files Browse the repository at this point in the history
* Start of work on motors docs

* Add descriptions for color files.

* Error.h

* gps.hpp done

* Gps.h done

* More motors docs

* Motor docs and fixed the build

* added changes to device.hpp, distance.hpp and
imu.hpp

* Revert "added changes to device.hpp, distance.hpp and"

This reverts commit 380a2de.

* Do the link files

* attempt to fix issue with ADI

* Fix ADI Doc value

* Remove accidental addition of extra bracket

* AbstractMotor work

* attempt to refix something

* yep looks like that was the culprit

* Add it back because it was breaking stuff

* The serial files

* Optical cpp examples

* Get rid of legacy api file (nobody uses PROS 2 API anymore)

* Update documentation for the llemu api

* Update rtos.h

* Attempt to fix adi doc bracketing

* Update rtos.h

* Fix up formatting on rtos.h

* try something really stupid

* Finished functions in motors.h

* progress on motors.hpp

* Update adi bracketting

* Fix adi.h bracketing again

* Comment brackets in rtos.h

* Try removing \enum and \typedef to see if that breaks m.css

* Try removing \def

* Try some more things to fix CI

* Strip name and group commands to see if that lets the CI get further

* More more motors.hpp work

* Update rtos.h

* More rtos.h updates

* abstract motor work

* rotation.h and rotation.hpp documentation

* Fixes to code examples.

* do some of the _all functions

* more stuff

* imu_set_euler

* MOTORS.HPP DONE

* added example for device.h

* fix typo

* added example for device.hpp

* fix issue

* fix formatting

* fix and add example in distance.h

* WIP on rtos.hpp

* ext_adi.h file

* fix typo in distance.h

* motors and motor group fixes

* Trying to fix motor linking

* Wip in rtos

* update example in device.hpp

* updated device.hpp examples

* updated distance.hpp examples

* fix typo in device.h

* fix typo in device.hpp

* Vision c++ header docs

* Update motors

* docs for mics, screen and abstract_motor(enum)

* Fix up device file, apix.h work

* added example for constructors in device.hpp and
distance.hpp

* imu.hpp function examples

* Small edit for imu.hpp function examples

* Added header for imu.hpp constructor

* Small edit for imu.hpp constructor header

* Remove links

* Fix up color and device files

* Finish rtos.h and rtos.hpp

* Fix cpp-link

* Fixes to motors docs

* Rotation.hpp docs updates

* Reverse Flag param in Rotation constructor

* Formatting fixes

* Fix motor groups and fix colors

* fixed file for motor group

* Fix bracketing

* Fix MG docs

* Remove PROS 2 references, fix up readmes

* Another fix

* Most of the work done for motor groups

* Fix missing end codes

* Almost done

* FINISHED MOTOR GROUPS

* added namespace for screen.hpp

* Update version

* Fix a couple enum/struct issues

* 📝 Some fixes for motor headers

* 📝 Some fixes for enums

* 🐛Motor bug fixes and add new set_gearing (#611)

* ✨Add list_files function (#612)

* Add list_files

* renamed c function

* Clarify the docs

* ✨ ADI Get Port (#613)

* Initial Commit. Added get_port() for adi.

* Second commit. Fixed changes.

* 🐛Vex link default override (#614)

* Initial Commit. Changed defualt param.

* Fixed param docs

* ✨Field Control State Getter (#608)

* Field Control State Getter

* Fixed merge issues

* Removed left over testing code

* change macros to enum/functions

---------

Co-authored-by: noam987 <[email protected]>
Co-authored-by: noam987 <[email protected]>

* Added vexFileSync when writing to files (#619)

* 🐛Fix rotation sensor reversed port (#618)

* 🐛 Field Control Getter Return Value (#627)

* Field Control State Getter

* Fixed merge issues

* Removed left over testing code

* change macros to enum/functions

* fix return value issue

* fixed version

---------

Co-authored-by: noam987 <[email protected]>
Co-authored-by: noam987 <[email protected]>

* ✨default the VFS to the sd card (#621)

* Fix motor voltage limit port mutex returning

* Initial implementation for get_all_devices

* Remove use of templating

* modify gps functions

* add example code to gps header files

* revert api.h and version

* add newline at end of gps.c

* add newline at end of version

* Completed get_all_devices member function for all critical devices

* Fix compile issues

* 🐛ADI mutex fix (#633)

* Fixed duplicate zero indexing in ext_adi_led_set_pixel as well as validate_type

* testing

* Fixed zero indexing

* fix merge

* removes an extra -1

* Add missing -1

* Last -1

* Fix return without releasing mutex

---------

Co-authored-by: noam987 <[email protected]>

* ✨Adds static getters for some devices (#653)

* imu_v1

* revert main.cpp

* Add injector for gps

* rename to _ casing and add vision sensor

* 📝 PROS 4: Documentation Fixes for optical and distance sensor (#654)

* Documentation Fixes for optical sensor

* Distance sensor documentation fixes

* Added alias function get_distance for get for distance sensor

* Update get_distance func header for distance sensor

* 🐛Fixed Imu::is_calibrating function for PROS 4 #626 (#629)

* Fixed Imu::is_calibrating function

Updated imu status enums to properly reflect values returned by get_status. Also modifed imu::is_calibrating so it returns the correct value.

* Bugfixes from the pros 3 version

---------

Co-authored-by: noam987 <[email protected]>
Co-authored-by: noam987 <[email protected]>

* 🐛Remove = overload from motor groups (#656)

* 📝Update docs for pre-release (#657)

* Update version

* 🐛 Fix pros::E_TEXT_LARGE_CENTER Simple Name

* Update version numbers

* 🐛Motor bug fixes and add new set_gearing (#611)

* ✨Add list_files function (#612)

* Add list_files

* renamed c function

* Clarify the docs

* ✨ ADI Get Port (#613)

* Initial Commit. Added get_port() for adi.

* Second commit. Fixed changes.

* 🐛Vex link default override (#614)

* Initial Commit. Changed defualt param.

* Fixed param docs

* ✨Field Control State Getter (#608)

* Field Control State Getter

* Fixed merge issues

* Removed left over testing code

* change macros to enum/functions

---------

Co-authored-by: noam987 <[email protected]>
Co-authored-by: noam987 <[email protected]>

* Added vexFileSync when writing to files (#619)

* 🐛Fix rotation sensor reversed port (#618)

* 🐛 Field Control Getter Return Value (#627)

* Field Control State Getter

* Fixed merge issues

* Removed left over testing code

* change macros to enum/functions

* fix return value issue

* fixed version

---------

Co-authored-by: noam987 <[email protected]>
Co-authored-by: noam987 <[email protected]>

* ✨default the VFS to the sd card (#621)

* Fix motor voltage limit port mutex returning

* Initial implementation for get_all_devices

* Remove use of templating

* modify gps functions

* add example code to gps header files

* revert api.h and version

* add newline at end of gps.c

* add newline at end of version

* Completed get_all_devices member function for all critical devices

* Fix compile issues

* 🐛ADI mutex fix (#633)

* Fixed duplicate zero indexing in ext_adi_led_set_pixel as well as validate_type

* testing

* Fixed zero indexing

* fix merge

* removes an extra -1

* Add missing -1

* Last -1

* Fix return without releasing mutex

---------

Co-authored-by: noam987 <[email protected]>

* ✨Adds static getters for some devices (#653)

* imu_v1

* revert main.cpp

* Add injector for gps

* rename to _ casing and add vision sensor

* 📝 PROS 4: Documentation Fixes for optical and distance sensor (#654)

* Documentation Fixes for optical sensor

* Distance sensor documentation fixes

* Added alias function get_distance for get for distance sensor

* Update get_distance func header for distance sensor

* 🐛Fixed Imu::is_calibrating function for PROS 4 #626 (#629)

* Fixed Imu::is_calibrating function

Updated imu status enums to properly reflect values returned by get_status. Also modifed imu::is_calibrating so it returns the correct value.

* Bugfixes from the pros 3 version

---------

Co-authored-by: noam987 <[email protected]>
Co-authored-by: noam987 <[email protected]>

* 🐛Remove = overload from motor groups (#656)

---------

Co-authored-by: Richard Stump <[email protected]>
Co-authored-by: Will Xu <[email protected]>
Co-authored-by: Will Xu <[email protected]>
Co-authored-by: phinc23 <[email protected]>
Co-authored-by: Yuechan Li <[email protected]>
Co-authored-by: Sprocket Riggs <[email protected]>
Co-authored-by: Cooper7196 <[email protected]>
Co-authored-by: Gavin-Niederman <[email protected]>
Co-authored-by: aberiggs <[email protected]>
Co-authored-by: Yuechan Li <[email protected]>
Co-authored-by: Gracelu128 <[email protected]>
Co-authored-by: Richard Li <[email protected]>

* Update version numbers (#658)

* 🐛Fix imu get device typo (#659)

* Fix motor docs

* minor docs fixes

* 📝 Fix typo in main.h (#662)

* Add documentation to literals

* 📝 Fix typo in main.cpp (#663)

* Fix a typo in main.h

* Fix a typo in main.cpp

* 🐛Converts appending, and constructors to take in AbstractMotor& instead of MotorGroup& (#661)

* 📝Update docs for pre-release (#657)

* Update version

* 🐛 Fix pros::E_TEXT_LARGE_CENTER Simple Name

* Update version numbers

* 🐛Motor bug fixes and add new set_gearing (#611)

* ✨Add list_files function (#612)

* Add list_files

* renamed c function

* Clarify the docs

* ✨ ADI Get Port (#613)

* Initial Commit. Added get_port() for adi.

* Second commit. Fixed changes.

* 🐛Vex link default override (#614)

* Initial Commit. Changed defualt param.

* Fixed param docs

* ✨Field Control State Getter (#608)

* Field Control State Getter

* Fixed merge issues

* Removed left over testing code

* change macros to enum/functions

---------

Co-authored-by: noam987 <[email protected]>
Co-authored-by: noam987 <[email protected]>

* Added vexFileSync when writing to files (#619)

* 🐛Fix rotation sensor reversed port (#618)

* 🐛 Field Control Getter Return Value (#627)

* Field Control State Getter

* Fixed merge issues

* Removed left over testing code

* change macros to enum/functions

* fix return value issue

* fixed version

---------

Co-authored-by: noam987 <[email protected]>
Co-authored-by: noam987 <[email protected]>

* ✨default the VFS to the sd card (#621)

* Fix motor voltage limit port mutex returning

* Initial implementation for get_all_devices

* Remove use of templating

* modify gps functions

* add example code to gps header files

* revert api.h and version

* add newline at end of gps.c

* add newline at end of version

* Completed get_all_devices member function for all critical devices

* Fix compile issues

* 🐛ADI mutex fix (#633)

* Fixed duplicate zero indexing in ext_adi_led_set_pixel as well as validate_type

* testing

* Fixed zero indexing

* fix merge

* removes an extra -1

* Add missing -1

* Last -1

* Fix return without releasing mutex

---------

Co-authored-by: noam987 <[email protected]>

* ✨Adds static getters for some devices (#653)

* imu_v1

* revert main.cpp

* Add injector for gps

* rename to _ casing and add vision sensor

* 📝 PROS 4: Documentation Fixes for optical and distance sensor (#654)

* Documentation Fixes for optical sensor

* Distance sensor documentation fixes

* Added alias function get_distance for get for distance sensor

* Update get_distance func header for distance sensor

* 🐛Fixed Imu::is_calibrating function for PROS 4 #626 (#629)

* Fixed Imu::is_calibrating function

Updated imu status enums to properly reflect values returned by get_status. Also modifed imu::is_calibrating so it returns the correct value.

* Bugfixes from the pros 3 version

---------

Co-authored-by: noam987 <[email protected]>
Co-authored-by: noam987 <[email protected]>

* 🐛Remove = overload from motor groups (#656)

---------

Co-authored-by: Richard Stump <[email protected]>
Co-authored-by: Will Xu <[email protected]>
Co-authored-by: Will Xu <[email protected]>
Co-authored-by: phinc23 <[email protected]>
Co-authored-by: Yuechan Li <[email protected]>
Co-authored-by: Sprocket Riggs <[email protected]>
Co-authored-by: Cooper7196 <[email protected]>
Co-authored-by: Gavin-Niederman <[email protected]>
Co-authored-by: aberiggs <[email protected]>
Co-authored-by: Yuechan Li <[email protected]>
Co-authored-by: Gracelu128 <[email protected]>
Co-authored-by: Richard Li <[email protected]>

* Fix motor docs

* minor docs fixes

* Compiles, haven't tested past that

* Revert main.cpp

* remove extra includes in main

* another small style fix

* ixed issue found during testing

---------

Co-authored-by: Richard Stump <[email protected]>
Co-authored-by: Will Xu <[email protected]>
Co-authored-by: Will Xu <[email protected]>
Co-authored-by: phinc23 <[email protected]>
Co-authored-by: Yuechan Li <[email protected]>
Co-authored-by: Sprocket Riggs <[email protected]>
Co-authored-by: Cooper7196 <[email protected]>
Co-authored-by: Gavin-Niederman <[email protected]>
Co-authored-by: aberiggs <[email protected]>
Co-authored-by: Yuechan Li <[email protected]>
Co-authored-by: Gracelu128 <[email protected]>
Co-authored-by: Richard Li <[email protected]>

* 📝Docs + implementation forgotten for rotation sensor (#665)

* Fix compile issues

* Update version nums

---------

Co-authored-by: Noam987 <[email protected]>
Co-authored-by: Will Xu <[email protected]>
Co-authored-by: Richard Stump <[email protected]>
Co-authored-by: Aaryan Gautam <[email protected]>
Co-authored-by: Andrew Lu <[email protected]>
Co-authored-by: aberiggs <[email protected]>
Co-authored-by: Grace Lu <[email protected]>
Co-authored-by: AnnZi <[email protected]>
Co-authored-by: Jerrylum <[email protected]>
Co-authored-by: Will Xu <[email protected]>
Co-authored-by: noam987 <[email protected]>
Co-authored-by: Yuechan Li <[email protected]>
Co-authored-by: Sprocket Riggs <[email protected]>
Co-authored-by: Cooper7196 <[email protected]>
Co-authored-by: Gavin-Niederman <[email protected]>
Co-authored-by: Yuechan Li <[email protected]>
Co-authored-by: Gracelu128 <[email protected]>
Co-authored-by: Richard Li <[email protected]>
Co-authored-by: THERocky <[email protected]>
  • Loading branch information
20 people authored May 19, 2024
1 parent 6e648a6 commit b31e125
Show file tree
Hide file tree
Showing 44 changed files with 3,108 additions and 1,736 deletions.
6 changes: 3 additions & 3 deletions include/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@
#endif /* __cplusplus */

#define PROS_VERSION_MAJOR 4
#define PROS_VERSION_MINOR 0
#define PROS_VERSION_PATCH 6
#define PROS_VERSION_STRING "4.0.6"
#define PROS_VERSION_MINOR 1

#define PROS_VERSION_PATCH 0
#define PROS_VERSION_STRING "4.1.0"

#include "pros/adi.h"
#include "pros/colors.h"
Expand Down
2 changes: 1 addition & 1 deletion include/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*
* For instance, E_CONTROLLER_MASTER has a shorter name: CONTROLLER_MASTER.
* E_CONTROLLER_MASTER is pedantically correct within the PROS styleguide, but
* not convienent for most student programmers.
* not convenient for most student programmers.
*/
#define PROS_USE_SIMPLE_NAMES

Expand Down
49 changes: 15 additions & 34 deletions include/pros/abstract_motor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace pros {
inline namespace v5 {

/**
* \enum motor_brake
* \enum MotorBrake
* Indicates the current 'brake mode' of a motor.
*/
enum class MotorBrake {
Expand All @@ -42,7 +42,7 @@ enum class MotorBrake {
};

/**
* \enum Motor_Encoder_Units
* \enum MotorEncoderUnits
* Indicates the units used by the motor encoders.
*/
enum class MotorEncoderUnits {
Expand All @@ -53,7 +53,7 @@ enum class MotorEncoderUnits {
invalid = INT32_MAX ///< Invalid motor encoder units
};

// Alias for Motor_Encoder_Units
// Alias for MotorEncoderUnits
using MotorUnits = MotorEncoderUnits;

enum class MotorGears {
Expand All @@ -70,7 +70,7 @@ enum class MotorGears {
};


// Provide Aliases for Motor_Gears
// Provide Aliases for MotorGears
using MotorGearset = MotorGears;
using MotorCart = MotorGears;
using MotorCartridge = MotorGears;
Expand All @@ -89,25 +89,6 @@ class AbstractMotor {
/// These functions allow programmers to make motors move
///@{

/**
* Sets the voltage for the motor from -127 to 127.
*
* This is designed to map easily to the input from the controller's analog
* stick for simple opcontrol use. The actual behavior of the motor is
* analogous to use of pros::Motor::move().
*
* This function uses the following values of errno when an error state is
* reached:
* ENODEV - The port cannot be configured as a motor
*
* \param voltage
* The new motor voltage from -127 to 127
*
* \return 1 if the operation was successful or PROS_ERR if the operation
* failed, setting errno.
*/
virtual std::int32_t operator=(std::int32_t voltage) const = 0;

/**
* Sets the voltage for the motor from -127 to 127.
*
Expand Down Expand Up @@ -778,7 +759,7 @@ class AbstractMotor {
* The index of the motor to get the target position of.
* By default index is 0, and will return an error for an out of bounds index
*
* \return One of Motor_Brake, according to what was set for the
* \return One of MotorBrake, according to what was set for the
* motor, or E_MOTOR_BRAKE_INVALID if the operation failed, setting errno.
*/
virtual MotorBrake get_brake_mode(const std::uint8_t index = 0) const = 0;
Expand All @@ -794,7 +775,7 @@ class AbstractMotor {
* The index of the motor to get the target position of.
* By default index is 0, and will return an error for an out of bounds index
*
* \return A vector containing Motor_Brake(s), according to what was set for the
* \return A vector containing MotorBrake(s), according to what was set for the
* motor(s), or E_MOTOR_BRAKE_INVALID if the operation failed, setting errno.
*/
virtual std::vector<MotorBrake> get_brake_mode_all(void) const = 0;
Expand Down Expand Up @@ -846,7 +827,7 @@ class AbstractMotor {
* The index of the motor to get the target position of.
* By default index is 0, and will return an error for an out of bounds index
*
* \return One of Motor_Units according to what is set for the
* \return One of MotorUnits according to what is set for the
* motor or E_MOTOR_ENCODER_INVALID if the operation failed.
*/
virtual MotorUnits get_encoder_units(const std::uint8_t index = 0) const = 0;
Expand All @@ -862,7 +843,7 @@ class AbstractMotor {
* The index of the motor to get the target position of.
* By default index is 0, and will return an error for an out of bounds index
*
* \return A vector of Motor_Units according to what is set for the
* \return A vector of MotorUnits according to what is set for the
* motor(s) or E_MOTOR_ENCODER_INVALID if the operation failed.
*/
virtual std::vector<MotorUnits> get_encoder_units_all(void) const = 0;
Expand All @@ -878,8 +859,8 @@ class AbstractMotor {
* The index of the motor to get the target position of.
* By default index is 0, and will return an error for an out of bounds index
*
* \return One of Motor_Gears according to what is set for the motor,
* or pros::Motor_Gears::invalid if the operation failed.
* \return One of MotorGears according to what is set for the motor,
* or pros::MotorGears::invalid if the operation failed.
*/
virtual MotorGears get_gearing(const std::uint8_t index = 0) const = 0;

Expand All @@ -894,8 +875,8 @@ class AbstractMotor {
* The index of the motor to get the target position of.
* By default index is 0, and will return an error for an out of bounds index
*
* \return A vector of Motor_Gears according to what is set for the motor(s),
* or pros::Motor_Gears::invalid if the operation failed.
* \return A vector of MotorGears according to what is set for the motor(s),
* or pros::MotorGears::invalid if the operation failed.
*/
virtual std::vector<MotorGears> get_gearing_all(void) const = 0;

Expand Down Expand Up @@ -977,15 +958,15 @@ class AbstractMotor {
virtual std::vector<std::int32_t> is_reversed_all(void) const = 0;

/**
* Sets one of Motor_Brake to the motor. Works with the C enum
* Sets one of MotorBrake to the motor. Works with the C enum
* and the C++ enum class.
*
* This function uses the following values of errno when an error state is
* reached:
* ENODEV - The port cannot be configured as a motor
*
* \param mode
* The Motor_Brake to set for the motor
* The MotorBrake to set for the motor
*
* \param index Optional parameter.
* The index of the motor to get the target position of.
Expand Down Expand Up @@ -1018,7 +999,7 @@ class AbstractMotor {
virtual std::int32_t set_current_limit(const std::int32_t limit, const std::uint8_t index = 0) const = 0;
virtual std::int32_t set_current_limit_all(const std::int32_t limit) const = 0;
/**
* Sets one of Motor_Units for the motor encoder. Works with the C
* Sets one of MotorUnits for the motor encoder. Works with the C
* enum and the C++ enum class.
*
* This function uses the following values of errno when an error state is
Expand Down
51 changes: 51 additions & 0 deletions include/pros/adi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,33 @@ class Port {
*/
std::int32_t set_value(std::int32_t value) const;

/**
* Gets the port of the sensor.
*
* \return returns a tuple of integer ports.
*
* \note The parts of the tuple are {smart port, adi port, second adi port (when applicable)}.
*
*
* \b Example
* \code
* #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);
* }
* \endcode
*/
virtual ext_adi_port_tuple_t get_port() const;

protected:
std::uint8_t _smart_port;
std::uint8_t _adi_port;
Expand Down Expand Up @@ -396,6 +423,8 @@ class AnalogIn : protected Port {
* value calibrated HR: (16 bit calibrated value), value: (12 bit value)]
*/
friend std::ostream& operator<<(std::ostream& os, pros::adi::AnalogIn& analog_in);

using Port::get_port;
};

///@}
Expand Down Expand Up @@ -484,6 +513,8 @@ class AnalogOut : private Port {
* \endcode
*/
using Port::set_value;

using Port::get_port;

/**
* This is the overload for the << operator for printing to streams
Expand Down Expand Up @@ -595,6 +626,8 @@ class DigitalOut : private Port {
*/
using Port::set_value;

using Port::get_port;

/**
* This is the overload for the << operator for printing to streams
*
Expand Down Expand Up @@ -731,6 +764,8 @@ class DigitalIn : private Port {
* value: (value)]
*/
friend std::ostream& operator<<(std::ostream& os, pros::adi::DigitalIn& digital_in);

using Port::get_port;
};

///@}
Expand Down Expand Up @@ -875,6 +910,8 @@ class Motor : private Port {
* \endcode
*/
using Port::get_value;

using Port::get_port;
};

///@}
Expand Down Expand Up @@ -1004,6 +1041,11 @@ class Encoder : private Port {
* value: (value)]
*/
friend std::ostream& operator<<(std::ostream& os, pros::adi::Encoder& encoder);
ext_adi_port_tuple_t get_port() const override;

private:
ext_adi_port_pair_t _port_pair;

};

///@}
Expand Down Expand Up @@ -1108,6 +1150,8 @@ class Ultrasonic : private Port {
* \endcode
*/
std::int32_t get_value() const;

using Port::get_port;
};

///@}
Expand Down Expand Up @@ -1259,6 +1303,8 @@ class Gyro : private Port {
* \endcode
*/
std::int32_t reset() const;

using Port::get_port;
};

///@}
Expand Down Expand Up @@ -1419,6 +1465,9 @@ class Potentiometer : public AnalogIn {
* Prints in format(this below is all in one line with no new line):
*/
friend std::ostream& operator<<(std::ostream& os, pros::adi::Potentiometer& potentiometer);

using Port::get_port;

};

///@}
Expand Down Expand Up @@ -1710,6 +1759,8 @@ class Led : protected Port {
*/
std::int32_t length();

using Port::get_port;

protected:
std::vector<uint32_t> _buffer;
};
Expand Down
45 changes: 44 additions & 1 deletion include/pros/device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class Device {
* }
* \endcode
*/
std::uint8_t get_port(void);
std::uint8_t get_port(void) const;

/**
* Checks if the device is installed.
Expand Down Expand Up @@ -138,6 +138,49 @@ class Device {
pros::DeviceType get_plugged_type() const;


/**
* Gets the type of device on a given port.
*
* This function uses the following values of errno when an error state is
* reached:
* EACCES - Mutex of port cannot be taken (access denied).
*
* \param port The V5 port number from 1-21
*
* \return The device type as an enum.
*
* \b Example
* \code
* #define DEVICE_PORT 1
*
* void opcontrol() {
* while (true) {
* DeviceType dt = pros::Device::get_plugged_type(DEVICE_PORT);
* printf("device plugged type: {plugged type: %d}\n", dt);
* delay(20);
* }
* }
* \endcode
*/
static pros::DeviceType get_plugged_type(std::uint8_t port);

/**
* Gets all devices of a given device type.
*
* \param device_type The pros::DeviceType enum that matches the type of device desired.
*
* \return A vector of Device objects for the given device type.
*
* \b Example
* \code
* void opcontrol() {
* std::vector<Device> motor_devices = pros::Device::get_all_devices(pros::DeviceType::motor); // All Device objects are motors
* }
* \endcode
*/

static std::vector<Device> get_all_devices(pros::DeviceType device_type = pros::DeviceType::undefined);

protected:
/**
* Creates a Device object.
Expand Down
Loading

0 comments on commit b31e125

Please sign in to comment.