// 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.

#include "wpi/framework/TimedRobot.hpp"
#include "wpi/hardware/accelerometer/AnalogAccelerometer.hpp"
#include "wpi/hardware/discrete/AnalogInput.hpp"

/**
 * AnalogAccelerometer snippets for wpilib-docs.
 * https://docs.wpilib.org/en/stable/docs/software/hardware-apis/sensors/accelerometers-software.html
 */
class Robot : public wpi::TimedRobot {
 public:
  Robot() {
    // Sets the sensitivity of the accelerometer to 1 volt per G
    accelerometer.SetSensitivity(1);
    // Sets the zero voltage of the accelerometer to 3 volts
    accelerometer.SetZero(3);
  }

  void TeleopPeriodic() override {
    // Gets the current acceleration
    accelerometer.GetAcceleration();
  }

 private:
  // Creates an analog accelerometer on analog input 0
  wpi::AnalogAccelerometer accelerometer{0};
};

#ifndef RUNNING_WPILIB_TESTS
int main() {
  return wpi::StartRobot<Robot>();
}
#endif
