Pinguino Forum
(SOLVED)[Library] Only one pulseIn() constructor recognized ? - Printable Version

+- Pinguino Forum (http://forum.pinguino.cc)
+-- Forum: Software (http://forum.pinguino.cc/forumdisplay.php?fid=7)
+--- Forum: Syntax & Programs (http://forum.pinguino.cc/forumdisplay.php?fid=19)
+--- Thread: (SOLVED)[Library] Only one pulseIn() constructor recognized ? (/showthread.php?tid=4136)



(SOLVED)[Library] Only one pulseIn() constructor recognized ? - FlacoDev - 02-11-2013

Hi guys,

I have a little problem with the function pulseIn().

On the pulseIn() page in the Arduino language's documentation we can see that pulseIn() has two constructor: pulseIn(pin, value) and pulseIn(pin, value, timeout), where timeout is, in fact, an optional parameter.

so, when I do (for example):

Code:
... (some definitions)
#define echoPin 6

long duration;

setup()
{
   ...
   pinMode(echoPin, INPUT);
   ...
}

loop()
{
   ...
   duration = pulseIn(echoPin, HIGH);
   ...
}

It will not work; I must write : duration = pulseIn(echoPin, HIGH, 1000)

I know, it's no big deal, but I just wanted to note that. ^^

Sorry if this thread is in the wrong section.

Flaco


RE: [Library] Only one pulseIn() constructor recognized ? - regis - 03-11-2013

Arduino uses C++ and Pinguino uses C.
C doesn't allow optional argument. The only way would be to declare each function as a varargs function. Not sure it's a good idea.
This is one of the reason why Pinguino will never be 100% compatible with Arduino.


RE: [Library] Only one pulseIn() constructor recognized ? - FlacoDev - 03-11-2013

Smile Okay; I see!
Thank you regis!