blob: 5fb50211601fc3f791a509420521ab9a54c3c334 [file] [log] [blame]
Brian Silverman41cdd3e2019-01-19 19:48:58 -08001/*----------------------------------------------------------------------------*/
James Kuszmaul4f3ad3c2019-12-01 16:35:21 -08002/* Copyright (c) 2008-2019 FIRST. All Rights Reserved. */
Brian Silverman41cdd3e2019-01-19 19:48:58 -08003/* Open Source Software - may be modified and shared by FRC teams. The code */
4/* must be accompanied by the FIRST BSD license file in the root directory of */
5/* the project. */
6/*----------------------------------------------------------------------------*/
7
8#include "frc/GearTooth.h"
9
10#include "frc/smartdashboard/SendableBuilder.h"
James Kuszmaul4f3ad3c2019-12-01 16:35:21 -080011#include "frc/smartdashboard/SendableRegistry.h"
Brian Silverman41cdd3e2019-01-19 19:48:58 -080012
13using namespace frc;
14
15constexpr double GearTooth::kGearToothThreshold;
16
17GearTooth::GearTooth(int channel, bool directionSensitive) : Counter(channel) {
18 EnableDirectionSensing(directionSensitive);
James Kuszmaul4f3ad3c2019-12-01 16:35:21 -080019 SendableRegistry::GetInstance().SetName(this, "GearTooth", channel);
Brian Silverman41cdd3e2019-01-19 19:48:58 -080020}
21
22GearTooth::GearTooth(DigitalSource* source, bool directionSensitive)
23 : Counter(source) {
24 EnableDirectionSensing(directionSensitive);
James Kuszmaul4f3ad3c2019-12-01 16:35:21 -080025 SendableRegistry::GetInstance().SetName(this, "GearTooth",
26 source->GetChannel());
Brian Silverman41cdd3e2019-01-19 19:48:58 -080027}
28
29GearTooth::GearTooth(std::shared_ptr<DigitalSource> source,
30 bool directionSensitive)
31 : Counter(source) {
32 EnableDirectionSensing(directionSensitive);
James Kuszmaul4f3ad3c2019-12-01 16:35:21 -080033 SendableRegistry::GetInstance().SetName(this, "GearTooth",
34 source->GetChannel());
Brian Silverman41cdd3e2019-01-19 19:48:58 -080035}
36
37void GearTooth::EnableDirectionSensing(bool directionSensitive) {
38 if (directionSensitive) {
39 SetPulseLengthMode(kGearToothThreshold);
40 }
41}
42
43void GearTooth::InitSendable(SendableBuilder& builder) {
44 Counter::InitSendable(builder);
45 builder.SetSmartDashboardType("Gear Tooth");
46}