Skip to content

Commit

Permalink
Version bump and port change for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
ssejrog committed Mar 30, 2023
1 parent 03ec78d commit 47c65f7
Show file tree
Hide file tree
Showing 40 changed files with 1,656 additions and 216 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ permalink: /
Simple plug-and-play PROS template that handles drive base functions for VEX robots.


[EZ-Template Version](https://github.com/EZ-Robotics/EZ-Template): 2.1.2-RC1
[EZ-Template Version](https://github.com/EZ-Robotics/EZ-Template): 3.0.0-RC1

[Autonomous routines that used EZ-Template](https://photos.app.goo.gl/yRwuvmq7hDoM4f6EA)

Expand Down
16 changes: 12 additions & 4 deletions common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ARCHTUPLE=arm-none-eabi-
DEVICE=VEX EDR V5

MFLAGS=-mcpu=cortex-a9 -mfpu=neon-fp16 -mfloat-abi=softfp -Os -g
CPPFLAGS=-D_POSIX_THREADS -D_UNIX98_THREAD_MUTEX_ATTRIBUTES
CPPFLAGS=-D_POSIX_THREADS -D_UNIX98_THREAD_MUTEX_ATTRIBUTES -D_POSIX_TIMERS -D_POSIX_MONOTONIC_CLOCK
GCCFLAGS=-ffunction-sections -fdata-sections -fdiagnostics-color -funwind-tables

WARNFLAGS+=-Wno-psabi
Expand Down 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 All @@ -227,7 +227,7 @@ $(COLD_BIN): $(COLD_ELF)
$(COLD_ELF): $(COLD_LIBRARIES)
$(VV)mkdir -p $(dir $@)
$(call test_output_2,Creating cold package with $(ARCHIVE_TEXT_LIST) ,$(LD) $(LDFLAGS) $(call wlprefix,--gc-keep-exported --whole-archive $^ -lstdc++ --no-whole-archive) $(call wlprefix,-T$(FWDIR)/v5.ld $(LNK_FLAGS) -o $@),$(OK_STRING))
$(call test_output_2,Stripping cold package ,$(OBJCOPY) --strip-symbol=install_hot_table --strip-symbol=__libc_init_array --strip-symbol=_PROS_COMPILE_DIRECTORY --strip-symbol=_PROS_COMPILE_TIMESTAMP $@ $@, $(DONE_STRING))
$(call test_output_2,Stripping cold package ,$(OBJCOPY) --strip-symbol=install_hot_table --strip-symbol=__libc_init_array --strip-symbol=_PROS_COMPILE_DIRECTORY --strip-symbol=_PROS_COMPILE_TIMESTAMP --strip-symbol=_PROS_COMPILE_TIMESTAMP_INT $@ $@, $(DONE_STRING))
@echo Section sizes:
-$(VV)$(SIZETOOL) $(SIZEFLAGS) $@ $(SIZES_SED) $(SIZES_NUMFMT)

Expand Down Expand Up @@ -272,7 +272,15 @@ $(VV)mkdir -p $(dir $(LDTIMEOBJ))
@# Pipe a line of code defining _PROS_COMPILE_TOOLSTAMP and _PROS_COMPILE_DIRECTORY into GCC,
@# which allows compilation from stdin. We define _PROS_COMPILE_DIRECTORY using a command line-defined macro
@# which is the pwd | tail bit, which will truncate the path to the last 23 characters
$(call test_output_2,Adding timestamp ,echo '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))
@#
@# const int _PROS_COMPILE_TIMESTAMP_INT = $(( $(date +%s) - $(date +%z) * 3600 ))
@# char const * const _PROS_COMPILE_TIEMSTAMP = __DATE__ " " __TIME__
@# char const * const _PROS_COMPILE_DIRECTORY = "$(shell pwd | tail -c 23)";
@#
@# 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 = "$(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.
12 changes: 5 additions & 7 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,16 +40,14 @@
#endif /* __cplusplus */

#define PROS_VERSION_MAJOR 3
#define PROS_VERSION_MINOR 6
#define PROS_VERSION_PATCH 2
#define PROS_VERSION_STRING "3.6.2"

#define PROS_ERR (INT32_MAX)
#define PROS_ERR_F (INFINITY)
#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"
#include "pros/distance.h"
#include "pros/error.h"
#include "pros/ext_adi.h"
#include "pros/gps.h"
#include "pros/imu.h"
Expand Down
113 changes: 111 additions & 2 deletions 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 Expand Up @@ -701,7 +701,7 @@ int32_t adi_gyro_shutdown(adi_gyro_t gyro);
* Reference type for an initialized potentiometer.
*
* This merely contains the port number for the potentiometer, unlike its use as an
* object to store gyro data in PROS 2.
* object to store potentiometer data in PROS 2.
*/
typedef int32_t adi_potentiometer_t;

Expand Down Expand Up @@ -757,6 +757,115 @@ adi_potentiometer_t adi_potentiometer_type_init(uint8_t port, adi_potentiometer_
*/
double adi_potentiometer_get_angle(adi_potentiometer_t potentiometer);

/**
* Reference type for an initialized addressable led.
*
* This merely contains the port number for the led, unlike its use as an
* object to store led data in PROS 2.
*/
typedef int32_t adi_led_t;

/**
* Initializes a led on the given port of the original led.
*
* This function uses the following values of errno when an error state is
* reached:
* ENXIO - The given value is not within the range of ADI Ports
* EINVAL - The ADI port given is not a valid port as defined below
* EADDRINUSE - The port is not configured for ADI output
*
* \param port
* The ADI port to initialize as a led (from 1-8, 'a'-'h', 'A'-'H')
*
* \return An adi_led_t object containing the given port, or PROS_ERR if the
* initialization failed, setting errno
*/
adi_led_t adi_led_init(uint8_t port);

/**
* @brief Clear the entire led strip of color
*
* This function uses the following values of errno when an error state is
* reached:
* ENXIO - The given value is not within the range of ADI Ports
* EINVAL - A given value is not correct, or the buffer is null
* EADDRINUSE - The port is not configured for ADI output
*
* @param led port of type adi_led_t
* @param buffer array of colors in format 0xRRGGBB, recommended that individual RGB value not to exceed 0x80 due to current draw
* @param buffer_length length of buffer to clear
* @return PROS_SUCCESS if successful, PROS_ERR if not
*/
int32_t adi_led_clear_all(adi_led_t led, uint32_t* buffer, uint32_t buffer_length);

/**
* @brief Set the entire led strip using the colors contained in the buffer
*
* This function uses the following values of errno when an error state is
* reached:
* ENXIO - The given value is not within the range of ADI Ports
* EINVAL - A given value is not correct, or the buffer is null
* EADDRINUSE - The port is not configured for ADI output
*
* @param led port of type adi_led_t
* @param buffer array of colors in format 0xRRGGBB, recommended that individual RGB value not to exceed 0x80 due to current draw
* @param buffer_length length of buffer to clear
* @return PROS_SUCCESS if successful, PROS_ERR if not
*/
int32_t adi_led_set(adi_led_t led, uint32_t* buffer, uint32_t buffer_length);

/**
* @brief Set the entire led strip to one color
*
* This function uses the following values of errno when an error state is
* reached:
* ENXIO - The given value is not within the range of ADI Ports
* EINVAL - A given value is not correct, or the buffer is null
* EADDRINUSE - The port is not configured for ADI output
*
* @param led port of type adi_led_t
* @param buffer array of colors in format 0xRRGGBB, recommended that individual RGB value not to exceed 0x80 due to current draw
* @param buffer_length length of buffer to clear
* @param color color to set all the led strip value to
* @return PROS_SUCCESS if successful, PROS_ERR if not
*/
int32_t adi_led_set_all(adi_led_t led, uint32_t* buffer, uint32_t buffer_length, uint32_t color);

/**
* @brief Set one pixel on the led strip
*
* This function uses the following values of errno when an error state is
* reached:
* ENXIO - The given value is not within the range of ADI Ports
* EINVAL - A given value is not correct, or the buffer is null
* EADDRINUSE - The port is not configured for ADI output
*
* @param led port of type adi_led_t
* @param buffer array of colors in format 0xRRGGBB, recommended that individual RGB value not to exceed 0x80 due to current draw
* @param buffer_length length of the input buffer
* @param color color to clear all the led strip to
* @param pixel_position position of the pixel to clear
* @return PROS_SUCCESS if successful, PROS_ERR if not
*/
int32_t adi_led_set_pixel(adi_led_t led, uint32_t* buffer, uint32_t buffer_length, uint32_t color, uint32_t pixel_position);

/**
* @brief Clear one pixel on the led strip
*
* This function uses the following values of errno when an error state is
* reached:
* ENXIO - The given value is not within the range of ADI Ports
* EINVAL - A given value is not correct, or the buffer is null
* EADDRINUSE - The port is not configured for ADI output
*
* @param led port of type adi_led_t
* @param buffer array of colors in format 0xRRGGBB, recommended that individual RGB value not to exceed 0x80 due to current draw
* @param buffer_length length of the input buffer
* @param pixel_position position of the pixel to clear
* @return PROS_SUCCESS if successful, PROS_ERR if not
*/
int32_t adi_led_clear_pixel(adi_led_t led, uint32_t* buffer, uint32_t buffer_length, uint32_t pixel_position);

#ifdef __cplusplus
} // namespace c
} // namespace pros
Expand Down
136 changes: 134 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 All @@ -21,6 +21,7 @@
#include <cstdint>
#include <tuple>
#include <utility>
#include <vector>

#include "pros/adi.h"

Expand Down Expand Up @@ -493,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 Expand Up @@ -760,6 +764,134 @@ class ADIPotentiometer : public ADIAnalogIn {
using ADIAnalogIn::get_value_calibrated;
};

class ADILed : protected ADIPort {
public:
/**
* @brief Configures an ADI port to act as a LED.
*
* This function uses the following values of errno when an error state is
* reached:
* ENXIO - Either the ADI port value or the smart port value is not within its
* valid range (ADI port: 1-8, 'a'-'h', or 'A'-'H'; smart port: 1-21).
*
* \param adi_port
* The ADI port number (from 1-8, 'a'-'h', 'A'-'H') to configure
* \param length
* The number of LEDs in the chain
*/
ADILed(std::uint8_t adi_port, std::uint32_t length);

/**
* @brief Configures an ADI port on a adi_expander to act as a LED.
*
* This function uses the following values of errno when an error state is
* reached:
* ENXIO - Either the ADI port value or the smart port value is not within its
* valid range (ADI port: 1-8, 'a'-'h', or 'A'-'H'; smart port: 1-21).
*
* \param port_pair
* The pair of the smart port number (from 1-22) and the
* ADI port number (from 1-8, 'a'-'h', 'A'-'H') to configure
* \param length
* The number of LEDs in the chain
*/
ADILed(ext_adi_port_pair_t port_pair, std::uint32_t length);

/**
* @brief Operator overload to access the buffer in the ADILed class, it is
* recommended that you call .update(); after doing any operations with this.
*
* @param i 0 indexed pixel of the lED
* @return uint32_t& the address of the buffer at i to modify
*/
std::uint32_t& operator[] (size_t i);

/**
* @brief Clear the entire led strip of color
*
* This function uses the following values of errno when an error state is
* reached:
* ENXIO - The given value is not within the range of ADI Ports
* EINVAL - A parameter is out of bounds/incorrect
* EADDRINUSE - The port is not configured for ADI output
*
* @return PROS_SUCCESS if successful, PROS_ERR if not
*/
std::int32_t clear_all();
std::int32_t clear();

/**
* @brief Force the LED strip to update with the current buffered values, this
* should be called after any changes to the buffer using the [] operator.
*
* This function uses the following values of errno when an error state is
* reached:
* EINVAL - A parameter is out of bounds/incorrect
* EADDRINUSE - The port is not configured for ADI output
*
* @return PROS_SUCCESS if successful, PROS_ERR if not
*/
std::int32_t update() const;

/**
* @brief Set the entire led strip to one color
*
* This function uses the following values of errno when an error state is
* reached:
* EINVAL - A parameter is out of bounds/incorrect
* EADDRINUSE - The port is not configured for ADI output
*
* @param color color to set all the led strip value to
* @return PROS_SUCCESS if successful, PROS_ERR if not
*/
std::int32_t set_all(uint32_t color);

/**
* @brief Set one pixel on the led strip
*
* This function uses the following values of errno when an error state is
* reached:
* EINVAL - A parameter is out of bounds/incorrect
* EADDRINUSE - The port is not configured for ADI output
*
* @param color color to clear all the led strip to
* @param pixel_position position of the pixel to clear
* @return PROS_SUCCESS if successful, PROS_ERR if not
*/
std::int32_t set_pixel(uint32_t color, uint32_t pixel_position);

/**
* @brief Clear one pixel on the led strip
*
* This function uses the following values of errno when an error state is
* reached:
* EINVAL - A parameter is out of bounds/incorrect
* EADDRINUSE - The port is not configured for ADI output
*
* @param pixel_position position of the pixel to clear
* @return PROS_SUCCESS if successful, PROS_ERR if not
*/
std::int32_t clear_pixel(uint32_t pixel_position);

/**
* @brief Get the length of the led strip
*
* This function uses the following values of errno when an error state is
* reached:
* EINVAL - A parameter is out of bounds/incorrect
* EADDRINUSE - The port is not configured for ADI output
*
* @return The length (in pixels) of the LED strip
*/
std::int32_t length();

protected:
std::vector<uint32_t> _buffer;
};

// Alias for ADILed
using ADILED = ADILed;

} // namespace pros

#endif // _PROS_ADI_HPP_
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
Loading

0 comments on commit 47c65f7

Please sign in to comment.