mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Merge branch 'main' into 2027
This commit is contained in:
@@ -34,6 +34,13 @@ AddressableLED::AddressableLED(int port) : m_port{port} {
|
||||
HAL_ReportUsage("IO", port, "AddressableLED");
|
||||
}
|
||||
|
||||
void AddressableLED::SetColorOrder(AddressableLED::ColorOrder order) {
|
||||
int32_t status = 0;
|
||||
HAL_SetAddressableLEDColorOrder(
|
||||
m_handle, static_cast<HAL_AddressableLEDColorOrder>(order), &status);
|
||||
FRC_CheckErrorStatus(status, "Port {} Color order {}", m_port, order);
|
||||
}
|
||||
|
||||
void AddressableLED::SetLength(int length) {
|
||||
int32_t status = 0;
|
||||
HAL_SetAddressableLEDLength(m_handle, length, &status);
|
||||
|
||||
@@ -82,17 +82,18 @@ class Alert::SendableAlerts : public nt::NTSendable,
|
||||
* @return the SendableAlerts for the group
|
||||
*/
|
||||
static SendableAlerts& ForGroup(std::string_view group) {
|
||||
// Force initialization of SendableRegistry before our magic static to
|
||||
// prevent incorrect destruction order.
|
||||
wpi::SendableRegistry::EnsureInitialized();
|
||||
static wpi::StringMap<Alert::SendableAlerts> groups;
|
||||
|
||||
auto [iter, exists] = groups.try_emplace(group);
|
||||
SendableAlerts& sendable = iter->second;
|
||||
if (!exists) {
|
||||
frc::SmartDashboard::PutData(group, &iter->second);
|
||||
SendableAlerts* salert = nullptr;
|
||||
try {
|
||||
auto* sendable = frc::SmartDashboard::GetData(group);
|
||||
salert = dynamic_cast<SendableAlerts*>(sendable);
|
||||
} catch (frc::RuntimeError&) {
|
||||
}
|
||||
return sendable;
|
||||
if (!salert) {
|
||||
// this leaks if ResetSmartDashboardInstance is called, but that's fine
|
||||
salert = new Alert::SendableAlerts;
|
||||
frc::SmartDashboard::PutData(group, salert);
|
||||
}
|
||||
return *salert;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -119,5 +119,13 @@ double Joystick::GetMagnitude() const {
|
||||
}
|
||||
|
||||
units::radian_t Joystick::GetDirection() const {
|
||||
// https://docs.wpilib.org/en/stable/docs/software/basic-programming/coordinate-system.html#joystick-and-controller-coordinate-system
|
||||
// A positive rotation around the X axis moves the joystick right, and a
|
||||
// positive rotation around the Y axis moves the joystick backward. When
|
||||
// treating them as translations, 0 radians is measured from the right
|
||||
// direction, and angle increases clockwise.
|
||||
//
|
||||
// It's rotated 90 degrees CCW (y is negated and the arguments are reversed)
|
||||
// so that 0 radians is forward.
|
||||
return units::radian_t{std::atan2(GetX(), -GetY())};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user