// 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 #include "frc/simulation/CallbackStore.h" struct HAL_AddressableLEDData; namespace frc { class AddressableLED; namespace sim { /** * Class to control a simulated addressable LED. */ class AddressableLEDSim { public: /** * Constructs for the first addressable LED. */ AddressableLEDSim(); /** * Constructs from an AddressableLED object. * * @param addressableLED AddressableLED to simulate */ explicit AddressableLEDSim(const AddressableLED& addressableLED); /** * Creates an AddressableLEDSim for a PWM channel. * * @param pwmChannel PWM channel * @return Simulated object * @throws std::out_of_range if no AddressableLED is configured for that * channel */ static AddressableLEDSim CreateForChannel(int pwmChannel); /** * Creates an AddressableLEDSim for a simulated index. * The index is incremented for each simulated AddressableLED. * * @param index simulator index * @return Simulated object */ static AddressableLEDSim CreateForIndex(int index); std::unique_ptr RegisterInitializedCallback( NotifyCallback callback, bool initialNotify); bool GetInitialized() const; void SetInitialized(bool initialized); std::unique_ptr RegisterOutputPortCallback( NotifyCallback callback, bool initialNotify); int GetOutputPort() const; void SetOutputPort(int outputPort); std::unique_ptr RegisterLengthCallback(NotifyCallback callback, bool initialNotify); int GetLength() const; void SetLength(int length); std::unique_ptr RegisterRunningCallback( NotifyCallback callback, bool initialNotify); int GetRunning() const; void SetRunning(bool running); std::unique_ptr RegisterDataCallback(NotifyCallback callback, bool initialNotify); int GetData(struct HAL_AddressableLEDData* data) const; void SetData(struct HAL_AddressableLEDData* data, int length); private: explicit AddressableLEDSim(int index) : m_index{index} {} int m_index; }; } // namespace sim } // namespace frc