Skip to content

Commit

Permalink
Merge pull request #262 from purduesigbots/release/3.3.1
Browse files Browse the repository at this point in the history
🔖 Release 3.3.1
  • Loading branch information
HotelCalifornia authored Oct 29, 2020
2 parents e446dba + 4be77c6 commit ddabba1
Show file tree
Hide file tree
Showing 17 changed files with 1,500 additions and 5 deletions.
10 changes: 8 additions & 2 deletions include/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,28 +41,34 @@

#define PROS_VERSION_MAJOR 3
#define PROS_VERSION_MINOR 3
#define PROS_VERSION_PATCH 0
#define PROS_VERSION_STRING "3.3.0"
#define PROS_VERSION_PATCH 1
#define PROS_VERSION_STRING "3.3.1"

#define PROS_ERR (INT32_MAX)
#define PROS_ERR_F (INFINITY)

#include "pros/adi.h"
#include "pros/colors.h"
#include "pros/distance.h"
#include "pros/ext_adi.h"
#include "pros/imu.h"
#include "pros/llemu.h"
#include "pros/misc.h"
#include "pros/motors.h"
#include "pros/optical.h"
#include "pros/rtos.h"
#include "pros/rotation.h"
#include "pros/vision.h"

#ifdef __cplusplus
#include "pros/adi.hpp"
#include "pros/distance.hpp"
#include "pros/imu.hpp"
#include "pros/llemu.hpp"
#include "pros/misc.hpp"
#include "pros/motors.hpp"
#include "pros/optical.hpp"
#include "pros/rotation.hpp"
#include "pros/rtos.hpp"
#include "pros/vision.hpp"
#endif
Expand Down
2 changes: 1 addition & 1 deletion include/pros/adi.h
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ int32_t adi_encoder_get(adi_encoder_t enc);
*
* \param port_top
* The "top" wire from the encoder sensor with the removable cover side
* up
* up. This should be in port 1, 3, 5, or 7 ('A', 'C', 'E', or 'G').
* \param port_bottom
* The "bottom" wire from the encoder sensor
* \param reverse
Expand Down
3 changes: 3 additions & 0 deletions include/pros/apix.h
Original file line number Diff line number Diff line change
Expand Up @@ -369,10 +369,13 @@ void queue_reset(queue_t queue);
typedef enum v5_device_e {
E_DEVICE_NONE = 0,
E_DEVICE_MOTOR = 2,
E_DEVICE_ROTATION = 4,
E_DEVICE_IMU = 6,
E_DEVICE_DISTANCE = 7,
E_DEVICE_RADIO = 8,
E_DEVICE_VISION = 11,
E_DEVICE_ADI = 12,
E_DEVICE_OPTICAL = 16,
E_DEVICE_GENERIC = 129,
E_DEVICE_UNDEFINED = 255
} v5_device_e_t;
Expand Down
101 changes: 101 additions & 0 deletions include/pros/distance.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/**
* \file pros/distance.h
*
* Contains prototypes for functions related to the VEX Distance sensor.
*
* Visit https://pros.cs.purdue.edu/v5/tutorials/topical/distance.html to learn
* more.
*
* This file should not be modified by users, since it gets replaced whenever
* a kernel upgrade occurs.
*
* Copyright (c) 2017-2020, Purdue University ACM SIGBots.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

#ifndef _PROS_DISTANCE_H_
#define _PROS_DISTANCE_H_

#include <stdbool.h>
#include <stdint.h>

#ifdef __cplusplus
extern "C" {
namespace pros {
namespace c {
#endif

/**
* Get the currently measured distance from the sensor in mm
*
* This function uses the following values of errno when an error state is
* reached:
* ENXIO - The given value is not within the range of V5 ports (1-21).
* ENODEV - The port cannot be configured as an Distance Sensor
*
* \param port The V5 Distance Sensor port number from 1-21
* \return The distance value or PROS_ERR if the operation failed, setting
* errno.
*/
int32_t distance_get(uint8_t port);

/**
* Get the confidence in the distance reading
*
* This is a value that has a range of 0 to 63. 63 means high confidence,
* lower values imply less confidence. Confidence is only available
* when distance is > 200mm (the value 10 is returned in this scenario).
*
* This function uses the following values of errno when an error state is
* reached:
* ENXIO - The given value is not within the range of V5 ports (1-21).
* ENODEV - The port cannot be configured as an Distance Sensor
*
* \param port The V5 Distance Sensor port number from 1-21
* \return The confidence value or PROS_ERR if the operation failed, setting
* errno.
*/
int32_t distance_get_confidence(uint8_t port);

/**
* Get the current guess at relative object size
*
* This is a value that has a range of 0 to 400.
* A 18" x 30" grey card will return a value of approximately 75
* in typical room lighting.
*
* This function uses the following values of errno when an error state is
* reached:
* ENXIO - The given value is not within the range of V5 ports (1-21).
* ENODEV - The port cannot be configured as an Distance Sensor
*
* \param port The V5 Distance Sensor port number from 1-21
* \return The size value or PROS_ERR if the operation failed, setting
* errno.
*/
int32_t distance_get_object_size(uint8_t port);

/**
* Get the object velocity in m/s
*
* This function uses the following values of errno when an error state is
* reached:
* ENXIO - The given value is not within the range of V5 ports (1-21).
* ENODEV - The port cannot be configured as an Distance Sensor
*
* \param port The V5 Distance Sensor port number from 1-21
* \return The velocity value or PROS_ERR if the operation failed, setting
* errno.
*/
double distance_get_object_velocity(uint8_t port);

#ifdef __cplusplus
}
}
}
#endif

#endif
114 changes: 114 additions & 0 deletions include/pros/distance.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
/**
* \file pros/distance.hpp
*
* Contains prototypes for the V5 Distance Sensor-related functions.
*
* Visit https://pros.cs.purdue.edu/v5/tutorials/topical/distance.html to learn
* more.
*
* This file should not be modified by users, since it gets replaced whenever
* a kernel upgrade occurs.
*
* \copyright (c) 2017-2018, Purdue University ACM SIGBots.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

#ifndef _PROS_DISTANCE_HPP_
#define _PROS_DISTANCE_HPP_

#include <cstdint>

#include "pros/distance.h"

namespace pros {
class Distance {
public:
/**
* Creates a Distance Sensor object for the given port.
*
* This function uses the following values of errno when an error state is
* reached:
* ENXIO - The given value is not within the range of V5 ports (1-21).
* ENODEV - The port cannot be configured as a Distance Sensor
*
* \param port
* The V5 port number from 1-21
*/
explicit Distance(const std::uint8_t port);

/**
* Get the currently measured distance from the sensor in mm
*
* This function uses the following values of errno when an error state is
* reached:
* ENXIO - The given value is not within the range of V5 ports (1-21).
* ENODEV - The port cannot be configured as an Distance Sensor
*
* \return The distance value or PROS_ERR if the operation failed, setting
* errno.
*/
virtual std::int32_t get();

/**
* Get the confidence in the distance reading
*
* This is a value that has a range of 0 to 63. 63 means high confidence,
* lower values imply less confidence. Confidence is only available
* when distance is > 200mm.
*
* This function uses the following values of errno when an error state is
* reached:
* ENXIO - The given value is not within the range of V5 ports (1-21).
* ENODEV - The port cannot be configured as an Distance Sensor
*
* \return The confidence value or PROS_ERR if the operation failed, setting
* errno.
*/
virtual std::int32_t get_confidence();

/**
* Get the current guess at relative object size
*
* This is a value that has a range of 0 to 400.
* A 18" x 30" grey card will return a value of approximately 75
* in typical room lighting.
*
* This function uses the following values of errno when an error state is
* reached:
* ENXIO - The given value is not within the range of V5 ports (1-21).
* ENODEV - The port cannot be configured as an Distance Sensor
*
* \return The size value or PROS_ERR if the operation failed, setting
* errno.
*/
virtual std::int32_t get_object_size();

/**
* Get the object velocity in m/s
*
* This function uses the following values of errno when an error state is
* reached:
* ENXIO - The given value is not within the range of V5 ports (1-21).
* ENODEV - The port cannot be configured as an Distance Sensor
*
* \return The velocity value or PROS_ERR if the operation failed, setting
* errno.
*/
virtual double get_object_velocity();

/**
* Gets the port number of the distance sensor.
*
* \return The distance sensor's port number.
*/
std::uint8_t get_port();

private:
const std::uint8_t _port;
};
} // namespace pros

#endif
2 changes: 1 addition & 1 deletion include/pros/ext_adi.h
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ int32_t ext_adi_encoder_get(ext_adi_encoder_t enc);
* The smart port number that the ADI Expander is in
* \param adi_port_top
* The "top" wire from the encoder sensor with the removable cover side
* up
* up. This should be in port 1, 3, 5, or 7 ('A', 'C', 'E', or 'G').
* \param adi_port_bottom
* The "bottom" wire from the encoder sensor
* \param reverse
Expand Down
Loading

0 comments on commit ddabba1

Please sign in to comment.