コード例 #1
0
ファイル: Gyro_43.cs プロジェクト: EmiiFont/MyShuttle_RC
        /// <summary>Constructs a new instance.</summary>
        /// <param name="socketNumber">The socket that this module is plugged in to.</param>
        public Gyro(int socketNumber)
        {
            Socket socket = Socket.GetSocket(socketNumber, true, this, null);
            socket.EnsureTypeIsSupported('I', this);
            
            this.readBuffer1 = new byte[1];
            this.writeBuffer1 = new byte[1];
            this.writeBuffer2 = new byte[2];
            this.readBuffer8 = new byte[8];

            this.offsetX = 0;
            this.offsetY = 0;
            this.offsetZ = 0;

            this.ready = false;
            this.timer = new GT.Timer(200);
            this.timer.Tick += (a) => this.TakeMeasurement();

            this.i2c = GTI.I2CBusFactory.Create(socket, 0x68, 100, this);
            
            this.interruptInput = GTI.InterruptInputFactory.Create(socket, GT.Socket.Pin.Three, GTI.GlitchFilterMode.Off, GTI.ResistorMode.Disabled, GTI.InterruptMode.RisingEdge, this);
            this.interruptInput.Interrupt += this.OnInterrupt;

            this.SetFullScaleRange();
        }
コード例 #2
0
        /// <summary>Constructs a new instance.</summary>
        /// <param name="socketNumber">The socket that this module is plugged in to.</param>
        public Gyro(int socketNumber)
        {
            Socket socket = Socket.GetSocket(socketNumber, true, this, null);

            socket.EnsureTypeIsSupported('I', this);

            this.readBuffer1  = new byte[1];
            this.writeBuffer1 = new byte[1];
            this.writeBuffer2 = new byte[2];
            this.readBuffer8  = new byte[8];

            this.offsetX = 0;
            this.offsetY = 0;
            this.offsetZ = 0;

            this.ready       = false;
            this.timer       = new GT.Timer(200);
            this.timer.Tick += (a) => this.TakeMeasurement();

            this.i2c = GTI.I2CBusFactory.Create(socket, 0x68, 100, this);

            this.interruptInput            = GTI.InterruptInputFactory.Create(socket, GT.Socket.Pin.Three, GTI.GlitchFilterMode.Off, GTI.ResistorMode.Disabled, GTI.InterruptMode.RisingEdge, this);
            this.interruptInput.Interrupt += this.OnInterrupt;

            this.SetFullScaleRange();
        }
コード例 #3
0
        /// <summary>Constructs a new TouchC8 sensor.</summary>
        /// <param name="socketNumber">The socket number the sensor is plugged into.</param>
        public TouchC8(int socketNumber)
        {
            this.readBuffer    = new byte[1];
            this.writeBuffer   = new byte[2];
            this.addressBuffer = new byte[1];

            this.socket = GT.Socket.GetSocket(socketNumber, false, this, "I");
            this.reset  = GTI.DigitalOutputFactory.Create(this.socket, GT.Socket.Pin.Six, true, this);

            this.Reset();

            this.device = GTI.I2CBusFactory.Create(this.socket, TouchC8.I2C_ADDRESS, TouchC8.I2C_CLOCK_RATE, this);

            this.interrupt            = GTI.InterruptInputFactory.Create(socket, GT.Socket.Pin.Three, GTI.GlitchFilterMode.Off, GTI.ResistorMode.PullUp, GTI.InterruptMode.FallingEdge, this);
            this.interrupt.Interrupt += this.OnInterrupt;

            this.previousWheelDirection = (Direction)(-1);
            this.previousWheelPosition  = 0;
            this.previousWheelTouched   = false;
            this.previousButton1Touched = false;
            this.previousButton2Touched = false;
            this.previousButton3Touched = false;

            Thread.Sleep(250);

            this.ConfigureSPM();
        }
コード例 #4
0
        /// <summary>Constructs a new instance.</summary>
        /// <param name="socketNumber">The socket that this module is plugged in to.</param>
        public AccelG248(int socketNumber)
        {
            Socket socket = Socket.GetSocket(socketNumber, true, this, null);

            socket.EnsureTypeIsSupported('I', this);

            this.buffer1 = new byte[1];
            this.buffer2 = new byte[2];
            this.buffer6 = new byte[6];

            this.i2c = GTI.I2CBusFactory.Create(socket, 0x1C, 400, this);
            this.i2c.Write(0x2A, 0x01);
        }
コード例 #5
0
ファイル: HubAP5_43.cs プロジェクト: valoni/NETMF-Gadgeteer
            public IO60P16(Socket socket)
            {
                this.interruptHandlers = new ArrayList();
                this.write2            = new byte[2];
                this.write1            = new byte[1];
                this.read1             = new byte[1];
                this.pwms = new byte[30] {
                    0x60, 0, 0x61, 1, 0x62, 2, 0x63, 3, 0x64, 4, 0x65, 5, 0x66, 6, 0x67, 7, 0x70, 8, 0x71, 9, 0x72, 10, 0x73, 11, 0x74, 12, 0x75, 13, 0x76, 14
                };

                this.io60Chip = GTI.I2CBusFactory.Create(socket, 0x20, 100, null);

                this.interrupt            = GTI.InterruptInputFactory.Create(socket, Socket.Pin.Three, GTI.GlitchFilterMode.On, GTI.ResistorMode.Disabled, GTI.InterruptMode.RisingEdge, null);
                this.interrupt.Interrupt += this.OnInterrupt;
            }
コード例 #6
0
        /// <summary>Constructs a new instance.</summary>
        /// <param name="socketNumber">The socket that this module is plugged in to.</param>
        public Compass(int socketNumber)
        {
            Socket socket = Socket.GetSocket(socketNumber, true, this, null);

            socket.EnsureTypeIsSupported('I', this);

            this.writeBuffer1 = new byte[1];
            this.readBuffer6  = new byte[6];

            this.timer       = new GT.Timer(200);
            this.timer.Tick += (a) => this.TakeMeasurement();

            this.dataReady            = GTI.InterruptInputFactory.Create(socket, Socket.Pin.Three, GTI.GlitchFilterMode.Off, GTI.ResistorMode.Disabled, GTI.InterruptMode.RisingEdge, this);
            this.dataReady.Interrupt += this.OnInterrupt;

            this.i2c = GTI.I2CBusFactory.Create(socket, 0x1E, 100, this);
        }
コード例 #7
0
ファイル: IO60P16_43.cs プロジェクト: valoni/NETMF-Gadgeteer
        /// <summary>Constructs a new instance.</summary>
        /// <param name="socketNumber">The socket that this module is plugged in to.</param>
        public IO60P16(int socketNumber)
        {
            var socket = Socket.GetSocket(socketNumber, true, this, null);

            socket.EnsureTypeIsSupported('X', this);

            this.interruptHandlers = new ArrayList();
            this.write2            = new byte[2];
            this.write1            = new byte[1];
            this.read1             = new byte[1];
            this.pwms = new byte[30] {
                0x60, 0, 0x61, 1, 0x62, 2, 0x63, 3, 0x64, 4, 0x65, 5, 0x66, 6, 0x67, 7, 0x70, 8, 0x71, 9, 0x72, 10, 0x73, 11, 0x74, 12, 0x75, 13, 0x76, 14
            };

            this.io60Chip = new GTI.SoftwareI2CBus(socket, Socket.Pin.Five, Socket.Pin.Four, 0x20, 400, this);

            this.interrupt            = GTI.InterruptInputFactory.Create(socket, Socket.Pin.Three, GTI.GlitchFilterMode.On, GTI.ResistorMode.Disabled, GTI.InterruptMode.RisingEdge, null);
            this.interrupt.Interrupt += this.OnInterrupt;
        }
コード例 #8
0
        /// <summary>Constructs a new instance.</summary>
        /// <param name="socketNumber">The socket that this module is plugged in to.</param>
        public Gyro(int socketNumber)
        {
            Socket socket = Socket.GetSocket(socketNumber, true, this, null);

            socket.EnsureTypeIsSupported('I', this);

            this.readBuffer1  = new byte[1];
            this.writeBuffer1 = new byte[1];
            this.writeBuffer2 = new byte[2];
            this.readBuffer8  = new byte[8];

            this.offsetX = 0;
            this.offsetY = 0;
            this.offsetZ = 0;

            this.timer       = new GT.Timer(200);
            this.timer.Tick += (a) => this.TakeMeasurement();

            this.i2c = GTI.I2CBusFactory.Create(socket, 0x68, 100, this);

            this.SetFullScaleRange();
        }
コード例 #9
0
        /// <summary>Constructs a new instance.</summary>
        /// <param name="socketNumber">The socket that this module is plugged in to.</param>
        public Accelerometer(int socketNumber)
        {
            Socket socket = Socket.GetSocket(socketNumber, true, this, null);

            socket.EnsureTypeIsSupported('I', this);

            this.read1  = new byte[1];
            this.write1 = new byte[1];
            this.autoResetThresholdDetection = false;

            this.interrupt            = GTI.InterruptInputFactory.Create(socket, GT.Socket.Pin.Three, GTI.GlitchFilterMode.Off, GTI.ResistorMode.Disabled, GTI.InterruptMode.RisingEdge, this);
            this.interrupt.Interrupt += this.OnInterrupt;

            this.i2c         = GTI.I2CBusFactory.Create(socket, 0x1D, 50, this);
            this.i2c.Timeout = 1000;

            this.timer       = new GT.Timer(200);
            this.timer.Tick += (a) => this.TakeMeasurement();

            this.OperatingMode    = Mode.Measurement;
            this.MeasurementRange = Range.TwoG;
        }
コード例 #10
0
        /// <summary>Constructs a new instance.</summary>
        /// <param name="socketNumber">The socket that this module is plugged in to.</param>
        public Barometer(int socketNumber)
        {
            Socket socket = Socket.GetSocket(socketNumber, true, this, null);

            socket.EnsureTypeIsSupported('I', this);

            this.writeBuffer1 = new byte[1];
            this.readBuffer1  = new byte[1];
            this.readBuffer2  = new byte[2];
            this.readBuffer18 = new byte[18];
            this.coefficients = new Coefficients();

            this.xclr = GTI.DigitalOutputFactory.Create(socket, Socket.Pin.Three, false, this);
            this.i2c  = GTI.I2CBusFactory.Create(socket, Barometer.EEPROM_ADDR, 100, this);

            this.ReadFactoryCalibrationData();

            this.i2c.Address = Barometer.ADC_ADDRESS;

            this.timer       = new GT.Timer(200);
            this.timer.Tick += (a) => this.TakeMeasurement();
        }
コード例 #11
0
        /// <summary>Constructs a new instance.</summary>
        /// <param name="rSocketNumber">The mainboard socket that has the display's R socket connected to it.</param>
        /// <param name="gSocketNumber">The mainboard socket that has the display's G socket connected to it.</param>
        /// <param name="bSocketNumber">The mainboard socket that has the display's B socket connected to it.</param>
        /// <param name="tSocketNumber">The mainboard socket that has the display's T socket connected to it.</param>
        /// <param name="iSocketNumber">The mainboard socket that has the display's I socket connected to it.</param>
        public DisplayNHVN(int rSocketNumber, int gSocketNumber, int bSocketNumber, int tSocketNumber, int iSocketNumber)
            : base(WpfMode.PassThrough)
        {
            if (tSocketNumber != Socket.Unused && iSocketNumber != Socket.Unused)
            {
                throw new InvalidOperationException("The T and I sockets may not be connected at the same time.");
            }

            var rSocket = Socket.GetSocket(rSocketNumber, true, this, null);
            var gSocket = Socket.GetSocket(gSocketNumber, true, this, null);
            var bSocket = Socket.GetSocket(bSocketNumber, true, this, null);

            rSocket.EnsureTypeIsSupported('R', this);
            gSocket.EnsureTypeIsSupported('G', this);
            bSocket.EnsureTypeIsSupported('B', this);

            this.backlightPin = GTI.DigitalOutputFactory.Create(gSocket, Socket.Pin.Nine, true, this);

            rSocket.ReservePin(Socket.Pin.Three, this);
            rSocket.ReservePin(Socket.Pin.Four, this);
            rSocket.ReservePin(Socket.Pin.Five, this);
            rSocket.ReservePin(Socket.Pin.Six, this);
            rSocket.ReservePin(Socket.Pin.Seven, this);
            rSocket.ReservePin(Socket.Pin.Eight, this);
            rSocket.ReservePin(Socket.Pin.Nine, this);

            gSocket.ReservePin(Socket.Pin.Three, this);
            gSocket.ReservePin(Socket.Pin.Four, this);
            gSocket.ReservePin(Socket.Pin.Five, this);
            gSocket.ReservePin(Socket.Pin.Six, this);
            gSocket.ReservePin(Socket.Pin.Seven, this);
            gSocket.ReservePin(Socket.Pin.Eight, this);

            bSocket.ReservePin(Socket.Pin.Three, this);
            bSocket.ReservePin(Socket.Pin.Four, this);
            bSocket.ReservePin(Socket.Pin.Five, this);
            bSocket.ReservePin(Socket.Pin.Six, this);
            bSocket.ReservePin(Socket.Pin.Seven, this);
            bSocket.ReservePin(Socket.Pin.Eight, this);
            bSocket.ReservePin(Socket.Pin.Nine, this);

            if (tSocketNumber != Socket.Unused)
            {
                var tSocket = Socket.GetSocket(tSocketNumber, true, this, null);

                tSocket.EnsureTypeIsSupported('T', this);

                tSocket.ReservePin(Socket.Pin.Four, this);
                tSocket.ReservePin(Socket.Pin.Five, this);
                tSocket.ReservePin(Socket.Pin.Six, this);
                tSocket.ReservePin(Socket.Pin.Seven, this);

                GT.Program.BeginInvoke(new NullParamsDelegate(() => Microsoft.SPOT.Touch.Touch.Initialize(Application.Current)), null);
            }
            else if (iSocketNumber != Socket.Unused)
            {
                var iSocket = Socket.GetSocket(iSocketNumber, true, this, null);

                this.transactions              = new I2CDevice.I2CTransaction[2];
                this.resultBuffer              = new byte[1];
                this.addressBuffer             = new byte[1];
                this.i2cBus                    = GTI.I2CBusFactory.Create(iSocket, 0x38, 400, this);
                this.touchInterrupt            = GTI.InterruptInputFactory.Create(iSocket, GT.Socket.Pin.Three, GTI.GlitchFilterMode.Off, GTI.ResistorMode.Disabled, GTI.InterruptMode.RisingAndFallingEdge, this);
                this.touchInterrupt.Interrupt += (a, b) => this.OnTouchEvent();
            }
        }
コード例 #12
0
            private DaisyLink(Socket socket, DaisyLinkModule module)
            {
                Ready = false;
                this.Socket = socket;

                this.ReservedCount = 0;
                this.NodeCount = 0;

                daisyLinkBus = I2CBusFactory.Create(socket, defaultI2cAddress, 10, i2cDataPin, i2cClockPin, module);

                // The link pin (port) is initialized as an input.  It is only driven during initialization of the daisylinked modules.
                daisyLinkResetPort = DigitalIOFactory.Create(socket, daisyLinkPin, false, GlitchFilterMode.Off, ResistorMode.PullUp, module);
                daisyLinkInterruptPort = null;
            }
コード例 #13
0
        /// <summary>Constructs a new instance.</summary>
        /// <param name="rSocketNumber">The mainboard socket that has the display's R socket connected to it.</param>
        /// <param name="gSocketNumber">The mainboard socket that has the display's G socket connected to it.</param>
        /// <param name="bSocketNumber">The mainboard socket that has the display's B socket connected to it.</param>
        /// <param name="i2cSocketNumber">The mainboard socket that has the display's I socket connected to it.</param>
        public DisplayCP7(int rSocketNumber, int gSocketNumber, int bSocketNumber, int i2cSocketNumber)
            : base(WpfMode.PassThrough)
        {
            var config = new DisplayModule.TimingRequirements()
            {
                UsesCommonSyncPin                 = true, //not the proper property, but we needed it for OutputEnableIsFixed
                CommonSyncPinIsActiveHigh         = true, //not the proper property, but we needed it for OutputEnablePolarity
                HorizontalSyncPulseIsActiveHigh   = true,
                VerticalSyncPulseIsActiveHigh     = true,
                PixelDataIsValidOnClockRisingEdge = false,
                HorizontalSyncPulseWidth          = 1,
                HorizontalBackPorch               = 46,
                HorizontalFrontPorch              = 16,
                VerticalSyncPulseWidth            = 1,
                VerticalBackPorch                 = 23,
                VerticalFrontPorch                = 7,
                MaximumClockSpeed                 = 24000,
            };

            base.OnDisplayConnected("Display CP7", 800, 480, DisplayOrientation.Normal, config);

            var rSocket = Socket.GetSocket(rSocketNumber, true, this, null);
            var gSocket = Socket.GetSocket(gSocketNumber, true, this, null);
            var bSocket = Socket.GetSocket(bSocketNumber, true, this, null);

            rSocket.EnsureTypeIsSupported('R', this);
            gSocket.EnsureTypeIsSupported('G', this);
            bSocket.EnsureTypeIsSupported('B', this);

            this.backlightPin = GTI.DigitalOutputFactory.Create(gSocket, Socket.Pin.Nine, true, this);

            rSocket.ReservePin(Socket.Pin.Three, this);
            rSocket.ReservePin(Socket.Pin.Four, this);
            rSocket.ReservePin(Socket.Pin.Five, this);
            rSocket.ReservePin(Socket.Pin.Six, this);
            rSocket.ReservePin(Socket.Pin.Seven, this);
            rSocket.ReservePin(Socket.Pin.Eight, this);
            rSocket.ReservePin(Socket.Pin.Nine, this);

            gSocket.ReservePin(Socket.Pin.Three, this);
            gSocket.ReservePin(Socket.Pin.Four, this);
            gSocket.ReservePin(Socket.Pin.Five, this);
            gSocket.ReservePin(Socket.Pin.Six, this);
            gSocket.ReservePin(Socket.Pin.Seven, this);
            gSocket.ReservePin(Socket.Pin.Eight, this);

            bSocket.ReservePin(Socket.Pin.Three, this);
            bSocket.ReservePin(Socket.Pin.Four, this);
            bSocket.ReservePin(Socket.Pin.Five, this);
            bSocket.ReservePin(Socket.Pin.Six, this);
            bSocket.ReservePin(Socket.Pin.Seven, this);
            bSocket.ReservePin(Socket.Pin.Eight, this);
            bSocket.ReservePin(Socket.Pin.Nine, this);

            if (i2cSocketNumber == Socket.Unused)
            {
                return;
            }

            this.onScreenPressed   = this.OnScreenPressed;
            this.onScreenReleased  = this.OnScreenReleased;
            this.onHomePressed     = this.OnHomePressed;
            this.onMenuPressed     = this.OnMenuPressed;
            this.onBackPressed     = this.OnBackPressed;
            this.onGestureDetected = this.OnGestureDetected;

            Socket i2cSocket = Socket.GetSocket(i2cSocketNumber, true, this, null);

            this.releaseSent               = false;
            this.transactions              = new I2CDevice.I2CTransaction[2];
            this.resultBuffer              = new byte[1];
            this.addressBuffer             = new byte[1];
            this.i2cBus                    = GTI.I2CBusFactory.Create(i2cSocket, 0x38, 400, this);
            this.touchInterrupt            = GTI.InterruptInputFactory.Create(i2cSocket, GT.Socket.Pin.Three, GTI.GlitchFilterMode.Off, GTI.ResistorMode.PullUp, GTI.InterruptMode.RisingAndFallingEdge, this);
            this.touchInterrupt.Interrupt += (a, b) => this.OnTouchEvent();
        }
コード例 #14
0
ファイル: HubAP5_43.cs プロジェクト: valoni/NETMF-Gadgeteer
 public ADS7830(Socket socket)
 {
     this.i2c = GTI.I2CBusFactory.Create(socket, ADS7830.I2C_ADDRESS, 400, null);
 }