Restore the home method. Now it compiles.

This commit is contained in:
Matt McWilliams 2023-10-03 13:44:04 -04:00
parent 66b18dd351
commit 6f68081dc5
9 changed files with 95 additions and 35 deletions

View File

@ -1,5 +1,5 @@
{
"version": "1.8.40",
"version": "1.8.41",
"ext_port": 1111,
"profiles": {
"mcopy": {

2
app/package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "mcopy-app",
"version": "1.8.40",
"version": "1.8.41",
"lockfileVersion": 2,
"requires": true,
"packages": {

View File

@ -1,6 +1,6 @@
{
"name": "mcopy-app",
"version": "1.8.40",
"version": "1.8.41",
"description": "GUI for the mcopy small gauge film optical printer platform",
"main": "main.js",
"scripts": {

View File

@ -1,5 +1,5 @@
{
"version": "1.8.40",
"version": "1.8.41",
"ext_port": 1111,
"profiles": {
"mcopy": {

View File

@ -157,56 +157,110 @@ void McopyProjector::setStepperMode (uint8_t mode) {
}
void McopyProjector::home () {
/*
uint16_t steps = _motorSteps * _mode;
long reading;
//
uint16_t quarter = steps / 4;
uint16_t eighth = quarter / 2;
uint16_t takeupPeak = 0;
uint16_t feedPeak = 0;
uint16_t takeupOffset = 0;
uint16_t feedOffset = 0;
long takeupReading = 0.0;
long feedReading = 0.0;
emitters(true);
delay(10);
for (uint16_t i = 0; i < steps; i++) {
reading = analogReadAccurateAverage(_takeupReceiver);
_takeupSamples[i] = reading;
takeupReading = analogReadAccurateAverage(_takeupReceiver);
feedReading = analogReadAccurateAverage(_feedReceiver);
_takeupSamples[i] = takeupReading;
_feedSamples[i] = feedReading;
if (i < steps - 1) {
_takeup.move(1);
_feed.move(1);
_takeup.runToPosition();
_feed.runToPosition();
}
}
//
for (uint16_t i = 0; i < steps; i++) {
Serial.print(i);
Serial.print(", ");
Serial.println(_takeupSamples[i]);
Serial.print(_takeupSamples[i]);
Serial.print(", ");
Serial.println(_feedSamples[i]);
}
uint16_t peak = findPeak(_takeupSamples, steps);
Serial.print("peak: ");
Serial.println(peak);
uint16_t offset = abs(200 - peak);
Serial.print("offset: ");
Serial.println(offset);
if (offset != 0) {
for (uint16_t i = 0; i < offset; i++) {
_takeup.move(-1);
_takeup.runToPosition();
}
for (uint16_t i = 0; i < 25; i++) {
takeupPeak = findPeak(_takeupSamples, steps);
feedPeak = findPeak(_feedSamples, steps);
Serial.print(" takeup peak: ");
Serial.println(takeupPeak);
Serial.print(" feed peak: ");
Serial.println(feedPeak);
takeupOffset = abs(steps - takeupPeak);
feedOffset = abs(steps - takeupPeak);
Serial.print("takeup offset: ");
Serial.println(takeupOffset);
Serial.print(" feed offset: ");
Serial.println(feedOffset);
if (takeupOffset > 0) {
for (uint16_t i = 0; i < takeupOffset; i++) {
_takeup.move(-1);
_takeup.runToPosition();
}
}
for (uint16_t i = 0; i < 50; i++) {
reading = analogReadAccurateAverage(_takeupReceiver);
_takeupSamples[i] = reading;
if (feedOffset > 0) {
for (uint16_t i = 0; i < feedOffset; i++) {
_feed.move(-1);
_feed.runToPosition();
}
}
for (uint16_t i = 0; i < eighth; i++) {
_takeup.move(-1);
_feed.move(-1);
_takeup.runToPosition();
_feed.runToPosition();
}
for (uint16_t i = 0; i < quarter; i++) {
takeupReading = analogReadAccurateAverage(_takeupReceiver);
feedReading = analogReadAccurateAverage(_feedReceiver);
_takeupSamples[i] = takeupReading;
_feedSamples[i] = feedReading;
if (i < steps - 1) {
_takeup.move(1);
_feed.move(1);
_takeup.runToPosition();
_feed.runToPosition();
}
}
uint16_t peak2 = findPeak(_takeupSamples, 50);
uint16_t offset2 = abs(50 - peak2);
if (offset2 != 0) {
for (uint16_t i = 0; i < offset2; i++) {
emitters(false);
takeupPeak = findPeak(_takeupSamples, quarter);
feedPeak = findPeak(_feedSamples, quarter);
takeupOffset = abs(quarter - takeupPeak);
feedOffset = abs(quarter - feedPeak);
if (takeupOffset > 0) {
for (uint16_t i = 0; i < takeupOffset; i++) {
_takeup.move(-1);
_takeup.runToPosition();
}
}*/
}
if (feedOffset > 0) {
for (uint16_t i = 0; i < feedOffset; i++) {
_feed.move(-1);
_feed.runToPosition();
}
}
_posTakeup = 0;
_posFeed = 0;
}
long McopyProjector::readVcc() {
@ -249,3 +303,8 @@ uint16_t McopyProjector::findPeak(long (&arr)[200], uint16_t &steps) {
}
return maxI;
}
void McopyProjector::emitters (bool enabled) {
digitalWrite(_takeupEmitter, enabled ? HIGH : LOW);
digitalWrite(_feedEmitter, enabled ? HIGH : LOW);
}

View File

@ -62,6 +62,7 @@ class McopyProjector {
long analogReadAccurate (uint8_t &pin);
long analogReadAccurateAverage (uint8_t &pin);
uint16_t findPeak(long (&arr)[200], uint16_t &steps);
void emitters(bool enabled);
public:

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "mcopy",
"version": "1.8.40",
"version": "1.8.41",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "mcopy",
"version": "1.8.40",
"version": "1.8.41",
"license": "MIT",
"dependencies": {
"arduino": "file:app/lib/arduino",

View File

@ -1,6 +1,6 @@
{
"name": "mcopy",
"version": "1.8.40",
"version": "1.8.41",
"description": "Small gauge film optical printer platform",
"main": "build.js",
"directories": {

View File

@ -1,5 +1,5 @@
{
"version": "1.8.40",
"version": "1.8.41",
"ext_port": 1111,
"profiles": {
"mcopy": {