Allow for falcon inverting in swerve_module

Signed-off-by: Maxwell Henderson <maxwell.henderson@mailbox.org>
Change-Id: Ibbe7a28396fa3f249788d3f7b1e18d3eb384f0ec
diff --git a/frc971/wpilib/falcon.cc b/frc971/wpilib/falcon.cc
index 014556d..c3ff26d 100644
--- a/frc971/wpilib/falcon.cc
+++ b/frc971/wpilib/falcon.cc
@@ -3,11 +3,12 @@
 using frc971::wpilib::Falcon;
 using frc971::wpilib::kMaxBringupPower;
 
-Falcon::Falcon(int device_id, std::string canbus,
+Falcon::Falcon(int device_id, bool inverted, std::string canbus,
                std::vector<ctre::phoenix6::BaseStatusSignal *> *signals,
                double stator_current_limit, double supply_current_limit)
     : talon_(device_id, canbus),
       device_id_(device_id),
+      inverted_(inverted),
       device_temp_(talon_.GetDeviceTemp()),
       supply_voltage_(talon_.GetSupplyVoltage()),
       supply_current_(talon_.GetSupplyCurrent()),
@@ -37,6 +38,12 @@
   signals->push_back(&duty_cycle_);
 }
 
+Falcon::Falcon(FalconParams params, std::string canbus,
+               std::vector<ctre::phoenix6::BaseStatusSignal *> *signals,
+               double stator_current_limit, double supply_current_limit)
+    : Falcon(params.device_id, params.inverted, canbus, signals,
+             stator_current_limit, supply_current_limit) {}
+
 void Falcon::PrintConfigs() {
   ctre::phoenix6::configs::TalonFXConfiguration configuration;
   ctre::phoenix::StatusCode status =
@@ -48,9 +55,7 @@
   AOS_LOG(INFO, "configuration: %s", configuration.ToString().c_str());
 }
 
-void Falcon::WriteConfigs(ctre::phoenix6::signals::InvertedValue invert) {
-  inverted_ = invert;
-
+void Falcon::WriteConfigs() {
   ctre::phoenix6::configs::CurrentLimitsConfigs current_limits;
   current_limits.StatorCurrentLimit = stator_current_limit_;
   current_limits.StatorCurrentLimitEnable = true;
diff --git a/frc971/wpilib/falcon.h b/frc971/wpilib/falcon.h
index d516290..6ea8735 100644
--- a/frc971/wpilib/falcon.h
+++ b/frc971/wpilib/falcon.h
@@ -18,19 +18,28 @@
 namespace frc971 {
 namespace wpilib {
 
+struct FalconParams {
+  int device_id;
+  bool inverted;
+};
+
 static constexpr units::frequency::hertz_t kCANUpdateFreqHz = 200_Hz;
 static constexpr double kMaxBringupPower = 12.0;
 
 // Gets info from and writes to falcon motors using the TalonFX controller.
 class Falcon {
  public:
-  Falcon(int device_id, std::string canbus,
+  Falcon(int device_id, bool inverted, std::string canbus,
+         std::vector<ctre::phoenix6::BaseStatusSignal *> *signals,
+         double stator_current_limit, double supply_current_limit);
+
+  Falcon(FalconParams params, std::string canbus,
          std::vector<ctre::phoenix6::BaseStatusSignal *> *signals,
          double stator_current_limit, double supply_current_limit);
 
   void PrintConfigs();
 
-  void WriteConfigs(ctre::phoenix6::signals::InvertedValue invert);
+  void WriteConfigs();
   ctre::phoenix::StatusCode WriteCurrent(double current, double max_voltage);
 
   ctre::phoenix6::hardware::TalonFX *talon() { return &talon_; }
diff --git a/frc971/wpilib/swerve/swerve_drivetrain_writer.cc b/frc971/wpilib/swerve/swerve_drivetrain_writer.cc
index 2b6ef9e..bfc5d73 100644
--- a/frc971/wpilib/swerve/swerve_drivetrain_writer.cc
+++ b/frc971/wpilib/swerve/swerve_drivetrain_writer.cc
@@ -37,8 +37,8 @@
 
 void DrivetrainWriter::WriteConfigs() {
   for (auto module : {front_left_, front_right_, back_left_, back_right_}) {
-    module->rotation->WriteConfigs(false);
-    module->translation->WriteConfigs(false);
+    module->rotation->WriteConfigs();
+    module->translation->WriteConfigs();
   }
 }
 
diff --git a/frc971/wpilib/swerve/swerve_module.h b/frc971/wpilib/swerve/swerve_module.h
index 534f0ce..f449afa 100644
--- a/frc971/wpilib/swerve/swerve_module.h
+++ b/frc971/wpilib/swerve/swerve_module.h
@@ -8,14 +8,15 @@
 namespace swerve {
 
 struct SwerveModule {
-  SwerveModule(int rotation_id, int translation_id, std::string canbus,
+  SwerveModule(FalconParams rotation_params, FalconParams translation_params,
+               std::string canbus,
                std::vector<ctre::phoenix6::BaseStatusSignal *> *signals,
                double stator_current_limit, double supply_current_limit)
-      : rotation(std::make_shared<Falcon>(rotation_id, canbus, signals,
+      : rotation(std::make_shared<Falcon>(rotation_params, canbus, signals,
                                           stator_current_limit,
                                           supply_current_limit)),
-        translation(std::make_shared<Falcon>(translation_id, canbus, signals,
-                                             stator_current_limit,
+        translation(std::make_shared<Falcon>(translation_params, canbus,
+                                             signals, stator_current_limit,
                                              supply_current_limit)) {}
 
   void WriteModule(