blob: d8d3b2a43b5eff3c4ec856478ebeb44a0a14a13d [file] [log] [blame]
James Kuszmaul4f3ad3c2019-12-01 16:35:21 -08001/*----------------------------------------------------------------------------*/
2/* Copyright (c) 2019 FIRST. All Rights Reserved. */
3/* 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/PWMSparkMax.h"
9
10#include <hal/HAL.h>
11
12#include "frc/smartdashboard/SendableRegistry.h"
13
14using namespace frc;
15
16PWMSparkMax::PWMSparkMax(int channel) : PWMSpeedController(channel) {
17 /* Note that the SparkMax uses the following bounds for PWM values.
18 *
19 * 2.003ms = full "forward"
20 * 1.55ms = the "high end" of the deadband range
21 * 1.50ms = center of the deadband range (off)
22 * 1.46ms = the "low end" of the deadband range
23 * 0.999ms = full "reverse"
24 */
25 SetBounds(2.003, 1.55, 1.50, 1.46, .999);
26 SetPeriodMultiplier(kPeriodMultiplier_1X);
27 SetSpeed(0.0);
28 SetZeroLatch();
29
30 HAL_Report(HALUsageReporting::kResourceType_RevSparkMaxPWM, GetChannel());
31 SendableRegistry::GetInstance().SetName(this, "PWMSparkMax", GetChannel());
32}