ESP32 Micromod + Qwiic Haptic Driver DA7280 => cpp compile error in Arduino IDE 2.3.6

Hi,

I’ve found an issue and a possible solution for this:

I have a Micromod Single Board with an ESP32 plus a Haptic Driver DA7280 connected via Qwiic.

Following the hookup guide and uploading the unaltered I2C example, I get this compile error (compiler exits):

Arduino\libraries\SparkFun_Qwiic_Haptic_Driver_DA7280_Library\src\Haptic_Driver.cpp: In member function 'float Haptic_Driver::getBemf()':
Arduino\libraries\SparkFun_Qwiic_Haptic_Driver_DA7280_Library\src\Haptic_Driver.cpp:502:1: error: control reaches end of non-void function [-Werror=return-type]
  502 | }
      | ^
cc1plus.exe: some warnings being treated as errors
exit status 1

I was able to workaround this by adding to Haptic_Driver.cpp
Line 501

	default:
		return 0.0;

Example works then.

I am not sure though if that is the proper solution. Could anyone confirm that or suggest another solution?

I will open a ticket in the Git repo and link this post there.

1 Like

That works fine.

The routine will only process what is in the case-statement, it will never get to the return() you added. There are other ways to handle, but this is simple and will work to overcome the compile error.

1 Like