added button edge logging + cleaned up various naming and comments
diff --git a/aos/atom_code/input/joystick_input.cc b/aos/atom_code/input/joystick_input.cc
index 01bcbc6..3c66606 100644
--- a/aos/atom_code/input/joystick_input.cc
+++ b/aos/atom_code/input/joystick_input.cc
@@ -46,7 +46,23 @@
}
data.Update(joysticks);
- // TODO(brians): posedge/negedge logging
+
+ {
+ using driver_station::JoystickFeature;
+ using driver_station::ButtonLocation;
+ for (int joystick = 0; joystick < JoystickFeature::kJoysticks;
+ ++joystick) {
+ for (int button = 0; button < ButtonLocation::kButtons; ++button) {
+ ButtonLocation location(joystick, button);
+ if (data.PosEdge(location)) {
+ LOG(INFO, "PosEdge(%d, %d)\n", joystick, button);
+ }
+ if (data.NegEdge(location)) {
+ LOG(INFO, "NegEdge(%d, %d)\n", joystick, button);
+ }
+ }
+ }
+ }
RunIteration(data);
}
diff --git a/aos/atom_code/input/joystick_input.h b/aos/atom_code/input/joystick_input.h
index d905eaa..de0ed9e 100644
--- a/aos/atom_code/input/joystick_input.h
+++ b/aos/atom_code/input/joystick_input.h
@@ -6,11 +6,17 @@
namespace aos {
namespace input {
+// A class for handling joystick packet values.
+// It will call RunIteration each time a new packet is received.
+//
+// This class automatically handles updating ::aos::robot_state and logging (at
+// INFO) button edges.
class JoystickInput {
public:
void Run();
private:
+ // Subclasses should do whatever they want with data here.
virtual void RunIteration(const driver_station::Data &data) = 0;
};