fixes for ledc, servo lib is broken and external so we cantfix/wontfix

This commit is contained in:
brentru 2023-10-11 14:37:32 -04:00
parent e1ace0ac6f
commit 0f94088d28
6 changed files with 12 additions and 26 deletions

View file

@ -31,8 +31,7 @@ void setup() {
// set up led pin as an analog output
#if defined(ARDUINO_ARCH_ESP32)
// ESP32 pinMode()
ledcAttachPin(LED_PIN, 1);
ledcSetup(1, 1200, 8);
ledcAttachPin(LED_PIN,analogGetChannel(LED_PIN));
#else
pinMode(LED_PIN, OUTPUT);
#endif
@ -87,12 +86,6 @@ void handleMessage(AdafruitIO_Data *data) {
Serial.print("received <- ");
Serial.println(reading);
// write the current 'reading' to the led
#if defined(ARDUINO_ARCH_ESP32)
ledcWrite(1, reading); // ESP32 analogWrite()
#else
analogWrite(LED_PIN, reading);
#endif
analogWrite(LED_PIN, reading);
}

View file

@ -40,13 +40,9 @@ void setup() {
#if defined(ARDUINO_ARCH_ESP32) // ESP32 pinMode
// assign rgb pins to channels
ledcAttachPin(RED_PIN, 1);
ledcAttachPin(GREEN_PIN, 2);
ledcAttachPin(BLUE_PIN, 3);
// init. channels
ledcSetup(1, 12000, 8);
ledcSetup(2, 12000, 8);
ledcSetup(3, 12000, 8);
ledcAttachPin(RED_PIN,analogGetChannel(RED_PIN));
ledcAttachPin(GREEN_PIN,analogGetChannel(GREEN_PIN));
ledcAttachPin(BLUE_PIN,analogGetChannel(BLUE_PIN));
#else
pinMode(RED_PIN, OUTPUT);
pinMode(GREEN_PIN, OUTPUT);
@ -108,14 +104,7 @@ void handleMessage(AdafruitIO_Data *data) {
Serial.println(data->value());
// invert RGB values for common anode LEDs
#if defined(ARDUINO_ARCH_ESP32) // ESP32 analogWrite
ledcWrite(1, 255 - data->toRed());
ledcWrite(2, 255 - data->toGreen());
ledcWrite(3, 255 - data->toBlue());
#else
analogWrite(RED_PIN, 255 - data->toRed());
analogWrite(GREEN_PIN, 255 - data->toGreen());
analogWrite(BLUE_PIN, 255 - data->toBlue());
#endif
analogWrite(RED_PIN, 255 - data->toRed());
analogWrite(GREEN_PIN, 255 - data->toGreen());
analogWrite(BLUE_PIN, 255 - data->toBlue());
}

View file

@ -0,0 +1 @@

View file

@ -0,0 +1 @@

View file

@ -0,0 +1 @@