Files
allwpilib/hal/src/main/native/sim/Accelerometer.cpp
Peter Johnson c0ff6198b3 Change hal sim to use spinlocks (#1291)
This makes callback registration completely thread safe.

This patch also uses templates and macros to dramatically reduce the amount of
manual boilerplate.
2018-09-03 16:08:07 -07:00

32 lines
1.1 KiB
C++

/*----------------------------------------------------------------------------*/
/* Copyright (c) 2017-2018 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. */
/*----------------------------------------------------------------------------*/
#include "hal/Accelerometer.h"
#include "mockdata/AccelerometerDataInternal.h"
using namespace hal;
namespace hal {
namespace init {
void InitializeAccelerometer() {}
} // namespace init
} // namespace hal
extern "C" {
void HAL_SetAccelerometerActive(HAL_Bool active) {
SimAccelerometerData[0].active = active;
}
void HAL_SetAccelerometerRange(HAL_AccelerometerRange range) {
SimAccelerometerData[0].range = range;
}
double HAL_GetAccelerometerX(void) { return SimAccelerometerData[0].x; }
double HAL_GetAccelerometerY(void) { return SimAccelerometerData[0].y; }
double HAL_GetAccelerometerZ(void) { return SimAccelerometerData[0].z; }
} // extern "C"