|
From: | Cathy Zupke |
Subject: | Re: playTone duration in Arduino package |
Date: | Thu, 11 Mar 2021 21:54:10 -0800 |
> -----Original Message-----
> From: JohnD [mailto:john.david.donoghue@gmail.com]
> Sent: Thursday, March 11, 2021 12:21 AM
> To: 'Cathy Zupke'
> Cc: help-octave@gnu.org
> Subject: RE: playTone duration in Arduino package
>
>
> >> playTone(a,'D10',440,1) %piezo speaker is attached to D10 and makes a
> tone that never stops
> >> playTone(a,'D10',300,1) %frequency changes but never stops
> >> playTone(a,'D10',0,1) %sound stops
> >> playTone(a,'D10',180,3) %makes a tone that never stops
> >> playTone(a,'D10',440,0) %frequency changes but never stops
> >> version %I think this gives the version of octave
>
> > It is my understanding that the last parameter is supposed to be duration in
> seconds. So I'd expect the tones to stop after that time has elapsed.
>
>
>
>
> It looks good to me, so must be a bug in the code - the duration should be
> passed to the Arduino tone function in the library code, so if its not turning
> off, its acting like the duration its receiving is 0 that would play until the stop
> is called.
>
> I will have to hook up an Arduino and take a look.
Found an obvious mistake in inst/@arduino/playTone.m. If you change the line
if nargin >= 3
to be
if nargin < 4
It then works for me.
Diff format:
--- a/inst/@arduino/playTone.m Wed Mar 10 15:57:09 2021 -0500
+++ b/inst/@arduino/playTone.m Thu Mar 11 07:35:29 2021 -0500
@@ -35,7 +35,7 @@
if nargin < 3
error ("@arduino.playTone: expected pin name and frequency");
endif
- if nargin >= 3
+ if nargin < 4
duration = 0;
endif
[Prev in Thread] | Current Thread | [Next in Thread] |