mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-28 02:11:43 +00:00
[hal] Fix unfinished/incorrect GetCPUTemp functions (#5598)
This commit is contained in:
@@ -284,6 +284,23 @@ void RoboRioSim::SetBrownoutVoltage(units::volt_t vInVoltage) {
|
||||
HALSIM_SetRoboRioBrownoutVoltage(vInVoltage.value());
|
||||
}
|
||||
|
||||
std::unique_ptr<CallbackStore> RoboRioSim::RegisterCPUTempCallback(
|
||||
NotifyCallback callback, bool initialNotify) {
|
||||
auto store = std::make_unique<CallbackStore>(
|
||||
-1, callback, &HALSIM_CancelRoboRioCPUTempCallback);
|
||||
store->SetUid(HALSIM_RegisterRoboRioCPUTempCallback(
|
||||
&CallbackStoreThunk, store.get(), initialNotify));
|
||||
return store;
|
||||
}
|
||||
|
||||
units::celsius_t RoboRioSim::GetCPUTemp() {
|
||||
return units::celsius_t{HALSIM_GetRoboRioCPUTemp()};
|
||||
}
|
||||
|
||||
void RoboRioSim::SetCPUTemp(units::celsius_t cpuTemp) {
|
||||
HALSIM_SetRoboRioCPUTemp(cpuTemp.value());
|
||||
}
|
||||
|
||||
std::string RoboRioSim::GetSerialNumber() {
|
||||
char serialNum[9];
|
||||
size_t len = HALSIM_GetRoboRioSerialNumber(serialNum, sizeof(serialNum));
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <string>
|
||||
|
||||
#include <units/current.h>
|
||||
#include <units/temperature.h>
|
||||
#include <units/voltage.h>
|
||||
|
||||
#include "frc/simulation/CallbackStore.h"
|
||||
@@ -435,6 +436,31 @@ class RoboRioSim {
|
||||
*/
|
||||
static void SetBrownoutVoltage(units::volt_t brownoutVoltage);
|
||||
|
||||
/**
|
||||
* Register a callback to be run whenever the cpu temp changes.
|
||||
*
|
||||
* @param callback the callback
|
||||
* @param initialNotify whether to call the callback with the initial state
|
||||
* @return the CallbackStore object associated with this callback
|
||||
*/
|
||||
[[nodiscard]]
|
||||
static std::unique_ptr<CallbackStore> RegisterCPUTempCallback(
|
||||
NotifyCallback callback, bool initialNotify);
|
||||
|
||||
/**
|
||||
* Get the cpu temp.
|
||||
*
|
||||
* @return the cpu temp.
|
||||
*/
|
||||
static units::celsius_t GetCPUTemp();
|
||||
|
||||
/**
|
||||
* Define the cpu temp.
|
||||
*
|
||||
* @param cpuTemp the new cpu temp.
|
||||
*/
|
||||
static void SetCPUTemp(units::celsius_t cpuTemp);
|
||||
|
||||
/**
|
||||
* Get the serial number.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user