Create placeholder scripts for Mitchell and Oxberry cameras

This commit is contained in:
Matt McWilliams 2024-06-23 21:38:36 -04:00
parent d1028a7e02
commit b858c9fba0
14 changed files with 428 additions and 6 deletions

View File

@ -13,7 +13,10 @@
class EndstopCameraShield {
private:
const
const uint8_t receiverClosePin = 2;
const uint8_t receiverOpenPin = 3;
const uint8_t emitterOpenPin = 4;
const uint8_t emitterClosePin = 5;
public:

View File

@ -0,0 +1,29 @@
#ifndef EndstopCameraShield_h
#define EndstopCameraShield_h
#include <Arduino.h>
/**
* Default pins
* 2 Close Receiver Pin
* 3 Open Receiver Pin
* 4 Open Emitter Pin
* 5 Close Emitter Pin
**/
class EndstopCameraShield {
private:
const uint8_t receiverClosePin = 2;
const uint8_t receiverOpenPin = 3;
const uint8_t emitterOpenPin = 4;
const uint8_t emitterClosePin = 5;
public:
EndstopCameraShield();
void setup();
void loop();
};
#endif

View File

@ -30,9 +30,13 @@ class McopySerial {
const char CAMERA_CAPPER_IDENTIFIER = '8';
const char CAMERA_CAPPER_PROJECTOR_IDENTIFIER = '9';
const char CAMERA_CAPPER_PROJECTORS_IDENTIFIER = '0';
const char CAMERA_CLOSE_BACKWARD = 'M';
const char CAMERA_CLOSE_FORWARD = 'L';
const char CAMERA_EXPOSURE = 'G';
const char CAMERA_FORWARD = 'e';
const char CAMERA_IDENTIFIER = 'k';
const char CAMERA_OPEN_BACKWARD = 'K';
const char CAMERA_OPEN_FORWARD = 'J';
const char CAMERA_PROJECTORS_IDENTIFIER = '5';
const char CAMERA_SECOND = '3';
const char CAMERA_SECOND_BACKWARD = '2';
@ -72,6 +76,27 @@ class McopySerial {
const char TAKEUP_FORWARD = 'D';
/* END CMD FLAGS */
/* IDENTIFIERS FLAGS */
const char MCOPY_IDENTIFIER = 'm';
const char CAMERA_IDENTIFIER = 'k';
const char PROJECTOR_IDENTIFIER = 'j';
const char PROJECTOR_CAMERA_IDENTIFIER = 's';
const char CAMERA_PROJECTORS_IDENTIFIER = '5';
const char CAMERA_CAPPER_IDENTIFIER = '8';
const char CAMERA_CAPPER_PROJECTOR_IDENTIFIER = '9';
const char CAMERA_CAPPER_PROJECTORS_IDENTIFIER = '0';
const char PROJECTOR_LIGHT_IDENTIFIER = 'q';
const char PROJECTORS_IDENTIFIER = 'd';
const char PROJECTOR_SECOND_IDENTIFIER = 't';
const char PROJECTOR_CAMERA_LIGHT_IDENTIFIER = 'r';
const char CAMERA_SECOND_IDENTIFIER = 'y';
const char CAMERAS_IDENTIFIER = 'a';
const char CAMERAS_PROJECTOR_IDENTIFIER = '6';
const char CAMERAS_PROJECTORS_IDENTIFIER = '7';
const char CAPPER_IDENTIFIER = 'C';
const char LIGHT_IDENTIFIER = 'o';
/* END IDENTIFIERS FLAGS */
McopySerial();
void begin(char identity);

View File

@ -33,12 +33,12 @@ void TB6600MotorDriver::setDirection(uint8_t direction) {
}
}
void TB6600MotorDriver::_setDirection{
void TB6600MotorDriver::_setDirection () {
digitalWrite(_directionPin, _direction ? LOW : HIGH);
}
void TB6600MotorDriver::setSpeed(uint16_t rpm) {
_usPulse = 60000000 / ((uint32_t) revsteps * (uint32_t) rpm);
_usPulse = 60000000 / ((uint32_t) _revsteps * (uint32_t) rpm);
}
void TB6600MotorDriver::steps(uint64_t stepCount) {

View File

@ -0,0 +1,29 @@
#ifndef EndstopCameraShield_h
#define EndstopCameraShield_h
#include <Arduino.h>
/**
* Default pins
* 2 Close Receiver Pin
* 3 Open Receiver Pin
* 4 Open Emitter Pin
* 5 Close Emitter Pin
**/
class EndstopCameraShield {
private:
const uint8_t receiverClosePin = 2;
const uint8_t receiverOpenPin = 3;
const uint8_t emitterOpenPin = 4;
const uint8_t emitterClosePin = 5;
public:
EndstopCameraShield();
void setup();
void loop();
};
#endif

View File

@ -0,0 +1,74 @@
/// mcopy Serial Library
#include "McopySerial.h"
McopySerial::McopySerial () {}
void McopySerial::begin (char identity) {
id = identity;
Serial.begin(baud);
Serial.flush();
Serial.setTimeout(serialDelay);
}
char McopySerial::loop () {
if (Serial.available()) {
cmdChar = (char) Serial.read();
_internal();
} else {
cmdChar = 'z';
}
return cmdChar;
}
void McopySerial::_internal () {
if (cmdChar == DEBUG) {
debug(!debugOn);
} else if (cmdChar == CONNECT) {
_connect();
} else if (cmdChar == MCOPY_IDENTIFIER) {
_identify();
}
}
void McopySerial::_connect () {
connected = true;
Serial.println(CONNECT);
log("connect()");
}
void McopySerial::_identify () {
identified = true;
Serial.println(id);
log("identify()");
}
void McopySerial::debug (bool state) {
debugOn = state;
log("debug()");
}
void McopySerial::confirm (char cmd) {
Serial.println(cmd);
}
void McopySerial::log (String message) {
if (debugOn) {
Serial.println(message);
}
}
String McopySerial::getString () {
while (Serial.available() == 0) {
//Wait for value string
}
return Serial.readString();
}
void McopySerial::sendString (String str) {
Serial.println(str);
}
void McopySerial::print (String message) {
Serial.println(message);
}

View File

@ -0,0 +1,114 @@
#ifndef MCOPY_SERIAL
#define MCOPY_SERIAL
#include <Arduino.h>
class McopySerial {
private:
const uint16_t serialDelay = 5;
const uint16_t baud = 57600;
volatile bool debugOn = false;
volatile char cmdChar = 'z';
volatile char id;
void _internal ();
void _connect ();
void _identify ();
public:
volatile bool connected = false;
volatile bool identified = false;
/* CMD FLAGS */
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_CLOSE_BACKWARD = 'M';
const char CAMERA_CLOSE_FORWARD = 'L';
const char CAMERA_EXPOSURE = 'G';
const char CAMERA_FORWARD = 'e';
const char CAMERA_IDENTIFIER = 'k';
const char CAMERA_OPEN_BACKWARD = 'K';
const char CAMERA_OPEN_FORWARD = 'J';
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 HOME = 'I';
const char LIGHT = 'l';
const char LIGHT_IDENTIFIER = 'o';
const char MCOPY_IDENTIFIER = 'm';
const char OFFSET = 'O';
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';
/* END CMD FLAGS */
/* IDENTIFIERS FLAGS */
const char MCOPY_IDENTIFIER = 'm';
const char CAMERA_IDENTIFIER = 'k';
const char PROJECTOR_IDENTIFIER = 'j';
const char PROJECTOR_CAMERA_IDENTIFIER = 's';
const char CAMERA_PROJECTORS_IDENTIFIER = '5';
const char CAMERA_CAPPER_IDENTIFIER = '8';
const char CAMERA_CAPPER_PROJECTOR_IDENTIFIER = '9';
const char CAMERA_CAPPER_PROJECTORS_IDENTIFIER = '0';
const char PROJECTOR_LIGHT_IDENTIFIER = 'q';
const char PROJECTORS_IDENTIFIER = 'd';
const char PROJECTOR_SECOND_IDENTIFIER = 't';
const char PROJECTOR_CAMERA_LIGHT_IDENTIFIER = 'r';
const char CAMERA_SECOND_IDENTIFIER = 'y';
const char CAMERAS_IDENTIFIER = 'a';
const char CAMERAS_PROJECTOR_IDENTIFIER = '6';
const char CAMERAS_PROJECTORS_IDENTIFIER = '7';
const char CAPPER_IDENTIFIER = 'C';
const char LIGHT_IDENTIFIER = 'o';
/* END IDENTIFIERS FLAGS */
McopySerial();
void begin(char identity);
char loop();
void confirm(char cmd);
String getString();
void print(String message);
void sendString(String str);
void debug (bool state);
void log (String message);
};
#endif

View File

@ -0,0 +1,76 @@
#include "TB6600MotorDriver.h"
TB6600MotorDriver::TB6600MotorDriver() {
//
}
TB6600MotorDriver::TB6600MotorDriver(uint8_t enablePin, uint8_t directionPin, uint8_t pulsePin, uint32_t usPulse, uint8_t microsteps) {
_enablePin = enablePin;
_directionPin = directionPin;
_pulsePin = pulsePin;
_usPulse = usPulse;
_microsteps = microsteps;
_revsteps = 200 * microsteps;
}
void TB6600MotorDriver::setup() {
if (_enablePin != 0) {
pinMode(_enablePin, OUTPUT);
}
pinMode(_directionPin, OUTPUT);
pinMode(_pulsePin, OUTPUT);
digitalWrite(_directionPin, LOW);
digitalWrite(_enablePin, HIGH);
}
void TB6600MotorDriver::setDirection(uint8_t direction) {
if (direction != _direction) {
_direction = direction;
_setDirection();
}
}
void TB6600MotorDriver::_setDirection () {
digitalWrite(_directionPin, _direction ? LOW : HIGH);
}
void TB6600MotorDriver::setSpeed(uint16_t rpm) {
_usPulse = 60000000 / ((uint32_t) _revsteps * (uint32_t) rpm);
}
void TB6600MotorDriver::steps(uint64_t stepCount) {
for (uint64_t i = 0; i < stepCount; i++) {
_step();
}
}
void TB6600MotorDriver::_step() {
digitalWrite(_pulsePin, HIGH);
delayMicroseconds(_usPulse);
digitalWrite(_pulsePin, LOW);
delayMicroseconds(_usPulse);
}
void TB6600MotorDriver::step() {
_step();
}
void TB6600MotorDriver::release() {
_enabled = false;
_setEnable();
}
void TB6600MotorDriver::enable() {
_enabled = true;
_setEnable();
}
void TB6600MotorDriver::_setEnable() {
if (_enablePin != 0) {
digitalWrite(_enablePin, _enabled ? HIGH : LOW);
}
}

View File

@ -0,0 +1,52 @@
#ifndef TB6600MotorDriver_h
#define TB6600MotorDriver_h
#include <Arduino.h>
/**
* Default pins
* D6 Enable +
* D7 Direction +
* D8 Pulse +
**/
class TB6600MotorDriver {
private:
volatile uint8_t _enablePin = 0; //0 is disabled
volatile uint8_t _directionPin = 7;
volatile uint8_t _pulsePin = 8;
volatile uint32_t _usPulse = 300;
//physically set, can't change
volatile uint8_t _microsteps = 1; //1, 2, 4, 8, 16, 32
volatile uint16_t _revsteps = 200; // # steps per revolution
volatile bool _direction = true;
volatile bool _enabled = true;
void _step();
void _setDirection();
void _setEnable();
public:
TB6600MotorDriver();
TB6600MotorDriver(uint8_t enablePin, uint8_t directionPin, uint8_t pulsePin, uint32_t usPulse, uint8_t microsteps);
void setup();
void setDirection(uint8_t direction);
void setSpeed(uint16_t rpm);
//full
void steps(uint64_t stepCount);
void step();
void enable();
void release();
};
#endif

View File

@ -0,0 +1,10 @@
#include "EndstopCameraShield.h"
#include "McopySerial.h"
void setup () {
}
void loop () {
}

View File

@ -16,7 +16,7 @@ if [ -f "$(which jq)" ]; then
rm -f "${TMP_FILE}"
fi
SKETCHES=(
MCOPYSERIAL=(
mcopy_arri_s_firmware
mcopy_cam_canon_ble_nano
mcopy_cam_relay
@ -26,13 +26,23 @@ SKETCHES=(
components/mcopy_light
mcopy_projector_firmware
mcopy_ACME_Trebes_Nanolab
mcopy_oxberry_mitchell
mcopy_oxberry_camera
mcopy_mitchell_camera
)
for sketch in "${SKETCHES[@]}"; do
ENSTOPCAMERASHIELD=(
mcopy_oxberry_camera
mcopy_mitchell_camera
)
for sketch in "${MCOPYSERIAL[@]}"; do
cp ino/lib/McopySerial/McopySerial.* ino/${sketch}/
done
for sketch in "${ENDSTOPCAMERASHIELD[@]}"; do
cp ino/lib/EndstopCameraShield/EndstopCameraShield.* ino/${sketch}/
done
if [ -d ../McopySerial ]; then
cp ino/lib/McopySerial/McopySerial.* ../McopySerial/
fi