Convert BufferedSolenoid to use HAL.
Change-Id: Ibb1f5d800923b340a4632ad79611442dc54aec34
diff --git a/frc971/wpilib/buffered_pcm.h b/frc971/wpilib/buffered_pcm.h
index 4ff625b..877e830 100644
--- a/frc971/wpilib/buffered_pcm.h
+++ b/frc971/wpilib/buffered_pcm.h
@@ -3,8 +3,7 @@
#include <memory>
-#include "Solenoid.h"
-#undef ERROR
+#include <HAL/HAL.h>
#include "frc971/wpilib/buffered_solenoid.h"
@@ -17,24 +16,28 @@
// The way to use this is to call MakeSolenoid for whichever solenoid numbers
// you want, call Set on those, and then periodically call Flush on this object
// to write all of the buffered values out.
-class BufferedPcm : public Solenoid {
+class BufferedPcm {
public:
- explicit BufferedPcm() : Solenoid(0) {}
+ explicit BufferedPcm(int module = 0);
// Creates a new BufferedSolenoid for a specified port number.
::std::unique_ptr<BufferedSolenoid> MakeSolenoid(int number);
+ // Returns a bitmask of the state of all the solenoids.
+ int32_t GetAll();
+
// Actually sends all of the values out.
void Flush();
private:
- // WPILib declares this pure virtual and then never calls it...
-#ifdef WPILIB2015
- virtual void InitSolenoid() override {}
-#endif
-
void DoSet(int number, bool value);
+ int module_;
+ ::std::array<HAL_SolenoidHandle, 8> solenoid_handles_{
+ {HAL_kInvalidHandle, HAL_kInvalidHandle, HAL_kInvalidHandle,
+ HAL_kInvalidHandle, HAL_kInvalidHandle, HAL_kInvalidHandle,
+ HAL_kInvalidHandle, HAL_kInvalidHandle}};
+
uint8_t values_ = 0;
friend class BufferedSolenoid;