Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
29cd3cd
rename v5_device_e_t to V5Device
SizzinSeal May 3, 2025
915f005
start removing old vdml and registry
SizzinSeal May 3, 2025
6dcae1b
remove screen API
SizzinSeal May 3, 2025
db9281f
delete registry.c
SizzinSeal May 3, 2025
320b7a7
remove screen header files
SizzinSeal May 3, 2025
c856822
remove color headers
SizzinSeal May 3, 2025
40df79a
remove errors.h
SizzinSeal May 3, 2025
0dad69b
Merge branch 'main' into refactor/vdml
SizzinSeal May 3, 2025
77ce640
reimplement battery API
SizzinSeal May 4, 2025
dcf2329
start work on Port class
SizzinSeal May 8, 2025
e91f58b
add port types
SizzinSeal May 9, 2025
cff2a5b
fix battery.cpp build
SizzinSeal May 9, 2025
e9db499
port bugfixes
SizzinSeal May 16, 2025
8147465
document SmartPort class
SizzinSeal May 16, 2025
7c42ce0
improve SmartPort documentation
SizzinSeal May 16, 2025
9f613f5
document AdiPort class
SizzinSeal May 16, 2025
dfe13ff
add mutex array to SmartPort class
SizzinSeal May 16, 2025
189f2c1
improve SmartPort::get_mutex documentation
SizzinSeal May 16, 2025
ad4bda4
add ADI expander support to AdiPort class
SizzinSeal May 16, 2025
083f5f3
add get_expander_port function to AdiPort class
SizzinSeal May 16, 2025
839a590
fix AdiPort::get_mutex bug
SizzinSeal May 16, 2025
e6933b1
further SmartPort documentation
SizzinSeal May 16, 2025
41f4b6d
simplify port.hpp
SizzinSeal May 18, 2025
84ce58e
add AdiExpander and Brain class
SizzinSeal May 18, 2025
450519c
add port.cpp
SizzinSeal May 18, 2025
d1f7f2c
fix build errors
SizzinSeal May 18, 2025
50d2f27
define AdiPort::get_mutex out of line
SizzinSeal May 18, 2025
3412f54
restructure ports
SizzinSeal May 19, 2025
5455004
delete SmartPort and AdiPort copy constructors
SizzinSeal May 19, 2025
a9b9e29
document AdiExpander class
SizzinSeal May 19, 2025
98c1376
update STRUCTURE.md to reflect VDML refactor
SizzinSeal May 19, 2025
b23dce0
document system_daemon mutex helper functions
SizzinSeal May 19, 2025
2e16c0b
further document lock_ports helper function
SizzinSeal May 19, 2025
300d787
try using constinit
SizzinSeal May 20, 2025
b89fb52
fix compiler errors
SizzinSeal May 20, 2025
e2c2785
simplify port_mutex_lock_all
SizzinSeal May 20, 2025
0c9e913
simplify port_mutex_unlock_all
SizzinSeal May 20, 2025
d68bb2a
remove unused helper functions
SizzinSeal May 20, 2025
b510600
further restructuring of port mutexes
SizzinSeal May 26, 2025
5cdce86
remove VDML readme
SizzinSeal May 26, 2025
910401e
fix AdiPort class docs
SizzinSeal May 26, 2025
bfbda47
clarify AdiPort docs
SizzinSeal May 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/STRUCTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ Looking at the file structure of a project like this can feel intimidating. This
- `include` contains the header files
- `include/common` headers used in various parts of the project
- `include/pros` headers that are distributed to user projects
- `include/pros/devices` headers containing api for interacting with V5 devices
- `include/rtos` headers for the scheduler (FreeRTOS)
- `include/system` headers for low-level system functionality
- `include/system/dev` headers for serial I/O and file management
- `include/system/user_functions` a horrifying mess that should be destroyed
- `include/vdml` headers for the VEX Data Management Layer (VDML), a system to ensure thread-safety when interacting with VEX devices

- `scripts` contains scripts used for building ZestCode and projects that use ZestCode

- `src` contains the source files
- `src/common` sources defining symbols used throughout the project
- `src/devices` implementations of VEX device abstractions. Files prefixed with `vdml_` indicate that the file makes use of the VDML
- `src/devices` implementations of VEX device abstractions
- `src/rtos` sources, build scripts, and misc files of FreeRTOS
- `src/system` sources for low-level system functionality
- `src/system/dev` sources for serial I/O and file management
Expand Down
4 changes: 0 additions & 4 deletions include/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,12 @@
#include <unistd.h>
#endif /* __cplusplus */

#include "pros/colors.h"
#include "pros/error.h"
#include "pros/misc.h"
#include "pros/rtos.h"

#ifdef __cplusplus
#include "pros/colors.hpp"
#include "pros/misc.hpp"
#include "pros/rtos.hpp"
#include "pros/screen.hpp"
#endif

#endif // _PROS_API_H_
14 changes: 14 additions & 0 deletions include/common/result.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,20 @@ class ResultError {
std::optional<RuntimeData> runtime_data;
};

/**
* @brief Unknown Error
*
*/
class UnknownError : public ResultError {
public:
template<typename T>
requires std::convertible_to<T, std::string>
UnknownError(T&& message)
: message(std::forward<T>(message)) {}

std::string message;
};

/**
* @brief Trait to define a "sentinel" value for types indicating an error state.
* @tparam T Type to provide a sentinel value for.
Expand Down
2 changes: 1 addition & 1 deletion include/kapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#pragma once

#include "api.h"
#include "pros/apix.h"
#include "pros/apix.hpp"
#include "rtos/FreeRTOS.h"
#include "rtos/stream_buffer.h"

Expand Down
128 changes: 0 additions & 128 deletions include/pros/apix.h → include/pros/apix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -559,134 +559,6 @@ void queue_reset(queue_t queue);

///@}

/// \name Device Registration
///@{

/**
* \enum v5_device_e
* \brief
* List of possible v5 devices
*
* This list contains all current V5 Devices, and mirrors V5_DeviceType from the
* api.
*/
typedef enum v5_device_e {
E_DEVICE_NONE = 0, ///< No device is plugged into the port
E_DEVICE_MOTOR = 2, ///< A motor is plugged into the port
E_DEVICE_ROTATION = 4, ///< A rotation sensor is plugged into the port
E_DEVICE_IMU = 6, ///< An inertial sensor is plugged into the port
E_DEVICE_DISTANCE = 7, ///< A distance sensor is plugged into the port
E_DEVICE_RADIO = 8, ///< A radio is plugged into the port
E_DEVICE_VISION = 11, ///< A vision sensor is plugged into the port
E_DEVICE_ADI = 12, ///< This port is an ADI expander
E_DEVICE_OPTICAL = 16, ///< An optical sensor is plugged into the port
E_DEVICE_GPS = 20, ///< A GPS sensor is plugged into the port
E_DEVICE_AIVISION = 29, ///< An AI Vision sensor is plugged into the port
E_DEVICE_SERIAL = 129, ///< A serial device is plugged into the port
E_DEVICE_GENERIC __attribute__((deprecated("use E_DEVICE_SERIAL instead"))) = E_DEVICE_SERIAL,
E_DEVICE_UNDEFINED = 255 ///< The device type is not defined, or is not a valid device
} v5_device_e_t;

/**
* Registers a device in the given zero-indexed port
*
* Registers a device of the given type in the given port into the registry, if
* that type of device is detected to be plugged in to that 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 (0-20), or a
* a different device than specified is plugged in.
* EADDRINUSE - The port is already registered to another device.
*
* \param port
* The port number to register the device
* \param device
* The type of device to register
*
* \return 1 upon success, PROS_ERR upon failure
*
* \b Example:
* \code
* void opcontrol(void) {
* registry_bind_port(1, E_DEVICE_MOTOR);
* }
* \endcode
*/
int registry_bind_port(uint8_t port, v5_device_e_t device_type);

/**
* Deregisters a devices from the given zero-indexed port
*
* Removes the device registed in the given port, if there is one.
*
* 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 (0-20).
*
* \param port
* The port number to deregister
*
* \return 1 upon success, PROS_ERR upon failure
*
* \b Example:
* \code
* void opcontrol(void) {
* registry_bind_port(1, E_DEVICE_MOTOR);
* registry_unbind_port(1);
* }
* \endcode
*/
int registry_unbind_port(uint8_t port);

/**
* Returns the type of device registered to the zero-indexed 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 (0-20).
*
* \param port
* The V5 port number from 0-20
*
* \return The type of device that is registered into the port (NOT what is
* plugged in)
*
* \b Example:
* \code
* void opcontrol(void) {
* registry_bind_port(1, E_DEVICE_MOTOR);
* printf("port 1 is registered to a motor: %d", registry_get_bound_type(1) == E_DEVICE_MOTOR);
* }
* \endcode
*/
v5_device_e_t registry_get_bound_type(uint8_t port);

/**
* Returns the type of the device plugged into the zero-indexed 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 (0-20).
*
* \param port
* The V5 port number from 0-20
*
* \return The type of device that is plugged into the port (NOT what is
* registered)
*
* \b Example:
* \code
* void opcontrol(void) {
* registry_bind_port(1, E_DEVICE_MOTOR);
* printf("port 1 is registered to a motor: %d", registry_get_plugged_type(1) == E_DEVICE_MOTOR);
* }
* \endcode
*/
v5_device_e_t registry_get_plugged_type(uint8_t port);

///@}

/// \name Startup options
///@{

Expand Down
Loading
Loading