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>
This commit is contained in:
Sugar Glider 2025-03-10 17:00:34 -03:00 committed by GitHub
parent e680e7b538
commit d9dbc4af41
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 20 additions and 0 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -49,6 +49,10 @@ void fanDCMotorDrive(bool fanState, uint8_t speedPercent) {
// drive the Fan DC motor
if (fanState == false) {
// turn off the Fan
#ifndef RGB_BUILTIN
// after analogWrite(), it is necessary to set the GPIO to digital mode first
pinMode(dcMotorPin, OUTPUT);
#endif
digitalWrite(dcMotorPin, LOW);
} else {
// set the Fan speed

View file

@ -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