end2endzone / anyrtttl Goto Github PK
View Code? Open in Web Editor NEWA feature rich arduino library for playing rtttl melodies
License: MIT License
A feature rich arduino library for playing rtttl melodies
License: MIT License
Open an issue on Arduino's GitHub for proposing the library. See this issue for example.
I'm trying to use this library in blocking::playProgMem
mode, but while it sounds great and works well on its own, it also stops the tone routine I'm using from working. I'm using the following routine, it can be called by using note(n, o)
, where 'n' is the note, from 0 to 11 and 'o' is the octave, from 0 to 10:
const int Output = 1; // Can be 1 or 4
// Cater for 16MHz, 8MHz, or 1MHz clock:
const int Clock = ((F_CPU/1000000UL) == 16) ? 4 : ((F_CPU/1000000UL) == 8) ? 3 : 0;
const uint8_t scale[] PROGMEM = {239,226,213,201,190,179,169,160,151,142,134,127};
void note (int n, int octave) {
int prescaler = 8 + Clock - (octave + n/12);
if (prescaler<1 || prescaler>15 || octave==0) prescaler = 0;
DDRB = (DDRB & ~(1<<Output)) | (prescaler != 0)<<Output;
OCR1C = pgm_read_byte(&scale[n % 12]) - 1;
GTCCR = (Output == 4)<<COM1B0;
TCCR1 = 1<<CTC1 | (Output == 1)<<COM1A0 | prescaler<<CS10;
}
My code plays a boot-up sound using this routine and plays a tone whenever a button is being pressed. I'm using this kind of routine because it is non-blocking (there are other things going on in the loop() ) and because the standard tone()
function can play the boot-up sound but not the tone, which is toggled by a button that has a condition linked to an ISR call:
attachInterrupt(0, hornISR, FALLING);
void loop () {
if (hornButtonPressed == true) {
note(0, 5);
}
if (digitalRead(hornButton) == HIGH && hornButtonPressed == true) {
note(0, 0);
hornButtonPressed = false;
}
}
void hornISR() {
hornButtonPressed = true;
}
As soon as I call anyrtttl::blocking::playProgMem(BUZZER_PIN, pacman);
, the tune plays, but the tone routine is unable to play anymore. The anyrtttl library is being used in blocking mode because there is no need to run other things while the tune is playing, however, everything should return to normal once the tune has stopped playing.
The library does not support playing RTTTL data in non-blocking mode.
The following new API should be created:
/****************************************************************************
* Description:
* Plays a native RTTTL melody which is stored in Program Memory (PROGMEM).
* Parameters:
* iPin: The pin which is connected to the piezo buffer.
* iBuffer: The string buffer of the RTTTL melody.
****************************************************************************/
void rtttl::nonblocking::playProgMem(byte iPin, const char * iBuffer);
Latest version of Arduino IDE does not include the command line build tool. This change is breaking continuous integration scripts on AppVeyor and Github Actions.
The solution is to use Arduino CLI instead and continue building this library from the command line.
Hello,
I have a code base I use mainly on two boards, a XIAO_ESP32C3 and a ESP32_WROVER_KIT. After adding the AnyRtttl library and compiling for the WROVER board, it fails. The ESP32C3 board compiles and works just fine! Any ideas? Error below...
I'm liking this library otherwise!
Thank you!
Regards,
-Moses
C:\Users\Mo\Documents\Arduino\libraries\arduino_65006\src\anyrtttl.cpp:116:23: error: invalid conversion from 'void ()(uint32_t)' {aka 'void ()(unsigned int)'} to 'anyrtttl::DelayFuncPtr' {aka 'void (*)(long unsigned int)'} [-fpermissive]
DelayFuncPtr _delay = &delay;
^~~~~~
Error compiling for board ESP32 Wrover Kit (all versions).
getting a compile error:
Invalid conversion from 'void ()(uint8_t, unsigned int, long unsigned int)' {aka 'void ()(unsigned char, unsigned int, long unsigned int)'} to 'anyrtttl::ToneFuncPtr' {aka 'void (*)(unsigned char, short unsigned int, unsigned int)'} [-fpermissive]
ToneFuncPtr _tone = &tone;
when trying to compile the basic example, pulled latest from arduino ide, v 2.2.0
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.