CTRE Phoenix 6 C++ 26.50.0-alpha-1
Loading...
Searching...
No Matches
CANdle.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) Cross The Road Electronics.  All rights reserved.
3 * License information can be found in CTRE_LICENSE.txt
4 * For support and suggestions contact support@ctr-electronics.com or file
5 * an issue tracker at https://github.com/CrossTheRoadElec/Phoenix-Releases
6 */
7#pragma once
8
10
11#include <wpi/hal/SimDevice.hpp>
12
13namespace ctre {
14namespace phoenix6 {
15namespace hardware {
16
17#if defined(_WIN32) || defined(_WIN64)
18#pragma warning(push)
19#pragma warning(disable : 4250)
20#endif
21
22/**
23 * Class for CTR Electronics' CANdle® branded device,
24 * a device that controls LEDs over the CAN bus.
25 */
26class CANdle : public core::CoreCANdle {
27 /*
28 * The StatusSignal getters are copies so that calls
29 * to the WPI interface do not update any references
30 *
31 * These are also mutable so the const getter methods are
32 * properly managed.
33 */
34
35 wpi::hal::SimDevice m_simCANdle;
36 wpi::hal::SimDouble m_simSupplyVoltage;
37 wpi::hal::SimDouble m_simFiveVRail;
38 wpi::hal::SimDouble m_simOutputCurrent;
39 wpi::hal::SimDouble m_simTemperature;
40 wpi::hal::SimDouble m_simVBatModulation;
41
42 int32_t m_simPeriodicUid{-1};
43 std::vector<int32_t> m_simValueChangedUids;
44
45 static void OnValueChanged(
46 const char *name, void *param, HAL_SimValueHandle handle,
47 HAL_Bool readonly, const struct HAL_Value *value
48 );
49 static void OnPeriodic(void *param);
50
51public:
52 /** The number of animation slots. */
53 static constexpr int kAnimSlotCount = 8;
54
55 /**
56 * Constructs a new CANdle object.
57 *
58 * \param deviceId ID of the device, as configured in Phoenix Tuner
59 * \param canbus The CAN bus this device is on
60 */
61 CANdle(int deviceId, CANBus canbus);
62
64
65 /**
66 * \brief Constructs a stubbed-out CANdle, where all status signals, controls,
67 * configs, etc. perform no action and immediately return OK. This can be used to
68 * silence error messages for devices that have been completely removed from the robot.
69 *
70 * \returns Stubbed-out CANdle
71 */
72 static CANdle None()
73 {
74 return CANdle{-1, CANBus{}};
75 }
76
77 /**
78 * \brief Clears all animations on the CANdle. This is equivalent to applying a
79 * controls#EmptyAnimation to all the animation slots on the CANdle.
80 *
81 * \returns Status code of the first failed control call, or OK if all succeeded
82 */
84};
85
86#if defined(_WIN32) || defined(_WIN64)
87#pragma warning(pop)
88#endif
89
90}
91}
92}
Class for getting information about an available CAN bus.
Definition CANBus.hpp:19
ctre::phoenix::StatusCode ClearAllAnimations()
Clears all animations on the CANdle.
static CANdle None()
Constructs a stubbed-out CANdle, where all status signals, controls, configs, etc.
Definition CANdle.hpp:72
CANdle(int deviceId, CANBus canbus)
Constructs a new CANdle object.
static constexpr int kAnimSlotCount
The number of animation slots.
Definition CANdle.hpp:53
Class for CTR Electronics' CANdle® branded device, a device that controls LEDs over the CAN bus.
Definition CoreCANdle.hpp:839
Status codes reported by APIs, including OK, warnings, and errors.
Definition StatusCodes.h:28
Definition ExternalFeedbackConfigs.hpp:17
Definition ExternalFeedbackConfigs.hpp:16
Definition motor_constants.h:14