📄 cvictor.cpp
字号:
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008. 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 $(WIND_BASE)/WPILib. */
/*----------------------------------------------------------------------------*/
#include "CVictor.h"
#include "CPWM.h"
#include "Victor.h"
/**
* Create an instance of a Victor object (used internally by this module)
*
* @param slot The slot that the digital module is plugged into
* @param channel The PWM channel that the motor is plugged into */
static SensorBase *CreateVictor(UINT32 slot, UINT32 channel)
{
return new Victor(slot, channel);
}
/**
* Set the PWM value.
*
* The PWM value is set using a range of -1.0 to 1.0, appropriately
* scaling the value for the FPGA.
*
* @param slot The slot the digital module is plugged into
* @param channel The PWM channel used for this Victor
* @param speed The speed value between -1.0 and 1.0 to set.
*/
void SetVictorSpeed(UINT32 slot, UINT32 channel, float speed)
{
Victor *victor = (Victor *) AllocatePWM(slot, channel, CreateVictor);
if (victor) victor->Set(speed);
}
/**
* Set the PWM value directly to the hardware.
*
* Write a raw value to a PWM channel.
*
* @param channel The PWM channel used for this Victor
* @param value Raw PWM value. Range 0 - 255.
*/
void SetVictorRaw(UINT32 channel, UINT8 value)
{
Victor *victor = (Victor *) AllocatePWM(channel, CreateVictor);
if (victor) victor->SetRaw(value);
}
/**
* Set the PWM value.
*
* The PWM value is set using a range of -1.0 to 1.0, appropriately
* scaling the value for the FPGA.
*
* @param channel The PWM channel used for this Victor
* @param speed The speed value between -1.0 and 1.0 to set.
*/
void SetVictorSpeed(UINT32 channel, float speed)
{
Victor *victor = (Victor *) AllocatePWM(channel, CreateVictor);
if (victor) victor->Set(speed);
}
/**
* Get the PWM value directly from the hardware.
*
* Read a raw value from a PWM channel.
*
* @param channel The PWM channel used for this Victor
* @return Raw PWM control value. Range: 0 - 255.
*/
UINT8 GetVictorRaw(UINT32 channel)
{
Victor *victor = (Victor *) AllocatePWM(channel, CreateVictor);
if (victor)
return victor->GetRaw();
else
return 0;
}
/**
* Set the PWM value directly to the hardware.
*
* Write a raw value to a PWM channel.
*
* @param slot The slot the digital module is plugged into
* @param channel The PWM channel used for this Victor
* @param value Raw PWM value. Range 0 - 255.
*/
void SetVictorRaw(UINT32 slot, UINT32 channel, UINT8 value)
{
Victor *victor = (Victor *) AllocatePWM(slot, channel, CreateVictor);
if (victor) victor->SetRaw(value);
}
/**
* Get the PWM value directly from the hardware.
*
* Read a raw value from a PWM channel.
*
* @param slot The slot the digital module is plugged into
* @param channel The PWM channel used for this Victor
* @return Raw PWM control value. Range: 0 - 255.
*/
UINT8 GetVictorRaw(UINT32 slot, UINT32 channel)
{
Victor *victor = (Victor *) AllocatePWM(slot, channel, CreateVictor);
if (victor)
return victor->GetRaw();
else
return 0;
}
/**
* Delete resources for a Victor
* Free the underlying object and delete the allocated resources for the Victor
*
* @param slot The slot the digital module is plugged into
* @param channel The PWM channel used for this Victor */
void DeleteVictor(UINT32 slot, UINT32 channel)
{
Victor *victor = (Victor *) AllocatePWM(slot, channel, CreateVictor);
delete victor;
DeletePWM(slot, channel);
}
/**
* Delete resources for a Victor
* Free the underlying object and delete the allocated resources for the Victor
*
* @param channel The PWM channel used for this Victor
*/
void DeleteVictor(UINT32 channel)
{
DeleteVictor(SensorBase::GetDefaultDigitalModule(), channel);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -