From 95e58b56a56788e4f7b793a157b10c840511d97f Mon Sep 17 00:00:00 2001 From: Joshua Yang Date: Thu, 4 Jul 2019 14:47:19 +0900 Subject: [PATCH] ODROID-COMMON: Edit _analogRead to work with physical analog channel numbering --- wiringPi/odroidc1.c | 10 ++++++++++ wiringPi/odroidc2.c | 10 ++++++++++ wiringPi/odroidn1.c | 10 ++++++++++ wiringPi/odroidn2.c | 10 ++++++++++ wiringPi/odroidxu3.c | 10 ++++++++++ 5 files changed, 50 insertions(+) diff --git a/wiringPi/odroidc1.c b/wiringPi/odroidc1.c index c7c6618..e5ddb20 100755 --- a/wiringPi/odroidc1.c +++ b/wiringPi/odroidc1.c @@ -526,12 +526,22 @@ static int _analogRead (int pin) /* wiringPi ADC number = pin 25, pin 29 */ switch (pin) { +#if defined(ARDUINO) + /* To work with physical analog channel numbering */ + case 1: case 25: + pin = 0; + break; + case 0: case 29: + pin = 1; + break; +#else case 0: case 25: pin = 0; break; case 1: case 29: pin = 1; break; +#endif default: return 0; } diff --git a/wiringPi/odroidc2.c b/wiringPi/odroidc2.c index 2780b5d..4230bb4 100755 --- a/wiringPi/odroidc2.c +++ b/wiringPi/odroidc2.c @@ -596,12 +596,22 @@ static int _analogRead (int pin) /* wiringPi ADC number = pin 25, pin 29 */ switch (pin) { +#if defined(ARDUINO) + /* To work with physical analog channel numbering */ + case 1: case 25: + pin = 0; + break; + case 0: case 29: + pin = 1; + break; +#else case 0: case 25: pin = 0; break; case 1: case 29: pin = 1; break; +#endif default: return 0; } diff --git a/wiringPi/odroidn1.c b/wiringPi/odroidn1.c index b8d30a7..71d8648 100755 --- a/wiringPi/odroidn1.c +++ b/wiringPi/odroidn1.c @@ -523,12 +523,22 @@ static int _analogRead (int pin) /* wiringPi ADC number = pin 25, pin 29 */ switch (pin) { +#if defined(ARDUINO) + /* To work with physical analog channel numbering */ + case 1: case 25: + pin = 0; + break; + case 0: case 29: + pin = 1; + break; +#else case 0: case 25: pin = 0; break; case 1: case 29: pin = 1; break; +#endif default: return 0; } diff --git a/wiringPi/odroidn2.c b/wiringPi/odroidn2.c index 0988004..9b42ff7 100755 --- a/wiringPi/odroidn2.c +++ b/wiringPi/odroidn2.c @@ -498,12 +498,22 @@ static int _analogRead (int pin) /* wiringPi ADC number = pin 25, pin 29 */ switch (pin) { +#if defined(ARDUINO) + /* To work with physical analog channel numbering */ + case 3: case 25: + pin = 0; + break; + case 2: case 29: + pin = 1; + break; +#else case 0: case 25: pin = 0; break; case 1: case 29: pin = 1; break; +#endif default: return 0; } diff --git a/wiringPi/odroidxu3.c b/wiringPi/odroidxu3.c index 236fcbe..263c2cd 100755 --- a/wiringPi/odroidxu3.c +++ b/wiringPi/odroidxu3.c @@ -547,12 +547,22 @@ static int _analogRead (int pin) /* wiringPi ADC number = pin 25, pin 29 */ switch (pin) { +#if defined(ARDUINO) + /* To work with physical analog channel numbering */ + case 0: case 25: + pin = 0; + break; + case 3: case 29: + pin = 1; + break; +#else case 0: case 25: pin = 0; break; case 1: case 29: pin = 1; break; +#endif default: return 0; }