diff --git a/app/data/cfg.json b/app/data/cfg.json index a5a5625..b92a291 100644 --- a/app/data/cfg.json +++ b/app/data/cfg.json @@ -1,5 +1,5 @@ { - "version": "1.8.48", + "version": "1.8.49", "ext_port": 1111, "profiles": { "mcopy": { diff --git a/app/package-lock.json b/app/package-lock.json index db2c4ef..125df2f 100644 --- a/app/package-lock.json +++ b/app/package-lock.json @@ -1,6 +1,6 @@ { "name": "mcopy-app", - "version": "1.8.48", + "version": "1.8.49", "lockfileVersion": 2, "requires": true, "packages": { diff --git a/app/package.json b/app/package.json index 5feb0bc..bf61f36 100644 --- a/app/package.json +++ b/app/package.json @@ -1,6 +1,6 @@ { "name": "mcopy-app", - "version": "1.8.48", + "version": "1.8.49", "description": "GUI for the mcopy small gauge film optical printer platform", "main": "main.js", "scripts": { diff --git a/data/cfg.json b/data/cfg.json index a5a5625..b92a291 100644 --- a/data/cfg.json +++ b/data/cfg.json @@ -1,5 +1,5 @@ { - "version": "1.8.48", + "version": "1.8.49", "ext_port": 1111, "profiles": { "mcopy": { diff --git a/ino/mcopy_projector_firmware/McopyProjector.cpp b/ino/mcopy_projector_firmware/McopyProjector.cpp index ca0a745..eac0c18 100644 --- a/ino/mcopy_projector_firmware/McopyProjector.cpp +++ b/ino/mcopy_projector_firmware/McopyProjector.cpp @@ -6,7 +6,8 @@ McopyProjector::McopyProjector (AccelStepper takeup, AccelStepper feed, uint8_t takeupSettingA, uint8_t takeupSettingB, uint8_t feedSettingA, uint8_t feedSettingB, uint8_t takeupEmitter, uint8_t takeupReceiver, - uint8_t feedEmitter, uint8_t feedReceiver) { + uint8_t feedEmitter, uint8_t feedReceiver, + uint8_t servoPin) { _takeup = takeup; _feed = feed; @@ -18,6 +19,7 @@ McopyProjector::McopyProjector (AccelStepper takeup, AccelStepper feed, _takeupReceiver = takeupReceiver; _feedEmitter = feedEmitter; _feedReceiver = feedReceiver; + _servoPin = servoPin; } void McopyProjector::begin () { @@ -40,6 +42,9 @@ void McopyProjector::begin () { //keep at 1 for now setStepperMode(1); + + _servo.attach(_servoPin); + _servo.write(_servoHome); } void McopyProjector::setDirection (bool dir) { @@ -64,6 +69,9 @@ void McopyProjector::frame (bool dir) { _running = true; + _servo.write(_servoAway); + delay(20); + while (running) { if (_takeup.distanceToGo() == 0 && _feed.distanceToGo() == 0) { running = false; @@ -74,6 +82,9 @@ void McopyProjector::frame (bool dir) { _feed.run(); } } + + delay(20); + _servo.write(_servoHome); _running = false; diff --git a/ino/mcopy_projector_firmware/McopyProjector.h b/ino/mcopy_projector_firmware/McopyProjector.h index ff10c48..c03d451 100644 --- a/ino/mcopy_projector_firmware/McopyProjector.h +++ b/ino/mcopy_projector_firmware/McopyProjector.h @@ -3,6 +3,7 @@ #include #include +#include /** * D2 X Step @@ -28,11 +29,16 @@ class McopyProjector { AccelStepper _takeup; AccelStepper _feed; + Servo _servo; + const uint16_t _motorSteps = 200; //full steps const uint8_t _frames = 8; const uint16_t _stepsPerFrame = 25; //round(_motorSteps / _frames); const float _speed = 2000.0; + const uint8_t _servoHome = 90; + const uint8_t _servoAway = 60; + volatile uint8_t _mode = 1; int64_t _posTakeup = 0; @@ -50,6 +56,8 @@ class McopyProjector { uint8_t _feedEmitter; uint8_t _feedReceiver; + uint8_t _servoPin; + long _feedSamples[200]; long _takeupSamples[200]; @@ -70,7 +78,8 @@ class McopyProjector { uint8_t takeupSettingA, uint8_t takeupSettingB, uint8_t feedSettingA, uint8_t feedSettingB, uint8_t takeupEmitter, uint8_t takeupReceiver, - uint8_t feedEmitter, uint8_t feedReceiver); + uint8_t feedEmitter, uint8_t feedReceiver, + uint8_t servoPin); void begin(); //0 = takeup, 1 = feed void adjust(uint8_t motor, int64_t steps); diff --git a/ino/mcopy_projector_firmware/mcopy_projector_firmware.ino b/ino/mcopy_projector_firmware/mcopy_projector_firmware.ino index 65cc71c..18b9310 100644 --- a/ino/mcopy_projector_firmware/mcopy_projector_firmware.ino +++ b/ino/mcopy_projector_firmware/mcopy_projector_firmware.ino @@ -42,6 +42,8 @@ #define FEED_EMITTER 18 #define FEED_RECEIVER A9 +#define SERVO_PIN 14 + AccelStepper takeup(AccelStepper::DRIVER, TAKEUP_STEP_PIN, TAKEUP_DIR_PIN); AccelStepper feed(AccelStepper::DRIVER, FEED_STEP_PIN, FEED_DIR_PIN); @@ -64,7 +66,8 @@ McopyProjector projector(takeup, feed, TAKEUP_SETTINGS_A, TAKEUP_SETTINGS_B, FEED_SETTINGS_A, FEED_SETTINGS_B, TAKEUP_EMITTER, TAKEUP_RECEIVER, - FEED_EMITTER, FEED_RECEIVER); + FEED_EMITTER, FEED_RECEIVER, + SERVO_PIN); void setup () { pins(); @@ -75,6 +78,7 @@ void setup () { delay(42); digitalWrite(LED_FWD, LOW); digitalWrite(LED_BWD, LOW); + //projector.home(); } @@ -83,9 +87,9 @@ void loop () { cmdChar = mcopy.loop(); cmd(cmdChar); if (digitalRead(BUTTON) == LOW) { - projector_frame(); + //projector_frame(); } - projector.loop(); + //projector.loop(); } void pins () { diff --git a/package-lock.json b/package-lock.json index 7a382c9..a6bf945 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "mcopy", - "version": "1.8.48", + "version": "1.8.49", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "mcopy", - "version": "1.8.48", + "version": "1.8.49", "license": "MIT", "dependencies": { "arduino": "file:app/lib/arduino", diff --git a/package.json b/package.json index 3097569..faffaf5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mcopy", - "version": "1.8.48", + "version": "1.8.49", "description": "Small gauge film optical printer platform", "main": "build.js", "directories": { diff --git a/processing/mcopy/cfg.json b/processing/mcopy/cfg.json index a5a5625..b92a291 100644 --- a/processing/mcopy/cfg.json +++ b/processing/mcopy/cfg.json @@ -1,5 +1,5 @@ { - "version": "1.8.48", + "version": "1.8.49", "ext_port": 1111, "profiles": { "mcopy": {