Open wuppiwuppi opened 3 years ago
I was able to compile and use this for esp8266 by modifying the following line of code in CapacitiveSensor.cpp. The issue here is that abs() function is taking unsigned long as arguments which doesn't make sense.
unsigned long diff = (total > leastTotal) ? total - leastTotal : leastTotal - total;
if ( (millis() - lastCal > CS_AutocaL_Millis) && diff < (int)(.10 * (float)leastTotal) ) {
Description
Simple compilation of the example sketch fails with the below error.
Workaround:
Install older board package version < 3.0.0 esp8266 by ESP8266 Community Version 2.7.4
Steps To Reproduce Problem
Open example sketch and verify (compile) it.
Hardware & Software
IDE: Arduino 1.8.16 OR Arudino IDE 2.0.0-beta.12 Board: Generic ESP8266 Board: esp8266 by ESP8266 Community Version 3.0.2 ESP01-S Win11
Arduino Sketch
Errors or Incorrect Output
Compiling library "CapacitiveSensor-master" "C:\\Users\\xyz\\AppData\\Local\\Arduino15\\packages\\esp8266\\tools\\xtensa-lx106-elf-gcc\\3.0.4-gcc10.3-1757bed/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ -D_GNU_SOURCE "-IC:\\Users\\xyz\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\3.0.2/tools/sdk/include" "-IC:\\Users\\xyz\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\3.0.2/tools/sdk/lwip2/include" "-IC:\\Users\\xyz\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\3.0.2/tools/sdk/libc/xtensa-lx106-elf/include" "-IC:\\Users\\xyz\\AppData\\Local\\Temp\\arduino-sketch-D98C7FED0C5F5F9EA38B42012BE2DB9B/core" -c -Werror=return-type -Os -g -free -fipa-pta -mlongcalls -mtext-section-literals -fno-rtti -falign-functions=4 -std=gnu++17 -MMD -ffunction-sections -fdata-sections -fno-exceptions -DMMU_IRAM_SIZE=0x8000 -DMMU_ICACHE_SIZE=0x8000 -DNONOSDK22x_190703=1 -DF_CPU=80000000L -DLWIP_OPEN_SRC -DTCP_MSS=536 -DLWIP_FEATURES=1 -DLWIP_IPV6=0 -DARDUINO=10607 -DARDUINO_ESP8266_GENERIC -DARDUINO_ARCH_ESP8266 "-DARDUINO_BOARD=\"ESP8266_GENERIC\"" -DLED_BUILTIN=2 -DFLASHMODE_DOUT -DESP8266 "-IC:\\Users\\xyz\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\3.0.2\\cores\\esp8266" "-IC:\\Users\\xyz\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\3.0.2\\variants\\generic" "-Ie:\\Stuff\\Arduino\\projects\\libraries\\CapacitiveSensor-master" "e:\\Stuff\\Arduino\\projects\\libraries\\CapacitiveSensor-master\\CapacitiveSensor.cpp" -o "C:\\Users\\xyz\\AppData\\Local\\Temp\\arduino-sketch-D98C7FED0C5F5F9EA38B42012BE2DB9B\\libraries\\CapacitiveSensor-master\\CapacitiveSensor.cpp.o" e:\Stuff\Arduino\projects\libraries\CapacitiveSensor-master\CapacitiveSensor.cpp: In member function 'long int CapacitiveSensor::capacitiveSensor(uint8_t)': e:\Stuff\Arduino\projects\libraries\CapacitiveSensor-master\CapacitiveSensor.cpp:94:75: error: call of overloaded 'abs(long unsigned int)' is ambiguous 94 | if ( (millis() - lastCal > CS_AutocaL_Millis) && abs(total - leastTotal) < (int)(.10 * (float)leastTotal) ) { | ^ In file included from c:\users\xyz\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.0.4-gcc10.3-1757bed\xtensa-lx106-elf\include\c++\10.3.0\cstdlib:75, from c:\users\xyz\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.0.4-gcc10.3-1757bed\xtensa-lx106-elf\include\c++\10.3.0\stdlib.h:36, from C:\Users\xyz\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266/Arduino.h:27, from e:\Stuff\Arduino\projects\libraries\CapacitiveSensor-master\CapacitiveSensor.cpp:30: c:\users\xyz\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.0.4-gcc10.3-1757bed\xtensa-lx106-elf\include\stdlib.h:74:5: note: candidate: 'int abs(int)' 74 | int abs (int); | ^~~ In file included from c:\users\xyz\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.0.4-gcc10.3-1757bed\xtensa-lx106-elf\include\c++\10.3.0\cstdlib:77, from c:\users\xyz\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.0.4-gcc10.3-1757bed\xtensa-lx106-elf\include\c++\10.3.0\stdlib.h:36, from C:\Users\xyz\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266/Arduino.h:27, from e:\Stuff\Arduino\projects\libraries\CapacitiveSensor-master\CapacitiveSensor.cpp:30: c:\users\xyz\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.0.4-gcc10.3-1757bed\xtensa-lx106-elf\include\c++\10.3.0\bits\std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)' 79 | abs(long double __x) | ^~~ c:\users\xyz\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.0.4-gcc10.3-1757bed\xtensa-lx106-elf\include\c++\10.3.0\bits\std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)' 75 | abs(float __x) | ^~~ c:\users\xyz\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.0.4-gcc10.3-1757bed\xtensa-lx106-elf\include\c++\10.3.0\bits\std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)' 71 | abs(double __x) | ^~~ c:\users\xyz\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.0.4-gcc10.3-1757bed\xtensa-lx106-elf\include\c++\10.3.0\bits\std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)' 61 | abs(long long __x) { return __builtin_llabs (__x); } | ^~~ c:\users\xyz\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\3.0.4-gcc10.3-1757bed\xtensa-lx106-elf\include\c++\10.3.0\bits\std_abs.h:56:3: note: candidate: 'long int std::abs(long int)' 56 | abs(long __i) { return __builtin_labs(__i); } | ^~~ Using library CapacitiveSensor-master at version 0.5.1 in folder: E:\Stuff\Arduino\projects\libraries\CapacitiveSensor-master Compilation error: Error: 13 INTERNAL: exit status 1