mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
Add ability to associate other devices with a SimDevice
Implemented only for AnalogInput, DIO, and Encoder.
This commit is contained in:
@@ -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. */
|
||||
@@ -84,6 +84,7 @@ HAL_EncoderHandle HAL_InitializeEncoder(
|
||||
SimEncoderData[index].digitalChannelA = getHandleIndex(digitalSourceHandleA);
|
||||
SimEncoderData[index].initialized = true;
|
||||
SimEncoderData[index].reverseDirection = reverseDirection;
|
||||
SimEncoderData[index].simDevice = 0;
|
||||
// TODO: Add encoding type to Sim data
|
||||
encoder->index = index;
|
||||
encoder->nativeHandle = nativeHandle;
|
||||
@@ -104,6 +105,13 @@ void HAL_FreeEncoder(HAL_EncoderHandle encoderHandle, int32_t* status) {
|
||||
SimEncoderData[encoder->index].initialized = false;
|
||||
}
|
||||
|
||||
void HAL_SetEncoderSimDevice(HAL_EncoderHandle handle,
|
||||
HAL_SimDeviceHandle device) {
|
||||
auto encoder = encoderHandles->Get(handle);
|
||||
if (encoder == nullptr) return;
|
||||
SimEncoderData[encoder->index].simDevice = device;
|
||||
}
|
||||
|
||||
static inline int EncodingScaleFactor(Encoder* encoder) {
|
||||
switch (encoder->encodingType) {
|
||||
case HAL_Encoder_k1X:
|
||||
|
||||
Reference in New Issue
Block a user