Adjust calibration process
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

Signed-off-by: Severin Kaderli <severin@kaderli.dev>
This commit is contained in:
Severin Kaderli 2022-11-24 15:06:58 +01:00
parent 21448cbd4b
commit 445e59c539
Signed by: severinkaderli
GPG key ID: F419F8835B72F0C4
2 changed files with 23 additions and 4 deletions

View file

@ -5,7 +5,7 @@ class Constants {
* @type {Number}
*/
static get CLOCK_TIME() {
return 500;
return 1000;
}
/**
@ -17,6 +17,15 @@ class Constants {
return [1, 1, 1, 0, 0, 0, 1, 1, 1];
}
/**
* The signal used in calibration mode.
*
* @type {Number[]}
*/
static get CALIBRATION_SIGNAL() {
return [1, 1, 0, 0];
}
/**
* The number of workers that should be started.
*

View file

@ -67,13 +67,23 @@ function stopWorkers() {
/**
* Starts the calibration process by simply starting all web workers.
*/
function startCalibration() {
async function startCalibration() {
Utility.setMessage("Calibration currently ongoing.");
startCalibrationButton.classList.add(Constants.HIDE_CLASS);
stopCalibrationButton.classList.remove(Constants.HIDE_CLASS);
startWorkers();
isTransmitting = true;
while (isTransmitting) {
for (let i = 0; i < Constants.CALIBRATION_SIGNAL.length; i++) {
if (!isTransmitting) {
stopWorkers();
return;
}
await transmitBit(Constants.CALIBRATION_SIGNAL[i]);
}
}
}
/**
@ -85,7 +95,7 @@ function stopCalibration() {
stopCalibrationButton.classList.add(Constants.HIDE_CLASS);
startCalibrationButton.classList.remove(Constants.HIDE_CLASS);
stopWorkers();
isTransmitting = false;
}
/**