Skip to content

Commit

Permalink
Update for EspressIf 2.x to 3.0
Browse files Browse the repository at this point in the history
EspressIf 2.x to 3.0 had a breaking change for ledc this fixed PWM pin writes.
  • Loading branch information
cornbrandon committed Jun 11, 2024
1 parent c013c6c commit 1c34e42
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions papracode-thruhole/papracode-thruhole.ino
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include <dummy.h>

/*
papracode
- Reads battery voltage and lights up LEDs to mimic M12 battery fuel gauge
Expand Down Expand Up @@ -137,8 +139,7 @@ void setup() {
pinMode(analogPot, INPUT);
pinMode(analogBatt, INPUT);
pinMode(buzzerPin, OUTPUT);
ledcAttachPin(PWMPin, pwmChannel);
ledcSetup(pwmChannel, PWM_Freq, PWM_Res);
ledcAttach(PWMPin, PWM_Freq, PWM_Res);

digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
Expand Down Expand Up @@ -191,7 +192,7 @@ void loop() {
} else {
fanPWM = maxPWM;
}
ledcWrite(pwmChannel, fanPWM);
ledcWrite(PWMPin, fanPWM);

uint32_t rawBatteryValue = analogRead(analogBatt);
battery = ( ( battery * ( numBatterySamples - 1 ) ) + ( rawBatteryValue ) ) / numBatterySamples;
Expand Down

0 comments on commit 1c34e42

Please sign in to comment.