cotestatnt / AsyncTelegram2

Powerful, flexible and secure Arduino Telegram BOT library. Hardware independent, it can be used with any MCU capable of handling an SSL connection.
MIT License
83 stars 25 forks source link

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

Open FBMinis opened 4 weeks ago

FBMinis commented 4 weeks ago
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);
  }
}

2) 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 commented 4 weeks ago

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