-->
Page 1 of 2

Added new function for pin i/o

PostPosted: Wed Nov 18, 2015 11:53 pm
by Mmiscool
Added a new function that will allow for use of i/o from a function

Useful for in if then statements and for math applying to input from a pin.

Example:
Code: Select allif io(pi,0) = 1 then print "Pin high" else print "pin low"


Also the below will now work:
Code: Select allbla = io(pwi,0)


Functions can be called with out returning a value:
Code: Select allio(pwo,0,500)


Syntax is same as normal commands. Just in the form of a function.

Re: Added new function for pin i/o

PostPosted: Thu Nov 19, 2015 12:01 am
by forlotto
A valiant effort and a much improved ide imho with this tid bit of code.

Re: Added new function for pin i/o

PostPosted: Mon Nov 23, 2015 2:14 am
by forlotto
That does leave me with the question after messing about a little more.

How would you reference TX, RX, and A0 as pins?

D9 or RX?
D10 or TX?
A0 or D11?

Leaves me a bit curious on what the proper syntax is in these cases?
According to the MAP you left here download/file.php?id=1668&mode=view

Re: Added new function for pin i/o

PostPosted: Mon Nov 23, 2015 7:25 am
by Mmiscool
You can use the rx and ty pin like so

Code: Select allpo RX 1


There is only one analog input so there is no need to reference the pin number at all.

Code: Select allai bla
print bla



internally the code looks like this.
Code: Select all  if (PinDesignaor == "D0")  pin = 16;
  if (PinDesignaor == "D1")  pin = 5;
  if (PinDesignaor == "D2")  pin = 4;
  if (PinDesignaor == "D3")  pin = 0;
  if (PinDesignaor == "D4")  pin = 2;
  if (PinDesignaor == "D5")  pin = 14;
  if (PinDesignaor == "D6")  pin = 12;
  if (PinDesignaor == "D7")  pin = 13;
  if (PinDesignaor == "D8")  pin = 15;
  if (PinDesignaor == "RX")  pin = 3;
  if (PinDesignaor == "TX")  pin = 1;