Skip to content

Commit d9dbc4a

Browse files
fix(matter): examples must set pin to Digital Mode after analogWrite() and before digitalWrite() (#11070)
* fix(matter): itshall set digital mode before digitalWrite * fix(matter): example must set pin in digital mode before writting * fix(matter): example shall set digital mode before writing * fix(matter): digitalMode necessary before digitalWrite(LOW) * fix(matter): example must set digital mode after analogwrite * fix(matter): wrong copy paste * ci(pre-commit): Apply automatic fixes --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
1 parent e680e7b commit d9dbc4a

File tree

5 files changed

+20
-0
lines changed

5 files changed

+20
-0
lines changed

libraries/Matter/examples/MatterColorLight/MatterColorLight.ino

+4
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ bool setLightState(bool state, espHsvColor_t colorHSV) {
6060
analogWrite(ledPin, colorHSV.v);
6161
#endif
6262
} else {
63+
#ifndef RGB_BUILTIN
64+
// after analogWrite(), it is necessary to set the GPIO to digital mode first
65+
pinMode(ledPin, OUTPUT);
66+
#endif
6367
digitalWrite(ledPin, LOW);
6468
}
6569
// store last HSV Color and OnOff state for when the Light is restarted / power goes off

libraries/Matter/examples/MatterDimmableLight/MatterDimmableLight.ino

+4
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ bool setLightState(bool state, uint8_t brightness) {
5656
analogWrite(ledPin, brightness);
5757
#endif
5858
} else {
59+
#ifndef RGB_BUILTIN
60+
// after analogWrite(), it is necessary to set the GPIO to digital mode first
61+
pinMode(ledPin, OUTPUT);
62+
#endif
5963
digitalWrite(ledPin, LOW);
6064
}
6165
// store last Brightness and OnOff state for when the Light is restarted / power goes off

libraries/Matter/examples/MatterEnhancedColorLight/MatterEnhancedColorLight.ino

+4
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ bool setLightState(bool state, espHsvColor_t colorHSV, uint8_t brighteness, uint
6464
analogWrite(ledPin, colorHSV.v);
6565
#endif
6666
} else {
67+
#ifndef RGB_BUILTIN
68+
// after analogWrite(), it is necessary to set the GPIO to digital mode first
69+
pinMode(ledPin, OUTPUT);
70+
#endif
6771
digitalWrite(ledPin, LOW);
6872
}
6973
// store last HSV Color and OnOff state for when the Light is restarted / power goes off

libraries/Matter/examples/MatterFan/MatterFan.ino

+4
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ void fanDCMotorDrive(bool fanState, uint8_t speedPercent) {
4949
// drive the Fan DC motor
5050
if (fanState == false) {
5151
// turn off the Fan
52+
#ifndef RGB_BUILTIN
53+
// after analogWrite(), it is necessary to set the GPIO to digital mode first
54+
pinMode(dcMotorPin, OUTPUT);
55+
#endif
5256
digitalWrite(dcMotorPin, LOW);
5357
} else {
5458
// set the Fan speed

libraries/Matter/examples/MatterTemperatureLight/MatterTemperatureLight.ino

+4
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ bool setLightState(bool state, uint8_t brightness, uint16_t temperature_Mireds)
6666
analogWrite(ledPin, brightness);
6767
#endif
6868
} else {
69+
#ifndef RGB_BUILTIN
70+
// after analogWrite(), it is necessary to set the GPIO to digital mode first
71+
pinMode(ledPin, OUTPUT);
72+
#endif
6973
digitalWrite(ledPin, LOW);
7074
}
7175
// store last Brightness and OnOff state for when the Light is restarted / power goes off

0 commit comments

Comments
 (0)