Skip to content

Commit 63c9592

Browse files
committed
Re-sequence examples.
1 parent 8a2b2be commit 63c9592

File tree

14 files changed

+43
-1230
lines changed

14 files changed

+43
-1230
lines changed

examples/Example1_BasicReadWrite/Example1_BasicReadWrite.ino

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,13 @@ ExternalEEPROM myMem;
2727
void setup()
2828
{
2929
Serial.begin(115200);
30+
//delay(250); //Often needed for ESP based platforms
3031
Serial.println("Qwiic EEPROM example");
3132

3233
Wire.begin();
3334

35+
//We must set the memory specs. Pick your EEPROM From the list:
36+
3437
// 24xx00 - 128 bit / 16 bytes - 1 address byte, 1 byte page
3538
// 24xx01 - 1024 bit / 128 bytes - 1 address byte, 8 byte page
3639
// 24xx02 - 2048 bit / 256 bytes - 1 address byte, 8 byte page
@@ -45,30 +48,16 @@ void setup()
4548
// 24xx1024 - 1024000 bit / 128000 byte - 2 address byte, 128 byte page
4649
// 24xxM02 - 2097152 bit / 262144 byte - 2 address bytes, 256 byte page
4750

48-
// 24xx16 - 16384 bit / 2048 bytes - 1 address byte, 16 byte page size
49-
//myMem.setAddressBytes(1);
50-
//myMem.setPageSizeBytes(16);
51-
//myMem.setMemorySizeBytes(2048);
51+
// Valid types: 24xx00, 01, 02, 04, 08, 16, 32, 64, 128, 256, 512, 1024, 2048
52+
// myMem.setMemoryType(16);
5253

53-
// 24xx04 - 4096 bit / 512 bytes - 1 address byte, 16 byte page
54-
//myMem.setAddressBytes(1);
55-
//myMem.setPageSizeBytes(16);
56-
//myMem.setMemorySizeBytes(2048);
57-
58-
// 24xx02 - 2048 bit / 256 bytes - 1 address byte, 8 byte page
59-
//myMem.setAddressBytes(1);
60-
//myMem.setPageSizeBytes(8);
61-
//myMem.setMemorySizeBytes(256);
62-
63-
// 24xx512 - 524288 bit / 65536 bytes - 2 address bytes, 128 byte page
64-
myMem.setAddressBytes(2);
65-
myMem.setPageSizeBytes(128);
66-
myMem.setMemorySizeBytes(65536);
54+
// Default to the Qwiic 24xx512 EEPROM: https://www.sparkfun.com/products/14764
55+
myMem.setMemoryType(512); // Valid types: 24xx00, 0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048
6756

6857
if (myMem.begin() == false)
6958
{
7059
Serial.println("No memory detected. Freezing.");
71-
while (1)
60+
while (true)
7261
;
7362
}
7463
Serial.println("Memory detected!");
@@ -81,7 +70,7 @@ void setup()
8170
myMem.write(0, myValue1); //(location, data)
8271

8372
byte myRead1 = myMem.read(0);
84-
Serial.print("I read: ");
73+
Serial.print("I read (should be 200): ");
8574
Serial.println(myRead1);
8675

8776
//You should use gets and puts. This will automatically and correctly arrange
@@ -90,14 +79,14 @@ void setup()
9079
myMem.put(10, myValue2); //(location, data)
9180
int myRead2;
9281
myMem.get(10, myRead2); //location to read, thing to put data into
93-
Serial.print("I read: ");
82+
Serial.print("I read (should be -366): ");
9483
Serial.println(myRead2);
9584

9685
float myValue3 = -7.35;
9786
myMem.put(20, myValue3); //(location, data)
9887
float myRead3;
9988
myMem.get(20, myRead3); //location to read, thing to put data into
100-
Serial.print("I read: ");
89+
Serial.print("I read (should be -7.35): ");
10190
Serial.println(myRead3);
10291

10392
String myString = "Hi, I am just a simple test string";

examples/Example4_AdvancedI2C/Example4_AdvancedI2C.ino renamed to examples/Example2_AdvancedI2C/Example2_AdvancedI2C.ino

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ ExternalEEPROM myMem;
3636
void setup()
3737
{
3838
Serial.begin(115200);
39-
delay(10);
40-
Serial.println("I2C EEPROM example");
39+
//delay(250); //Often needed for ESP based platforms
40+
Serial.println("Qwiic EEPROM example");
4141

4242
// Wire1.setClock(400000); //set I2C communication to 400kHz
4343
Wire1.begin();
@@ -48,7 +48,8 @@ void setup()
4848
if (myMem.begin(EEPROM_ADDRESS, Wire1) == false) //And Uno will fail to compile here
4949
{
5050
Serial.println("No memory detected. Freezing.");
51-
while (1);
51+
while (true)
52+
;
5253
}
5354
Serial.println("Memory detected!");
5455

examples/Example2_Settings/Example2_Settings.ino

Lines changed: 0 additions & 68 deletions
This file was deleted.

examples/Example3_AdvancedI2C/Example3_AdvancedI2C.ino

Lines changed: 0 additions & 66 deletions
This file was deleted.

examples/Example3_ManualSettings/Example3_ManualSettings.ino

Lines changed: 0 additions & 70 deletions
This file was deleted.

examples/Example4_UserOptions/Example4_UserOptions.ino renamed to examples/Example3_SettingsStruc/Example3_SettingsStruc.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ struct_userSettings settings = {
4545
void setup()
4646
{
4747
Serial.begin(115200);
48-
delay(10);
48+
//delay(250); //Often needed for ESP based platforms
4949
Serial.println(F("Qwiic EEPROM example"));
5050

5151
Wire.begin();
5252

5353
if (myMem.begin() == false)
5454
{
5555
Serial.println(F("No memory detected. Freezing."));
56-
while (1);
56+
while (true);
5757
}
5858
Serial.println(F("Memory detected!"));
5959

examples/Example2_DetectSettings/Example2_DetectSettings.ino renamed to examples/Example4_DetectSettings/Example4_DetectSettings.ino

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,9 @@ void setup()
3636

3737
Wire.begin();
3838

39-
//The memory specs can be set before begin() to skip the auto-detection delay and write wear
40-
//24LC16 - 16384 bit / 2048 bytes - 1 address byte, 16 byte page size
41-
//myMem.setAddressBytes(1);
42-
//myMem.setPageSizeBytes(16);
43-
//myMem.setMemorySizeBytes(2048);
39+
//We don't need to specify the memory specs before begin(). We're just looking
40+
//for a I2C device to ACK.
4441

45-
//If specs are not available at begin(), they are auto-detected
4642
if (myMem.begin() == false)
4743
{
4844
Serial.println("No memory detected. Freezing.");
@@ -51,12 +47,11 @@ void setup()
5147
}
5248
Serial.println("Memory detected!");
5349

54-
//Detection functions can also be called/re-run after begin()
5550
Serial.print("Detected number of address bytes: ");
5651
Serial.println(myMem.detectAddressBytes());
5752

58-
//Page size detection is limited by the platform. For example, the Uno has a I2C buffer
59-
//that is 32 bytes. Therefor, page sizes above 16 bytes cannot be detected or used. For maximum
53+
//Page size detection is limited by the platform. For example, the Uno has an I2C buffer
54+
//that is 32 bytes. Therefore, page sizes above 16 bytes cannot be detected or used. For maximum
6055
//write speeds to an EEPROM, use a platform with a large I2C buffer (ie ESP32 is 128 bytes)
6156
//and an EEPROM with a large page size (24XX512 is 128 bytes).
6257
Serial.print("Detected pageSizeBytes: ");

0 commit comments

Comments
 (0)