mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[sim] Add WPILib-class-taking constructors (#2538)
When not direct mapped, make index constructors private and add factory functions for channel and index. Co-authored-by: GabrielDeml <gabrielddeml@gmail.com>
This commit is contained in:
@@ -36,6 +36,16 @@ void EncoderData::ResetData() {
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
int32_t HALSIM_FindEncoderForChannel(int32_t channel) {
|
||||
for (int i = 0; i < kNumEncoders; ++i) {
|
||||
if (!SimEncoderData[i].initialized) continue;
|
||||
if (SimEncoderData[i].digitalChannelA == channel ||
|
||||
SimEncoderData[i].digitalChannelB == channel)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void HALSIM_ResetEncoderData(int32_t index) {
|
||||
SimEncoderData[index].ResetData();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user