Yes, im trying to use PA0 as an ON/OFF button. Once the code runs PA0 should run Shutdown and once its shutdown it should by design Wakeup (restart).
This works with LDR button but not when i use PA0.
Btw i don’t have any more interrupts available. All 16 are used as buttons.
This is not a big issue atm, i can just shutdown every 5 minutes of inactivity (not pressing any of the buttons) and PA0 will then work as expected.
But i need to know if the button will be labeled ON/OFF on the membrane keyboard or just ON.
class Program
{
static GpioController gpio;
static GpioPin led;
static GpioPin ldr;
static Thread wkupThread;
static void Main()
{
gpio = GpioController.GetDefault();
led = gpio.OpenPin(SC20100.GpioPin.PA6);
led.SetDriveMode(GpioPinDriveMode.Output);
ldr = gpio.OpenPin(SC20100.GpioPin.PE3);
ldr.SetDriveMode(GpioPinDriveMode.InputPullUp);
wkupThread = new Thread(PollWkup);
wkupThread.Start();
while (true)
{
for (int i = 0; i < 10; i++)
{
led.Write(GpioPinValue.High);
Thread.Sleep(500);
led.Write(GpioPinValue.Low);
Thread.Sleep(500);
}
}
}
static void PollWkup()
{
while (true)
{
Debug.WriteLine("poll wkup");
if (ldr.Read() == GpioPinValue.Low)
{
Debug.WriteLine("ldr low");
Power.Shutdown(true, DateTime.MaxValue);
}
else {
Debug.WriteLine("ldr high");
}
Thread.Sleep(100);
}
}
}