Giter Site home page Giter Site logo

Comments (5)

dfrencham avatar dfrencham commented on July 22, 2024

What are your thoughts on implementing this?

Something along these lines might suffice:

  • ToneHistory class, similar to pin history
  • ToneHistory uses a ArduinoCIQueue to record state
  • ToneState class or struct with the following members:
    • pin
    • frequency
    • duration
    • start tick
    • playSound (bool reflecting play start or end)
assertEqual(2, state->toneHistory[PIN].size());
ToneState toneStates[]  = state->toneHistory[PIN].toArray();
assetEqual(true,toneStates[0].play); // started playing
assetEqual(false,toneStates[1].play); //stopped

Would that fit with your code base? or is there a better way?

from arduino_ci.

ianfixes avatar ianfixes commented on July 22, 2024

That's more or less what I'm thinking, although I'm not sure how best to combine that with all of pulseIn, pulseOut, PinHistory, etc. I put a bunch of work into making PinHistory compatible with a readable bytestream to support SoftwareSerial. I can't imagine any reason you'd mix those functions with tone/pulse in a real application, so it should be fine to just create a separate history queue for tone stuff.

The other thing that crossed my mind is that if you start a tone and then delay(), then eventually the tone will end. I'm not sure if it's as simple as revisiting that history / Queue template that I made.

How many use cases do you think there are?

from arduino_ci.

dfrencham avatar dfrencham commented on July 22, 2024

Use cases:

  1. start tone, stop tone
  2. start tone with time, let tone finish automatically
  3. start tone with time, explicitly stop tone
  4. start tone, call tone again on the same pin with a different frequency

Tone can only be called on PWM pins (3 and 11 on most boards). There could be multiple tones running at the same time on different pins, but that would be a bit odd.

from arduino_ci.

ianfixes avatar ianfixes commented on July 22, 2024

Aah, my own ignorance getting the better of me again -- didn't know that these were PWM-pins-only features. Are there other PWM functions I need to support or are those just commanded via analogWrite()?

from arduino_ci.

dfrencham avatar dfrencham commented on July 22, 2024

All PWM features are via analogWrite() as far as I know.

from arduino_ci.

Related Issues (20)

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.