2020-12-26 14:12:05 -08:00
|
|
|
// Copyright (c) FIRST and other WPILib contributors.
|
|
|
|
|
// Open Source Software; you can modify and/or share it under the terms of
|
|
|
|
|
// the WPILib BSD license file in the root directory of this project.
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2018-07-20 00:03:45 -07:00
|
|
|
#include "frc/GearTooth.h"
|
2016-09-25 16:50:13 -07:00
|
|
|
|
2018-07-20 00:03:45 -07:00
|
|
|
#include "frc/smartdashboard/SendableBuilder.h"
|
2019-09-14 15:22:54 -05:00
|
|
|
#include "frc/smartdashboard/SendableRegistry.h"
|
2013-12-15 18:30:16 -05:00
|
|
|
|
2016-11-01 22:33:12 -07:00
|
|
|
using namespace frc;
|
|
|
|
|
|
2013-12-15 18:30:16 -05:00
|
|
|
constexpr double GearTooth::kGearToothThreshold;
|
|
|
|
|
|
2016-09-06 00:01:45 -07:00
|
|
|
GearTooth::GearTooth(int channel, bool directionSensitive) : Counter(channel) {
|
2015-06-25 15:07:55 -04:00
|
|
|
EnableDirectionSensing(directionSensitive);
|
2019-09-14 15:22:54 -05:00
|
|
|
SendableRegistry::GetInstance().SetName(this, "GearTooth", channel);
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
2016-05-20 17:30:37 -07:00
|
|
|
GearTooth::GearTooth(DigitalSource* source, bool directionSensitive)
|
2015-06-25 15:07:55 -04:00
|
|
|
: Counter(source) {
|
|
|
|
|
EnableDirectionSensing(directionSensitive);
|
2019-09-14 15:22:54 -05:00
|
|
|
SendableRegistry::GetInstance().SetName(this, "GearTooth",
|
|
|
|
|
source->GetChannel());
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
2016-05-20 17:30:37 -07:00
|
|
|
GearTooth::GearTooth(std::shared_ptr<DigitalSource> source,
|
|
|
|
|
bool directionSensitive)
|
2015-06-25 15:07:55 -04:00
|
|
|
: Counter(source) {
|
|
|
|
|
EnableDirectionSensing(directionSensitive);
|
2019-09-14 15:22:54 -05:00
|
|
|
SendableRegistry::GetInstance().SetName(this, "GearTooth",
|
|
|
|
|
source->GetChannel());
|
2013-12-15 18:30:16 -05:00
|
|
|
}
|
|
|
|
|
|
2018-05-31 20:47:15 -07:00
|
|
|
void GearTooth::EnableDirectionSensing(bool directionSensitive) {
|
|
|
|
|
if (directionSensitive) {
|
|
|
|
|
SetPulseLengthMode(kGearToothThreshold);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-04 23:28:33 -08:00
|
|
|
void GearTooth::InitSendable(SendableBuilder& builder) {
|
|
|
|
|
Counter::InitSendable(builder);
|
|
|
|
|
builder.SetSmartDashboardType("Gear Tooth");
|
|
|
|
|
}
|