> Message: 2 > Date: Mon, 1 Mar 2021 22:04:22 -0600 (CST) > From: Ekpuz <[hidden email]> > To: [hidden email] > Subject: playTone duration in Arduino package > Message-ID: <[hidden email]> > Content-Type: text/plain; charset=us-ascii > > I'm trying to use the Arduino package to control an Arduino Uno compatible > board. When I use playTone, it will play a tone of the specified frequency, > but the duration parameter seems to do nothing. I'm wondering if this is a > bug or if there is something I may not be doing correctly. > > -Cathy > What version of octave, what version of the Arduino package, and can you give a simple example of what you are doing ? |
Here is an annotated interactive session that I hope answers John's questions (Octave version is 5.2.0, on Windows 10, arduino version looks like 0.6.0): >> pkg load arduino >> a=arduino() a = arduino object with fields of: port = \\.\COM4 board = uno libraries = { i2c spi servo shiftregister } availablepins = { d0 - d13 a0 - a5 } >> 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 ans = 5.2.0 >> pkg list %It looks like arduino package version is 0.6.0 Package Name | Version | Installation directory ---------------------+---------+----------------------- arduino *| 0.6.0 | ...\OCTAVE~1.0\mingw64\share\octave\packages\arduino-0.6.0 audio | 2.0.0 | C:\Octave\OCTAVE~1.0\mingw64\share\octave\packages\audio-2.0.0 communications | 1.2.2 | ...\mingw64\share\octave\packages\communications-1.2.2 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. Thanks. -Cathy On Wed, Mar 10, 2021 at 7:06 AM JohnD <[hidden email]> wrote:
|
>> 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. |
> -----Original Message----- > From: JohnD [mailto:[hidden email]] > Sent: Thursday, March 11, 2021 12:21 AM > To: 'Cathy Zupke' > Cc: [hidden email] > 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 |
John, Thanks so much for the help. I didn't appreciate that the code was available to look at and modify. I made the change and it works! Is there a mechanism to report the bug/fix to the developers so that the fix becomes official? -Cathy On Thu, Mar 11, 2021 at 4:39 AM JohnD <[hidden email]> wrote:
|
On Fri, Mar 12, 2021 at 12:54 AM Cathy Zupke <[hidden email]> wrote:
Normally creating a bug on the octave bug page will work [1] However, since I am the author of the package, it has already been added to the repo and will appear in the next release. |
Free forum by Nabble | Edit this page |