mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-05 03:21:42 +00:00
SCRIPT namespace replacements
This commit is contained in:
committed by
Peter Johnson
parent
ae6c043632
commit
9aca8e0fd6
@@ -9,7 +9,7 @@
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
/**
|
||||
* Persistent alert to be sent via NetworkTables. Alerts are tagged with a type
|
||||
@@ -27,7 +27,7 @@ namespace frc {
|
||||
*
|
||||
* <pre>
|
||||
* class Robot {
|
||||
* frc::Alert alert{"Something went wrong", frc::Alert::AlertType::kWarning};
|
||||
* wpi::Alert alert{"Something went wrong", wpi::Alert::AlertType::kWarning};
|
||||
* }
|
||||
*
|
||||
* Robot::periodic() {
|
||||
@@ -138,4 +138,4 @@ class Alert {
|
||||
|
||||
std::string format_as(Alert::AlertType type);
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "wpi/util/StringExtras.hpp"
|
||||
#include "wpi/util/ct_string.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
/**
|
||||
* Represents colors that can be used with Addressable LEDs.
|
||||
@@ -782,19 +782,19 @@ class Color {
|
||||
*/
|
||||
explicit constexpr Color(std::string_view hexString) {
|
||||
if (hexString.length() != 7 || !hexString.starts_with("#") ||
|
||||
!wpi::isHexDigit(hexString[1]) || !wpi::isHexDigit(hexString[2]) ||
|
||||
!wpi::isHexDigit(hexString[3]) || !wpi::isHexDigit(hexString[4]) ||
|
||||
!wpi::isHexDigit(hexString[5]) || !wpi::isHexDigit(hexString[6])) {
|
||||
!wpi::util::isHexDigit(hexString[1]) || !wpi::util::isHexDigit(hexString[2]) ||
|
||||
!wpi::util::isHexDigit(hexString[3]) || !wpi::util::isHexDigit(hexString[4]) ||
|
||||
!wpi::util::isHexDigit(hexString[5]) || !wpi::util::isHexDigit(hexString[6])) {
|
||||
throw std::invalid_argument(
|
||||
fmt::format("Invalid hex string for Color \"{}\"", hexString));
|
||||
}
|
||||
|
||||
int r = wpi::hexDigitValue(hexString[1]) * 16 +
|
||||
wpi::hexDigitValue(hexString[2]);
|
||||
int g = wpi::hexDigitValue(hexString[3]) * 16 +
|
||||
wpi::hexDigitValue(hexString[4]);
|
||||
int b = wpi::hexDigitValue(hexString[5]) * 16 +
|
||||
wpi::hexDigitValue(hexString[6]);
|
||||
int r = wpi::util::hexDigitValue(hexString[1]) * 16 +
|
||||
wpi::util::hexDigitValue(hexString[2]);
|
||||
int g = wpi::util::hexDigitValue(hexString[3]) * 16 +
|
||||
wpi::util::hexDigitValue(hexString[4]);
|
||||
int b = wpi::util::hexDigitValue(hexString[5]) * 16 +
|
||||
wpi::util::hexDigitValue(hexString[6]);
|
||||
|
||||
red = r / 255.0;
|
||||
green = g / 255.0;
|
||||
@@ -859,10 +859,10 @@ class Color {
|
||||
const int g = 255.0 * green;
|
||||
const int b = 255.0 * blue;
|
||||
|
||||
return wpi::ct_string<char, std::char_traits<char>, 7>{
|
||||
{'#', wpi::hexdigit(r / 16), wpi::hexdigit(r % 16),
|
||||
wpi::hexdigit(g / 16), wpi::hexdigit(g % 16), wpi::hexdigit(b / 16),
|
||||
wpi::hexdigit(b % 16)}};
|
||||
return wpi::util::ct_string<char, std::char_traits<char>, 7>{
|
||||
{'#', wpi::util::hexdigit(r / 16), wpi::util::hexdigit(r % 16),
|
||||
wpi::util::hexdigit(g / 16), wpi::util::hexdigit(g % 16), wpi::util::hexdigit(b / 16),
|
||||
wpi::util::hexdigit(b % 16)}};
|
||||
}
|
||||
|
||||
/// Red component (0-1).
|
||||
@@ -1053,4 +1053,4 @@ inline constexpr Color Color::kWhiteSmoke{0.9607843f, 0.9607843f, 0.9607843f};
|
||||
inline constexpr Color Color::kYellow{1.0f, 1.0f, 0.0f};
|
||||
inline constexpr Color Color::kYellowGreen{0.6039216f, 0.8039216f, 0.19607843f};
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "wpi/util/StringExtras.hpp"
|
||||
#include "wpi/util/ct_string.hpp"
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
/**
|
||||
* Represents colors that can be used with Addressable LEDs.
|
||||
@@ -57,19 +57,19 @@ class Color8Bit {
|
||||
*/
|
||||
explicit constexpr Color8Bit(std::string_view hexString) {
|
||||
if (hexString.length() != 7 || !hexString.starts_with("#") ||
|
||||
!wpi::isHexDigit(hexString[1]) || !wpi::isHexDigit(hexString[2]) ||
|
||||
!wpi::isHexDigit(hexString[3]) || !wpi::isHexDigit(hexString[4]) ||
|
||||
!wpi::isHexDigit(hexString[5]) || !wpi::isHexDigit(hexString[6])) {
|
||||
!wpi::util::isHexDigit(hexString[1]) || !wpi::util::isHexDigit(hexString[2]) ||
|
||||
!wpi::util::isHexDigit(hexString[3]) || !wpi::util::isHexDigit(hexString[4]) ||
|
||||
!wpi::util::isHexDigit(hexString[5]) || !wpi::util::isHexDigit(hexString[6])) {
|
||||
throw std::invalid_argument(
|
||||
fmt::format("Invalid hex string for Color \"{}\"", hexString));
|
||||
}
|
||||
|
||||
red = wpi::hexDigitValue(hexString[1]) * 16 +
|
||||
wpi::hexDigitValue(hexString[2]);
|
||||
green = wpi::hexDigitValue(hexString[3]) * 16 +
|
||||
wpi::hexDigitValue(hexString[4]);
|
||||
blue = wpi::hexDigitValue(hexString[5]) * 16 +
|
||||
wpi::hexDigitValue(hexString[6]);
|
||||
red = wpi::util::hexDigitValue(hexString[1]) * 16 +
|
||||
wpi::util::hexDigitValue(hexString[2]);
|
||||
green = wpi::util::hexDigitValue(hexString[3]) * 16 +
|
||||
wpi::util::hexDigitValue(hexString[4]);
|
||||
blue = wpi::util::hexDigitValue(hexString[5]) * 16 +
|
||||
wpi::util::hexDigitValue(hexString[6]);
|
||||
}
|
||||
|
||||
constexpr bool operator==(const Color8Bit&) const = default;
|
||||
@@ -87,19 +87,19 @@ class Color8Bit {
|
||||
*/
|
||||
static constexpr Color8Bit FromHexString(std::string_view hexString) {
|
||||
if (hexString.length() != 7 || !hexString.starts_with("#") ||
|
||||
!wpi::isHexDigit(hexString[1]) || !wpi::isHexDigit(hexString[2]) ||
|
||||
!wpi::isHexDigit(hexString[3]) || !wpi::isHexDigit(hexString[4]) ||
|
||||
!wpi::isHexDigit(hexString[5]) || !wpi::isHexDigit(hexString[6])) {
|
||||
!wpi::util::isHexDigit(hexString[1]) || !wpi::util::isHexDigit(hexString[2]) ||
|
||||
!wpi::util::isHexDigit(hexString[3]) || !wpi::util::isHexDigit(hexString[4]) ||
|
||||
!wpi::util::isHexDigit(hexString[5]) || !wpi::util::isHexDigit(hexString[6])) {
|
||||
throw std::invalid_argument(
|
||||
fmt::format("Invalid hex string for Color \"{}\"", hexString));
|
||||
}
|
||||
|
||||
int r = wpi::hexDigitValue(hexString[0]) * 16 +
|
||||
wpi::hexDigitValue(hexString[1]);
|
||||
int g = wpi::hexDigitValue(hexString[2]) * 16 +
|
||||
wpi::hexDigitValue(hexString[3]);
|
||||
int b = wpi::hexDigitValue(hexString[4]) * 16 +
|
||||
wpi::hexDigitValue(hexString[5]);
|
||||
int r = wpi::util::hexDigitValue(hexString[0]) * 16 +
|
||||
wpi::util::hexDigitValue(hexString[1]);
|
||||
int g = wpi::util::hexDigitValue(hexString[2]) * 16 +
|
||||
wpi::util::hexDigitValue(hexString[3]);
|
||||
int b = wpi::util::hexDigitValue(hexString[4]) * 16 +
|
||||
wpi::util::hexDigitValue(hexString[5]);
|
||||
return Color8Bit{r, g, b};
|
||||
}
|
||||
|
||||
@@ -109,10 +109,10 @@ class Color8Bit {
|
||||
* @return a string of the format <tt>\#RRGGBB</tt>
|
||||
*/
|
||||
constexpr auto HexString() const {
|
||||
return wpi::ct_string<char, std::char_traits<char>, 7>{
|
||||
{'#', wpi::hexdigit(red / 16), wpi::hexdigit(red % 16),
|
||||
wpi::hexdigit(green / 16), wpi::hexdigit(green % 16),
|
||||
wpi::hexdigit(blue / 16), wpi::hexdigit(blue % 16)}};
|
||||
return wpi::util::ct_string<char, std::char_traits<char>, 7>{
|
||||
{'#', wpi::util::hexdigit(red / 16), wpi::util::hexdigit(red % 16),
|
||||
wpi::util::hexdigit(green / 16), wpi::util::hexdigit(green % 16),
|
||||
wpi::util::hexdigit(blue / 16), wpi::util::hexdigit(blue % 16)}};
|
||||
}
|
||||
|
||||
/// Red component (0-255).
|
||||
@@ -125,4 +125,4 @@ class Color8Bit {
|
||||
int blue = 0;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
/**
|
||||
* The preferences class provides a relatively simple way to save important
|
||||
@@ -218,4 +218,4 @@ class Preferences {
|
||||
Preferences() = default;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace frc {
|
||||
namespace wpi {
|
||||
|
||||
/**
|
||||
* Stores most recent status information as well as containing utility functions
|
||||
@@ -63,4 +63,4 @@ class SensorUtil final {
|
||||
static int GetNumPwmChannels();
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
} // namespace wpi
|
||||
|
||||
Reference in New Issue
Block a user