From 9a89dbe6a5b9956e01bcdd701082eb16f821ab1e Mon Sep 17 00:00:00 2001 From: mattmcw Date: Thu, 9 Mar 2023 21:08:36 -0500 Subject: [PATCH] Automatically toggle debug state internally --- ino/lib/McopySerial/McopySerial.cpp | 8 ++++++++ ino/lib/McopySerial/McopySerial.h | 2 ++ ino/mcopy_cam_canon/McopySerial.cpp | 8 ++++++++ ino/mcopy_cam_canon/McopySerial.h | 2 ++ 4 files changed, 20 insertions(+) diff --git a/ino/lib/McopySerial/McopySerial.cpp b/ino/lib/McopySerial/McopySerial.cpp index d764af3..d8e40c4 100644 --- a/ino/lib/McopySerial/McopySerial.cpp +++ b/ino/lib/McopySerial/McopySerial.cpp @@ -13,12 +13,20 @@ void McopySerial::begin () { char McopySerial::loop () { if (Serial.available()) { cmdChar = (char) Serial.read(); + internal(); } else { cmdChar = 'z'; } return cmdChar; } +void McopySerial::internal () { + if (cmdChar == DEBUG) { + debugOn = !debugOn; + cmdChar = 'z'; + } +} + void McopySerial::setBaud (int baudRate) { baud = baudRate; } diff --git a/ino/lib/McopySerial/McopySerial.h b/ino/lib/McopySerial/McopySerial.h index 1b29d1b..505430f 100644 --- a/ino/lib/McopySerial/McopySerial.h +++ b/ino/lib/McopySerial/McopySerial.h @@ -10,6 +10,8 @@ class McopySerial { volatile bool debugOn = false; volatile char cmdChar = 'z'; + void internal (); + public: /* CMD FLAGS */ diff --git a/ino/mcopy_cam_canon/McopySerial.cpp b/ino/mcopy_cam_canon/McopySerial.cpp index d764af3..d8e40c4 100644 --- a/ino/mcopy_cam_canon/McopySerial.cpp +++ b/ino/mcopy_cam_canon/McopySerial.cpp @@ -13,12 +13,20 @@ void McopySerial::begin () { char McopySerial::loop () { if (Serial.available()) { cmdChar = (char) Serial.read(); + internal(); } else { cmdChar = 'z'; } return cmdChar; } +void McopySerial::internal () { + if (cmdChar == DEBUG) { + debugOn = !debugOn; + cmdChar = 'z'; + } +} + void McopySerial::setBaud (int baudRate) { baud = baudRate; } diff --git a/ino/mcopy_cam_canon/McopySerial.h b/ino/mcopy_cam_canon/McopySerial.h index 1b29d1b..505430f 100644 --- a/ino/mcopy_cam_canon/McopySerial.h +++ b/ino/mcopy_cam_canon/McopySerial.h @@ -10,6 +10,8 @@ class McopySerial { volatile bool debugOn = false; volatile char cmdChar = 'z'; + void internal (); + public: /* CMD FLAGS */