Main Site Documentation

Reload Main()


#1

Hi,
how can I re-raise the instructions that are inside the programStarter () without performing all the main ()?
the code:

void ProgramStarted()
{
Debug.Print(“Program Started”);
PWM Srclk = new PWM(Cpu.PWMChannel.PWM_2, 500, 0.5, true); // Socket4 PIEDINO 9 …CLOCK

            GT.Socket socket = GT.Socket.GetSocket(4, false, null, null);
            Ser = new GT.Interfaces.DigitalOutput(socket, GT.Socket.Pin.Three, false, null); //Socket4 PIEDINO 3  .....Dato seriale
            Rclk = new GT.Interfaces.DigitalOutput(socket, GT.Socket.Pin.Four, false, null); //Socket4 PIEDINO 4  .....Avanzamento Dato seriale
            Oe_Neg = new GT.Interfaces.DigitalOutput(socket, GT.Socket.Pin.Five, false, null); //Socket4 PIEDINO 5  .....Abilita Uscite
            Srclr_Neg = new GT.Interfaces.DigitalOutput(socket, GT.Socket.Pin.Six, false, null); //Socket4 PIEDINO 6  .....Pulisce lo shift register

            Srclk.Start();
            Oe_Neg.Write(false);
            Thread.Sleep(2);
            Ser.Write(true);
            Srclr_Neg.Write(true);
            Thread.Sleep(2);
            Ser.Write(false);
            
            buttonForMountaineer.ButtonPressed += new ButtonForMountaineer.ButtonEventHandler(buttonForMountaineer_ButtonPressed);
            buttonForMountaineer.ButtonReleased += new ButtonForMountaineer.ButtonEventHandler(buttonForMountaineer_ButtonReleased);
       
    }

void buttonForMountaineer_ButtonReleased(ButtonForMountaineer sender, ButtonForMountaineer.ButtonState state)
{
Debug.Print("Dato inserito…posizione "+a);
if (a == 8)
{
a = 0;
Oe_Neg.Write(true);
Thread.Sleep(4);
Oe_Neg.Write(false);
Main(); <<<---------------Reload MAIN()
}
}

thanks.
Scorpion1


#2

Hi, putting code inside the code tags (the 101010 button above input window) will make code easier to read.

I’m not sure I understand what you mean there. What are you trying to achieve?

If you take the code you want to run and put into another method and call that method from both places.