Skip to content

Commit 7c42ce0

Browse files
committed
improve SmartPort documentation
1 parent 8147465 commit 7c42ce0

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

include/pros/devices/port.hpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ namespace zest {
77
/**
88
* @brief Smart Port class. Represents a Smart Port on the V5 brain.
99
*
10-
* @details Smart Ports may be represented as a 1-indexed number or a 0-indexed number. While the
10+
* Smart Ports may be represented as a 1-indexed number or a 0-indexed number. While the
1111
* user expects a 1-indexed number (matching the labels on the brain), treating it as an index makes
1212
* development easier. This class abstracts that away so we don't have to worry about it.
13-
*
1413
*/
1514
class SmartPort {
1615
public:
@@ -71,6 +70,13 @@ class SmartPort {
7170
};
7271

7372
namespace ports {
73+
/*
74+
* Physical smart ports have a number from 1 to 21 (inclusive). While compile-time error checking
75+
* could prevent an invalid port being constructed, the error messages that would be produced
76+
* wouldn't be very concise.
77+
* However, if the user tried constructing a device on the imaginary port 42, the project wouldn't
78+
* compile since PORT_42 isn't declared. This error message is much clearer.
79+
*/
7480
constexpr auto PORT_1 = SmartPort::from_number(1);
7581
constexpr auto PORT_2 = SmartPort::from_number(2);
7682
constexpr auto PORT_3 = SmartPort::from_number(3);

0 commit comments

Comments
 (0)