Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compilation failure on STM32 "Blue pill" #8

Open
gschintgen opened this issue Nov 27, 2024 · 0 comments
Open

compilation failure on STM32 "Blue pill" #8

gschintgen opened this issue Nov 27, 2024 · 0 comments

Comments

@gschintgen
Copy link

Hi, thanks for your library! It's the most advanced RTTTL library I could find and it works wonderfully on the Nano. But on a STM32 it won't compile due to a differing signature of the noTone function:

extern void noTone(uint8_t _pin, bool destruct = false);

https://github.com/stm32duino/Arduino_Core_STM32/blob/6f28a4884a77ffddc8bdc1e44a781b9f6cbccf08/cores/arduino/Tone.h#L37

The optional second argument breaks the asignment to _noTone:

.pio/libdeps/bluepill_f103c6/AnyRtttl/src/anyrtttl.cpp:70:25: error: invalid conversion from 'void (*)(uint8_t, bool)' {aka 'void (*)(unsigned char, bool)'} to 'anyrtttl::NoToneFuncPtr' {aka 'void (*)(unsigned char)'} [-fpermissive]
   70 | NoToneFuncPtr _noTone = &noTone;
      |                         ^~~~~~~
      |                         |
      |                         void (*)(uint8_t, bool) {aka void (*)(unsigned char, bool)}

For what it's worth, here's my simple fix:

/****************************************************************************
 * Custom functions
 ****************************************************************************/

// Arduino on STM32 (and potentially other platforms) defines
// noTone() with a second (optional) argument. This leads to
// compilation failures, unless the second argument is bound
// to its default value.
void noToneWrapper(uint8_t pin) {
  noTone(pin);
}

ToneFuncPtr _tone = &tone;
NoToneFuncPtr _noTone = &noToneWrapper;
DelayFuncPtr _delay = &delay;
MillisFuncPtr _millis = &millis;

(I can submit a proper PR if you want.)

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

No branches or pull requests

1 participant