Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: errors.cpp
- Revision:
- 187:523cf8c962e4
- Parent:
- 181:d3510c8beab6
- Child:
- 193:3abadeecf908
diff -r c18db1e31da6 -r 523cf8c962e4 errors.cpp
--- a/errors.cpp	Fri Feb 09 22:25:44 2018 +0000
+++ b/errors.cpp	Fri Feb 09 23:24:25 2018 +0000
@@ -1,4 +1,6 @@
 #include "errors.h"
+#include "globals.h"
+#include "defaults.h"
 
 int errors = 0, moded_errors = 0;
 int masks[32];
@@ -15,4 +17,20 @@
                                     _MASK_OP_TORQUE | _MASK_OP_DRIVING |
                                     _MASK_SRC_RC | _MASK_SRC_ANALOG | _MASK_SRC_TERMINAL | _MASK_SRC_SERIAL |
                                     _MASK_SRC_CAN | _MASK_SRC_INTERNAL;
+}
+
+void go_enabled() {
+    control.enabled = true;
+    io.en->write(1);
+}
+
+void go_disabled() {
+    control.d_integral = 0.0f;
+    control.q_integral = 0.0f;
+    control.enabled = false;
+    io.en->write(0);
+}
+
+bool is_driving() {
+    return control.torque_percent > 0.01f || fabsf(read.w) > W_SAFE;
 }
\ No newline at end of file