Skip to content

Commit

Permalink
Added untracked file
Browse files Browse the repository at this point in the history
  • Loading branch information
WillXuCodes authored and WillXuCodes committed Sep 29, 2020
1 parent cf00b7f commit 4db4b1b
Showing 1 changed file with 168 additions and 0 deletions.
168 changes: 168 additions & 0 deletions include/pros/rotation.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
/**
* \file pros/rotation.h
*
* Contains prototypes for functions related to the VEX Rotation sensor.
*
* Visit https://pros.cs.purdue.edu/v5/tutorials/topical/rotation.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_ROTATION_H_
#define _PROS_ROTATION_H_

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

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


// NOTE: Descriptions of what each of these methods do may be inaccurate,
// as it's just a speculative guess as to what they actually do.

// TODO: Make revisions when proper documentation is given.

/**
* Resets Rotational Sensor
*
* Resets rotation presumably to 0.
*
* 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 Rotation Sensor
* EAGAIN - The sensor is already calibrating
*
* \param port
* The V5 Rotation Sensor port number from 1-21
* \return 1 if the operation was successful or PROS_ERR if the operation
* failed, setting errno.
*/
int32_t rotation_reset(uint8_t port);


/**
* Set the Rotation sensor to a desired rotation value.
*
* 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 Rotation Sensor
* EAGAIN - The sensor is still calibrating
*
* \param port
* The V5 Rotation Sensor port number from 1-21
* \param position
* The position in terms of ticks
* \return 1 if the operation was successful or PROS_ERR if the operation
* failed, setting errno.
*/
int32_t rotation_set_position(uint8_t port, uint32_t position);

/**
* Get the Rotation sensor's current rotational position.
*
* 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 Rotation Sensor
* EAGAIN - The sensor is still calibrating
*
* \param port
* The V5 Rotation Sensor port number from 1-21
* \return The degree value or PROS_ERR_F if the operation failed, setting
* errno.
*/
int32_t rotation_get_position(uint8_t port);

/**
* Get the Rotation sensor's current rotational velocity.
*
* 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 Rotation Sensor
* EAGAIN - The sensor is still calibrating
*
* \param port
* The V5 Rotation Sensor port number from 1-21
* \return The degree value or PROS_ERR_F if the operation failed, setting
* errno.
*/
int32_t rotation_get_velocity(uint8_t port);

/**
* Get the Rotation sensor's current rotational position in terms of an angle.
*
* TODO: Add description for what units this uses.
*
* 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 Rotation Sensor
* EAGAIN - The sensor is still calibrating
*
* \param port
* The V5 Rotation Sensor port number from 1-21
* \return The degree value or PROS_ERR_F if the operation failed, setting
* errno.
*/
int32_t rotation_get_angle(uint8_t port);

/**
* Sets if the rotational sensor's positive/negative direction is reversed or not.
*
* 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 Rotation Sensor
* EAGAIN - The sensor is still calibrating
*
* \param port
* The V5 Rotation Sensor port number from 1-21
* \param value
* Determines if the direction of the rotational sensor is reversed or not.
*
* \return The degree value or PROS_ERR_F if the operation failed, setting
* errno.
*/
int32_t rotation_set_reversed(uint8_t port, bool value);

/**
* Gets if the rotational sensor's positive/negative direction is reversed or not.
*
* 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 Rotation Sensor
* EAGAIN - The sensor is still calibrating
*
* \param port
* The V5 Rotation Sensor port number from 1-21
*
* \return The degree value or PROS_ERR_F if the operation failed, setting
* errno.
*/
int32_t rotation_get_reversed(uint8_t port);

uint32_t rotational_get_status(uint8_t port);

#ifdef __cplusplus
}
}
}
#endif

#endif

0 comments on commit 4db4b1b

Please sign in to comment.