Skip to content

Commit

Permalink
Merge pull request #168 from brentru/fixes-for-esp-3-alpha
Browse files Browse the repository at this point in the history
Fixes warnings introduced by ESP32 BSP 3.0.0 alpha 1
  • Loading branch information
brentru authored Oct 11, 2023
2 parents 4d87df2 + 140f13f commit a76e50b
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 81 deletions.
12 changes: 2 additions & 10 deletions examples/adafruitio_09_analog_out/adafruitio_09_analog_out.ino
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,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);
ledcAttach(LED_PIN, 12000, 8); // 12 kHz PWM, 8-bit resolution
#else
pinMode(LED_PIN, OUTPUT);
#endif
Expand Down Expand Up @@ -87,12 +85,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);
}
24 changes: 6 additions & 18 deletions examples/adafruitio_13_rgb/adafruitio_13_rgb.ino
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,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);
ledcAttach(RED_PIN, 12000, 8); // 12 kHz PWM, 8-bit resolution
ledcAttach(GREEN_PIN, 12000, 8);
ledcAttach(BLUE_PIN, 12000, 8);
#else
pinMode(RED_PIN, OUTPUT);
pinMode(GREEN_PIN, OUTPUT);
Expand Down Expand Up @@ -108,14 +103,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());
}
1 change: 1 addition & 0 deletions examples/adafruitio_16_servo/.esp32.test.skip
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions examples/adafruitio_23_ifttt/.esp32.test.skip
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions examples/adafruitio_27_wifimanager/.esp32.test.skip
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=Adafruit IO Arduino
version=4.2.7
version=4.2.8
author=Adafruit
maintainer=Adafruit <[email protected]>
sentence=Arduino library to access Adafruit IO.
Expand Down
55 changes: 3 additions & 52 deletions src/AdafruitIO_Data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,12 +419,7 @@ void AdafruitIO_Data::setValue(double value, double lat, double lon, double ele,
@return Feed's name if feed exists.
*/
/**************************************************************************/
char *AdafruitIO_Data::feedName() {
if (!_feed)
return (char *)"";

return _feed;
}
char *AdafruitIO_Data::feedName() { return _feed; }

/**************************************************************************/
/*!
Expand All @@ -448,12 +443,7 @@ char *AdafruitIO_Data::toChar() { return _value; }
@return String of value.
*/
/**************************************************************************/
String AdafruitIO_Data::toString() {
if (!_value)
return String();

return String(_value);
}
String AdafruitIO_Data::toString() { return String(_value); }

/**************************************************************************/
/*!
Expand All @@ -462,13 +452,9 @@ String AdafruitIO_Data::toString() {
*/
/**************************************************************************/
bool AdafruitIO_Data::toBool() {
if (!_value)
return false;

if (strcmp(_value, "1") == 0 || _value[0] == 't' || _value[0] == 'T')
return true;
else
return false;
return false;
}

/**************************************************************************/
Expand All @@ -494,9 +480,6 @@ bool AdafruitIO_Data::isFalse() { return !toBool(); }
*/
/**************************************************************************/
int AdafruitIO_Data::toInt() {
if (!_value)
return 0;

char *endptr;
return (int)strtol(_value, &endptr, 10);
}
Expand All @@ -522,9 +505,6 @@ int AdafruitIO_Data::toPinLevel() {
*/
/**************************************************************************/
unsigned int AdafruitIO_Data::toUnsignedInt() {
if (!_value)
return 0;

char *endptr;
#ifdef ESP8266
// For some reason strtoul is not defined on the ESP8266 platform right now.
Expand All @@ -542,9 +522,6 @@ unsigned int AdafruitIO_Data::toUnsignedInt() {
*/
/**************************************************************************/
float AdafruitIO_Data::toFloat() {
if (!_value)
return 0;

char *endptr;
return (float)strtod(_value, &endptr);
}
Expand All @@ -556,9 +533,6 @@ float AdafruitIO_Data::toFloat() {
*/
/**************************************************************************/
double AdafruitIO_Data::toDouble() {
if (!_value)
return 0;

char *endptr;
return strtod(_value, &endptr);
}
Expand All @@ -570,9 +544,6 @@ double AdafruitIO_Data::toDouble() {
*/
/**************************************************************************/
long AdafruitIO_Data::toLong() {
if (!_value)
return 0;

char *endptr;
return strtol(_value, &endptr, 10);
}
Expand All @@ -584,9 +555,6 @@ long AdafruitIO_Data::toLong() {
*/
/**************************************************************************/
unsigned long AdafruitIO_Data::toUnsignedLong() {
if (!_value)
return 0;

char *endptr;
#ifdef ESP8266
// For some reason strtoul is not defined on the ESP8266 platform right now.
Expand All @@ -605,9 +573,6 @@ unsigned long AdafruitIO_Data::toUnsignedLong() {
/**************************************************************************/
int AdafruitIO_Data::toRed() {
// Convert 0xRRGGBB to red.
if (!_value) {
return 0;
}
char r[5];
strcpy(r, "0x");
strncpy(&r[2], toChar() + 1, 2);
Expand All @@ -623,9 +588,6 @@ int AdafruitIO_Data::toRed() {
/**************************************************************************/
int AdafruitIO_Data::toGreen() {
// Convert 0xRRGGBB to green.
if (!_value) {
return 0;
}
char g[5];
strcpy(g, "0x");
strncpy(&g[2], toChar() + 3, 2);
Expand All @@ -641,9 +603,6 @@ int AdafruitIO_Data::toGreen() {
/**************************************************************************/
int AdafruitIO_Data::toBlue() {
// Convert 0xRRGGBB to blue.
if (!_value) {
return 0;
}
char b[5];
strcpy(b, "0x");
strncpy(&b[2], toChar() + 5, 2);
Expand All @@ -659,9 +618,6 @@ int AdafruitIO_Data::toBlue() {
*/
/**************************************************************************/
long AdafruitIO_Data::toNeoPixel() {
if (!_value) {
return 0;
}
char rgb[9];
strcpy(rgb, "0x");
strncpy(&rgb[2], toChar() + 1, 6);
Expand All @@ -676,11 +632,7 @@ long AdafruitIO_Data::toNeoPixel() {
*/
/**************************************************************************/
char *AdafruitIO_Data::toCSV() {
if (!_value)
return _csv;

memset(_csv, 0, AIO_CSV_LENGTH);

strcpy(_csv, "\"");
strcat(_csv, _value);
strcat(_csv, "\",");
Expand All @@ -689,7 +641,6 @@ char *AdafruitIO_Data::toCSV() {
strcat(_csv, charFromDouble(_lon));
strcat(_csv, ",");
strcat(_csv, charFromDouble(_ele, 2));

return _csv;
}

Expand Down

0 comments on commit a76e50b

Please sign in to comment.