2023-03-04 23:52:51 +00:00
|
|
|
#ifndef MCOPY_SERIAL
|
|
|
|
#define MCOPY_SERIAL
|
|
|
|
|
|
|
|
#include "Arduino.h"
|
|
|
|
|
|
|
|
class McopySerial {
|
|
|
|
|
|
|
|
private:
|
2023-03-10 02:51:29 +00:00
|
|
|
const int serialDelay = 5;
|
|
|
|
|
2023-03-04 23:52:51 +00:00
|
|
|
volatile int baud = 57600;
|
|
|
|
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
|
|
|
|
|
|
|
/* CMD FLAGS */
|
2023-03-10 02:18:10 +00:00
|
|
|
static const char BLACK = 'b';
|
|
|
|
static const char CAMERA = 'c';
|
|
|
|
static const char CAMERA_BACKWARD = 'f';
|
|
|
|
static const char CAMERA_CAPPER_IDENTIFIER = '8';
|
|
|
|
static const char CAMERA_CAPPER_PROJECTOR_IDENTIFIER = '9';
|
|
|
|
static const char CAMERA_CAPPER_PROJECTORS_IDENTIFIER = '0';
|
|
|
|
static const char CAMERA_FORWARD = 'e';
|
|
|
|
static const char CAMERA_IDENTIFIER = 'k';
|
|
|
|
static const char CAMERA_PROJECTORS_IDENTIFIER = '5';
|
|
|
|
static const char CAMERA_SECOND = '3';
|
|
|
|
static const char CAMERA_SECOND_BACKWARD = '2';
|
|
|
|
static const char CAMERA_SECOND_FORWARD = '1';
|
|
|
|
static const char CAMERA_SECOND_IDENTIFIER = 'y';
|
|
|
|
static const char CAMERA_TIMED = 'n';
|
|
|
|
static const char CAMERAS = '4';
|
|
|
|
static const char CAMERAS_IDENTIFIER = 'a';
|
|
|
|
static const char CAMERAS_PROJECTOR_IDENTIFIER = '6';
|
|
|
|
static const char CAMERAS_PROJECTORS_IDENTIFIER = '7';
|
|
|
|
static const char CAPPER_IDENTIFIER = 'C';
|
|
|
|
static const char CAPPER_OFF = 'B';
|
|
|
|
static const char CAPPER_ON = 'A';
|
|
|
|
static const char CONNECT = 'i';
|
|
|
|
static const char DEBUG = 'd';
|
|
|
|
static const char LIGHT = 'l';
|
|
|
|
static const char LIGHT_IDENTIFIER = 'o';
|
|
|
|
static const char MCOPY_IDENTIFIER = 'm';
|
|
|
|
static const char PROJECTOR = 'p';
|
|
|
|
static const char PROJECTOR_BACKWARD = 'h';
|
|
|
|
static const char PROJECTOR_CAMERA_IDENTIFIER = 's';
|
|
|
|
static const char PROJECTOR_CAMERA_LIGHT_IDENTIFIER = 'r';
|
|
|
|
static const char PROJECTOR_FORWARD = 'g';
|
|
|
|
static const char PROJECTOR_IDENTIFIER = 'j';
|
|
|
|
static const char PROJECTOR_LIGHT_IDENTIFIER = 'q';
|
|
|
|
static const char PROJECTOR_SECOND = 'w';
|
|
|
|
static const char PROJECTOR_SECOND_BACKWARD = 'v';
|
|
|
|
static const char PROJECTOR_SECOND_FORWARD = 'u';
|
|
|
|
static const char PROJECTOR_SECOND_IDENTIFIER = 't';
|
|
|
|
static const char PROJECTORS = 'x';
|
|
|
|
static const char PROJECTORS_IDENTIFIER = 'd';
|
|
|
|
static const char TAKEUP_BACKWARD = 'E';
|
|
|
|
static const char TAKEUP_FORWARD = 'D';
|
2023-03-10 02:01:20 +00:00
|
|
|
/* END CMD FLAGS */
|
|
|
|
|
2023-03-10 02:18:10 +00:00
|
|
|
McopySerial(char identity);
|
2023-03-05 00:25:50 +00:00
|
|
|
|
2023-03-04 23:52:51 +00:00
|
|
|
void begin();
|
2023-03-05 00:25:50 +00:00
|
|
|
void setBaud(int baudRate);
|
2023-03-10 02:26:31 +00:00
|
|
|
void setIdentity(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-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
|