From 382ba56fa7d5f81466beb2c99e8e2546da3689d0 Mon Sep 17 00:00:00 2001 From: mattmcw Date: Tue, 10 Oct 2023 22:29:02 -0400 Subject: [PATCH] Create a prospective "inaccurate" analogReadAverage method. --- app/data/cfg.json | 2 +- app/package-lock.json | 2 +- app/package.json | 2 +- data/cfg.json | 5 +++-- ino/mcopy_projector_firmware/McopyProjector.cpp | 10 ++++++++++ ino/mcopy_projector_firmware/McopyProjector.h | 1 + package-lock.json | 4 ++-- package.json | 2 +- processing/mcopy/cfg.json | 2 +- 9 files changed, 21 insertions(+), 9 deletions(-) diff --git a/app/data/cfg.json b/app/data/cfg.json index e987ee0..0577cc7 100644 --- a/app/data/cfg.json +++ b/app/data/cfg.json @@ -1,5 +1,5 @@ { - "version": "1.8.59", + "version": "1.8.60", "ext_port": 1111, "profiles": { "mcopy": { diff --git a/app/package-lock.json b/app/package-lock.json index c87f9da..0d2733b 100644 --- a/app/package-lock.json +++ b/app/package-lock.json @@ -1,6 +1,6 @@ { "name": "mcopy-app", - "version": "1.8.59", + "version": "1.8.60", "lockfileVersion": 2, "requires": true, "packages": { diff --git a/app/package.json b/app/package.json index fdea9c9..38a0eff 100644 --- a/app/package.json +++ b/app/package.json @@ -1,6 +1,6 @@ { "name": "mcopy-app", - "version": "1.8.59", + "version": "1.8.60", "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 e987ee0..04cc4de 100644 --- a/data/cfg.json +++ b/data/cfg.json @@ -1,5 +1,5 @@ { - "version": "1.8.59", + "version": "1.8.60", "ext_port": 1111, "profiles": { "mcopy": { @@ -190,7 +190,8 @@ "error": "E", "camera_exposure": "G", "state": "H", - "home": "I" + "home": "I", + "offset": "O" } } } diff --git a/ino/mcopy_projector_firmware/McopyProjector.cpp b/ino/mcopy_projector_firmware/McopyProjector.cpp index 1d96e26..13fd845 100644 --- a/ino/mcopy_projector_firmware/McopyProjector.cpp +++ b/ino/mcopy_projector_firmware/McopyProjector.cpp @@ -303,6 +303,16 @@ long McopyProjector::analogReadAccurateAverage (uint8_t &pin) { return sum / (double) count; } +long McopyProjector::analogReadAverage (uint8_t &pin) { + uint8_t count = 3; + double sum = 0.0; + for (uint8_t i = 0; i < count; i++) { + sum += analogRead(pin); + delay(1); + } + return sum / (double) count; +} + uint16_t McopyProjector::findPeak(long (&arr)[200], uint16_t &steps) { uint16_t maxI = 0; long max = 0; diff --git a/ino/mcopy_projector_firmware/McopyProjector.h b/ino/mcopy_projector_firmware/McopyProjector.h index 6cc72ef..c43b3fe 100644 --- a/ino/mcopy_projector_firmware/McopyProjector.h +++ b/ino/mcopy_projector_firmware/McopyProjector.h @@ -69,6 +69,7 @@ class McopyProjector { long readVcc(); long analogReadAccurate (uint8_t &pin); long analogReadAccurateAverage (uint8_t &pin); + long analogReadAverage (uint8_t &pin); uint16_t findPeak(long (&arr)[200], uint16_t &steps); void emitters(bool enabled); diff --git a/package-lock.json b/package-lock.json index d2572e2..48a4e44 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "mcopy", - "version": "1.8.59", + "version": "1.8.60", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "mcopy", - "version": "1.8.59", + "version": "1.8.60", "license": "MIT", "dependencies": { "arduino": "file:app/lib/arduino", diff --git a/package.json b/package.json index 32d810b..f73573d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mcopy", - "version": "1.8.59", + "version": "1.8.60", "description": "Small gauge film optical printer platform", "main": "build.js", "directories": { diff --git a/processing/mcopy/cfg.json b/processing/mcopy/cfg.json index e987ee0..0577cc7 100644 --- a/processing/mcopy/cfg.json +++ b/processing/mcopy/cfg.json @@ -1,5 +1,5 @@ { - "version": "1.8.59", + "version": "1.8.60", "ext_port": 1111, "profiles": { "mcopy": {