Skip to content

Conversation

ShijiMi-Soup
Copy link

Problem

While trying the I2C_mode example using Arduino IDE 2.3.4, I encountered the following error during compilation:

/Users/takahiro/Documents/Arduino/libraries/SparkFun_Qwiic_Haptic_Driver_DA7280_Library/src/Haptic_Driver.cpp: In member function 'float Haptic_Driver::getBemf()':
/Users/takahiro/Documents/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: some warnings being treated as errors

exit status 1

Compilation error: exit status 1

It seems the issue is that the getBemf() method not having a default return value, even though it is declared to return a float. The error occurs even when I only import "Haptic_Driver.h" without using the library in my code, which suggests it is an issue with the library's implementation rather than usage.

Fix

I added a return 0.0 at the end of the method as a workaround, and the example compiled successfully.

Concerns

I am unsure whether returning 0.0 is appropriate, as I am not familiar with the intended behavior of the getBemf() method. If another value is more appropriate, I am open to suggestions.

@@ -499,6 +499,8 @@ float Haptic_Driver::getBemf()
case 0x03:
return 49.9;
}
Copy link

@tyirvine tyirvine Sep 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for opening this pull request. Check the comment above the function. It states the default value is 0x01 or 4.9mV. In the switch statement you could insert the following:

default:
  return 4.9;

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with you on this.

@tyirvine
Copy link

@edspark Some compilers won't compile the library without this fix. Thank you for the library by the way. 🤙

@edspark
Copy link
Collaborator

edspark commented Sep 15, 2025

Only going to reject this pull request because I had a number of other warnings to fix as well.

@edspark edspark closed this Sep 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants