Example #1
0
        private void Initialize()
        {
            var spiSocket    = GT.Socket.GetSocket(10, true, null, null);
            var pwmSocket    = GT.Socket.GetSocket(11, true, null, null);
            var analogSocket = GT.Socket.GetSocket(12, true, null, null);

            this.forwardLEDs = new GTI.SPI(spiSocket, new GTI.SPI.Configuration(false, 0, 0, false, true, 2000), GTI.SPI.Sharing.Shared, spiSocket, GT.Socket.Pin.Six, null);
            this.leftIRLED   = new GTI.DigitalOutput(spiSocket, GT.Socket.Pin.Three, true, null);
            this.rightIRLED  = new GTI.DigitalOutput(spiSocket, GT.Socket.Pin.Four, true, null);

            this.leftMotorDirection  = new GTI.DigitalOutput(pwmSocket, GT.Socket.Pin.Three, false, null);
            this.rightMotorDirection = new GTI.DigitalOutput(pwmSocket, GT.Socket.Pin.Four, false, null);
            this.leftMotor           = new GTI.PWMOutput(pwmSocket, GT.Socket.Pin.Seven, false, null);
            this.rightMotor          = new GTI.PWMOutput(pwmSocket, GT.Socket.Pin.Eight, false, null);
            this.servo = new GTI.PWMOutput(pwmSocket, GT.Socket.Pin.Nine, false, null);

            this.buzzer         = new GTI.PWMOutput(analogSocket, GT.Socket.Pin.Seven, false, null);
            this.enableFaderPin = new GTI.PWMOutput(analogSocket, GT.Socket.Pin.Eight, true, null);
            this.leftSensor     = new GTI.AnalogInput(analogSocket, GT.Socket.Pin.Three, null);
            this.rightSensor    = new GTI.AnalogInput(analogSocket, GT.Socket.Pin.Four, null);

            this.leftMotor.Set(FEZCerbot.MOTOR_BASE_FREQUENCY, 0);
            this.rightMotor.Set(FEZCerbot.MOTOR_BASE_FREQUENCY, 0);

            this.enableFaderPin.Set(2000, 1.0);

            this.leftMotorInverted  = false;
            this.rightMotorInverted = false;
            this.servoConfigured    = false;

            this.SetLedBitmask(0x00);
        }
        /// <summary></summary>
        /// <param name="socketNumber">The socket that this module is plugged in to.</param>
        public CurrentACS712(int socketNumber)
        {
            Socket socket = Socket.GetSocket(socketNumber, true, this, null);

            socket.EnsureTypeIsSupported('A', this);

            ain = new GTI.AnalogInput(socket, Socket.Pin.Five, this);
        }
Example #3
0
        /// <summary></summary>
        /// <param name="socketNumber">The socket that this module is plugged in to.</param>
        public ReflectorR3(int socketNumber)
        {
            Socket socket = Socket.GetSocket(socketNumber, true, this, null);

            this.left         = new GTI.AnalogInput(socket, Socket.Pin.Three, this);
            this.center       = new GTI.AnalogInput(socket, Socket.Pin.Four, this);
            this.right        = new GTI.AnalogInput(socket, Socket.Pin.Five, this);
            this.centerSwitch = new GTI.DigitalOutput(socket, Socket.Pin.Six, true, this);
        }
Example #4
0
        /// <summary>Constructor</summary>
        /// <param name="socketNumber">The socket that this module is plugged in to.</param>
        public GasSense(int socketNumber)
        {
            Socket socket = Socket.GetSocket(socketNumber, true, this, null);

            socket.EnsureTypeIsSupported('A', this);

            ain = new GTI.AnalogInput(socket, Socket.Pin.Three, this);

            heatingElementEnable = new GTI.DigitalOutput(socket, Socket.Pin.Four, false, this);
        }
Example #5
0
        // Note: A constructor summary is auto-generated by the doc builder.
        /// <summary></summary>
        /// <param name="socketNumber">The mainboard socket that has the module plugged into it.</param>
        public Joystick(int socketNumber)
        {
            Socket socket = Socket.GetSocket(socketNumber, true, this, null);

            this.inputX           = new GTI.AnalogInput(socket, Socket.Pin.Four, this);
            this.inputY           = new GTI.AnalogInput(socket, Socket.Pin.Five, this);
            this.input            = new GTI.InterruptInput(socket, GT.Socket.Pin.Three, GTI.GlitchFilterMode.On, GTI.ResistorMode.PullUp, GTI.InterruptMode.RisingAndFallingEdge, this);
            this.input.Interrupt += new GTI.InterruptInput.InterruptEventHandler(this._input_Interrupt);
            this.offsetX          = 0;
            this.offsetY          = 0;
        }
Example #6
0
        private double Read(GTI.AnalogInput input)
        {
            double total = 0;

            for (int i = 0; i < 10; i++)
            {
                total += input.ReadProportion();
            }

            return(total / 10);
        }
        // Note: A constructor summary is auto-generated by the doc builder.
        /// <summary></summary>
        /// <param name="socketNumber">The socket that this module is plugged in to.</param>
        public ADC_Mux(int socketNumber)
        {
            // This finds the Socket instance from the user-specified socket number.
            // This will generate user-friendly error messages if the socket is invalid.
            // If there is more than one socket on this module, then instead of "null" for the last parameter,
            // put text that identifies the socket to the user (e.g. "S" if there is a socket type S)
            Socket socket = Socket.GetSocket(socketNumber, true, this, null);

            addr0 = new GTI.DigitalOutput(socket, Socket.Pin.Three, false, null);
            addr1 = new GTI.DigitalOutput(socket, Socket.Pin.Six, false, null);

            this.analogA = new GTI.AnalogInput(socket, Socket.Pin.Four, this);
            this.analogB = new GTI.AnalogInput(socket, Socket.Pin.Five, this);
        }
Example #8
0
        void ProgramStarted()
        {
            /**
             * Iniciliza los modulos conectados con Gadgeteer
             */

            Socket10 = GT.Socket.GetSocket(10, true, null, null);

            vibrationControl = new GT.Interfaces.DigitalOutput(Socket10, GT.Socket.Pin.Four, false, null);

            analogPressureMeter = new GT.Interfaces.AnalogInput(Socket10, GT.Socket.Pin.Three, null);
            analogFlexorMeter   = new GT.Interfaces.AnalogInput(Socket10, GT.Socket.Pin.Five, null);


            matrix = new Adafruit_BicolorMatrix(Socket10);

            graphics = new Graphics(matrix);

            data_manager = new DataManager(sdCard, graphics);

            peripheral_manager = new PeripheralManager(graphics, vibrationControl, analogPressureMeter, analogFlexorMeter);

            /**
             * Determina un timer y una funcion que se ejecuta cada 100 millis
             */
            intervalTimer       = new GT.Timer(100);
            intervalTimer.Tick += new GT.Timer.TickEventHandler(TimerTick);
            intervalTimer.Start();

            /*
             * Se inicializan las variables
             **/

            is_being_pressed = false;
            pressed_times    = 0;

            cycles          = 0;
            vibrationCycles = 0;

            Debug.Print("Program Started!!");
        }
Example #9
0
        // This method is run when the mainboard is powered up or reset.
        void ProgramStarted()
        {
            /*******************************************************************************************
            *  Modules added in the Program.gadgeteer designer view are used by typing
            *  their name followed by a period, e.g.  button.  or  camera.
            *
            *  Many modules generate useful events. Type +=<tab><tab> to add a handler to an event, e.g.:
            *   button.ButtonPressed +=<tab><tab>
            *
            *  If you want to do something periodically, use a GT.Timer and handle its Tick event, e.g.:
            *   GT.Timer timer = new GT.Timer(1000); // every second (1000ms)
            *   timer.Tick +=<tab><tab>
            *   timer.Start();
            *******************************************************************************************/


            // Use Debug.Print to show messages in Visual Studio's "Output" window during debugging.
            Debug.Print("Program Started");

            Socket10       = GT.Socket.GetSocket(10, true, null, null);
            AI_ForceSensor = new GTI.AnalogInput(Socket10, GT.Socket.Pin.Five, null);

            sdCard.SDCardMounted   += new SDCard.SDCardMountedEventHandler(sdCard_SDCardMounted);
            sdCard.SDCardUnmounted += new SDCard.SDCardUnmountedEventHandler(sdCard_SDCardUnmounted);

            is_being_pressed = false;
            pressed_times    = 0;
            cycles           = 0;

            currentFace = 0;

            sdCard.MountSDCard();
            System.Threading.Thread.Sleep(intervalMillis);

            rootDirectory = sdCard.GetStorageDevice().RootDirectory;

            _pollingTimer       = new GT.Timer(intervalMillis);
            _pollingTimer.Tick += new GT.Timer.TickEventHandler(TimerTick);
            _pollingTimer.Start();
        }