Giter Site home page Giter Site logo

end2endzone / anyrtttl Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 1.0 394 KB

A feature rich arduino library for playing rtttl melodies

License: MIT License

C++ 44.67% C 4.86% CMake 6.52% Batchfile 21.32% PowerShell 0.81% Shell 15.37% Python 6.46%
arduino rtttl tone piezo rttl

anyrtttl's People

Contributors

end2endzone avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

danowitz

anyrtttl's Issues

Incompatibility with non-blocking tone routine for ATtiny85.

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.

Support for PROGMEM / FLASH melodies in non-blocking mode.

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);

Refactor build process to use Arduino CLI instead of Arduino IDE

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.

Error compiling for board ESP32 Wrover Kit (all versions).

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).

error compiling example code

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.