Skip to content

Commit

Permalink
Update for 2024 bot
Browse files Browse the repository at this point in the history
  • Loading branch information
Ethanol5455 committed Jan 29, 2024
1 parent 4c0c76f commit 777b088
Show file tree
Hide file tree
Showing 40 changed files with 732 additions and 532 deletions.
3 changes: 2 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# https://clang.llvm.org/docs/ClangFormatStyleOptions.html
#
---
AccessModifierOffset: -4
AccessModifierOffset: 0
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
Expand Down Expand Up @@ -643,6 +643,7 @@ IndentGotoLabels: false
IndentPPDirectives: None
IndentWidth: 8
IndentWrappedFunctionNames: false
IndentAccessModifiers: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
Expand Down
4 changes: 2 additions & 2 deletions common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ library: $(LIBAR)

.PHONY: template
template: clean-template $(LIBAR)
$Dprosv5 c create-template . $(LIBNAME) $(VERSION) $(foreach file,$(TEMPLATE_FILES) $(LIBAR),--system "$(file)") --target v5 $(CREATE_TEMPLATE_FLAGS)
$Dpros c create-template . $(LIBNAME) $(VERSION) $(foreach file,$(TEMPLATE_FILES) $(LIBAR),--system "$(file)") --target v5 $(CREATE_TEMPLATE_FLAGS)
endif

# if project is a library source, compile the archive and link output.elf against the archive rather than source objects
Expand Down Expand Up @@ -280,7 +280,7 @@ $(VV)mkdir -p $(dir $(LDTIMEOBJ))
@# The shell command $$(($$(date +%s)+($$(date +%-z)/100*3600))) fetches the current
@# unix timestamp, and then adds the UTC timezone offset to account for time zones.

$(call test_output_2,Adding timestamp ,echo 'const int _PROS_COMPILE_TIMESTAMP_INT = $(shell echo $$(($$(date +%s)+($$(date +%-z)/100*3600)))); char const * const _PROS_COMPILE_TIMESTAMP = __DATE__ " " __TIME__; char const * const _PROS_COMPILE_DIRECTORY = "$(shell pwd | tail -c 23)";' | $(CC) -c -x c $(CFLAGS) $(EXTRA_CFLAGS) -o $(LDTIMEOBJ) -,$(OK_STRING))
$(call test_output_2,Adding timestamp ,echo 'const int _PROS_COMPILE_TIMESTAMP_INT = $(shell echo $$(($$(date +%s)+($$(date +%-z)/100*3600)))); char const * const _PROS_COMPILE_TIMESTAMP = __DATE__ " " __TIME__; char const * const _PROS_COMPILE_DIRECTORY = "$(wildcard $(shell pwd | tail -c 23))";' | $(CC) -c -x c $(CFLAGS) $(EXTRA_CFLAGS) -o $(LDTIMEOBJ) -,$(OK_STRING))
endef

# these rules are for build-compile-commands, which just print out sysroot information
Expand Down
Binary file modified firmware/libpros.a
Binary file not shown.
8 changes: 4 additions & 4 deletions include/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* This file should not be modified by users, since it gets replaced whenever
* a kernel upgrade occurs.
*
* Copyright (c) 2017-2022, Purdue University ACM SIGBots.
* \copyright Copyright (c) 2017-2023, Purdue University ACM SIGBots.
* All rights reserved.
*
* This Source Code Form is subject to the terms of the Mozilla Public
Expand Down Expand Up @@ -40,9 +40,9 @@
#endif /* __cplusplus */

#define PROS_VERSION_MAJOR 3
#define PROS_VERSION_MINOR 7
#define PROS_VERSION_PATCH 3
#define PROS_VERSION_STRING "3.7.3"
#define PROS_VERSION_MINOR 8
#define PROS_VERSION_PATCH 0
#define PROS_VERSION_STRING "3.8.0"

#include "pros/adi.h"
#include "pros/colors.h"
Expand Down
2 changes: 1 addition & 1 deletion include/pros/adi.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* This file should not be modified by users, since it gets replaced whenever
* a kernel upgrade occurs.
*
* Copyright (c) 2017-2022, Purdue University ACM SIGBots.
* \copyright Copyright (c) 2017-2023, 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
Expand Down
7 changes: 5 additions & 2 deletions include/pros/adi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* This file should not be modified by users, since it gets replaced whenever
* a kernel upgrade occurs.
*
* Copyright (c) 2017-2022, Purdue University ACM SIGBots.
* \copyright Copyright (c) 2017-2023, 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
Expand Down Expand Up @@ -494,10 +494,13 @@ class ADIEncoder : private ADIPort {
* sensor with the removable cover side up, and the "bottom" wire from
* the encoder sensor
* \param reverse
* If "true", the sensor will count in theopposite direction
* If "true", the sensor will count in the opposite direction
*/
ADIEncoder(ext_adi_port_tuple_t port_tuple, bool reversed = false);

// Delete copy constructor to prevent a compilation error from the constructor above.
ADIEncoder(ADIEncoder &) = delete;

/**
* Sets the encoder value to zero.
*
Expand Down
2 changes: 1 addition & 1 deletion include/pros/api_legacy.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* This file should not be modified by users, since it gets replaced whenever
* a kernel upgrade occurs.
*
* Copyright (c) 2017-2022, Purdue University ACM SIGBots.
* \copyright Copyright (c) 2017-2023, Purdue University ACM SIGBots.
* All rights reserved.
*
* This Source Code Form is subject to the terms of the Mozilla Public
Expand Down
2 changes: 1 addition & 1 deletion include/pros/apix.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* This file should not be modified by users, since it gets replaced whenever
* a kernel upgrade occurs.
*
* Copyright (c) 2017-2022, Purdue University ACM SIGBots.
* \copyright Copyright (c) 2017-2023, Purdue University ACM SIGBots.
* All rights reserved.
*
* This Source Code Form is subject to the terms of the Mozilla Public
Expand Down
2 changes: 1 addition & 1 deletion include/pros/distance.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* This file should not be modified by users, since it gets replaced whenever
* a kernel upgrade occurs.
*
* Copyright (c) 2017-2022, Purdue University ACM SIGBots.
* \copyright Copyright (c) 2017-2023, 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
Expand Down
2 changes: 1 addition & 1 deletion include/pros/error.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* This file should not be modified by users, since it gets replaced whenever
* a kernel upgrade occurs.
*
* Copyright (c) 2017-2022, Purdue University ACM SIGBots.
* \copyright Copyright (c) 2017-2023, 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
Expand Down
2 changes: 1 addition & 1 deletion include/pros/ext_adi.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* This file should not be modified by users, since it gets replaced whenever
* a kernel upgrade occurs.
*
* Copyright (c) 2017-2022, Purdue University ACM SIGBots.
* \copyright Copyright (c) 2017-2023, 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
Expand Down
2 changes: 1 addition & 1 deletion include/pros/gps.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* This file should not be modified by users, since it gets replaced whenever
* a kernel upgrade occurs.
*
* Copyright (c) 2017-2022, Purdue University ACM SIGBots.
* \copyright Copyright (c) 2017-2023, 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
Expand Down
2 changes: 1 addition & 1 deletion include/pros/gps.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* This file should not be modified by users, since it gets replaced whenever
* a kernel upgrade occurs.
*
* Copyright (c) 2017-2022, Purdue University ACM SIGBots.
* \copyright Copyright (c) 2017-2023, 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
Expand Down
2 changes: 1 addition & 1 deletion include/pros/imu.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* This file should not be modified by users, since it gets replaced whenever
* a kernel upgrade occurs.
*
* Copyright (c) 2017-2022, Purdue University ACM SIGBots.
* \copyright Copyright (c) 2017-2023, 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
Expand Down
2 changes: 1 addition & 1 deletion include/pros/imu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* This file should not be modified by users, since it gets replaced whenever
* a kernel upgrade occurs.
*
* Copyright (c) 2017-2022, Purdue University ACM SIGBots.
* \copyright Copyright (c) 2017-2023, 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
Expand Down
2 changes: 1 addition & 1 deletion include/pros/link.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* This file should not be modified by users, since it gets replaced whenever
* a kernel upgrade occurs.
*
* Copyright (c) 2017-2022, Purdue University ACM SIGBots.
* \copyright Copyright (c) 2017-2023, 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
Expand Down
2 changes: 1 addition & 1 deletion include/pros/link.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* This file should not be modified by users, since it gets replaced whenever
* a kernel upgrade occurs.
*
* Copyright (c) 2017-2021, Purdue University ACM SIGBots.
* \copyright Copyright (c) 2017-2023, 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
Expand Down
2 changes: 1 addition & 1 deletion include/pros/llemu.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* This file should not be modified by users, since it gets replaced whenever
* a kernel upgrade occurs.
*
* Copyright (c) 2017-2022, Purdue University ACM SIGBots.
* \copyright Copyright (c) 2017-2023, 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
Expand Down
2 changes: 1 addition & 1 deletion include/pros/llemu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* This file should not be modified by users, since it gets replaced whenever
* a kernel upgrade occurs.
*
* Copyright (c) 2017-2022, Purdue University ACM SIGBots.
* \copyright Copyright (c) 2017-2023, 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
Expand Down
2 changes: 1 addition & 1 deletion include/pros/misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* This file should not be modified by users, since it gets replaced whenever
* a kernel upgrade occurs.
*
* Copyright (c) 2017-2022, Purdue University ACM SIGBots.
* \copyright Copyright (c) 2017-2023, Purdue University ACM SIGBots.
* All rights reservered.
*
* This Source Code Form is subject to the terms of the Mozilla Public
Expand Down
2 changes: 1 addition & 1 deletion include/pros/misc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* This file should not be modified by users, since it gets replaced whenever
* a kernel upgrade occurs.
*
* Copyright (c) 2017-2022, Purdue University ACM SIGBots.
* \copyright Copyright (c) 2017-2023, Purdue University ACM SIGBots.
* All rights reservered.
*
* This Source Code Form is subject to the terms of the Mozilla Public
Expand Down
2 changes: 1 addition & 1 deletion include/pros/motors.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* This file should not be modified by users, since it gets replaced whenever
* a kernel upgrade occurs.
*
* Copyright (c) 2017-2022, Purdue University ACM SIGBots.
* \copyright Copyright (c) 2017-2023, 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
Expand Down
130 changes: 128 additions & 2 deletions include/pros/motors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ class Motor {
*
* \return The motor's voltage in mV or PROS_ERR_F if the operation failed,
* setting errno.
*
*/
virtual std::int32_t get_voltage(void) const;

Expand Down Expand Up @@ -859,8 +860,11 @@ class Motor {

class Motor_Group {
public:
explicit Motor_Group(const std::initializer_list<Motor> motors);
explicit Motor_Group(const std::vector<std::int8_t> motor_ports);
Motor_Group(const std::initializer_list<Motor> motors);
explicit Motor_Group(const std::vector<pros::Motor>& motors);
explicit Motor_Group(const std::initializer_list<std::int8_t> motor_ports);
explicit Motor_Group(const std::vector<std::int8_t> motor_ports); // Pass by value to preserve ABI

/****************************************************************************/
/** Motor Group movement functions **/
/** **/
Expand Down Expand Up @@ -1014,6 +1018,101 @@ class Motor_Group {
* failed, setting errno.
*/
std::int32_t brake(void);

/*
* Gets the voltages delivered to the motors in millivolts.
*
* This function uses the following values of errno when an error state is
* reached:
* ENODEV - The port cannot be configured as a motor
* EACCESS - The Motor group mutex can't be taken or given
*
* \return The voltage of the motor in millivolts or PROS_ERR_F if the operation
* failed, setting errno.
*
* \b Example
* \code
* void opcontrol() {
* pros::Motor_Group motors({1, 2});
* std::vector<std::uint32_t> voltages;
* while (true) {
* voltages = motors.get_voltages();
*
* for (uint32_t i = 0; i < voltages.size(); i++) {
* printf("Voltages: %ld\n", voltages[i]);
* }
* pros::delay(20);
* }
* }
* \endcode
*
*/
std::vector<std::uint32_t> get_voltages(void);

/*
* Get the voltage limits of the motors set by the user.
*
* This function uses the following values of errno when an error state is
* reached:
* ENODEV - The port cannot be configured as a motor
* EACCESS - The Motor group mutex can't be taken or given
*
* \return The voltage limit of the motor in millivolts or PROS_ERR_F if the operation
* failed, setting errno.
*
* \b Example
* \code
* void opcontrol() {
* pros::Motor_Group motors({1, 2});
* std::vector<std::uint32_t> voltage_limits;
* while (true) {
* voltage_limits = motors.get_voltage_limits();
*
* for (uint32_t i = 0; i < voltage_limits.size(); i++) {
* printf("Voltage Limits: %ld\n", voltage_limits[i]);
* }
* pros::delay(20);
* }
* }
* \endcode
*/
std::vector<std::uint32_t> get_voltage_limits(void);

/*
* Gets the raw encoder positions of a motor group at a given timestamp.
*
* This function uses the following values of errno when an error state is
* reached:
* ENODEV - The port cannot be configured as a motor
* EACCESS - The Motor group mutex can't be taken or given
*
* \return A vector of the raw encoder positions of the motors in the motor group
* based on the timestamps passed in. If a timestamp is not found for a motor, the
* value at that index will be PROS_ERR.
*
* \b Example
* \code
* void opcontrol() {
* pros::Motor_Group motors({1, 2});
* std::vector<std::uint32_t*> timestamps;
* std::vector<std::int32_t> positions;
* std::uint32_t temp = 0;
* std::uint32_t temp2 = 0;
* timestamps.push_back(&temp);
* timestamps.push_back(&temp2);
*
* while (true) {
* positions = motors.get_raw_positions(timestamps);
*
* printf("Position: %ld, Time: %ln\n", positions[0], timestamps[0]);
* printf("Position: %ld, Time: %ln\n", positions[1], timestamps[1]);
*
* pros::delay(20);
* }
* }
* \endcode
*/
std::vector<std::int32_t> get_raw_positions(std::vector<std::uint32_t*> &timestamps);
/****************************************************************************/
/** Motor configuration functions **/
/** **/
Expand All @@ -1036,6 +1135,20 @@ class Motor_Group {
pros::Motor& operator[](int i);


/**
* Indexes Motor in the Motor_Group.
*
* This function uses the following values of errno when an error state is
* reached:
* Throws an std::out_of_range error when indexing out of range
*
* \param i
* The index value in the motor group.
*
* \return the appropriate Motor reference.
*/
pros::Motor& at(int i);

/**
* Indexes Motor in the Motor_Group in the same way as an array.
*
Expand Down Expand Up @@ -1341,6 +1454,19 @@ class Motor_Group {
* E_MOTOR_ENCODER_INVALID if the operation failed.
*/
std::vector<pros::motor_encoder_units_e_t> get_encoder_units(void);

/**
* Gets the encoder units that were set for each motor.
*
* This function uses the following values of errno when an error state is
* reached:
* ENODEV - The port cannot be configured as a motor
* EACCESS - The Motor group mutex can't be taken or given
*
* \return The vector filled with motors' temperature in degrees Celsius or PROS_ERR_F if the
* operation failed, setting errno.
*/
virtual std::vector<double> get_temperatures(void);

private:
std::vector<Motor> _motors;
Expand Down
Loading

0 comments on commit 777b088

Please sign in to comment.