From 3fd8dbdc93fe727e3c38e5c38a6ffa09006f7cb7 Mon Sep 17 00:00:00 2001 From: AJIOB Date: Tue, 20 Mar 2018 10:22:41 +0300 Subject: [PATCH 1/2] Program fix to new line board revision --- code/Arduino/config/Constants.cpp | 1 + code/Arduino/peripheral/LineSensorManager.cpp | 40 +++++++++++++++++++ code/Arduino/peripheral/LineSensorManager.h | 4 ++ 3 files changed, 45 insertions(+) diff --git a/code/Arduino/config/Constants.cpp b/code/Arduino/config/Constants.cpp index e2fbf82..c9e2008 100644 --- a/code/Arduino/config/Constants.cpp +++ b/code/Arduino/config/Constants.cpp @@ -79,6 +79,7 @@ const uint8_t Constants::kDistanceSensorBPin = 5; const uint8_t Constants::kDistanceSensorCPin = A3; /* Line controller */ +// A = 0, B = 1, C = 2 const uint8_t Constants::kLineSensorReadPin = A0; const uint8_t Constants::kLineSensorAPin = 6; const uint8_t Constants::kLineSensorBPin = 7; diff --git a/code/Arduino/peripheral/LineSensorManager.cpp b/code/Arduino/peripheral/LineSensorManager.cpp index 8f37e47..251e74f 100644 --- a/code/Arduino/peripheral/LineSensorManager.cpp +++ b/code/Arduino/peripheral/LineSensorManager.cpp @@ -10,6 +10,8 @@ LineSensorManager::LineSensorManager() } void LineSensorManager::choose_sensor(int number) { +#if (LINE_SENSOR_REV == 1) + switch (number) { case 1: digitalWrite(Constants::kLineSensorAPin, LOW); @@ -39,6 +41,44 @@ void LineSensorManager::choose_sensor(int number) { default: break; } + +#elif (LINE_SENSOR_REV == 2) + + switch (number) { + case 1: + digitalWrite(Constants::kLineSensorAPin, LOW); + digitalWrite(Constants::kLineSensorBPin, LOW); + digitalWrite(Constants::kLineSensorCPin, HIGH); + break; + case 2: + digitalWrite(Constants::kLineSensorAPin, HIGH); + digitalWrite(Constants::kLineSensorBPin, LOW); + digitalWrite(Constants::kLineSensorCPin, HIGH); + break; + case 3: + digitalWrite(Constants::kLineSensorAPin, LOW); + digitalWrite(Constants::kLineSensorBPin, HIGH); + digitalWrite(Constants::kLineSensorCPin, HIGH); + break; + case 4: + digitalWrite(Constants::kLineSensorAPin, HIGH); + digitalWrite(Constants::kLineSensorBPin, HIGH); + digitalWrite(Constants::kLineSensorCPin, HIGH); + break; + case 5: + digitalWrite(Constants::kLineSensorAPin, HIGH); + digitalWrite(Constants::kLineSensorBPin, HIGH); + digitalWrite(Constants::kLineSensorCPin, LOW); + break; + default: + break; + } + +#else + +#error Line sensor revisions 1 or 2 are supported only + +#endif } int LineSensorManager::get_sensor_value(int number) { diff --git a/code/Arduino/peripheral/LineSensorManager.h b/code/Arduino/peripheral/LineSensorManager.h index 85529a8..0401da3 100644 --- a/code/Arduino/peripheral/LineSensorManager.h +++ b/code/Arduino/peripheral/LineSensorManager.h @@ -2,6 +2,10 @@ #include "IBasicSensorManager.h" +// Line sensor board revision +// can be 1 or 2 +#define LINE_SENSOR_REV 2 + /** * @brief Get information from line sensors. Line values are returned as @AreaType values */ From 5db9474d1a68d2b57c26add44cf643865639e175 Mon Sep 17 00:00:00 2001 From: AJIOB Date: Fri, 23 Mar 2018 11:51:30 +0300 Subject: [PATCH 2/2] Line sensor mux timings fix --- code/Arduino/peripheral/LineSensorManager.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/code/Arduino/peripheral/LineSensorManager.cpp b/code/Arduino/peripheral/LineSensorManager.cpp index 251e74f..beed656 100644 --- a/code/Arduino/peripheral/LineSensorManager.cpp +++ b/code/Arduino/peripheral/LineSensorManager.cpp @@ -74,6 +74,7 @@ void LineSensorManager::choose_sensor(int number) { break; } + delay(1); #else #error Line sensor revisions 1 or 2 are supported only