Trying to add an event handler its actually a switch to my program.(hope to add 2)
But its crashing runs like 3 seconds stops.
seems to crash around this point "if ((System.DateTime.Now.Ticks - lastDebounceTime) > debounceDelay)"
please help
namespace Hydro
{
public class Program
{
public const int SecondMs = 1000;
public const int MinuteMs = 60 * SecondMs;
public const int HourMs = 60 * MinuteMs;
public const int DayMs = 24 * HourMs;
public const int WeekMs = 7 * DayMs;
static bool method_state_6, method_state_7;
static long lastDebounceTime = DateTime.Now.Ticks;
static long debounceDelay = 100000;
static InputPort phcontroller = new InputPort(Pins.GPIO_PIN_D0, false, Port.ResistorMode.Disabled);
static InputPort nutcontroller = new InputPort(Pins.GPIO_PIN_D1, false, Port.ResistorMode.Disabled);
static OutputPort ph = new OutputPort(Pins.GPIO_PIN_D2, true);
static OutputPort b = new OutputPort(Pins.GPIO_PIN_D3, true);
static OutputPort a = new OutputPort(Pins.GPIO_PIN_D4, true);
static OutputPort drain = new OutputPort(Pins.GPIO_PIN_D5, true);
static OutputPort solenoid = new OutputPort(Pins.GPIO_PIN_D6, true);
static OutputPort heater = new OutputPort(Pins.GPIO_PIN_D7, true);
static OutputPort led = new OutputPort(Pins.GPIO_PIN_D11, true);
public static void Main()
{
InterruptPort input = new InterruptPort(Pins.GPIO_PIN_D10, true, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeBoth);
input.OnInterrupt += new NativeEventHandler(input_OnInterrupt);
}
static void input_OnInterrupt(uint data1, uint data2, DateTime time)
{
if ((System.DateTime.Now.Ticks - lastDebounceTime) > debounceDelay)
{
lastDebounceTime = DateTime.Now.Ticks;
}
{
try
{
Thread led_proc = new Thread(new ThreadStart(turn_led));
led_proc.Start();
while (true)
{
Method_1();
call2_5();
call6_8();
Method_9();
Thread.Sleep(10000);