Render rpm, power as integers, and plot rpm with one decimal place

This commit is contained in:
Peter Stockings
2023-03-08 11:34:50 +11:00
parent a1a14b5aaf
commit f7805609b0

View File

@@ -64,20 +64,13 @@
let startTime = 0; let startTime = 0;
let intervalId = null; let intervalId = null;
const integerNumber = (num) => parseInt(num);
const decimalNumber = (num) => parseFloat(num.toFixed(1));
// Update RPM and Power // Update RPM and Power
function updateRpmPower(rpm, power) { function updateRpmPower(rpm, power) {
rpmDisplay.textContent = integerNumber(rpm);
// Update displays powerDisplay.textContent = integerNumber(power);
rpmDisplay.textContent = rpm;
powerDisplay.textContent = power;
const newData = {
x: data.length,
y: rpm,
};
// Add the new data point to the data array
data.push(newData);
} }
// Update Duration // Update Duration
@@ -258,6 +251,14 @@
let rpm = revsToRPM(prevRes, res); let rpm = revsToRPM(prevRes, res);
if (rpm > 0) { if (rpm > 0) {
const newData = {
x: data.length,
y: decimalNumber(rpm),
};
// Add the new data point to the data array
data.push(newData);
updateRpmPower(rpm, 0); updateRpmPower(rpm, 0);
updateGraph(); updateGraph();
/* /*