Comments (5)
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.
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.
Use cases:
- start tone, stop tone
- start tone with time, let tone finish automatically
- start tone with time, explicitly stop tone
- 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.
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.
All PWM features are via analogWrite() as far as I know.
from arduino_ci.
Related Issues (20)
- Output errors to stderr HOT 11
- Empty examples folder causes build to fail HOT 2
- arduino_ci.rb fails to report compile error
- The build-CI does not support setWireTimeout(). HOT 1
- Can RP2040 build environment be supported? HOT 10
- compiling unit tests uses arduino platform specific code HOT 6
- running in gitlab CI HOT 3
- Platform.io Support HOT 3
- Improve factorization of "unused space"
- Running "bundle install --path vendor/bundle" generates deprecated warning HOT 1
- Use temporary directories for unit test artifacts
- ESP32 failing to install in CI build HOT 2
- Update documentation to recommend version pinning
- ESP32 flags unused function as error (should be warning) HOT 9
- libraries: "SoftwareSerial" does not work. HOT 11
- "Bad file descriptor" error when installing HOT 2
- Implement Wire.h slave device mock support
- 1.6.0 error: undefined method `library_of_name' for nil:NilClass (NoMethodError) HOT 5
- Show differences lined up and in quotes
- Unable to find library location on Windows
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arduino_ci.