From e9296b44be0bdc6ba6c8014a16311726372db642 Mon Sep 17 00:00:00 2001 From: Kwstas Drakontidis Date: Sat, 7 Jun 2025 10:12:47 +0200 Subject: [PATCH] Code refactor --- can.js | 11 ----------- src/javascript/add.js | 1 - src/javascript/edit.js | 2 -- 3 files changed, 14 deletions(-) diff --git a/can.js b/can.js index 4ad1d88..0a8a0ef 100644 --- a/can.js +++ b/can.js @@ -82,33 +82,25 @@ function getMapIndex(array, input) { channel.addListener("onMessage", async function (message) { switch (message.id) { case can_conf.selector.id: - console.log("==INVOKE SELECTOR=="); if (Buffer.compare(message.data, can_conf.selector.command) == 0) { - console.log("enable"); enabled = true; } else { - console.log("disable"); enabled = false; } break; case can_conf.apps_id: - console.log("==INVOKE APPS=="); const apps_percentage = ((message.data[1] << 8) | message.data[0]) / 1000; throttle_output = loaded_map_data[getMapIndex(map_throttle, apps_percentage)][2]; - console.log(throttle_output); break; case erpm_id: - console.log("==INVOKE ERPM=="); if (enabled) { - console.log("enabled"); if (fs.existsSync(path.join(__dirname, map_conf.map_storage_path, "selected"))) { const enabled_map_name = fs.readFileSync(path.join(__dirname, map_conf.map_storage_path, "selected")); if (enabled_map_name != "") { - console.log("map selected"); if (loaded_map_name != enabled_map_name) { [loaded_map_name, loaded_map_data] = await parseMap(enabled_map_name); } @@ -117,15 +109,12 @@ channel.addListener("onMessage", async function (message) { let max_current = loaded_map_data[getMapIndex(map_rpm, ERPM / can_conf.motor_poles)][(throttle_output > 0) ? 0 : 1]; let current = throttle_output * max_current * 10; - console.log(max_current); - console.log(current); channel.send({ id: (throttle_output > 0) ? current_id : brake_current_id, ext: false, data: Buffer.from([(current >> 8) & 0xFF, current & 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]) }); } else { - console.log("map not selected"); channel.send({ id: brake_current_id, ext: false, diff --git a/src/javascript/add.js b/src/javascript/add.js index d2d7071..1af7cf6 100644 --- a/src/javascript/add.js +++ b/src/javascript/add.js @@ -73,7 +73,6 @@ setEventListeners(commit, async () => { } } catch (error) { alert(`Add unsuccessful. ${error.message}`); - console.error(error.message); } } else { alert("Nothing to commit."); diff --git a/src/javascript/edit.js b/src/javascript/edit.js index 8412624..01f7976 100644 --- a/src/javascript/edit.js +++ b/src/javascript/edit.js @@ -59,7 +59,6 @@ setEventListeners(remove, async () => { } } catch (error) { alert(`Remove unsuccessful. ${error.message}`); - console.error(error.message); } }); @@ -115,7 +114,6 @@ setEventListeners(commit, async () => { } } catch (error) { alert(`Edit unsuccessful. ${error.message}`); - console.error(error.message); } } else { alert("Nothing to commit.");