Skip to content

Commit

Permalink
removed deead code
Browse files Browse the repository at this point in the history
  • Loading branch information
modox94 committed Feb 24, 2023
1 parent 9c95867 commit 3b029c4
Showing 1 changed file with 0 additions and 53 deletions.
53 changes: 0 additions & 53 deletions src/hardware/motor_driver.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const Promise = require("bluebird");
const { round, noop, get, isFunction, isFinite } = require("lodash");
const fs = require("node:fs");
const { Gpio } = require("onoff");
const {
DIRECTION,
Expand Down Expand Up @@ -375,58 +374,6 @@ class MotorDriver {
return this[MOTOR_FIELDS.SLEEP_RATIO];
}

// TODO remove
async calibration_old(loops = 1) {
if (!this[MOTOR_FIELDS.MIN_POS] || !this[MOTOR_FIELDS.MAX_POS]) {
return console.log("Невозможно проводить калибровку без инициализации!");
}

if (this[MOTOR_FIELDS.SLEEP_RATIO]) {
delete this[MOTOR_FIELDS.SLEEP_RATIO];
}

const result = await this.setLevel(1);
if (result?.error) {
// TODO
console.log("Что-то не так с двигателем!");
this.stop();
return result;
}

let loopsCounter = loops;
let driveTimeSum = 0;

while (loopsCounter > 0) {
const { driveTime: driveTimeUp } = await this.setLevel(
RESIST_LEVELS,
true,
);
driveTimeSum += driveTimeUp;

const { driveTime: driveTimeDown } = await this.setLevel(1, true);
driveTimeSum += driveTimeDown;

loopsCounter -= 1;
}

const sleepRatio = round(
(driveTimeSum / 2 / loops / (RESIST_LEVELS - 1)) * 0.95,
);

this[MOTOR_FIELDS.SLEEP_RATIO] = sleepRatio;

fs.writeFileSync(
"./motor_settings.json",
JSON.stringify({
minPosition: this[MOTOR_FIELDS.MIN_POS],
maxPosition: this[MOTOR_FIELDS.MAX_POS],
sleepRatio: this[MOTOR_FIELDS.SLEEP_RATIO],
}),
);

return this[MOTOR_FIELDS.SLEEP_RATIO];
}

async setLevel(level) {
this.actionCancel();

Expand Down

0 comments on commit 3b029c4

Please sign in to comment.