mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-26 01:51:41 +00:00
Add multi PDP getter and sim PCM/PDP multi arg functions (#2014)
This commit is contained in:
committed by
Peter Johnson
parent
931b8ceefd
commit
2ad15cae19
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -49,6 +49,23 @@ DEFINE_CAPI(HAL_Bool, ClosedLoopEnabled, closedLoopEnabled)
|
||||
DEFINE_CAPI(HAL_Bool, PressureSwitch, pressureSwitch)
|
||||
DEFINE_CAPI(double, CompressorCurrent, compressorCurrent)
|
||||
|
||||
void HALSIM_GetPCMAllSolenoids(int32_t index, uint8_t* values) {
|
||||
auto& data = SimPCMData[index].solenoidOutput;
|
||||
uint8_t ret = 0;
|
||||
for (int i = 0; i < kNumSolenoidChannels; i++) {
|
||||
ret |= (data[i] << i);
|
||||
}
|
||||
*values = ret;
|
||||
}
|
||||
|
||||
void HALSIM_SetPCMAllSolenoids(int32_t index, uint8_t values) {
|
||||
auto& data = SimPCMData[index].solenoidOutput;
|
||||
for (int i = 0; i < kNumSolenoidChannels; i++) {
|
||||
data[i] = (values & 0x1) != 0;
|
||||
values >>= 1;
|
||||
}
|
||||
}
|
||||
|
||||
#define REGISTER(NAME) \
|
||||
SimPCMData[index].NAME.RegisterCallback(callback, param, initialNotify)
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -42,6 +42,20 @@ DEFINE_CAPI(double, Voltage, voltage)
|
||||
HAL_SIMDATAVALUE_DEFINE_CAPI_CHANNEL(double, HALSIM, PDPCurrent, SimPDPData,
|
||||
current)
|
||||
|
||||
void HALSIM_GetPDPAllCurrents(int32_t index, double* currents) {
|
||||
auto& data = SimPDPData[index].current;
|
||||
for (int i = 0; i < kNumPDPChannels; i++) {
|
||||
currents[i] = data[i];
|
||||
}
|
||||
}
|
||||
|
||||
void HALSIM_SetPDPAllCurrents(int32_t index, const double* currents) {
|
||||
auto& data = SimPDPData[index].current;
|
||||
for (int i = 0; i < kNumPDPChannels; i++) {
|
||||
data[i] = currents[i];
|
||||
}
|
||||
}
|
||||
|
||||
#define REGISTER(NAME) \
|
||||
SimPDPData[index].NAME.RegisterCallback(callback, param, initialNotify)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user