mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[hal, wpilib] Update Addressable LED support (#8100)
This commit is contained in:
@@ -28,9 +28,6 @@ class PWMSimModel : public glass::PWMModel {
|
||||
|
||||
bool Exists() override { return HALSIM_GetPWMInitialized(m_index); }
|
||||
|
||||
void SetAddressableLED(int led) { m_led = led; }
|
||||
int GetAddressableLED() const override { return m_led; }
|
||||
|
||||
glass::DoubleSource* GetSpeedData() override { return &m_speed; }
|
||||
|
||||
void SetSpeed(double val) override {
|
||||
@@ -39,7 +36,6 @@ class PWMSimModel : public glass::PWMModel {
|
||||
|
||||
private:
|
||||
int32_t m_index;
|
||||
int m_led = -1;
|
||||
PWMPulseMicrosecondSource m_speed;
|
||||
};
|
||||
|
||||
@@ -68,21 +64,10 @@ void PWMsSimModel::Update() {
|
||||
if (!model) {
|
||||
model = std::make_unique<PWMSimModel>(i);
|
||||
}
|
||||
model->SetAddressableLED(-1);
|
||||
} else {
|
||||
model.reset();
|
||||
}
|
||||
}
|
||||
|
||||
static const int32_t numLED = HAL_GetNumAddressableLEDs();
|
||||
for (int32_t i = 0; i < numLED; ++i) {
|
||||
if (HALSIM_GetAddressableLEDInitialized(i)) {
|
||||
int32_t channel = HALSIM_GetAddressableLEDOutputPort(i);
|
||||
if (channel >= 0 && channel < numPWM && m_sources[channel]) {
|
||||
m_sources[channel]->SetAddressableLED(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PWMsSimModel::ForEachPWM(
|
||||
|
||||
Reference in New Issue
Block a user