Skip to content
This repository has been archived by the owner on Feb 4, 2023. It is now read-only.

Commit

Permalink
Update README.md and use allman astyle
Browse files Browse the repository at this point in the history
  • Loading branch information
khoih-prog committed Nov 25, 2022
1 parent 0ec6ef5 commit cb76b66
Show file tree
Hide file tree
Showing 20 changed files with 222 additions and 78 deletions.
28 changes: 24 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ If you don't find anything, please [open a new issue](https://github.com/khoih-p
Please ensure to specify the following:

* Arduino IDE version (e.g. 1.8.19) or Platform.io version
* Board Core Version (e.g. Arduino STM32 core v2.2.0, etc.)
* Board Core Version (e.g. Arduino STM32 core v2.3.0, etc.)
* Board and Configuration
* Contextual information (e.g. what you were trying to achieve)
* Simplest possible steps to reproduce
Expand All @@ -28,13 +28,13 @@ Please ensure to specify the following:

```
Arduino IDE version: 1.8.19
Arduino STM32 core v2.2.0
Arduino STM32 core v2.3.0
Board: STM32F103C8T6, 64KB Flash
OS: Ubuntu 20.04 LTS
Linux Inspiron-3593 5.4.0-96-generic #109-Ubuntu SMP Wed Jan 12 16:49:16 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Linux xy-Inspiron-3593 5.15.0-53-generic #59~20.04.1-Ubuntu SMP Thu Oct 20 15:10:22 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Context:
The board couldn't autoreconnect to Local Blynk Server after router power recycling.
I encountered a crash while using this library
Steps to reproduce:
1. ...
Expand All @@ -43,12 +43,32 @@ Steps to reproduce:
4. ...
```

---

### Sending Feature Requests

Feel free to post feature requests. It's helpful if you can explain exactly why the feature would be useful.

There are usually some outstanding feature requests in the [existing issues list](https://github.com/khoih-prog/FlashStorage_STM32F1/issues?q=is%3Aopen+is%3Aissue+label%3Aenhancement), feel free to add comments to them.

---

### Sending Pull Requests

Pull Requests with changes and fixes are also welcome!

Please use the `astyle` to reformat the updated library code as follows (demo for Ubuntu Linux)

1. Change directory to the library GitHub

```
xy@xy-Inspiron-3593:~$ cd Arduino/xy/FlashStorage_STM32F1_GitHub/
xy@xy-Inspiron-3593:~/Arduino/xy/FlashStorage_STM32F1_GitHub$
```

2. Issue astyle command

```
xy@xy-Inspiron-3593:~/Arduino/xy/FlashStorage_STM32F1_GitHub$ bash utils/restyle.sh
```

6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](#Contributing)
[![GitHub issues](https://img.shields.io/github/issues/khoih-prog/FlashStorage_STM32F1.svg)](http://github.com/khoih-prog/FlashStorage_STM32F1/issues)


<a href="https://www.buymeacoffee.com/khoihprog6" title="Donate to my libraries using BuyMeACoffee"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Donate to my libraries using BuyMeACoffee" style="height: 50px !important;width: 181px !important;" ></a>
<a href="https://www.buymeacoffee.com/khoihprog6" title="Donate to my libraries using BuyMeACoffee"><img src="https://img.shields.io/badge/buy%20me%20a%20coffee-donate-orange.svg?logo=buy-me-a-coffee&logoColor=FFDD00" style="height: 20px !important;width: 200px !important;" ></a>
<a href="https://profile-counter.glitch.me/khoih-prog/count.svg" title="Total khoih-prog Visitor count"><img src="https://profile-counter.glitch.me/khoih-prog/count.svg" style="height: 30px;width: 200px;"></a>
<a href="https://profile-counter.glitch.me/khoih-prog-FlashStorage_STM32F1/count.svg" title="FlashStorage_STM32F1 Visitor count"><img src="https://profile-counter.glitch.me/khoih-prog-FlashStorage_STM32F1/count.svg" style="height: 30px;width: 200px;"></a>

---
---

Expand Down
8 changes: 5 additions & 3 deletions examples/EEPROM_CRC/EEPROM_CRC.ino
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#include <FlashStorage_STM32F1.h>

unsigned long eeprom_crc()
unsigned long eeprom_crc()
{
const unsigned long crc_table[16] =
{
Expand All @@ -66,11 +66,13 @@ unsigned long eeprom_crc()
void setup()
{
Serial.begin(115200);

while (!Serial);

delay(200);

Serial.print(F("\nStart EEPROM_CRC on ")); Serial.println(BOARD_NAME);
Serial.print(F("\nStart EEPROM_CRC on "));
Serial.println(BOARD_NAME);
Serial.println(FLASH_STORAGE_STM32F1_VERSION);

//Print length of data to run CRC on.
Expand All @@ -85,7 +87,7 @@ void setup()
Serial.print("Done!");
}

void loop()
void loop()
{
/* Empty loop */
}
17 changes: 10 additions & 7 deletions examples/EEPROM_Clear/EEPROM_Clear.ino
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,18 @@
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#include <FlashStorage_STM32F1.h>

void setup()
void setup()
{
Serial.begin(115200);

while (!Serial);

delay(200);

Serial.print(F("\nStart EEPROM_Clear on ")); Serial.println(BOARD_NAME);
Serial.print(F("\nStart EEPROM_Clear on "));
Serial.println(BOARD_NAME);
Serial.println(FLASH_STORAGE_STM32F1_VERSION);

// initialize the LED pin as an output.
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW);
Expand All @@ -53,8 +55,8 @@ void setup()
EEPROM.init();

unsigned long startMillis = millis();
for (int i = 0 ; i < EEPROM.length() ; i++)

for (int i = 0 ; i < EEPROM.length() ; i++)
{
EEPROM.write(i, 0);
}
Expand All @@ -63,13 +65,14 @@ void setup()

// The time spent can be very short (5-25ms) if the EEPROM is not dirty.
// For Seeed XIAO, the time is around 22 / 42 ms for 2048 / 4096 bytes of emulated-EEPROM
Serial.print("Done clearing emulated EEPROM. Time spent (ms) = "); Serial.println(millis() - startMillis);
Serial.print("Done clearing emulated EEPROM. Time spent (ms) = ");
Serial.println(millis() - startMillis);

// turn the LED on when we're done
digitalWrite(LED_BUILTIN, HIGH);
}

void loop()
void loop()
{
/** Empty loop. **/
}
16 changes: 11 additions & 5 deletions examples/EEPROM_get/EEPROM_get.ino
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,19 @@ struct MyObject
void printMyObject(MyObject &customVar)
{
Serial.println("===============");
Serial.print("Field1: "); Serial.println(customVar.field1, 5);
Serial.print("Field2: "); Serial.println(customVar.field2);
Serial.print("Name: "); Serial.println(customVar.name);
Serial.print("Field1: ");
Serial.println(customVar.field1, 5);
Serial.print("Field2: ");
Serial.println(customVar.field2);
Serial.print("Name: ");
Serial.println(customVar.name);
Serial.println("===============");
}

void secondTest()
{
int eeAddress = START_ADDRESS + sizeof(WRITTEN_SIGNATURE) + sizeof(float); //Move address to the next byte after float 'f'.
int eeAddress = START_ADDRESS + sizeof(WRITTEN_SIGNATURE) + sizeof(
float); //Move address to the next byte after float 'f'.

MyObject customVar; //Variable to store custom object read from EEPROM.
EEPROM.get(eeAddress, customVar);
Expand All @@ -80,11 +84,13 @@ void secondTest()
void setup()
{
Serial.begin(115200);

while (!Serial);

delay(200);

Serial.print(F("\nStart EEPROM_get on ")); Serial.println(BOARD_NAME);
Serial.print(F("\nStart EEPROM_get on "));
Serial.println(BOARD_NAME);
Serial.println(FLASH_STORAGE_STM32F1_VERSION);

Serial.print("EEPROM length: ");
Expand Down
12 changes: 7 additions & 5 deletions examples/EEPROM_iteration/EEPROM_iteration.ino
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,13 @@
void setup()
{
Serial.begin(115200);

while (!Serial);

delay(200);

Serial.print(F("\nStart EEPROM_iteration on ")); Serial.println(BOARD_NAME);
Serial.print(F("\nStart EEPROM_iteration on "));
Serial.println(BOARD_NAME);
Serial.println(FLASH_STORAGE_STM32F1_VERSION);

Serial.print("EEPROM length: ");
Expand All @@ -62,7 +64,7 @@ void setup()
Iterate the EEPROM using a for loop.
***/

for (int index = 0 ; index < EEPROM.length() ; index++)
for (int index = 0 ; index < EEPROM.length() ; index++)
{
// Add one to each cell in the EEPROM
EEPROM.write(index, EEPROM.read(index) + 1);
Expand All @@ -78,7 +80,7 @@ void setup()

int index = 0;

while (index < EEPROM.length())
while (index < EEPROM.length())
{
// Add one to each cell in the EEPROM
EEPROM.write(index, EEPROM.read(index) + 1);
Expand All @@ -95,7 +97,7 @@ void setup()

int idx = 0; //Used 'idx' to avoid name conflict with 'index' above.

do
do
{
// Add one to each cell in the EEPROM
EEPROM.write(index, EEPROM.read(index) + 1);
Expand All @@ -105,7 +107,7 @@ void setup()
EEPROM.commit();

Serial.println("Done do-while loop");

} //End of setup function.

void loop() {}
13 changes: 9 additions & 4 deletions examples/EEPROM_put/EEPROM_put.ino
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,25 @@ struct MyObject
void printMyObject(MyObject &customVar)
{
Serial.println("===============");
Serial.print("Field1: "); Serial.println(customVar.field1, 5);
Serial.print("Field2: "); Serial.println(customVar.field2);
Serial.print("Name: "); Serial.println(customVar.name);
Serial.print("Field1: ");
Serial.println(customVar.field1, 5);
Serial.print("Field2: ");
Serial.println(customVar.field2);
Serial.print("Name: ");
Serial.println(customVar.name);
Serial.println("===============");
}

void setup()
{
Serial.begin(115200);

while (!Serial);

delay(200);

Serial.print(F("\nStart EEPROM_put on ")); Serial.println(BOARD_NAME);
Serial.print(F("\nStart EEPROM_put on "));
Serial.println(BOARD_NAME);
Serial.println(FLASH_STORAGE_STM32F1_VERSION);

Serial.print("EEPROM length: ");
Expand Down
10 changes: 6 additions & 4 deletions examples/EEPROM_read/EEPROM_read.ino
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,13 @@ byte value;
void setup()
{
Serial.begin(115200);

while (!Serial);

delay(200);

Serial.print(F("\nStart EEPROM_read on ")); Serial.println(BOARD_NAME);
Serial.print(F("\nStart EEPROM_read on "));
Serial.println(BOARD_NAME);
Serial.println(FLASH_STORAGE_STM32F1_VERSION);

Serial.print("EEPROM length: ");
Expand All @@ -59,7 +61,7 @@ void setup()
EEPROM.init();
}

void loop()
void loop()
{
// read a byte from the current address of the EEPROM
value = EEPROM.read(address);
Expand All @@ -68,8 +70,8 @@ void loop()
Serial.print("\t");
Serial.print(value, DEC);
Serial.println();
if (++address == EEPROM.length())

if (++address == EEPROM.length())
{
address = 0;
}
Expand Down
15 changes: 9 additions & 6 deletions examples/EEPROM_update/EEPROM_update.ino
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,13 @@ int address = 0;
void setup()
{
Serial.begin(115200);

while (!Serial);

delay(200);

Serial.print(F("\nStart EEPROM_read on ")); Serial.println(BOARD_NAME);
Serial.print(F("\nStart EEPROM_read on "));
Serial.println(BOARD_NAME);
Serial.println(FLASH_STORAGE_STM32F1_VERSION);

Serial.print("EEPROM length: ");
Expand All @@ -67,23 +69,24 @@ void setup()
void loop()
{
unsigned long startMillis = millis();
for (int i = 0 ; i < EEPROM.length() ; i++)

for (int i = 0 ; i < EEPROM.length() ; i++)
{
/***
The function EEPROM.update(address, val) is equivalent to the following:
if( EEPROM.read(address) != val )
{
EEPROM.write(address, val);
}
***/
EEPROM.update(i, (uint8_t) analogRead(0));
}

EEPROM.commit();

Serial.print("Done updating emulated EEPROM. Time spent (ms) = "); Serial.println(millis() - startMillis);
Serial.print("Done updating emulated EEPROM. Time spent (ms) = ");
Serial.println(millis() - startMillis);

delay(60000);
}
7 changes: 5 additions & 2 deletions examples/EEPROM_write/EEPROM_write.ino
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,13 @@ int address = 0;
void setup()
{
Serial.begin(115200);

while (!Serial);

delay(200);

Serial.print(F("\nStart EEPROM_write on ")); Serial.println(BOARD_NAME);
Serial.print(F("\nStart EEPROM_write on "));
Serial.println(BOARD_NAME);
Serial.println(FLASH_STORAGE_STM32F1_VERSION);

Serial.print("EEPROM length: ");
Expand Down Expand Up @@ -79,7 +81,8 @@ void loop()

EEPROM.commit();

Serial.print("Done writing emulated EEPROM. Time spent (ms) = "); Serial.println(millis() - startMillis);
Serial.print("Done writing emulated EEPROM. Time spent (ms) = ");
Serial.println(millis() - startMillis);

delay(60000);
}

0 comments on commit cb76b66

Please sign in to comment.