当前位置: 首页>>代码示例>>C#>>正文


C# I2CDevice.Dispose方法代码示例

本文整理汇总了C#中Microsoft.SPOT.Hardware.I2CDevice.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# I2CDevice.Dispose方法的具体用法?C# I2CDevice.Dispose怎么用?C# I2CDevice.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.SPOT.Hardware.I2CDevice的用法示例。


在下文中一共展示了I2CDevice.Dispose方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ScanAddresses

        /// <summary>
        /// Scan range of addresses and print devices to debug output.
        /// </summary>
        /// <param name="startAddress">Start of scanning (included)</param>
        /// <param name="endAddress">End of scanning (included)</param>
        /// <param name="clockRateKhz">frequency in Khz</param>
        public static void ScanAddresses(ushort startAddress, ushort endAddress, ushort clockRateKhz = 100)
        {
            Debug.Print("Scanning...");
            for (ushort adr = startAddress; adr <= endAddress; adr++)
            {

                I2CDevice device = new I2CDevice(new I2CDevice.Configuration(adr, clockRateKhz));
                byte[] buff = new byte[1];
                try
                {
                    I2CDevice.I2CReadTransaction read = I2CDevice.CreateReadTransaction(buff);
                    var ret = device.Execute(new I2CDevice.I2CTransaction[] { read }, 1000);
                    if(ret > 0) Debug.Print("Device on address: "+adr+ " (0x"+adr.ToString("X")+")");

                }
                catch (Exception){
                    continue;
                }
                finally
                {
                    //otestovat yda se dela pokazde
                    device.Dispose();
                    device = null;
                }
            }
            Debug.Print("Scanning finished.");
        }
开发者ID:marinehero,项目名称:NETMF-Utils,代码行数:33,代码来源:I2CScanner.cs

示例2: WriteEeprom

 /* There is no generic public Write EEPROM command.
  * Specific commands are available for setting EEPROM values
  * where appropriate to the device. */
 void WriteEeprom(EEPROMAddress addr, byte data)
 {
     myI2Command[0] = I2CDevice.CreateWriteTransaction(new byte[] { (byte)Command.WriteEEPROM, (byte)addr, data });
     // Exécution de la transaction
     BusI2C = new I2CDevice(ConfigHM6352); // Connexion virtuelle de l'objet HMC6352  au bus I2C
     myBytesTransmitted = BusI2C.Execute(myI2Command, 100);
     BusI2C.Dispose(); // Déconnexion virtuelle de l'objet HMC6352 du bus I2C
 }
开发者ID:WebGE,项目名称:HMC6352,代码行数:11,代码来源:HMC6352.cs

示例3: WakeUp

 public void WakeUp()
 {
     myI2Command[0] = I2CDevice.CreateWriteTransaction(new byte[] { (byte)Command.WakeUp });
     // Exécution de la transaction
     BusI2C = new I2CDevice(ConfigHM6352); // Connexion virtuelle de l'objet HMC6352  au bus I2C
     myBytesTransmitted = BusI2C.Execute(myI2Command, 100);
     BusI2C.Dispose(); // Déconnexion virtuelle de l'objet HMC6352 du bus I2C
 }
开发者ID:WebGE,项目名称:HMC6352,代码行数:8,代码来源:HMC6352.cs

示例4: SetOperationalMode

 // Set the operational mode.
 // Mode = Standby, Query, Continuous
 // Frequency = 1, 45, 10, 20 Hz
 // Periodic reset = true/false
 public void SetOperationalMode(OperationalMode mode, Frequency freq, Boolean periodicReset)
 {
     byte r = periodicReset ? (byte)(0x01 << 3) : (byte) 0;
     byte f = (byte)((byte)freq << 5);
     byte op = (byte)((byte)mode | r | f);
     myI2Command[0] = I2CDevice.CreateWriteTransaction(new byte[] { (byte)Command.WriteEEPROM, (byte)EEPROMAddress.OperationalModeByte, op });
     // Exécution de la transaction
     BusI2C = new I2CDevice(ConfigHM6352); // Connexion virtuelle de l'objet HMC6352  au bus I2C
     myBytesTransmitted = BusI2C.Execute(myI2Command, 100);
     BusI2C.Dispose(); // Déconnexion virtuelle de l'objet HMC6352 du bus I2C
 }
开发者ID:WebGE,项目名称:HMC6352,代码行数:15,代码来源:HMC6352.cs

示例5: ReadEeprom

 public byte ReadEeprom(EEPROMAddress addr)
 {
     myI2Command[0] = I2CDevice.CreateWriteTransaction(new byte[] { (byte)Command.ReadEEPROM, (byte) addr });
     myI2Command[1] = I2CDevice.CreateReadTransaction(myReadEEPROM);
     // Exécution de la transaction
     BusI2C = new I2CDevice(ConfigHM6352); // Connexion virtuelle de l'objet HMC6352  au bus I2C
     myBytesTransmitted = BusI2C.Execute(myI2Command, 100);
     BusI2C.Dispose(); // Déconnexion virtuelle de l'objet HMC6352 du bus I2C
     return myReadEEPROM[0];
 }
开发者ID:WebGE,项目名称:HMC6352,代码行数:10,代码来源:HMC6352.cs

示例6: GetAllRegisters

        // Public methode
        /// <summary>
        /// Lecture des 17 registres de la carte MD2x
        /// et calcul de la valeur des encodeurs
        /// </summary>
        /// <returns></returns>
        public int GetAllRegisters()
        {
            // Buffer d'écriture
            byte[] outBuffer = new byte[] { 0 };
            I2CDevice.I2CWriteTransaction writeTransaction = I2CDevice.CreateWriteTransaction(outBuffer);

            // Buffer de lecture
            byte[] inBuffer = new byte[17];
            I2CDevice.I2CReadTransaction readTransaction = I2CDevice.CreateReadTransaction(inBuffer);

            // Tableau des transactions
            I2CDevice.I2CTransaction[] transactions = new I2CDevice.I2CTransaction[] { writeTransaction, readTransaction };
            // Exécution des transactions
            busI2C = new I2CDevice(configMD2x); // Connexion virtuelle de la carte MD2x au bus I2C

            if (busI2C.Execute(transactions, TRANSACTIONEXECUTETIMEOUT) != 0)
            {
                // Success
                //Debug.Print("Received the first data from at device " + busI2C.Config.Address + ": " + ((int)inBuffer[0]).ToString());
                // Sauvegarde de la valeur contenue dans les registres
                speed1 = inBuffer[0]; speed2Turn = inBuffer[1]; battery = inBuffer[10]; current1 = inBuffer[11]; current2 = inBuffer[12];
                softrev = inBuffer[13]; acceleration = inBuffer[14]; mode = inBuffer[15]; command = inBuffer[16];
                // Calcul de la valeur contenue dans les codeurs 32 bits signée
                encoder1 = (Int32)(inBuffer[2] << 24) | (Int32)(inBuffer[3] << 16) | (Int32)(inBuffer[4] << 8) | (Int32)(inBuffer[5]);
                encoder2 = (Int32)(inBuffer[6] << 24) | (Int32)(inBuffer[7] << 16) | (Int32)(inBuffer[8] << 8) | (Int32)(inBuffer[9]);
            }
            else
            {
                // Failed
                //Debug.Print("Failed to execute transaction at device: " + busI2C.Config.Address + ".");
            }
            busI2C.Dispose(); // Déconnexion virtuelle de l'objet Lcd du bus I2C
            return 1;
        }
开发者ID:WebGE,项目名称:MD25,代码行数:40,代码来源:DriverMD2x.cs

示例7: Read

        public void Read()
        {
            I2CDevice MyI2C = new I2CDevice(i2con);

            //create transactions (we need 2 in this example)
            I2CDevice.I2CTransaction[] readActions = new I2CDevice.I2CTransaction[2];

            // create write buffer (we need one byte)
            byte[] RegisterNum = new byte[1] { 2 };
            readActions[0] = I2CDevice.CreateWriteTransaction(RegisterNum);

            // create read buffer to read the register
            byte[] RegisterValue = new byte[1];
            readActions[1] = I2CDevice.CreateReadTransaction(RegisterValue);

            // Now we access the I2C bus and timeout in one second if no responce
            MyI2C.Execute(readActions, 1000);

            if (currentValue != RegisterValue[0])
            {
                currentValue = RegisterValue[0];

                if (OnChange != null)
                {
                    OnChange(dialId, currentValue);
                }
            }

            MyI2C.Dispose();

            //Debug.Print("Register value: " + RegisterValue[0].ToString());
        }
开发者ID:nocoolnicksleft,项目名称:yukidreh,代码行数:32,代码来源:Program.cs

示例8: GetRegister

        /// <summary>
        /// Returns the value contained in a register
        /// et +
        /// </summary>
        /// <param name="RegisterNumber">The register number</param>
        /// <returns></returns>
        private byte GetRegister(Registers RegisterNumber)
        {
            // Buffer d'écriture
                byte[] outBuffer = new byte[] { (byte)RegisterNumber };
                I2CDevice.I2CWriteTransaction writeTransaction = I2CDevice.CreateWriteTransaction(outBuffer);

                // Buffer de lecture
                byte[] inBuffer = new byte[1];
                I2CDevice.I2CReadTransaction readTransaction = I2CDevice.CreateReadTransaction(inBuffer);

                // Tableau des transactions
                I2CDevice.I2CTransaction[] transactions = new I2CDevice.I2CTransaction[] { writeTransaction, readTransaction };
                // Exécution des transactions
                busI2C = new I2CDevice(ConfigSRF08); // Connexion virtuelle du SRF08 au bus I2C

                if (busI2C.Execute(transactions, TRANSACTIONEXECUTETIMEOUT) != 0)
                {
                    // Success
                    //Debug.Print("Received the first data from at device " + busI2C.Config.Address + ": " + ((int)inBuffer[0]).ToString());
                }
                else
                {
                    // Failed
                    //Debug.Print("Failed to execute transaction at device: " + busI2C.Config.Address + ".");
                }
                busI2C.Dispose(); // Déconnexion virtuelle de l'objet Lcd du bus I2C
                return inBuffer[0];
        }
开发者ID:WebGE,项目名称:SRF08,代码行数:34,代码来源:SRF08.cs

示例9: PutString

        /// <summary>
        /// Write a line of text at x,y
        /// </summary>
        /// <param name="x_pos"></param>
        /// <param name="y_pos"></param>
        /// <param name="Text"></param>
        public void PutString(byte x_pos, byte y_pos, string Text)
        {
            byte addr = 0x80;
            if (x_pos < 17) addr += x_pos;                              // This is for 16 x 2, adjust as nessesary
            if (y_pos == 1) addr += 0x40;
            byte[] txt = System.Text.Encoding.UTF8.GetBytes((byte)'0' + (byte)'0' + (byte)'0' + Text);
            for (byte z = 3; z < (Text.Length + 3); z++)                // All characters have to be moved up!!
            { txt[z] += 128; }
               txt[2] = 0x40;  // R/S to Data

            // Création d'un buffer et de deux transactions pour l'accès au circuit en écriture
            byte[] outbuffer = new byte[] { 0, addr };
            I2CDevice.I2CTransaction WriteBytes = I2CDevice.CreateWriteTransaction(outbuffer); // set address
            I2CDevice.I2CTransaction WriteText = I2CDevice.CreateWriteTransaction(txt); // Print line
            // Tableaux des transactions
            I2CDevice.I2CTransaction[] T_WriteBytes = new I2CDevice.I2CTransaction[] { WriteBytes, WriteText };
            // Exécution de la transaction
            BusI2C = new I2CDevice(ConfigI2CLcd); // Connexion virtuelle de l'objet Lcd  au bus I2C
            BusI2C.Execute(T_WriteBytes, 1000);
            BusI2C.Dispose(); // Déconnexion virtuelle de l'objet Lcd du bus I2C
        }
开发者ID:WebGE,项目名称:LCDI2C,代码行数:27,代码来源:I2CLCD.cs

示例10: PutChar

        /// <summary>
        /// Single character write at x,y
        /// </summary>
        /// <param name="x_pos"></param>
        /// <param name="y_pos"></param>
        /// <param name="z_char"></param>
        public void PutChar(byte x_pos, byte y_pos, byte z_char)
        {
            byte addr = 0x80;                 // This is for 16 x 2, adjust as nessesary
            if (x_pos < 17) addr += x_pos;    // x dir
            if (y_pos == 1) addr += 0x40;     // y dir

            // Création d'un buffer et de deux transactions pour l'accès au circuit en écriture
            byte[] outbuffer = new byte[] { 0, addr };
            I2CDevice.I2CTransaction WriteBytes = I2CDevice.CreateWriteTransaction(outbuffer); // set address (R/S to Cmd )
            I2CDevice.I2CTransaction WriteText = I2CDevice.CreateWriteTransaction(new byte[] { 0, 0, 0x40, z_char });  // single char write
            // Tableaux des transactions
            I2CDevice.I2CTransaction[] T_WriteBytes = new I2CDevice.I2CTransaction[] { WriteBytes, WriteText };
            // Exécution de la transaction
            BusI2C = new I2CDevice(ConfigI2CLcd); // Connexion virtuelle de l'objet Lcd  au bus I2C
            BusI2C.Execute(T_WriteBytes, 1000);
            BusI2C.Dispose(); // Déconnexion virtuelle de l'objet Lcd du bus I2C
        }
开发者ID:WebGE,项目名称:LCDI2C,代码行数:23,代码来源:I2CLCD.cs

示例11: LineBegin

 /// <summary>
 /// Goto start of line
 /// </summary>
 /// <param name="x"></param>
 public void LineBegin(byte x)
 {
     byte addr = 0x80;
     if (x == 1) addr += 0x40;
     // Création d'un buffer et d'une transaction pour l'accès au circuit en écriture
     byte[] outbuffer = new byte[] { 0, addr };
     I2CDevice.I2CTransaction WriteTransaction = I2CDevice.CreateWriteTransaction(outbuffer);
     // Tableaux des transactions
     I2CDevice.I2CTransaction[] T_WriteBytes = new I2CDevice.I2CTransaction[] { WriteTransaction };
     // Exécution de la transaction
     BusI2C = new I2CDevice(ConfigI2CLcd); // Connexion virtuelle de l'objet Lcd  au bus I2C
     BusI2C.Execute(T_WriteBytes, 1000);
     BusI2C.Dispose(); // Déconnexion virtuelle de l'objet Lcd du bus I2C
 }
开发者ID:WebGE,项目名称:LCDI2C,代码行数:18,代码来源:I2CLCD.cs

示例12: Init

        // Méthodes publiques
        /// <summary>
        /// Initialize the LCD before use 
        /// </summary>
        public void Init()
        {
            Thread.Sleep(200);
            // Création d'un buffer et d'une transaction pour l'accès au circuit en écriture
            // Nop, Function_set, Display_ctl, Entry_mode_set, Function_set, Disp_conf, Temp_ctl, Hv_gen, VLCD_Set, Function_Set, Set DDRAM, Return Home
            // Configuration pour un afficheur MIDAS par défaut
            byte[] outbuffer = new byte[] { 0x00, 0x34, 0x0d, 0x06, 0x35, 0x05, 0x10, 0x40, 0x99, 0x34, 0x83, 0x02 };

            if (i2c_Add_7bits == (ushort)LcdManufacturer.BATRON)
            {
                outbuffer[5] = 0x04; //Disp_conf
                outbuffer[7] = 0x42; // Hv_gen
                outbuffer[8] = 0x9F; //VLCD_Set
            }

            I2CDevice.I2CTransaction WriteTransaction = I2CDevice.CreateWriteTransaction(outbuffer);
            // Tableaux des transactions
            I2CDevice.I2CTransaction[] T_WriteBytes = new I2CDevice.I2CTransaction[] { WriteTransaction };
            // Exécution de la transaction
            BusI2C = new I2CDevice(ConfigI2CLcd); // Connexion virtuelle de l'objet Lcd  au bus I2C
            BusI2C.Execute(T_WriteBytes, 1000);
            BusI2C.Dispose(); // Déconnexion virtuelle de l'objet Lcd du bus I2C
        }
开发者ID:WebGE,项目名称:LCDI2C,代码行数:27,代码来源:I2CLCD.cs

示例13: ClearScreen

 // If you use built in Clr
 // Clear screen with 0xA0 not 0x20
 /// <summary>
 /// Clear screen
 /// </summary>
 public void ClearScreen()
 {
     // the screen doen't clear
     byte[] clr = new byte[19];                // you just get arrows
     clr[0] = 0; clr[1] = 0; clr[2] = 0x40;    // R/S to Data
     for (byte x = 3; x < 19; x++)             // Space is not 0x20 on this unit!
     { clr[x] = 0xA0; }
     // Création d'un buffer et de quatre transactions pour l'accès au circuit en écriture
     I2CDevice.I2CTransaction SetTop = I2CDevice.CreateWriteTransaction(new byte[] { 0, 0x80 }); // set top line (R/S to Cmd )
     I2CDevice.I2CTransaction Setclr = I2CDevice.CreateWriteTransaction(clr);
     I2CDevice.I2CTransaction SetBottom = I2CDevice.CreateWriteTransaction(new byte[] { 0, 0, 0, 0xC0 });  // set bottom line (R/S to Cmd )
     I2CDevice.I2CTransaction SetHome = I2CDevice.CreateWriteTransaction(new byte[] { 0, 0, 0, 0x80 }); // Cursor to home (R/S to Cmd )
     // Tableaux des transactions
     I2CDevice.I2CTransaction[] T_WriteBytes = new I2CDevice.I2CTransaction[] { SetTop, Setclr, SetBottom, Setclr, SetHome };
     // Exécution de la transaction
     BusI2C = new I2CDevice(ConfigI2CLcd); // Connexion virtuelle de l'objet Lcd  au bus I2C
     BusI2C.Execute(T_WriteBytes, 1000);
     BusI2C.Dispose(); // Déconnexion virtuelle de l'objet Lcd du bus I2C
 }
开发者ID:WebGE,项目名称:LCDI2C,代码行数:24,代码来源:I2CLCD.cs

示例14: SetRegister

 // Private methode
 private int SetRegister(WRegister Register, byte value)
 {
     // Création d'un buffer et d'une transaction pour l'accès au circuit en écriture
     byte[] outbuffer = new byte[] { (byte)Register, value };
     I2CDevice.I2CTransaction writeTransaction = I2CDevice.CreateWriteTransaction(outbuffer);
     // Tableaux des transactions
     I2CDevice.I2CTransaction[] T_WriteByte = new I2CDevice.I2CTransaction[] { writeTransaction };
     busI2C = new I2CDevice(configMD2x); // Connexion virtuelle de l'objet MD2x au bus I2C
     busI2C.Execute(T_WriteByte, TRANSACTIONEXECUTETIMEOUT); // Exécution de la transaction
     busI2C.Dispose(); // Déconnexion virtuelle de l'objet MD2x du bus I2C
     return 1;
 }
开发者ID:WebGE,项目名称:MD25,代码行数:13,代码来源:DriverMD2x.cs

示例15: ReadRange

        /// <summary>
        /// Triggers a shot ulrasons, wait for 75ms and return result in the unit of measure
        /// </summary>
        /// <param name="units">unit of measure expected</param>
        /// <returns>range in cm or inches or millisec</returns>
        public UInt16 ReadRange(MeasuringUnits units)
        {
            this.unit = units;
                // Calcul du mot de commande à partir de l'unité de mesure
                byte command = (byte)(80 + (byte)units);

                // Création d'un buffer et d'une transaction pour l'accès au module en écriture
                byte[] outbuffer = new byte[] { (byte)Registers.Command, command };
                I2CDevice.I2CTransaction WriteUnit = I2CDevice.CreateWriteTransaction(outbuffer);

                // Création d'un buffer et d'une transaction pour l'accès au module en lecture
                byte[] inbuffer = new byte[4];
                I2CDevice.I2CTransaction ReadDist = I2CDevice.CreateReadTransaction(inbuffer);

                // Tableaux des transactions
                I2CDevice.I2CTransaction[] T_WriteUnit = new I2CDevice.I2CTransaction[] { WriteUnit };
                I2CDevice.I2CTransaction[] T_ReadDist = new I2CDevice.I2CTransaction[] { ReadDist };

                // Exécution des transactions
                busI2C = new I2CDevice(ConfigSRF08); // Connexion virtuelle de l'objet SRF08 au bus I2C
                busI2C.Execute(T_WriteUnit, TRANSACTIONEXECUTETIMEOUT); // Transaction : Activation US
                Thread.Sleep(75); // attente echo US
                busI2C.Execute(T_ReadDist, TRANSACTIONEXECUTETIMEOUT); // Transaction : Lecture distance
                UInt16 range = (UInt16)((UInt16)(inbuffer[3] << 8) + inbuffer[2]); // Calcul de la distance
                busI2C.Dispose(); // Déconnexion virtuelle de l'objet SRF08 du bus I2C
                return range;
        }
开发者ID:WebGE,项目名称:SRF08,代码行数:32,代码来源:SRF08.cs


注:本文中的Microsoft.SPOT.Hardware.I2CDevice.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。