From d7017af245165c75530becd10ba0f5babaece851 Mon Sep 17 00:00:00 2001 From: mattmcw Date: Thu, 9 Mar 2023 21:26:31 -0500 Subject: [PATCH] Move connect and identify methods to internal ones. --- ino/lib/McopySerial/McopySerial.cpp | 27 ++++++++++++++++++++------- ino/lib/McopySerial/McopySerial.h | 6 ++++-- ino/mcopy_cam_canon/McopySerial.cpp | 27 ++++++++++++++++++++------- ino/mcopy_cam_canon/McopySerial.h | 6 ++++-- 4 files changed, 48 insertions(+), 18 deletions(-) diff --git a/ino/lib/McopySerial/McopySerial.cpp b/ino/lib/McopySerial/McopySerial.cpp index 82da107..695c7d0 100644 --- a/ino/lib/McopySerial/McopySerial.cpp +++ b/ino/lib/McopySerial/McopySerial.cpp @@ -10,31 +10,44 @@ void McopySerial::begin () { Serial.begin(baud); } -void McopySerial::identify (char identity) { - id = identity; -} - char McopySerial::loop () { if (Serial.available()) { cmdChar = (char) Serial.read(); - internal(); + _internal(); } else { cmdChar = 'z'; } return cmdChar; } -void McopySerial::internal () { +void McopySerial::_internal () { if (cmdChar == DEBUG) { debugOn = !debugOn; - cmdChar = 'z'; + } else if (cmdChar == CONNECT) { + _connect(); + } else if (cmdChar == MCOPY_IDENTIFIER) { + _identify(); } } +void McopySerial::_connect () { + Serial.println(CONNECT); + log("connect()"); +} + +void McopySerial::_identify () { + Serial.println(id); + log("identify()"); +} + void McopySerial::setBaud (int baudRate) { baud = baudRate; } +void McopySerial::setIdentity (char identity) { + id = identity; +} + void McopySerial::debug (bool state) { debugOn = state; } diff --git a/ino/lib/McopySerial/McopySerial.h b/ino/lib/McopySerial/McopySerial.h index 776ea8b..60cf25b 100644 --- a/ino/lib/McopySerial/McopySerial.h +++ b/ino/lib/McopySerial/McopySerial.h @@ -11,7 +11,9 @@ class McopySerial { volatile char cmdChar = 'z'; volatile char id; - void internal (); + void _internal (); + void _connect (); + void _identify (); public: @@ -63,8 +65,8 @@ class McopySerial { void begin(); void setBaud(int baudRate); + void setIdentity(char identity); char loop(); - void identify(char identity); void debug (bool state); void log (String message); diff --git a/ino/mcopy_cam_canon/McopySerial.cpp b/ino/mcopy_cam_canon/McopySerial.cpp index 82da107..695c7d0 100644 --- a/ino/mcopy_cam_canon/McopySerial.cpp +++ b/ino/mcopy_cam_canon/McopySerial.cpp @@ -10,31 +10,44 @@ void McopySerial::begin () { Serial.begin(baud); } -void McopySerial::identify (char identity) { - id = identity; -} - char McopySerial::loop () { if (Serial.available()) { cmdChar = (char) Serial.read(); - internal(); + _internal(); } else { cmdChar = 'z'; } return cmdChar; } -void McopySerial::internal () { +void McopySerial::_internal () { if (cmdChar == DEBUG) { debugOn = !debugOn; - cmdChar = 'z'; + } else if (cmdChar == CONNECT) { + _connect(); + } else if (cmdChar == MCOPY_IDENTIFIER) { + _identify(); } } +void McopySerial::_connect () { + Serial.println(CONNECT); + log("connect()"); +} + +void McopySerial::_identify () { + Serial.println(id); + log("identify()"); +} + void McopySerial::setBaud (int baudRate) { baud = baudRate; } +void McopySerial::setIdentity (char identity) { + id = identity; +} + void McopySerial::debug (bool state) { debugOn = state; } diff --git a/ino/mcopy_cam_canon/McopySerial.h b/ino/mcopy_cam_canon/McopySerial.h index 776ea8b..60cf25b 100644 --- a/ino/mcopy_cam_canon/McopySerial.h +++ b/ino/mcopy_cam_canon/McopySerial.h @@ -11,7 +11,9 @@ class McopySerial { volatile char cmdChar = 'z'; volatile char id; - void internal (); + void _internal (); + void _connect (); + void _identify (); public: @@ -63,8 +65,8 @@ class McopySerial { void begin(); void setBaud(int baudRate); + void setIdentity(char identity); char loop(); - void identify(char identity); void debug (bool state); void log (String message);