This is a gray area for me , I am using this sensor with a adafruit QT PY SAMD21 board and get a compiler error on one of my PC’s. Doing some searches I found a topic for a different board with the same error and it talks about missing a ‘return value’ in the code. https://github.com/chrisjoyce911/esp32FOTA/issues/3
this is the compiler error I get using a board type of adafruit QT PY SAMD21:
C:\Users\Jim\Documents\Arduino\libraries\SparkFun_AS6212_Qwiic_Arduino_Library\src\SparkFun_AS6212_Qwiic.cpp: In member function ‘uint16_t AS6212::getConversionCycleTime()’:
C:\Users\Jim\Documents\Arduino\libraries\SparkFun_AS6212_Qwiic_Arduino_Library\src\SparkFun_AS6212_Qwiic.cpp:361:1: error: control reaches end of non-void function [-Werror=return-type]
361 | }
| ^
I am in way over my head on this but for the fun of it I edited SparkFun_AS6212_Qwiic.cpp and on the line the compiler said it was an error I added return 0; as the last line, and it compiled ok.
uint16_t AS6212::getConversionCycleTime()
{
int cycleTime;
uint16_t configReg = readRegister(CONFIG,2);
bool conversionRateBit_0 = bitRead(configReg, AS6212_CONFIG_BIT_CONVERSION_RATE_0);
bool conversionRateBit_1 = bitRead(configReg, AS6212_CONFIG_BIT_CONVERSION_RATE_1);
bitWrite(cycleTime, 0, conversionRateBit_0);
bitWrite(cycleTime, 1, conversionRateBit_1);
// conversion rate value is stored in just 2 bits in the config reg,
// so we must convert from stored values (0-3) to “human readable” values (125/250/1000/4000).
if(cycleTime == AS6212_CONVERSION_CYCLE_TIME_125MS) return 125;
if(cycleTime == AS6212_CONVERSION_CYCLE_TIME_250MS) return 250;
if(cycleTime == AS6212_CONVERSION_CYCLE_TIME_1000MS) return 1000;
if(cycleTime == AS6212_CONVERSION_CYCLE_TIME_4000MS) return 4000;
return 0; // I ADDED THIS LINE TO FIX THE COMPILER ERROR
}
thoughts ?