diff --git a/src/website/scripts/Constants.js b/src/website/scripts/Constants.js index 9f9756c..3987b6d 100644 --- a/src/website/scripts/Constants.js +++ b/src/website/scripts/Constants.js @@ -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. * diff --git a/src/website/scripts/Main.js b/src/website/scripts/Main.js index 22f4e0b..4b1bfb8 100644 --- a/src/website/scripts/Main.js +++ b/src/website/scripts/Main.js @@ -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; } /**