2025-Robot
Robot code for 2025 FRC season by Argos, FRC team #1756
Loading...
Searching...
No Matches
simple_led_subsystem.h
Go to the documentation of this file.
1
4
5#pragma once
6
9#include <ctre/phoenix/led/CANdle.h>
10#include <frc/DriverStation.h>
11#include <frc/util/Color.h>
12#include <frc2/command/SubsystemBase.h>
13
14#include <chrono>
15#include <functional>
16
19
20enum class LedGroup { TIARA };
21enum class LedStrip { TIARA };
23
24class SimpleLedSubsystem : public frc2::SubsystemBase {
25 public:
27
28 void Enable();
29 void Disable();
30
31 void SetLedsConnectedBrightness(bool connected);
32
33 void SetDisableAnimation(std::function<void()> animationFunction);
34
38 void SetLedGroupColor(LedGroup group, argos_lib::ArgosColor color, bool restorable = true);
39 void SetLedStripColor(LedStrip strip, argos_lib::ArgosColor color, bool restorable = true);
40
43 void SetAllGroupsColor(argos_lib::ArgosColor color, bool restorable = true);
44
45 void SetAllGroupsFade(argos_lib::ArgosColor color, bool restorable = true);
46
47 void SetAllGroupsFlash(argos_lib::ArgosColor color, bool restorable = true);
48
49 void FlashStrip(LedStrip strip, argos_lib::ArgosColor color, bool restorable = true);
50
51 void SetAllGroupsLarson(argos_lib::ArgosColor color, bool restorable = true);
52
54
56 void SetAllGroupsAllianceColor(bool fade, bool restorable = true);
57
58 void StopAllAnimations(bool restorable = true);
59
61 void SetAllGroupsOff(bool restorable = true);
62
66 void Periodic() override;
67 void FireEverywhere(bool restorable = true);
68
69 void ColorSweep(argos_lib::ArgosColor color, bool correctGamma = true, bool restorable = true);
70
71 void TemporaryAnimate(std::function<void()> animationFunction, units::millisecond_t duration);
72
73 private:
74 // Components (e.g. motor controllers and sensors) should generally be
75 // declared private and exposed only through public methods.
76 std::optional<ctre::phoenix::led::CANdle> m_CANdle;
80
81 std::function<void()> m_disableUpdateFunction;
82 std::function<void()> m_ledUpdateFunction;
83 std::optional<std::function<void(void)>> m_restoreAnimationFunction;
84 std::chrono::time_point<std::chrono::steady_clock> m_startTime;
85 units::millisecond_t m_temporaryDuration;
86
87 frc::DriverStation::Alliance m_latestAlliance;
88
89 constexpr static int startIndex_tiara = 0;
90 constexpr static int length_tiara = 37;
91 constexpr static bool inverted_tiara = false;
92};
Definition simple_led_subsystem.h:24
void TemporaryAnimate(std::function< void()> animationFunction, units::millisecond_t duration)
Definition simple_led_subsystem.cpp:365
void StopAllAnimations(bool restorable=true)
Definition simple_led_subsystem.cpp:281
bool m_enabled
Definition simple_led_subsystem.h:78
void SetLedGroupColor(LedGroup group, argos_lib::ArgosColor color, bool restorable=true)
Sets group of leds to given color.
Definition simple_led_subsystem.cpp:79
argos_lib::ArgosColor GetAllianceColor()
Definition simple_led_subsystem.cpp:253
units::millisecond_t m_temporaryDuration
Definition simple_led_subsystem.h:85
void SetAllGroupsOff(bool restorable=true)
Turn off all LEDs.
Definition simple_led_subsystem.cpp:295
void Enable()
Definition simple_led_subsystem.cpp:40
static constexpr int startIndex_tiara
Address of first LED in strip.
Definition simple_led_subsystem.h:89
void SetAllGroupsFade(argos_lib::ArgosColor color, bool restorable=true)
Definition simple_led_subsystem.cpp:160
void SetAllGroupsAllianceColor(bool fade, bool restorable=true)
Set all groups of LEDs to the alliance color.
Definition simple_led_subsystem.cpp:268
frc::DriverStation::Alliance m_latestAlliance
Definition simple_led_subsystem.h:87
void Periodic() override
Definition simple_led_subsystem.cpp:66
void SetAllGroupsColor(argos_lib::ArgosColor color, bool restorable=true)
Sets all led groups to a given color.
Definition simple_led_subsystem.cpp:142
static constexpr bool inverted_tiara
true indicates first index is at top of tower
Definition simple_led_subsystem.h:91
std::optional< std::function< void(void)> > m_restoreAnimationFunction
Definition simple_led_subsystem.h:83
std::chrono::time_point< std::chrono::steady_clock > m_startTime
Definition simple_led_subsystem.h:84
std::function< void()> m_disableUpdateFunction
Definition simple_led_subsystem.h:81
void SetDisableAnimation(std::function< void()> animationFunction)
Definition simple_led_subsystem.cpp:61
void SetAllGroupsLarson(argos_lib::ArgosColor color, bool restorable=true)
Definition simple_led_subsystem.cpp:227
SimpleLedSubsystem(argos_lib::RobotInstance instance)
Definition simple_led_subsystem.cpp:22
void Disable()
Definition simple_led_subsystem.cpp:43
void SetAllGroupsFlash(argos_lib::ArgosColor color, bool restorable=true)
Definition simple_led_subsystem.cpp:178
argos_lib::ArgosLogger m_log
Definition simple_led_subsystem.h:77
static constexpr int length_tiara
Number of LEDs in strip.
Definition simple_led_subsystem.h:90
bool m_hasBeenConnected
Definition simple_led_subsystem.h:79
void FireEverywhere(bool restorable=true)
Definition simple_led_subsystem.cpp:303
void SetLedsConnectedBrightness(bool connected)
Definition simple_led_subsystem.cpp:51
void SetLedStripColor(LedStrip strip, argos_lib::ArgosColor color, bool restorable=true)
Definition simple_led_subsystem.cpp:112
void FlashStrip(LedStrip strip, argos_lib::ArgosColor color, bool restorable=true)
Definition simple_led_subsystem.cpp:196
std::function< void()> m_ledUpdateFunction
Definition simple_led_subsystem.h:82
void ColorSweep(argos_lib::ArgosColor color, bool correctGamma=true, bool restorable=true)
Definition simple_led_subsystem.cpp:321
std::optional< ctre::phoenix::led::CANdle > m_CANdle
Definition simple_led_subsystem.h:76
Log to the console in a clean, repeatable manner.
Definition log.h:22
RobotInstance
Differentiates between practice robot and competition robot.
Definition config_types.h:13
LedStrip
Definition simple_led_subsystem.h:21
LedGroup
Definition simple_led_subsystem.h:20
AlignLedStatus
Definition simple_led_subsystem.h:22
Definition color.h:10