mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-27 02:01:42 +00:00
Renamed folders for consistency, using sim/athena/shared schema (#27)
Rename the following folders: hal/lib/Athena -> hal/lib/athena hal/lib/Desktop -> hal/lib/sim hal/lib/Shared -> hal/lib/shared wpilibc/Athena -> wpilibc/athena wpilibc/simulation -> wpilibc/sim Windows users may need to run gradlew clean after updating.
This commit is contained in:
committed by
Peter Johnson
parent
54092378e9
commit
e71f454b9d
83
wpilibc/sim/src/AnalogInput.cpp
Normal file
83
wpilibc/sim/src/AnalogInput.cpp
Normal file
@@ -0,0 +1,83 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2008-2016. 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 "AnalogInput.h"
|
||||
#include "LiveWindow/LiveWindow.h"
|
||||
#include "WPIErrors.h"
|
||||
|
||||
/**
|
||||
* Construct an analog input.
|
||||
*
|
||||
* @param channel The channel number to represent.
|
||||
*/
|
||||
AnalogInput::AnalogInput(uint32_t channel) {
|
||||
m_channel = channel;
|
||||
char buffer[50];
|
||||
int n = sprintf(buffer, "analog/%d", channel);
|
||||
m_impl = new SimFloatInput(buffer);
|
||||
|
||||
LiveWindow::GetInstance()->AddSensor("AnalogInput", channel, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a scaled sample straight from this channel.
|
||||
*
|
||||
* The value is scaled to units of Volts using the calibrated scaling data from
|
||||
* GetLSBWeight() and GetOffset().
|
||||
*
|
||||
* @return A scaled sample straight from this channel.
|
||||
*/
|
||||
float AnalogInput::GetVoltage() const { return m_impl->Get(); }
|
||||
|
||||
/**
|
||||
* Get a scaled sample from the output of the oversample and average engine for
|
||||
* this channel.
|
||||
*
|
||||
* The value is scaled to units of Volts using the calibrated scaling data from
|
||||
* GetLSBWeight() and GetOffset(). Using oversampling will cause this value to
|
||||
* be higher resolution, but it will update more slowly. Using averaging will
|
||||
* cause this value to be more stable, but it will update more slowly.
|
||||
*
|
||||
* @return A scaled sample from the output of the oversample and average engine
|
||||
* for this channel.
|
||||
*/
|
||||
float AnalogInput::GetAverageVoltage() const { return m_impl->Get(); }
|
||||
|
||||
/**
|
||||
* Get the channel number.
|
||||
*
|
||||
* @return The channel number.
|
||||
*/
|
||||
uint32_t AnalogInput::GetChannel() const { return m_channel; }
|
||||
|
||||
/**
|
||||
* Get the Average value for the PID Source base object.
|
||||
*
|
||||
* @return The average voltage.
|
||||
*/
|
||||
double AnalogInput::PIDGet() { return GetAverageVoltage(); }
|
||||
|
||||
void AnalogInput::UpdateTable() {
|
||||
if (m_table != nullptr) {
|
||||
m_table->PutNumber("Value", GetAverageVoltage());
|
||||
}
|
||||
}
|
||||
|
||||
void AnalogInput::StartLiveWindowMode() {}
|
||||
|
||||
void AnalogInput::StopLiveWindowMode() {}
|
||||
|
||||
std::string AnalogInput::GetSmartDashboardType() const {
|
||||
return "Analog Input";
|
||||
}
|
||||
|
||||
void AnalogInput::InitTable(std::shared_ptr<ITable> subTable) {
|
||||
m_table = subTable;
|
||||
UpdateTable();
|
||||
}
|
||||
|
||||
std::shared_ptr<ITable> AnalogInput::GetTable() const { return m_table; }
|
||||
Reference in New Issue
Block a user