2023-Robot
Robot code for 2023 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
8
9// Include GamePiece enum
11#include <ctre/Phoenix.h>
12#include <frc/util/Color.h>
13#include <frc2/command/SubsystemBase.h>
14
17
18#include <chrono>
19#include <functional>
20
21enum class LedGroup { SIDES, BACK, FRONT };
24
25class SimpleLedSubsystem : public frc2::SubsystemBase {
26 public:
28
29 void Enable();
30 void Disable();
31
32 void SetLedsConnectedBrightness(bool connected);
33
34 void SetDisableAnimation(std::function<void()> animationFunction);
35
39 void SetLedGroupColor(LedGroup group, argos_lib::ArgosColor color, bool restorable = true);
40 void SetLedStripColor(LedStrip strip, argos_lib::ArgosColor color, bool restorable = true);
41
45 bool restorable = true,
46 std::optional<std::function<GamePiece()>> tipColor = std::nullopt);
47
49 bool restorable = true,
50 std::optional<std::function<GamePiece()>> tipColor = std::nullopt);
51
52 void SetAllGroupsFlash(argos_lib::ArgosColor color, bool restorable = true);
53
54 void FlashStrip(LedStrip strip, argos_lib::ArgosColor color, bool restorable = true);
55
56 void SetAllGroupsLarson(argos_lib::ArgosColor color, bool restorable = true);
57
59
61 void SetAllGroupsAllianceColor(bool fade,
62 bool restorable = true,
63 std::optional<std::function<GamePiece()>> tipColor = std::nullopt);
64
65 void StopAllAnimations(bool restorable = true);
66
68 void SetAllGroupsGamePieceColor(GamePiece gp, bool restorable = true);
69
71 void SetAllGroupsOff(bool restorable = true);
72
76 void Periodic() override;
77 void FireEverywhere(bool restorable = true);
78 void Blind(bool restorable = true);
79
80 void ColorSweep(argos_lib::ArgosColor color, bool correctGamma = true, bool restorable = true);
81
82 void TemporaryAnimate(std::function<void()> animationFunction, units::millisecond_t duration);
83
84 private:
85 // Components (e.g. motor controllers and sensors) should generally be
86 // declared private and exposed only through public methods.
87 std::optional<CANdle> m_CANdle;
91
92 std::function<void()> m_disableUpdateFunction;
93 std::function<void()> m_ledUpdateFunction;
94 std::optional<std::function<void(void)>> m_restoreAnimationFunction;
95 std::chrono::time_point<std::chrono::steady_clock> m_startTime;
96 units::millisecond_t m_temporaryDuration;
97
98 constexpr static argos_lib::ArgosColor GetGamePieceColor(GamePiece gp, bool gammaCorrect = true);
99
100 constexpr static int startIndex_frontLeft = 8;
101 constexpr static int length_frontLeft = 29;
102 constexpr static bool inverted_frontLeft = false;
103 constexpr static int startIndex_frontRight = 37;
104 constexpr static int length_frontRight = 30;
105 constexpr static bool inverted_frontRight = true;
106
107 constexpr static int startIndex_sideFront = 67;
108 constexpr static int length_sideFront = 61;
109 constexpr static bool inverted_sideFront = false;
110 constexpr static int startIndex_sideBack = 128;
111 constexpr static int length_sideBack = 61;
112 constexpr static bool inverted_sideBack = true;
113
114 constexpr static int startIndex_backRight = 189;
115 constexpr static int length_backRight = 58;
116 constexpr static bool inverted_backRight = false;
117 constexpr static int startIndex_backLeft = 247;
118 constexpr static int length_backLeft = 57;
119 constexpr static bool inverted_backLeft = true;
120};
Definition simple_led_subsystem.h:25
void Blind(bool restorable=true)
Definition simple_led_subsystem.cpp:467
static constexpr int length_sideBack
Definition simple_led_subsystem.h:111
void TemporaryAnimate(std::function< void()> animationFunction, units::millisecond_t duration)
Definition simple_led_subsystem.cpp:540
static constexpr int startIndex_backLeft
Definition simple_led_subsystem.h:117
static constexpr bool inverted_frontLeft
true indicates first index is at top of tower
Definition simple_led_subsystem.h:102
void StopAllAnimations(bool restorable=true)
Definition simple_led_subsystem.cpp:414
bool m_enabled
Definition simple_led_subsystem.h:89
void SetLedGroupColor(LedGroup group, argos_lib::ArgosColor color, bool restorable=true)
Sets group of leds to given color.
Definition simple_led_subsystem.cpp:78
argos_lib::ArgosColor GetAllianceColor()
Definition simple_led_subsystem.cpp:381
units::millisecond_t m_temporaryDuration
Definition simple_led_subsystem.h:96
void SetAllGroupsOff(bool restorable=true)
Turn off all LEDs.
Definition simple_led_subsystem.cpp:431
void Enable()
Definition simple_led_subsystem.cpp:39
static constexpr int startIndex_sideFront
Definition simple_led_subsystem.h:107
static constexpr int length_frontRight
Definition simple_led_subsystem.h:104
static constexpr bool inverted_sideFront
Definition simple_led_subsystem.h:109
static constexpr int startIndex_backRight
Definition simple_led_subsystem.h:114
static constexpr int length_sideFront
Definition simple_led_subsystem.h:108
void Periodic() override
Definition simple_led_subsystem.cpp:65
void SetAllGroupsGamePieceColor(GamePiece gp, bool restorable=true)
Set all groups to color of given game piece.
Definition simple_led_subsystem.cpp:406
static constexpr int length_backRight
Definition simple_led_subsystem.h:115
void SetAllGroupsAllianceColor(bool fade, bool restorable=true, std::optional< std::function< GamePiece()> > tipColor=std::nullopt)
Set all groups of LEDs to the alliance color.
Definition simple_led_subsystem.cpp:391
static constexpr int length_backLeft
Definition simple_led_subsystem.h:118
std::optional< std::function< void(void)> > m_restoreAnimationFunction
Definition simple_led_subsystem.h:94
std::chrono::time_point< std::chrono::steady_clock > m_startTime
Definition simple_led_subsystem.h:95
std::function< void()> m_disableUpdateFunction
Definition simple_led_subsystem.h:92
static constexpr int startIndex_frontRight
Definition simple_led_subsystem.h:103
void SetDisableAnimation(std::function< void()> animationFunction)
Definition simple_led_subsystem.cpp:60
std::optional< CANdle > m_CANdle
Definition simple_led_subsystem.h:87
void SetAllGroupsColor(argos_lib::ArgosColor color, bool restorable=true, std::optional< std::function< GamePiece()> > tipColor=std::nullopt)
Sets all led groups to a given color.
Definition simple_led_subsystem.cpp:179
void SetAllGroupsLarson(argos_lib::ArgosColor color, bool restorable=true)
Definition simple_led_subsystem.cpp:350
void SetAllGroupsFade(argos_lib::ArgosColor color, bool restorable=true, std::optional< std::function< GamePiece()> > tipColor=std::nullopt)
Definition simple_led_subsystem.cpp:231
static constexpr bool inverted_backRight
Definition simple_led_subsystem.h:116
void Disable()
Definition simple_led_subsystem.cpp:42
static constexpr int length_frontLeft
Number of LEDs in strip.
Definition simple_led_subsystem.h:101
void SetAllGroupsFlash(argos_lib::ArgosColor color, bool restorable=true)
Definition simple_led_subsystem.cpp:276
argos_lib::ArgosLogger m_log
Definition simple_led_subsystem.h:88
bool m_hasBeenConnected
Definition simple_led_subsystem.h:90
void FireEverywhere(bool restorable=true)
Definition simple_led_subsystem.cpp:439
static constexpr bool inverted_sideBack
Definition simple_led_subsystem.h:112
static constexpr argos_lib::ArgosColor GetGamePieceColor(GamePiece gp, bool gammaCorrect=true)
Definition simple_led_subsystem.cpp:549
void SetLedsConnectedBrightness(bool connected)
Definition simple_led_subsystem.cpp:50
static constexpr bool inverted_backLeft
Definition simple_led_subsystem.h:119
static constexpr bool inverted_frontRight
Definition simple_led_subsystem.h:105
void SetLedStripColor(LedStrip strip, argos_lib::ArgosColor color, bool restorable=true)
Definition simple_led_subsystem.cpp:124
void FlashStrip(LedStrip strip, argos_lib::ArgosColor color, bool restorable=true)
Definition simple_led_subsystem.cpp:299
std::function< void()> m_ledUpdateFunction
Definition simple_led_subsystem.h:93
static constexpr int startIndex_sideBack
Definition simple_led_subsystem.h:110
void ColorSweep(argos_lib::ArgosColor color, bool correctGamma=true, bool restorable=true)
Definition simple_led_subsystem.cpp:496
static constexpr int startIndex_frontLeft
Address of first LED in strip.
Definition simple_led_subsystem.h:100
Log to the console in a clean, repeatable manner.
Definition log.h:22
GamePiece
Definition field_points.h:44
RobotInstance
Differentiates between practice robot and competition robot.
Definition config_types.h:13
LedStrip
Definition simple_led_subsystem.h:22
LedGroup
Definition simple_led_subsystem.h:21
AlignLedStatus
Definition simple_led_subsystem.h:23
Definition color.h:10