[examples] AddressableLED: Add unit test (#4779)

This commit is contained in:
Starlight220
2022-12-08 07:47:47 +02:00
committed by GitHub
parent b390cad095
commit fba191099c
5 changed files with 179 additions and 44 deletions

View File

@@ -0,0 +1,28 @@
// 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>
#include <frc/AddressableLED.h>
#include <frc/TimedRobot.h>
class Robot : public frc::TimedRobot {
public:
void Rainbow();
void RobotInit() override;
void RobotPeriodic() override;
private:
static constexpr int kLength = 60;
// PWM port 9
// Must be a PWM header, not MXP or DIO
frc::AddressableLED m_led{9};
std::array<frc::AddressableLED::LEDData, kLength>
m_ledBuffer; // Reuse the buffer
// Store what the last hue of the first pixel is
int firstPixelHue = 0;
};