Porting NETMF port operations to TinyCLR

Hello, I am taking a program I built for FEZ Panda 3 using NETMF and moving it to one of the new FEZ boards running TinyCLR.

On NETMF, there was an easy way to toggle an output, using the OutputPort class.

static OutputPort HEARTBEAT_IND = new OutputPort(FEZPandaIII.Gpio.Led4, false);

then, when I toggle it,

 while (true)

/* I am moving it over from NETMF to TinyCLR because the available classes of FEZ boards in the definition of an OutputPort do not include the FEZ. Error (Type or Namespace ‘FEZ’ does not exist in the namespace GHI.Pins) */

When I write for TinyCLR , I need to use the GpioPin type

static GpioPin HEARTBEAT_IND = GpioController.GetDefault().OpenPin(GHIElectronics.TinyCLR.Pins.FEZ.GpioPin.Led2);

If I attempt to toggle the same way , it flags an error that the operator ! cannot be applied to operand of type GpioPin.


I tried casting the return from HEARTBEAT_IND.Read(); without success


Error ----> Cannot convert type GpioPinValue to bool

Instead, I have to run through an if else statement to make the same function happen.

if(HEARTBEAT_IND.Read() == GpioPinValue.Low)

I cannot imagine a simple function like this is lost in TinyCLR, so it must be something I am missing.
Any help is appreciated.

Find out what the return type from HEARTBEAT_IND.Read() is and change your logic to match.

Reading the following might help…