Ejemplo n.º 1
0
        public static void Main()
        {
            OutputPort led = new OutputPort(Pins.ONBOARD_LED, false);
            InputPort button = new InputPort(Pins.ONBOARD_SW1, false, Port.ResistorMode.Disabled);

            bool buttonState = false;

            while (true)
            {
                buttonState = button.Read();

                if (buttonState == true)
                {

                    string URI = "http://RYANDESKTOP/blinky/home/push";
                    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URI);
                    request.Method = "GET";
                    HttpWebResponse response = (HttpWebResponse)request.GetResponse();

                    while (buttonState == true)
                    {

                        buttonState = button.Read();

                    }

                     URI = "http://RYANDESKTOP/blinky/home/release";
                    request = (HttpWebRequest)WebRequest.Create(URI);
                    request.Method = "GET";
                    response = (HttpWebResponse)request.GetResponse();

                }
            }
        }
Ejemplo n.º 2
0
        int valoreProporzionaleBotola; //Valore proporzionale asseganto alla botola.

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Costruttore
        /// </summary>
        /// <param name="pwm1">pwm1</param>
        /// <param name="pwm2">pwm2</param>
        /// <param name="pinApertura">pin perl' apertura</param>
        /// <param name="pinChiusura">pin per la chiusura</param>
        public Botola(FEZ_Pin.PWM pwm1, FEZ_Pin.PWM pwm2, FEZ_Pin.Digital pinApertura, FEZ_Pin.Digital pinChiusura)
        {
            open = new InputPort((Cpu.Pin)pinApertura, true, Port.ResistorMode.PullUp);     //Creazione porta per l' apertura.
            close = new InputPort((Cpu.Pin)pinChiusura, true, Port.ResistorMode.PullUp);    //Creazione porta per la chiusura.
            pwm5 = new PWM((PWM.Pin)pwm1);  //Creazione porta pwm.
            pwm6 = new PWM((PWM.Pin)pwm2);  //Creazione porta pwm.
        }
Ejemplo n.º 3
0
 /// <summary>
 /// To be called after setting the properties of the object.
 /// If not called explicitly, it is automatically called when
 /// the sensor is used for the first time.
 /// Preconditions
 ///     Sensor is not open
 ///     InputPin is set
 /// Postconditions
 ///     Sensor is open
 /// </summary>
 public void Open()
 {
     Contract.Requires(port == null);        // sensor is not open
     Contract.Requires(InputPin != Cpu.Pin.GPIO_NONE);
     port = new InputPort(InputPin, false,
         Port.ResistorMode.Disabled);
 }
Ejemplo n.º 4
0
        public static void Main()
        {
            // wait for DHCP-allocated IP address and turn
            while (IPAddress.GetDefaultLocalAddress() == IPAddress.Any);

            pc = new ParseClient("[Here goes your Parse Application ID]", "[Here goes your Parse REST API Key]");

            var doorPort = new InputPort(Pins.GPIO_PIN_D0, true, Port.ResistorMode.PullDown);

            bool lastStatus = doorPort.Read();
            bool currentStatus;
            while (true)
            {
                currentStatus = doorPort.Read();
                if (currentStatus != lastStatus)
                {
                    pc.SendPushToChannel((currentStatus ? "Someone closed the door" : "Someone opened the door"));
                }
                lastStatus = currentStatus;
            }
            #region Interrupt port buggy implementation

            //var doorPort = new InterruptPort(Pins.GPIO_PIN_D0, true, Port.ResistorMode.PullDown, Port.InterruptMode.InterruptEdgeBoth);
            //doorPort.OnInterrupt += DoorSwitch_OnInterrupt;
            //Thread.Sleep(Timeout.Infinite);

            #endregion
        }
Ejemplo n.º 5
0
        public static void Main()
        {
            // Initialize Outputs
            OutputPort ledBuiltIn = new OutputPort(Pins.ONBOARD_LED, false);
            OutputPort ledGreen = new OutputPort(Pins.GPIO_PIN_D11, true);

            // Initialize Inputs
            InputPort button = new InputPort(Pins.ONBOARD_SW1, false, Port.ResistorMode.Disabled);

            // Declare variables
            bool buttonState = false;
            int buttonPress = 0;

            // Loop until button has been pressed 5 times
            while (buttonPress < 6)
            {
                // Read the button bool
                // TRUE when open, FALSE when closed
                buttonState = button.Read();

                // Turn on blue light when button open
                ledBuiltIn.Write(buttonState);

                // Turn green light on when button closed
                ledGreen.Write(!buttonState);
            }
        }
Ejemplo n.º 6
0
        public static void Main()
        {
            Servo servo = new Servo(PWMChannels.PWM_PIN_D6);
            servo.Start();
            Servo servo2 = new Servo(PWMChannels.PWM_PIN_D9);
            servo2.Start();
            InputPort button = new InputPort(Pins.ONBOARD_BTN, false, Port.ResistorMode.Disabled);
            int pos = 0;

            while (true)
            {
                if (button.Read())
                {
                    if (pos == 0)
                    {
                        servo.MoveServoLeft();
                        servo2.MoveServoLeft();
                        pos = 1;
                    }
                    else if (pos == 1)
                    {
                        servo.MoveServoRight();
                        servo2.MoveServoRight();
                        pos = 0;
                    }
                }
            }
        }
Ejemplo n.º 7
0
        public static string GetMessage(InputPort digitalIn)
        {
            var message = "";
            DateTime startTime;

            if (!digitalIn.Read())
            {
                message += "1";
            }
            else
            {
                message += "0";
            }

            Thread.Sleep(sleep);

            if (!digitalIn.Read())
            {
                message += "1";
            }
            else
            {
                message += "0";
            }
            Thread.Sleep(sleep);
            if (message == "11" || message == "00")
            {
                state = TokenState.LISTEN;
                message = "";
                return "";
            }

            state = TokenState.ENDBYTE;
            return message;
        }
Ejemplo n.º 8
0
 public static void Open()
 {
     _I2C = new MultiI2C(0x50);
     TagDetectSignal = new InputPort(Pins.GPIO_PIN_D10, false, ResistorModes.PullUp);
     WakeUpPin = new OutputPort(Pins.GPIO_PIN_D9, true);
     Reset();
 }
Ejemplo n.º 9
0
        public Program()
        {
            _nrf = new Nrf8001(Pins.GPIO_PIN_D4, Pins.GPIO_PIN_D2, Pins.GPIO_PIN_D3, SPI_Devices.SPI1);

            _trigger = new InputPort(Pins.GPIO_PIN_D0, true, ResistorModes.PullUp);
            _reload = new InputPort(Pins.GPIO_PIN_D6, true, ResistorModes.PullUp);
        }
Ejemplo n.º 10
0
        public static void Main()
        {
            // write your code here
            OutputPort led = new OutputPort(Pins.GPIO_PIN_D0, false);
            InputPort button = new InputPort(Pins.GPIO_PIN_D1, false, Port.ResistorMode.PullUp);
            OutputPort ledLight = new OutputPort(Pins.GPIO_PIN_D2, false);
            InputPort buttonLight = new InputPort(Pins.GPIO_PIN_D3, false, Port.ResistorMode.PullUp);
            AnalogInput pot = new AnalogInput(Pins.GPIO_PIN_A0);
            bool buttonState = false;
            bool isDark = false;
            int potValue = 0;

            while (true)
            {
                buttonState = !button.Read();
                isDark = buttonLight.Read() || buttonState;
                ledLight.Write(isDark);
                led.Write(buttonState);
                if (buttonState)
                {
                    //while (buttonState)
                    //{
                    //    potValue = pot.Read();
                    //    led.Write(true);
                    //    Thread.Sleep(potValue*10);
                    //    led.Write(false);
                    //    Thread.Sleep(potValue*10);
                    //    buttonState = !button.Read();
                    //}
                }
            }
        }
Ejemplo n.º 11
0
        public static void Main()
        {
            bool currentState = false, lastState = false;
            led = new OutputPort(Pins.ONBOARD_LED, false);
            btn = new InputPort(Pins.ONBOARD_BTN, false, Port.ResistorMode.Disabled);

            int clicks = 0;

            StartApp(false);

            while (true)
            {
                currentState = btn.Read();

                //if button is pressed
                if (currentState && !lastState)
                {
                    clicks++;
                    bool prime = IsPrime(clicks);
                    if (prime)
                        FlashLed(1, true);

                    Debug.Print(clicks + " > " + prime);
                }

                lastState = currentState;
            }
        }
Ejemplo n.º 12
0
 public AudioShield(SPI.SPI_module module, Cpu.Pin dataSelectPin, Cpu.Pin cmdSelectPin, Cpu.Pin dreqPin)
 {
     dataConfig = new SPI.Configuration(dataSelectPin, false, 0, 0, false, true, 2000, module, dreqPin, false);
     cmdConfig = new SPI.Configuration(cmdSelectPin, false, 0, 0, false, true, 2000, module, dreqPin, false);
     dreq = new InputPort(dreqPin, false, Port.ResistorMode.PullUp);
     spi = new SPI(cmdConfig);
 }
Ejemplo n.º 13
0
        public static void Initialize()
        {
            if (isInitialized)
                Shutdown();

            spi = new SPI(cmdConfig);
            reset = new OutputPort(Pins.GPIO_PIN_D13, true); // Unused pin.
            DREQ = new InputPort(Pins.GPIO_PIN_D3, false, Port.ResistorMode.PullUp);

            isInitialized = true;

            Reset();

            Command_Write(SCI_MODE, 0x800 | (1 << 2));
            Command_Write(SCI_CLOCKF, 7 << 13);
            Command_Write(SCI_VOL, 1);  // highest volume

            Debug.Print(Command_Read(SCI_VOL).ToString()); //  <------------ always returns 0

            if (Command_Read(SCI_VOL) != (0))
            {
                throw new Exception("Failed to initialize VS1053 encoder.");
            }

            spi.Config = dataConfig;
        }
Ejemplo n.º 14
0
        //click, led will flash twice. click to enter a number n, wait and led will flash n times
        public static void Main()
        {
            OutputPort led = new OutputPort(Pins.ONBOARD_LED, false);
            InputPort btn = new InputPort(Pins.ONBOARD_BTN, false, Port.ResistorMode.Disabled);
            bool currentState = false;
            bool lastState = false;
            int flashes = 0;
            bool ledOn = false;
            int clicks = -1;
            Stopwatch timer = Stopwatch.StartNew(); ;

            while (true)
            {
                timer.Stop();

                //if user has already introduced number
                if(timer.ElapsedMilliseconds > 3000)
                {
                    timer.Reset();

                    while(clicks > 0)
                    {
                        clicks--;
                        led.Write(true);
                        Thread.Sleep(500);
                        led.Write(false);
                        Thread.Sleep(500);
                    }
                }

                timer.Start();

                currentState = btn.Read();

                //if button is pressed
                if (currentState && !lastState)
                {
                    clicks++;

                    //flash led twice to start
                    while(flashes < 4)
                    {
                        led.Write(!ledOn);
                        Thread.Sleep(500);
                        ledOn = !ledOn;
                        flashes++;
                    }

                    if(clicks > 0)
                    {
                        timer.Stop();
                        timer.Reset();
                        timer.Start();
                    }
                }

                lastState = currentState;
            }
        }
Ejemplo n.º 15
0
 public Door(string name, Motor motor, InputPort doorOpen, InputPort doorClosed)
 {
   Name = name;
   _motor = motor;
   _doorOpen = doorOpen;
   _doorClosed = doorClosed;
   Status = DoorStatus.Unknown;
 }
Ejemplo n.º 16
0
 private void CreateRowPorts(Cpu.Pin[] rowPins)
 {
     for (int index = 0; index < rowPins.Length; index++)
     {
         Cpu.Pin pin = rowPins[index];
         _rowPorts[index] = new InputPort(pin, true, Port.ResistorMode.PullUp);
     }
 }
 public ThreeReadLineTracker(int pin1, int pin2, int pin3)
 {
     // learn how to enumerate in c#
     ir1 = GetPort(pin1);
     ir2 = GetPort(pin2);
     ir3 = GetPort(pin3);
     irs = new InputPort[] {ir1, ir2, ir3};
 }
Ejemplo n.º 18
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="pinTrig">Netduino pin connected to the HC-SR04 Trig pin</param>
 /// <param name="pinEcho">Netduino pin connected to the HC-SR04 Echo pin</param>
 public HC_SR04(Cpu.Pin pinTrig, Cpu.Pin pinEcho)
 {
     portOut = new OutputPort(pinTrig, false);
     interIn = new InterruptPort(pinEcho, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeLow);
     interIn.OnInterrupt += new NativeEventHandler(interIn_OnInterrupt);
     minTicks = 6200L;
     inchConversion = 1440.0;
     version = 1.1;
 }
Ejemplo n.º 19
0
 public NavigateButtons(InputPort navButtonPrevious, InputPort navButtonNext)
 {
     _prevButton = new NavigateButton(navButtonPrevious);
     _nextButton = new NavigateButton(navButtonNext);
     var worker = new Thread(
     DoWork
     );
     worker.Start();
 }
        private OutputPort latch; // Variabile per la porta utilizzata per il "latch".

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Metodo costruttore
        /// </summary>
        /// <param name="pinData">Porta utilizzata per leggere i dati</param>
        /// <param name="pinClock">Porta utilizzata per il clock</param>
        /// <param name="pinLatch">Porta utilizzata per il latch</param>
        public ClassShiftRegisterInput(InputPort pinData, OutputPort pinClock, OutputPort pinLatch)
        {
            // La porta del dato restituito dal controllore.
            data = pinData;
            // La porta del clock dal controllore.
            clock = pinClock;
            // La porta del latch
            latch = pinLatch;
        }
Ejemplo n.º 21
0
        public NativeDigitalInput(Socket socket, Socket.Pin pin, GlitchFilterMode glitchFilterMode, ResistorMode resistorMode, Module module, Cpu.Pin cpuPin)
        {
            if (cpuPin == Cpu.Pin.GPIO_NONE)
            {
                // this is a mainboard error but should not happen since we check for this, but it doesnt hurt to double-check
                throw Socket.InvalidSocketException.FunctionalityException(socket, "DigitalInput");
            }

            _port = new InputPort(cpuPin, glitchFilterMode == GlitchFilterMode.On, (Port.ResistorMode)resistorMode);
        }
 public SoftwareShiftRegister(ushort size, Cpu.Pin clock, Cpu.Pin reset, Cpu.Pin data, Cpu.Pin commit, ShiftRegisterCallback callback)
 {
     Size = size;
     _bits = new bool[size];
     _clockPin = new InputPort(clock, true, Port.ResistorMode.Disabled);
     _resetPin = new InputPort(reset, true, Port.ResistorMode.Disabled);
     _dataPin = new InputPort(data, true, Port.ResistorMode.Disabled);
     _commitPin = new InputPort(commit, true, Port.ResistorMode.Disabled);
     _callback = callback;
 }
Ejemplo n.º 23
0
        // Note: A constructor summary is auto-generated by the doc builder.
        /// <summary></summary>
        /// <param name="socket">The socket for the digital input interface.</param>
        /// <param name="pin">The pin used by the digital input interface.</param>
        /// <param name="glitchFilterMode">
        ///  A value from the <see cref="GlitchFilterMode"/> enumeration that specifies 
        ///  whether to enable the glitch filter on this digital input interface.
        /// </param>
        /// <param name="resistorMode">
        ///  A value from the <see cref="ResistorMode"/> enumeration that establishes a default state for the digital input interface. N.B. .NET Gadgeteer mainboards are only required to support ResistorMode.PullUp on interruptable GPIOs and are never required to support ResistorMode.PullDown; consider putting the resistor on the module itself.
        /// </param>
        /// <param name="module">The module using this interface, which can be null if unspecified.</param>
        public DigitalInput(Socket socket, Socket.Pin pin, GlitchFilterMode glitchFilterMode, ResistorMode resistorMode, Module module)
        {
            this.port = new InputPort(socket.ReservePin(pin, module), glitchFilterMode == GlitchFilterMode.On, (Port.ResistorMode)resistorMode);

            if (this.port == null)
            {
                // this is a mainboard error but should not happen since we check for this, but it doesnt hurt to double-check
                throw new Socket.InvalidSocketException("Socket " + socket + " has an error with its Digital Input functionality. Please try a different socket.");
            }
        }
Ejemplo n.º 24
0
        public DigitalOutputPin (Cpu.Pin pin, double initialValue = 0)
		{
            Input = AddInput ("Input", Units.Digital, initialValue);

            port = new HWOutputPort (pin, initialValue >= HighMinValue);

            Input.ValueChanged += (s, e) => {
                port.Write (Input.Value >= HighMinValue);
            };
		}
Ejemplo n.º 25
0
        public GestioneMotore(Cpu.Pin motore1, Cpu.Pin motore2, Cpu.Pin motore3, Cpu.Pin motore4, Cpu.Pin inizioCorsa, Cpu.Pin fineCorsa)
        {
            OutputPort A = new OutputPort(motore1, false);
            OutputPort B = new OutputPort(motore2, false);
            OutputPort C = new OutputPort(motore3, false);
            OutputPort D = new OutputPort(motore4, false);

            InputPort btnInizioCorsa = new InputPort(inizioCorsa, true, Port.ResistorMode.PullUp);
            InputPort btnFineCorsa = new InputPort(fineCorsa, true, Port.ResistorMode.PullUp);
        }
Ejemplo n.º 26
0
 public static void Main()
 {
     InputPort inputPort = new InputPort(Cpu.Pin.GPIO_Pin2, false, Port.ResistorMode.PullDown);
     while (true)
     {
         bool state = inputPort.Read(); //polling of port state
         Debug.Print("GPIO input port at pin " + inputPort.Id + " is " + (state ? "high" : "low"));
         Thread.Sleep(10); //enable device to sleep or emulator to react to Visual Studio
     }
 }
Ejemplo n.º 27
0
        public NativeDigitalInput(Socket socket, Socket.Pin pin, GlitchFilterMode glitchFilterMode, ResistorMode resistorMode, Module module, Hardware.Cpu.Pin cpuPin)
        {
            if (cpuPin == Hardware.Cpu.Pin.GPIO_NONE)
            {
                // this is a mainboard error but should not happen since we check for this, but it doesnt hurt to double-check
                throw Socket.InvalidSocketException.FunctionalityException(socket, "DigitalInput");
            }

            _port = new Hardware.InputPort(cpuPin, glitchFilterMode == GlitchFilterMode.On, (Hardware.Port.ResistorMode)resistorMode);
        }
Ejemplo n.º 28
0
        public static void Test()
        {

            // Create new Thread that runs the ExampleThreadFunction
            Thread ExampleThread = new Thread(new ThreadStart(ExampleThreadFunction));

            // SD stuff is in
            PersistentStorage sdPS = new PersistentStorage("SD");

            // Led stuff is in 
            OutputPort LED;
            LED = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.LED, true);

            // Button stuff in
            InputPort Button;
            Button = new InputPort((Cpu.Pin)FEZ_Pin.Digital.LDR, false,
                                   Port.ResistorMode.PullUp);


            while (true)
            {
                //Led status at the beginning is off
                LED.Write(false);

                if (Button.Read())
                {

                    while (Button.Read()) ;   // wait while busy

                    //Led is on
                    LED.Write(true);

                    // Mount
                    sdPS.MountFileSystem();

                    // Start our new Thread
                    ExampleThread.Start();

                    while (Button.Read()) ;   // wait while busy

                    //Led is off
                    LED.Write(true);

                    // Abort our new Thread
                    ExampleThread.Abort();

                    // Unmount
                    sdPS.UnmountFileSystem();
                }

            }



        }
Ejemplo n.º 29
0
        public Encoder(FEZ_Pin.Digital pin)
        {
            //encoder = new InterruptPort((Cpu.Pin)pin, true, Port.ResistorMode.PullDown, Port.InterruptMode.InterruptEdgeHigh);
            //encoder.OnInterrupt += new NativeEventHandler(encoder_OnInterrupt);
            encoder = new InputPort((Cpu.Pin)pin, true, Port.ResistorMode.PullDown);
            stepmm = GlobalVal.wheelPerimeter_mm / GlobalVal.interruptsWheel;
            this.resetDistance();

            Thread th = new Thread(new ThreadStart(this.Run));
            th.Start();
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Creates new Sony TV Remote Receiver instance
        /// </summary>
        /// <param name="receiverPin">Infrared demodulator pin</param>
        public SonyReceiver(Cpu.Pin receiverPin)
        {
            this.ReceiverPin = receiverPin;
            _irdaPort = new InputPort(ReceiverPin, false, Port.ResistorMode.PullUp);
            _pulses = new long[DATA_LENGTH];

            // Start reading thread
            _runningThread = true;
            _mainThread = new Thread(new ThreadStart(DoWork));
            _mainThread.Start();
        }
Ejemplo n.º 31
0
        public static void Main()
        {
            OutputPort led = new OutputPort(Pins.ONBOARD_LED, false);
            InputPort button = new InputPort(Pins.ONBOARD_SW1, false, Port.ResistorMode.Disabled);
            bool buttonState = false;

            while (true)
            {
                buttonState = button.Read();
                led.Write(!buttonState);
            }
        }
Ejemplo n.º 32
0
        public Storage(string storageType, Microsoft.SPOT.Hardware.Cpu.Pin _detectPin)
        {
            cardDetectPin = new InputPort(_detectPin, false, Port.ResistorMode.PullUp);
            try
            {
                if (PersistentStorage.DetectSDCard())
                {
                    ps = new PersistentStorage(storageType);
                    ps.MountFileSystem();
                    Debug.Print("SD Card found and mounted.");
                }

                if (!VolumeInfo.GetVolumes()[0].IsFormatted)
                {
                    Debug.Print("SD Card not formatted.");
                    throw new HomeMonitorException("SD Card not formatted.");
                }
            }
            catch (Exception e)
            {
                Debug.Print("Error: No SD Card Found!");
                //throw new HomeMonitorException("Error: No SD Card Found!", e);
            }
        }
Ejemplo n.º 33
0
        //static bool roverHeadLights = false;
        //static bool roverTakePicture = false;

        public static void Main()
        {
            #region Newhaven 3.5" Display Graphic Setup

            /*
             *  var lcdConfig3 = new Configuration.LCD.Configurations();
             *
             *  lcdConfig3.Width = 320;
             *  lcdConfig3.Height = 240;
             *
             *  lcdConfig3.OutputEnableIsFixed = true;
             *  lcdConfig3.OutputEnablePolarity = true;
             *
             *  lcdConfig3.HorizontalSyncPolarity = false;
             *  lcdConfig3.VerticalSyncPolarity = false;
             *  lcdConfig3.PixelPolarity = true;
             *
             *  lcdConfig3.HorizontalSyncPulseWidth = 68;
             *  lcdConfig3.HorizontalBackPorch = 2;
             *  lcdConfig3.HorizontalFrontPorch = 18;
             *  lcdConfig3.VerticalSyncPulseWidth = 10;
             *  lcdConfig3.VerticalBackPorch = 3;
             *  lcdConfig3.VerticalFrontPorch = 10;
             *
             *  lcdConfig3.PixelClockRateKHz = 6400;
             *
             *  Configuration.LCD.Set(lcdConfig3);
             *
             */
            //if (Configuration.LCD.Set(lcdConfig3)) PowerState.RebootDevice(false);


            //Initialiazing and hooking to events
            var display = new DisplayNhd5(new Microsoft.SPOT.Hardware.I2CDevice(new Microsoft.SPOT.Hardware.I2CDevice.Configuration(0x38, 400)));
            //display.TouchUp += (sender, e) => Debug.Print("Finger " + e.FingerNumber + " up!");
            display.TouchUp += new TouchEventHandler(display_TouchUp);
            //display.TouchDown += (sender, e) => Debug.Print("Finger " + e.FingerNumber + " down!");
            display.TouchDown += new TouchEventHandler(display_TouchDown);
            display.ZoomIn    += (sender, e) => Debug.Print("Zoom in");
            display.ZoomOut   += (sender, e) => Debug.Print("Zoom out");

            /*
             * //Method one: polling manually. Uncomment the while cycle to use it.
             *
             * //while (true) {
             * // display.ReadAndProcessTouchData();
             * // Thread.Sleep(50);
             * //}
             */

            //Method two: using interrupt (for G120).
            var touchPin = new Microsoft.SPOT.Hardware.InterruptPort(GHI.Hardware.G120.Pin.P0_25, false, Microsoft.SPOT.Hardware.Port.ResistorMode.PullUp, Microsoft.SPOT.Hardware.Port.InterruptMode.InterruptEdgeLow);
            var wakePin  = new Microsoft.SPOT.Hardware.InputPort(GHI.Hardware.G120.Pin.P0_24, false, Microsoft.SPOT.Hardware.Port.ResistorMode.Disabled);
            //var touchPin = new Microsoft.SPOT.Hardware.InterruptPort(GHI.Hardware.G120.Pin.P0_23, false, Microsoft.SPOT.Hardware.Port.ResistorMode.PullUp, Microsoft.SPOT.Hardware.Port.InterruptMode.InterruptEdgeLow); //I DID THIS
            touchPin.OnInterrupt += (data1, data2, time) => display.ReadAndProcessTouchData();

            #endregion

            #region LAIRD XCVR SETUP

            //lairdWirelss.Configure(9600, GT.Interfaces.Serial.SerialParity.None, GT.Interfaces.Serial.SerialStopBits.One, 7);
            lairdComPort = new SerialPort("COM2", 115200); //TX2 = P2.0, RX2 = P0.16
            //lairdComPort = new SerialPort("COM2", 9600);

            lairdComPort.Open();

            lairdReset = new Microsoft.SPOT.Hardware.OutputPort(lairdResetPin, true);
            lairdCts   = new Microsoft.SPOT.Hardware.OutputPort(lairdCtsPin, false);
            //lairdRts = new Microsoft.SPOT.Hardware.InputPort(lairdRtsPin, false, Microsoft.SPOT.Hardware.Port.ResistorMode.PullUp);
            lairdRange = new Microsoft.SPOT.Hardware.InputPort(lairdRangePin, false, Microsoft.SPOT.Hardware.Port.ResistorMode.Disabled);

            /*
             * lairdCtsPin = GT.Socket.GetSocket(5, true, null, null).CpuPins[6];
             * //lairdRtsPin = GT.Socket.GetSocket(5, true, null, null).CpuPins[7];
             * lairdResetPin = GT.Socket.GetSocket(5, true, null, null).CpuPins[3];
             * lairdRangePin = GT.Socket.GetSocket(5, true, null, null).CpuPins[8];
             */

            lairdWirelessBuffer = new SerialBuffer(72);

            #endregion

            #region QUAD POWER SETUP

            quadPowerComPort = new SerialPort("COM3", 9600);
            quadPowerComPort.Open();
            quadPowerBuffer = new SerialBuffer(36);

            #endregion

            // Load the window
            _mainWindow = GlideLoader.LoadWindow(OakhillLandroverController.Resources.GetString(OakhillLandroverController.Resources.StringResources.wndMain));
            //pictureWindow = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.Picture_Window));
            outputsWindow = new OutputsWindow();//gndEfxWindow = GlideLoader.LoadWindow(Resources.GetString(Resources.StringResources.GroundEfx_Window));
            ecoCamWindow  = new EcoCamWindow();
            setupWindow   = new SetupWindow();

            // Activate touch
            //GlideTouch.Initialize();

            // Initialize the windows.
            initMainWindow(_mainWindow);

            // Assigning a window to MainWindow flushes it to the screen.
            // This also starts event handling on the window.
            Glide.MainWindow = _mainWindow;

            //bool mybool = SDCard.sdCardDetect;
            //bool yourBool  = batChargeState.Read();
            //lcdBacklight.Write(false); //turn lcd screen off
            //onBoardLed.Write(true);

            picCounter = -1;
            //Glide.MessageBoxManager.Show("SD Card not found.", "SD Card");

            UpdateMainWindowTimer     = new Timer(new TimerCallback(UpdateMainWindowTimer_Tick), null, 0, UpdateMainWindowTimerPeriod);
            PictureViewerTimer        = new Timer(new TimerCallback(PictureViewerTimer_Tick), null, -1, PictureViewerTimerPeriod);
            RoverJoystickControlTimer = new Timer(new TimerCallback(RoverJoystickControlTimer_Tick), null, 0, RoverJoystickTimerPeriod);

            //display_T35.SimpleGraphics.DisplayImage(SD_ROOT_DIRECTORY + @"\roverPic17.jpg", Bitmap.BitmapImageType.Jpeg, 0, 0);

            Thread.Sleep(-1);
        }
Ejemplo n.º 34
0
 void UpdateRealy()
 {
     var relayGP = new Microsoft.SPOT.Hardware.InputPort((Microsoft.SPOT.Hardware.Cpu.Pin) 20, true, Microsoft.SPOT.Hardware.Port.ResistorMode.PullDown);
 }