private void Interrupt_Setup() {
hGPIO = GPIOapi.GpioOpenHandle(); //returns a handle to the gpio GIPO_ON = true; Debug.WriteLine("Driver open \n" + hGPIO); string Trigger = "InputProcessUpdateHandler"; IntPtr handle = CreateEvent(IntPtr.Zero, false, true, Trigger); //used P/Invoke GPIO_Output(); //set output pins GPIO_Interrupt(Trigger);//configure interrupt
hGPIO = GPIOapi.GpioOpenHandle(); //returns a handle to the gpio
GIPO_ON = true;
Debug.WriteLine("Driver open \n" + hGPIO);
string Trigger = "InputProcessUpdateHandler";
IntPtr handle = CreateEvent(IntPtr.Zero, false, true, Trigger); //used P/Invoke
GPIO_Output(); //set output pins
GPIO_Interrupt(Trigger);//configure interrupt
} private void GPIO_Interrupt(string trigger) {
bool ok; //INTERRUPT DECALRATION ok = GPIOapi.GpioSetupInterruptPin(hGPIO, port6, 4, GPIOapi.INT_TRIGGER_MODE.TRIGGER_MODE_EDGE, GPIOapi.INT_TRIGGER_POLARITY.TRIGGER_POL_HIGH_RISING, trigger, true); //throws exception if (!ok) Debug.WriteLine("NO interrupt"); else Debug.WriteLine("Interrupt set for:" + port6 + "04" + " at " + hGPIO);
bool ok;
//INTERRUPT DECALRATION
ok = GPIOapi.GpioSetupInterruptPin(hGPIO, port6, 4, GPIOapi.INT_TRIGGER_MODE.TRIGGER_MODE_EDGE,
GPIOapi.INT_TRIGGER_POLARITY.TRIGGER_POL_HIGH_RISING, trigger, true); //throws exception
if (!ok)
Debug.WriteLine("NO interrupt");
else
Debug.WriteLine("Interrupt set for:" + port6 + "04" + " at " + hGPIO);
} private InputProcessor _inputProcessor = null; public ShowToggle(InputProcessor inputProcessor) {
_inputProcessor = inputProcessor; _inputProcessor.updateHandeledBy += InputProcessUpdateHandler;
_inputProcessor = inputProcessor;
_inputProcessor.updateHandeledBy += InputProcessUpdateHandler;
} private void InputProcessUpdateHandler() {
Debug.Write("execute");
}
public event InputProcessUpdateHandler updateHandledBy = null; public void Process(Label label) {
if (updateHandledBy != null) updateHandledBy(label);
if (updateHandledBy != null)
updateHandledBy(label);