Exemplo n.º 1
0
        public static void Main()
        {
            //Using EEprom
            Boolean Connect_EEprom = true;

            //Using SS1306 OLED display
            Boolean Connect_OLED = false;

            if (Connect_EEprom)
            {
                EEprom24LC256 eeprom = new EEprom24LC256(EEprom24LC256.DeviceConnectionSting.I2C1, 0x54);

                String str = "This is an EEprom test for ESP32.";

                eeprom.Write(EEprom24LC256.Address.SecondString, str);

                str = eeprom.Read(EEprom24LC256.Address.SecondString);

                Console.WriteLine("\r\nReturned " + str);

                // If the string exist read it
                if (eeprom.Exist(EEprom24LC256.Address.ThirdString))
                {
                    str = eeprom.Read(EEprom24LC256.Address.ThirdString);

                    Console.WriteLine("\r\nReturned " + str);
                }

                else
                {
                    // String did not exist create it
                    string ts = "This is the thrid string we just created.";

                    eeprom.Write(EEprom24LC256.Address.ThirdString, ts);

                    ts = eeprom.Read(EEprom24LC256.Address.ThirdString);

                    Console.WriteLine("\r\nReturned " + str);
                }
            }

            if (Connect_OLED)
            {
                OLED oled = new OLED(OLED.DeviceConnectionSting.I2C1, 0x3C);

                oled.Initialize();

                oled.Write(0, 2, "Hello ESP32");

                oled.Write(0, 4, "Connected to I2C1");
            }
        }
Exemplo n.º 2
0
        public static void Main()
        {
            // Set i2c device configutation for the EEprom 24LC256 device
            I2CDevice.Configuration EEpromCon = I2cBus.AddNewDeviceConfiguration(0x54);

            // Set the shared I2CDevice.Configuration property
            EEprom24LC256.Initialize(EEpromCon);

            // Set i2c device configutation for the SS1306 OLED device
            I2CDevice.Configuration OLEDCon = I2cBus.AddNewDeviceConfiguration(0x3C);

            // Set the shared I2CDevice.Configuration property
            OLED.Initialize(OLEDCon);

            EEprom24LC256.Write(EEprom24LC256.Address.TestWrite, "Hello");

            OLED.Write(0, 0, "I2c Test", true);

            string ReturnString = string.Empty;

            if (EEprom24LC256.Exist(EEprom24LC256.Address.TestWrite))
            {
                ReturnString = EEprom24LC256.Read(EEprom24LC256.Address.TestWrite);

                Debug.Print("Exist " + ReturnString);
            }

            OLED.Write(0, 2, "First String: " + ReturnString, true);

            EEprom24LC256.Write(EEprom24LC256.Address.TestWrite, "World!");

            if (EEprom24LC256.Exist(EEprom24LC256.Address.TestWrite))
            {
                ReturnString = EEprom24LC256.Read(EEprom24LC256.Address.TestWrite);

                Debug.Print("The address exists " + ReturnString);
            }

            OLED.Write(0, 4, "Second String: " + ReturnString, true);
        }