summaryrefslogtreecommitdiff
path: root/RobotFirmware/lib/HexaNRL/src/examples/ExampleSubsystem.h
diff options
context:
space:
mode:
authorBEAST <macbook@Macbooks-MacBook-Pro-2.local>2026-11-17 09:40:39 +0530
committerBEAST <macbook@Macbooks-MacBook-Pro-2.local>2026-11-17 09:40:39 +0530
commitd358423b15bbd89ca8b34bb4ffc787811774105a (patch)
tree5fa7233c0d5752d59e95c8070e28cd7d09b3170c /RobotFirmware/lib/HexaNRL/src/examples/ExampleSubsystem.h
Add local files and custom README
Diffstat (limited to 'RobotFirmware/lib/HexaNRL/src/examples/ExampleSubsystem.h')
-rw-r--r--RobotFirmware/lib/HexaNRL/src/examples/ExampleSubsystem.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/RobotFirmware/lib/HexaNRL/src/examples/ExampleSubsystem.h b/RobotFirmware/lib/HexaNRL/src/examples/ExampleSubsystem.h
new file mode 100644
index 0000000..b85a3c8
--- /dev/null
+++ b/RobotFirmware/lib/HexaNRL/src/examples/ExampleSubsystem.h
@@ -0,0 +1,41 @@
+#pragma once
+#include "NRL.h"
+
+// ============================================================
+// ExampleSubsystem.h — optional subsystem pattern
+// ============================================================
+// You do NOT need to use this. If your code is simple, put
+// everything directly in your own opmode file.
+//
+// Use this pattern when you want to group hardware belonging
+// to one mechanism (arm, intake, shooter, etc.) into its own
+// class with named states — the same way AG_2026 works.
+//
+// Pattern:
+// 1. Define an enum for the states your mechanism can be in
+// 2. Write update() to switch hardware based on the state
+// 3. Expose command() to return an Action for use in sequences
+//
+// Then in your OpMode:
+// #include "examples/ExampleSubsystem.h"
+// ExampleSubsystem mySub;
+// runBlocking(mySub.command(ExampleSubsystem::GRAB));
+
+class ExampleSubsystem {
+public:
+ enum State { INIT, GRAB, RELEASE };
+
+ // Update hardware immediately
+ void update(State s) {
+ switch (s) {
+ case INIT: arm.setPosition(90); break;
+ case GRAB: arm.setPosition(0); break;
+ case RELEASE: arm.setPosition(180); break;
+ }
+ }
+
+ // Return an Action that can be used in sequential() / parallel()
+ ActionPtr command(State s) {
+ return instant([this, s]() { update(s); });
+ }
+};