2022-12-08 07:47:47 +02:00
|
|
|
// Copyright (c) FIRST and other WPILib contributors.
|
|
|
|
|
// Open Source Software; you can modify and/or share it under the terms of
|
|
|
|
|
// the WPILib BSD license file in the root directory of this project.
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <array>
|
|
|
|
|
|
2025-11-08 15:08:38 -08:00
|
|
|
#include <wpi/framework/TimedRobot.hpp>
|
2025-11-07 19:57:55 -05:00
|
|
|
#include <wpi/hardware/led/AddressableLED.hpp>
|
|
|
|
|
#include <wpi/hardware/led/LEDPattern.hpp>
|
2022-12-08 07:47:47 +02:00
|
|
|
|
2025-11-07 20:00:05 -05:00
|
|
|
class Robot : public wpi::TimedRobot {
|
2022-12-08 07:47:47 +02:00
|
|
|
public:
|
2024-07-17 11:22:39 +08:00
|
|
|
Robot();
|
2022-12-08 07:47:47 +02:00
|
|
|
void RobotPeriodic() override;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
static constexpr int kLength = 60;
|
|
|
|
|
|
2025-07-21 21:52:10 -07:00
|
|
|
// SmartIO port 1
|
2025-11-07 20:00:05 -05:00
|
|
|
wpi::AddressableLED m_led{1};
|
|
|
|
|
std::array<wpi::AddressableLED::LEDData, kLength>
|
2022-12-08 07:47:47 +02:00
|
|
|
m_ledBuffer; // Reuse the buffer
|
2024-06-05 22:41:10 -04:00
|
|
|
|
|
|
|
|
// Our LED strip has a density of 120 LEDs per meter
|
2025-11-07 20:00:05 -05:00
|
|
|
wpi::units::meter_t kLedSpacing{1 / 120.0};
|
2024-06-05 22:41:10 -04:00
|
|
|
|
|
|
|
|
// Create an LED pattern that will display a rainbow across
|
|
|
|
|
// all hues at maximum saturation and half brightness
|
2025-11-07 20:00:05 -05:00
|
|
|
wpi::LEDPattern m_rainbow = wpi::LEDPattern::Rainbow(255, 128);
|
2024-06-05 22:41:10 -04:00
|
|
|
|
|
|
|
|
// Create a new pattern that scrolls the rainbow pattern across the LED
|
|
|
|
|
// strip, moving at a speed of 1 meter per second.
|
2025-11-07 20:00:05 -05:00
|
|
|
wpi::LEDPattern m_scrollingRainbow =
|
2024-06-05 22:41:10 -04:00
|
|
|
m_rainbow.ScrollAtAbsoluteSpeed(1_mps, kLedSpacing);
|
2022-12-08 07:47:47 +02:00
|
|
|
};
|