From 0f3490aa6ad31a87200ae519b3505685e0dd1f8f Mon Sep 17 00:00:00 2001 From: Sugar Glider Date: Mon, 10 Mar 2025 16:00:52 -0300 Subject: [PATCH 1/7] fix(matter): itshall set digital mode before digitalWrite --- .../Matter/examples/MatterColorLight/MatterColorLight.ino | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libraries/Matter/examples/MatterColorLight/MatterColorLight.ino b/libraries/Matter/examples/MatterColorLight/MatterColorLight.ino index dd1724f602d..f3e45887576 100644 --- a/libraries/Matter/examples/MatterColorLight/MatterColorLight.ino +++ b/libraries/Matter/examples/MatterColorLight/MatterColorLight.ino @@ -60,6 +60,10 @@ bool setLightState(bool state, espHsvColor_t colorHSV) { analogWrite(ledPin, colorHSV.v); #endif } else { +#ifndef RGB_BUILTIN + // after analogWrite(), it is necessary to set the GPIO to digital mode first + pinMode(ledPin, OUTPUT); +#endif digitalWrite(ledPin, LOW); } // store last HSV Color and OnOff state for when the Light is restarted / power goes off From 94b43d891e076937f35a3180e70d97f2b42dc05f Mon Sep 17 00:00:00 2001 From: Sugar Glider Date: Mon, 10 Mar 2025 16:02:31 -0300 Subject: [PATCH 2/7] fix(matter): example must set pin in digital mode before writting --- .../examples/MatterDimmableLight/MatterDimmableLight.ino | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libraries/Matter/examples/MatterDimmableLight/MatterDimmableLight.ino b/libraries/Matter/examples/MatterDimmableLight/MatterDimmableLight.ino index cb8b8b6f17f..79751905c20 100644 --- a/libraries/Matter/examples/MatterDimmableLight/MatterDimmableLight.ino +++ b/libraries/Matter/examples/MatterDimmableLight/MatterDimmableLight.ino @@ -56,6 +56,10 @@ bool setLightState(bool state, uint8_t brightness) { analogWrite(ledPin, brightness); #endif } else { +#ifndef RGB_BUILTIN + // after analogWrite(), it is necessary to set the GPIO to digital mode first + pinMode(ledPin, OUTPUT); +#endif digitalWrite(ledPin, LOW); } // store last Brightness and OnOff state for when the Light is restarted / power goes off From 05402c439426efa3cad03a537519eea751c7e623 Mon Sep 17 00:00:00 2001 From: Sugar Glider Date: Mon, 10 Mar 2025 16:03:47 -0300 Subject: [PATCH 3/7] fix(matter): example shall set digital mode before writing --- .../MatterEnhancedColorLight/MatterEnhancedColorLight.ino | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libraries/Matter/examples/MatterEnhancedColorLight/MatterEnhancedColorLight.ino b/libraries/Matter/examples/MatterEnhancedColorLight/MatterEnhancedColorLight.ino index bd2d13899ca..750ee172d9a 100644 --- a/libraries/Matter/examples/MatterEnhancedColorLight/MatterEnhancedColorLight.ino +++ b/libraries/Matter/examples/MatterEnhancedColorLight/MatterEnhancedColorLight.ino @@ -64,6 +64,10 @@ bool setLightState(bool state, espHsvColor_t colorHSV, uint8_t brighteness, uint analogWrite(ledPin, colorHSV.v); #endif } else { +#ifndef RGB_BUILTIN + // after analogWrite(), it is necessary to set the GPIO to digital mode first + pinMode(ledPin, OUTPUT); +#endif digitalWrite(ledPin, LOW); } // store last HSV Color and OnOff state for when the Light is restarted / power goes off From 1ec6a9d23baf24a6a408f71ea123a30e912d3f8e Mon Sep 17 00:00:00 2001 From: Sugar Glider Date: Mon, 10 Mar 2025 16:05:57 -0300 Subject: [PATCH 4/7] fix(matter): digitalMode necessary before digitalWrite(LOW) --- libraries/Matter/examples/MatterFan/MatterFan.ino | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libraries/Matter/examples/MatterFan/MatterFan.ino b/libraries/Matter/examples/MatterFan/MatterFan.ino index 1094126a843..5666fa69915 100644 --- a/libraries/Matter/examples/MatterFan/MatterFan.ino +++ b/libraries/Matter/examples/MatterFan/MatterFan.ino @@ -49,7 +49,11 @@ void fanDCMotorDrive(bool fanState, uint8_t speedPercent) { // drive the Fan DC motor if (fanState == false) { // turn off the Fan - digitalWrite(dcMotorPin, LOW); + #ifndef RGB_BUILTIN + // after analogWrite(), it is necessary to set the GPIO to digital mode first + pinMode(ledPin, OUTPUT); +#endif + digitalWrite(dcMotorPin, LOW); } else { // set the Fan speed uint8_t fanDCMotorPWM = map(speedPercent, 0, 100, 0, 255); From ed2d571676e44aa53d14969bf8cb322ed27640f9 Mon Sep 17 00:00:00 2001 From: Sugar Glider Date: Mon, 10 Mar 2025 16:08:16 -0300 Subject: [PATCH 5/7] fix(matter): example must set digital mode after analogwrite --- .../MatterTemperatureLight/MatterTemperatureLight.ino | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libraries/Matter/examples/MatterTemperatureLight/MatterTemperatureLight.ino b/libraries/Matter/examples/MatterTemperatureLight/MatterTemperatureLight.ino index b814ba89704..d46427591ab 100644 --- a/libraries/Matter/examples/MatterTemperatureLight/MatterTemperatureLight.ino +++ b/libraries/Matter/examples/MatterTemperatureLight/MatterTemperatureLight.ino @@ -66,6 +66,10 @@ bool setLightState(bool state, uint8_t brightness, uint16_t temperature_Mireds) analogWrite(ledPin, brightness); #endif } else { +#ifndef RGB_BUILTIN + // after analogWrite(), it is necessary to set the GPIO to digital mode first + pinMode(ledPin, OUTPUT); +#endif digitalWrite(ledPin, LOW); } // store last Brightness and OnOff state for when the Light is restarted / power goes off From e2bb733675e6b3107285454517742a93b3b70e5b Mon Sep 17 00:00:00 2001 From: Sugar Glider Date: Mon, 10 Mar 2025 16:32:19 -0300 Subject: [PATCH 6/7] fix(matter): wrong copy paste --- libraries/Matter/examples/MatterFan/MatterFan.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/Matter/examples/MatterFan/MatterFan.ino b/libraries/Matter/examples/MatterFan/MatterFan.ino index 5666fa69915..afd5f62dd1e 100644 --- a/libraries/Matter/examples/MatterFan/MatterFan.ino +++ b/libraries/Matter/examples/MatterFan/MatterFan.ino @@ -51,7 +51,7 @@ void fanDCMotorDrive(bool fanState, uint8_t speedPercent) { // turn off the Fan #ifndef RGB_BUILTIN // after analogWrite(), it is necessary to set the GPIO to digital mode first - pinMode(ledPin, OUTPUT); + pinMode(dcMotorPin, OUTPUT); #endif digitalWrite(dcMotorPin, LOW); } else { From 9401cf91411bc8cfb38b927ca1b4cd1b6574ad61 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Mon, 10 Mar 2025 19:43:14 +0000 Subject: [PATCH 7/7] ci(pre-commit): Apply automatic fixes --- .../MatterEnhancedColorLight/MatterEnhancedColorLight.ino | 2 +- libraries/Matter/examples/MatterFan/MatterFan.ino | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/Matter/examples/MatterEnhancedColorLight/MatterEnhancedColorLight.ino b/libraries/Matter/examples/MatterEnhancedColorLight/MatterEnhancedColorLight.ino index 750ee172d9a..8e12581fdf2 100644 --- a/libraries/Matter/examples/MatterEnhancedColorLight/MatterEnhancedColorLight.ino +++ b/libraries/Matter/examples/MatterEnhancedColorLight/MatterEnhancedColorLight.ino @@ -67,7 +67,7 @@ bool setLightState(bool state, espHsvColor_t colorHSV, uint8_t brighteness, uint #ifndef RGB_BUILTIN // after analogWrite(), it is necessary to set the GPIO to digital mode first pinMode(ledPin, OUTPUT); -#endif +#endif digitalWrite(ledPin, LOW); } // store last HSV Color and OnOff state for when the Light is restarted / power goes off diff --git a/libraries/Matter/examples/MatterFan/MatterFan.ino b/libraries/Matter/examples/MatterFan/MatterFan.ino index afd5f62dd1e..705aa4853da 100644 --- a/libraries/Matter/examples/MatterFan/MatterFan.ino +++ b/libraries/Matter/examples/MatterFan/MatterFan.ino @@ -49,11 +49,11 @@ void fanDCMotorDrive(bool fanState, uint8_t speedPercent) { // drive the Fan DC motor if (fanState == false) { // turn off the Fan - #ifndef RGB_BUILTIN +#ifndef RGB_BUILTIN // after analogWrite(), it is necessary to set the GPIO to digital mode first pinMode(dcMotorPin, OUTPUT); #endif - digitalWrite(dcMotorPin, LOW); + digitalWrite(dcMotorPin, LOW); } else { // set the Fan speed uint8_t fanDCMotorPWM = map(speedPercent, 0, 100, 0, 255);