From 75297712f2ba1873f016c864368b7393f3f69898 Mon Sep 17 00:00:00 2001 From: ATATC <futerry@outlook.com> Date: Mon, 29 Jul 2024 18:16:50 +0800 Subject: [PATCH] Using LEADS Arduino version `1.1.0`. (#319) (#320) (#321) --- arduino/leads_vec_power/leads_vec_power.ino | 11 ++++----- arduino/leads_vec_wsc/leads_vec_wsc.ino | 25 +++++++++++---------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/arduino/leads_vec_power/leads_vec_power.ino b/arduino/leads_vec_power/leads_vec_power.ino index 76e2e60f..a0efced3 100644 --- a/arduino/leads_vec_power/leads_vec_power.ino +++ b/arduino/leads_vec_power/leads_vec_power.ino @@ -1,15 +1,16 @@ -#include "LEADS.h" +#include "LEADS.h" // LEADS>=1.1.0 const int PIN_VOT[] = {A0}; -VoltageSensor VOT(30000.0, 7500.0, PIN_VOT); +Peer P{}; +VoltageSensor VOT{30000.0, 7500.0, ArrayList<int>(PIN_VOT)}; void setup() { - Serial.begin(9600); - VOT.initialize(); + P.initializeAsRoot(); + VOT.initializeAsRoot(); } void loop() { - returnFloat(VOLTAGE_SENSOR, VOT.read()); + returnFloat(P, VOLTAGE_SENSOR, VOT.read()); delay(100); } diff --git a/arduino/leads_vec_wsc/leads_vec_wsc.ino b/arduino/leads_vec_wsc/leads_vec_wsc.ino index fe1af6db..ffd154fe 100644 --- a/arduino/leads_vec_wsc/leads_vec_wsc.ino +++ b/arduino/leads_vec_wsc/leads_vec_wsc.ino @@ -1,4 +1,4 @@ -#include "LEADS.h" +#include "LEADS.h" // LEADS>=1.1.0 const int PIN_LFWSS[] = {2}; const int PIN_RFWSS[] = {3}; @@ -6,19 +6,20 @@ const int PIN_LRWSS[] = {4}; const int PIN_RRWSS[] = {5}; const int PIN_CRWSS[] = {6}; -WheelSpeedSensor LFWSS(PIN_LFWSS, [](float ws) {returnFloat(LEFT_FRONT_WHEEL_SPEED_SENSOR, ws);}); -WheelSpeedSensor RFWSS(PIN_RFWSS, [](float ws) {returnFloat(RIGHT_FRONT_WHEEL_SPEED_SENSOR, ws);}); -WheelSpeedSensor LRWSS(PIN_LRWSS, [](float ws) {returnFloat(LEFT_REAR_WHEEL_SPEED_SENSOR, ws);}); -WheelSpeedSensor RRWSS(PIN_RRWSS, [](float ws) {returnFloat(RIGHT_REAR_WHEEL_SPEED_SENSOR, ws);}); -WheelSpeedSensor CRWSS(PIN_CRWSS, [](float ws) {returnFloat(CENTER_REAR_WHEEL_SPEED_SENSOR, ws);}); +Peer P{}; +WheelSpeedSensor LFWSS{ArrayList<int>(PIN_LFWSS), [](float ws) {returnFloat(P, LEFT_FRONT_WHEEL_SPEED_SENSOR, ws);}}; +WheelSpeedSensor RFWSS{ArrayList<int>(PIN_RFWSS), [](float ws) {returnFloat(P, RIGHT_FRONT_WHEEL_SPEED_SENSOR, ws);}}; +WheelSpeedSensor LRWSS{ArrayList<int>(PIN_LRWSS), [](float ws) {returnFloat(P, LEFT_REAR_WHEEL_SPEED_SENSOR, ws);}}; +WheelSpeedSensor RRWSS{ArrayList<int>(PIN_RRWSS), [](float ws) {returnFloat(P, RIGHT_REAR_WHEEL_SPEED_SENSOR, ws);}}; +WheelSpeedSensor CRWSS{ArrayList<int>(PIN_CRWSS), [](float ws) {returnFloat(P, CENTER_REAR_WHEEL_SPEED_SENSOR, ws);}}; void setup() { - Serial.begin(9600); - LFWSS.initialize(); - RFWSS.initialize(); - LRWSS.initialize(); - RRWSS.initialize(); - CRWSS.initialize(); + P.initializeAsRoot(); + LFWSS.initializeAsRoot(); + RFWSS.initializeAsRoot(); + LRWSS.initializeAsRoot(); + RRWSS.initializeAsRoot(); + CRWSS.initializeAsRoot(); } void loop() {