diff --git a/Makefile b/Makefile index db46e86..49e3827 100755 --- a/Makefile +++ b/Makefile @@ -29,7 +29,7 @@ IS_LIBRARY:=1 # Be sure that your header files are in the include directory inside of a folder with the # same name as what you set LIBNAME to below. LIBNAME:=units -VERSION:=0.3.0 +VERSION:=0.3.1 # EXCLUDE_SRC_FROM_LIB= $(SRCDIR)/unpublishedfile.c # this line excludes opcontrol.c and similar files EXCLUDE_SRC_FROM_LIB+=$(foreach file, $(SRCDIR)/main,$(foreach cext,$(CEXTS),$(file).$(cext)) $(foreach cxxext,$(CXXEXTS),$(file).$(cxxext))) diff --git a/firmware/libpros.a b/firmware/libpros.a index 43f4e94..36de8fa 100644 Binary files a/firmware/libpros.a and b/firmware/libpros.a differ diff --git a/include/api.h b/include/api.h index b97e65d..d56915c 100644 --- a/include/api.h +++ b/include/api.h @@ -41,9 +41,9 @@ #define PROS_VERSION_MAJOR 4 #define PROS_VERSION_MINOR 1 +#define PROS_VERSION_PATCH 1 +#define PROS_VERSION_STRING "4.1.1" -#define PROS_VERSION_PATCH 0 -#define PROS_VERSION_STRING "4.1.0" #include "pros/adi.h" #include "pros/colors.h" diff --git a/include/main.h b/include/main.h index 9407e1e..438dc79 100644 --- a/include/main.h +++ b/include/main.h @@ -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 diff --git a/include/pros/optical.h b/include/pros/optical.h index 049c395..61a2c86 100644 --- a/include/pros/optical.h +++ b/include/pros/optical.h @@ -460,6 +460,39 @@ int32_t optical_enable_gesture(uint8_t port); */ int32_t optical_disable_gesture(uint8_t port); +/** + * Get integration time (update rate) of the optical sensor in milliseconds, with + * minimum time being + * + * 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 Optical Sensor + * + * \param port + * The V5 Optical Sensor port number from 1-21 + * \return Integration time in milliseconds if the operation is successful + * or PROS_ERR if the operation failed, setting errno. + */ +double optical_get_integration_time(uint8_t port); + +/** + * Set integration time (update rate) of the optical sensor in milliseconds. + * + * 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 Optical Sensor + * + * \param port + * The V5 Optical Sensor port number from 1-21 + * \param time + * The desired integration time in milliseconds + * \return 1 if the operation is successful or PROS_ERR if the operation failed, + * setting errno. + */ +int32_t optical_set_integration_time(uint8_t port, double time); + ///@} ///@} diff --git a/include/pros/optical.hpp b/include/pros/optical.hpp index 463daa8..b3e1d4e 100644 --- a/include/pros/optical.hpp +++ b/include/pros/optical.hpp @@ -398,6 +398,36 @@ class Optical : public Device { */ virtual std::int32_t disable_gesture(); + /** + * Set integration time (update rate) of the optical sensor in milliseconds, with + * minimum time being 3 ms and maximum time being 712 ms. Default is 100 ms, with the + * optical sensor communciating with the V5 brain every 20 ms. + * + * 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 Optical Sensor + * + * \return 1 if the operation is successful or PROS_ERR_F if the operation failed, + * setting errno. + */ + double get_integration_time(); + + /** + * Get integration time (update rate) of the optical sensor in milliseconds. + * + * 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 Optical Sensor + * + * \param time + * The desired integration time in milliseconds + * \return Integration time in milliseconds if the operation is successful + * or PROS_ERR if the operation failed, setting errno. + */ + std::int32_t set_integration_time(double time); + /** * This is the overload for the << operator for printing to streams * diff --git a/include/units/units.hpp b/include/units/units.hpp index cc0c7be..1b2d0c3 100644 --- a/include/units/units.hpp +++ b/include/units/units.hpp @@ -5,6 +5,7 @@ #include #include #include +#include // define M_PI if not already defined #ifndef M_PI diff --git a/project.pros b/project.pros index 78c4660..ba5ff5a 100755 --- a/project.pros +++ b/project.pros @@ -5,7 +5,7 @@ "target": "v5", "templates": { "kernel": { - "location": "C:\\Users\\liamt\\AppData\\Roaming\\PROS\\templates\\kernel@4.1.0", + "location": "C:\\Users\\Liam Teale\\AppData\\Roaming\\PROS\\templates\\kernel@4.1.1", "metadata": { "cold_addr": "58720256", "cold_output": "bin/cold.package.bin", @@ -18,64 +18,64 @@ "py/object": "pros.conductor.templates.local_template.LocalTemplate", "supported_kernels": null, "system_files": [ - "include\\pros\\rtos.hpp", - "firmware\\libpros.a", - "include\\pros\\imu.hpp", + "include/pros/gps.hpp", + "include/pros/motors.h", + "include/pros/error.h", + "include/pros/imu.hpp", + "include/pros/serial.h", + "include/pros/rtos.h", + "include/pros/optical.hpp", + "firmware/libc.a", + "include/pros/distance.hpp", + "include/pros/rotation.h", "common.mk", - "include\\pros\\rotation.hpp", - "include\\pros\\abstract_motor.hpp", - "include\\pros\\serial.h", - "include\\pros\\vision.hpp", - "include\\pros\\colors.h", - "include\\pros\\colors.hpp", - "include\\pros\\device.hpp", - "include\\pros\\misc.h", - "include\\api.h", - "include\\pros\\link.h", - "firmware\\v5-hot.ld", - "include\\pros\\distance.h", - "firmware\\v5-common.ld", - "include\\pros\\imu.h", - "include\\pros\\motor_group.hpp", - "include\\pros\\vision.h", - "include\\pros\\misc.hpp", - "include\\pros\\adi.h", - "include\\pros\\screen.h", - "include\\pros\\motors.h", - "include\\pros\\llemu.h", - "include\\pros\\adi.hpp", - "include\\pros\\device.h", - "include\\pros\\motors.hpp", - "include\\pros\\serial.hpp", - "include\\pros\\ext_adi.h", - "include\\pros\\apix.h", - "include\\pros\\rtos.h", - "include\\pros\\rotation.h", - "include\\pros\\llemu.hpp", - "firmware\\libc.a", - "firmware\\v5.ld", - "include\\pros\\gps.h", - "include\\pros\\optical.hpp", - "include\\pros\\gps.hpp", - "firmware\\libm.a", - "include\\pros\\distance.hpp", - "include\\pros\\link.hpp", - "include\\pros\\optical.h", - "include\\pros\\screen.hpp", - "include\\pros\\error.h" + "include/pros/motors.hpp", + "firmware/v5.ld", + "include/pros/gps.h", + "include/pros/link.hpp", + "include/pros/colors.h", + "include/pros/imu.h", + "include/pros/adi.hpp", + "include/pros/ext_adi.h", + "include/pros/misc.hpp", + "include/pros/link.h", + "include/pros/device.h", + "include/pros/misc.h", + "firmware/v5-common.ld", + "include/pros/adi.h", + "include/pros/abstract_motor.hpp", + "include/api.h", + "firmware/v5-hot.ld", + "firmware/libm.a", + "include/pros/device.hpp", + "include/pros/apix.h", + "include/pros/llemu.h", + "include/pros/vision.hpp", + "include/pros/serial.hpp", + "include/pros/llemu.hpp", + "include/pros/colors.hpp", + "include/pros/rotation.hpp", + "include/pros/distance.h", + "include/pros/rtos.hpp", + "include/pros/vision.h", + "include/pros/screen.h", + "include/pros/optical.h", + "firmware/libpros.a", + "include/pros/motor_group.hpp", + "include/pros/screen.hpp" ], "target": "v5", "user_files": [ - "src\\main.c", - "include\\main.hh", + "src/main.cpp", + "src/main.c", "Makefile", - "include\\main.h", + "src/main.cc", + "include/main.h", ".gitignore", - "src\\main.cc", - "include\\main.hpp", - "src\\main.cpp" + "include/main.hh", + "include/main.hpp" ], - "version": "4.1.0" + "version": "4.1.1" } }, "upload_options": {}, diff --git a/src/units/dummy.cpp b/src/units/dummy.cpp new file mode 100644 index 0000000..b422cc3 --- /dev/null +++ b/src/units/dummy.cpp @@ -0,0 +1,4 @@ +// this file exists to force the PROS build script to produce a .a file +// otherwise units does not compile reliably on all platforms +// and the pros conductor will not let you create a template if there is +// no .a file