AsyncTelegram2 icon indicating copy to clipboard operation
AsyncTelegram2 copied to clipboard

After Arduino Release v3.0.1 some lines need to be changed in example "ESP32-CAM"

Open FBMinis opened this issue 1 year ago • 1 comments

Used: F:\arduino-1.8.19\portable\packages\esp32\hardware\esp32\3.0.1\libraries\WiFi
Using library AsyncTelegram2 at version 2.3.1 in folder: F:\arduino-1.8.19\portable\sketchbook\libraries\AsyncTelegram2 
Using library ArduinoJson at version 7.0.4 in folder: F:\arduino-1.8.19\portable\sketchbook\libraries\ArduinoJson 
  1. Replace:
// Lamp Control
void setLamp(int newVal) {
  if (newVal != -1) {
    // Apply a logarithmic function to the scale.
    int brightness = round((pow(2, (1 + (newVal * 0.02))) - 2) / 6 * pwmMax);
    ledcWrite(lampChannel, brightness);
    Serial.print("Lamp: ");
    Serial.print(newVal);
    Serial.print("%, pwm = ");
    Serial.println(brightness);
  }
}

With:

// Lamp Control
void setLamp(int newVal) {
  if (newVal != -1) {
    // Apply a logarithmic function to the scale.
    int brightness = round((pow(2, (1 + (newVal * 0.02))) - 2) / 6 * pwmMax);
    ledcWrite(LAMP_PIN, brightness);
    Serial.print("Lamp: ");
    Serial.print(newVal);
    Serial.print("%, pwm = ");
    Serial.println(brightness);
  }
}
  1. Replace:
  WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0);       // disable brownout detector
  pinMode(LAMP_PIN, OUTPUT);                       // set the lamp pin as output
  ledcSetup(lampChannel, pwmfreq, pwmresolution);  // configure LED PWM channel
  setLamp(0);                                      // set default value
  ledcAttachPin(LAMP_PIN, lampChannel);            // attach the GPIO pin to the channel

With:

 WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0);       // disable brownout detector
  pinMode(LAMP_PIN, OUTPUT);                       // set the lamp pin as output
  ledcAttach(LAMP_PIN, pwmfreq, pwmresolution);  // configure LED PWM channel
  setLamp(0);                                      // set default value

FBMinis avatar Jun 07 '24 15:06 FBMinis

Reason: https://docs.espressif.com/projects/arduino-esp32/en/latest/migration_guides/2.x_to_3.0.html#id2 https://docs.espressif.com/projects/arduino-esp32/en/latest/api/ledc.html#arduino-esp32-ledc-api

FBMinis avatar Jun 07 '24 15:06 FBMinis