2023-03-04 23:52:51 +00:00
|
|
|
#ifndef MCOPY_SERIAL
|
|
|
|
#define MCOPY_SERIAL
|
|
|
|
|
2023-03-22 00:35:00 +00:00
|
|
|
#include <Arduino.h>
|
2023-03-04 23:52:51 +00:00
|
|
|
|
|
|
|
class McopySerial {
|
|
|
|
|
|
|
|
private:
|
2023-03-10 02:51:29 +00:00
|
|
|
|
2023-03-22 00:35:00 +00:00
|
|
|
const uint16_t serialDelay = 5;
|
|
|
|
const uint16_t baud = 57600;
|
|
|
|
|
2023-03-04 23:52:51 +00:00
|
|
|
volatile bool debugOn = false;
|
2023-03-09 02:28:09 +00:00
|
|
|
volatile char cmdChar = 'z';
|
2023-03-10 02:18:10 +00:00
|
|
|
volatile char id;
|
2023-03-04 23:52:51 +00:00
|
|
|
|
2023-03-10 02:26:31 +00:00
|
|
|
void _internal ();
|
|
|
|
void _connect ();
|
|
|
|
void _identify ();
|
2023-03-10 02:08:36 +00:00
|
|
|
|
2023-03-04 23:52:51 +00:00
|
|
|
public:
|
2023-03-10 02:01:20 +00:00
|
|
|
|
2023-04-21 02:37:37 +00:00
|
|
|
volatile bool connected = false;
|
|
|
|
volatile bool identified = false;
|
|
|
|
|
2023-03-10 02:01:20 +00:00
|
|
|
/* CMD FLAGS */
|
2023-03-22 00:35:00 +00:00
|
|
|
const char BLACK = 'b';
|
|
|
|
const char CAMERA = 'c';
|
|
|
|
const char CAMERA_BACKWARD = 'f';
|
|
|
|
const char CAMERA_CAPPER_IDENTIFIER = '8';
|
|
|
|
const char CAMERA_CAPPER_PROJECTOR_IDENTIFIER = '9';
|
|
|
|
const char CAMERA_CAPPER_PROJECTORS_IDENTIFIER = '0';
|
|
|
|
const char CAMERA_EXPOSURE = 'G';
|
|
|
|
const char CAMERA_FORWARD = 'e';
|
|
|
|
const char CAMERA_IDENTIFIER = 'k';
|
|
|
|
const char CAMERA_PROJECTORS_IDENTIFIER = '5';
|
|
|
|
const char CAMERA_SECOND = '3';
|
|
|
|
const char CAMERA_SECOND_BACKWARD = '2';
|
|
|
|
const char CAMERA_SECOND_FORWARD = '1';
|
|
|
|
const char CAMERA_SECOND_IDENTIFIER = 'y';
|
|
|
|
const char CAMERA_TIMED = 'n';
|
|
|
|
const char CAMERAS = '4';
|
|
|
|
const char CAMERAS_IDENTIFIER = 'a';
|
|
|
|
const char CAMERAS_PROJECTOR_IDENTIFIER = '6';
|
|
|
|
const char CAMERAS_PROJECTORS_IDENTIFIER = '7';
|
|
|
|
const char CAPPER_IDENTIFIER = 'C';
|
|
|
|
const char CAPPER_OFF = 'B';
|
|
|
|
const char CAPPER_ON = 'A';
|
|
|
|
const char CONNECT = 'i';
|
|
|
|
const char DEBUG = 'd';
|
|
|
|
const char ERROR = 'E';
|
|
|
|
const char LIGHT = 'l';
|
|
|
|
const char LIGHT_IDENTIFIER = 'o';
|
|
|
|
const char MCOPY_IDENTIFIER = 'm';
|
|
|
|
const char PROJECTOR = 'p';
|
|
|
|
const char PROJECTOR_BACKWARD = 'h';
|
|
|
|
const char PROJECTOR_CAMERA_IDENTIFIER = 's';
|
|
|
|
const char PROJECTOR_CAMERA_LIGHT_IDENTIFIER = 'r';
|
|
|
|
const char PROJECTOR_FORWARD = 'g';
|
|
|
|
const char PROJECTOR_IDENTIFIER = 'j';
|
|
|
|
const char PROJECTOR_LIGHT_IDENTIFIER = 'q';
|
|
|
|
const char PROJECTOR_SECOND = 'w';
|
|
|
|
const char PROJECTOR_SECOND_BACKWARD = 'v';
|
|
|
|
const char PROJECTOR_SECOND_FORWARD = 'u';
|
|
|
|
const char PROJECTOR_SECOND_IDENTIFIER = 't';
|
|
|
|
const char PROJECTORS = 'x';
|
|
|
|
const char PROJECTORS_IDENTIFIER = 'd';
|
|
|
|
const char STATE = 'H';
|
|
|
|
const char TAKEUP_BACKWARD = 'F';
|
|
|
|
const char TAKEUP_FORWARD = 'D';
|
2023-03-10 02:01:20 +00:00
|
|
|
/* END CMD FLAGS */
|
|
|
|
|
2023-03-22 00:35:00 +00:00
|
|
|
McopySerial();
|
2023-03-05 00:25:50 +00:00
|
|
|
|
2023-03-22 00:35:00 +00:00
|
|
|
void begin(char identity);
|
2023-03-10 02:01:20 +00:00
|
|
|
char loop();
|
2023-03-10 02:51:29 +00:00
|
|
|
void confirm(char cmd);
|
2023-03-18 21:04:06 +00:00
|
|
|
String getString();
|
|
|
|
void print(String message);
|
2023-06-17 15:40:56 +00:00
|
|
|
void sendString(String str);
|
2023-03-04 23:52:51 +00:00
|
|
|
|
|
|
|
void debug (bool state);
|
|
|
|
void log (String message);
|
2023-03-10 02:01:20 +00:00
|
|
|
|
2023-03-04 23:52:51 +00:00
|
|
|
};
|
|
|
|
|
2023-03-10 02:01:20 +00:00
|
|
|
#endif
|