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 b6523d3 commit bb0dd71
Show file tree
Hide file tree
Showing 21 changed files with 470 additions and 316 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.)
* Contextual information (e.g. what you were trying to achieve)
* Simplest possible steps to reproduce
* Anything that might be relevant in your opinion, such as:
Expand All @@ -27,12 +27,12 @@ Please ensure to specify the following:

```
Arduino IDE version: 1.8.19
Arduino STM32 core v2.2.0
Arduino STM32 core v2.3.0
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 @@ -41,13 +41,33 @@ 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_STM32/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_STM32_GitHub/
xy@xy-Inspiron-3593:~/Arduino/xy/FlashStorage_STM32_GitHub$
```

2. Issue astyle command

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


7 changes: 7 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
[![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_STM32.svg)](http://github.com/khoih-prog/FlashStorage_STM32/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_STM32/count.svg" title="FlashStorage_STM32 Visitor count"><img src="https://profile-counter.glitch.me/khoih-prog-FlashStorage_STM32/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 @@ -23,7 +23,7 @@
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#include <FlashStorage_STM32.h>

unsigned long eeprom_crc()
unsigned long eeprom_crc()
{
const unsigned long crc_table[16] =
{
Expand All @@ -48,11 +48,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_STM32_VERSION);

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

void loop()
void loop()
{
/* Empty loop */
}
24 changes: 14 additions & 10 deletions examples/EEPROM_Clear/EEPROM_Clear.ino
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
EEPROM_Clear.ino
For STM32 using Flash emulated-EEPROM
The FlashStorage_STM32 library aims to provide a convenient way to store and retrieve user's data using the non-volatile flash memory
of STM32F/L/H/G/WB/MP1. It's using the buffered read and write to minimize the access to Flash.
The FlashStorage_STM32 library aims to provide a convenient way to store and retrieve user's data using the non-volatile flash memory
of STM32F/L/H/G/WB/MP1. It's using the buffered read and write to minimize the access to Flash.
It now supports writing and reading the whole object, not just byte-and-byte.
Inspired by Cristian Maglie's FlashStorage (https://github.com/cmaglie/FlashStorage)
Expand All @@ -15,25 +15,28 @@
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#include <FlashStorage_STM32.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_STM32_VERSION);

// initialize the LED pin as an output.
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW);

Serial.print("Emulated EEPROM length (bytes) = "); Serial.println(EEPROM.length());
Serial.print("Emulated EEPROM length (bytes) = ");
Serial.println(EEPROM.length());

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 @@ -42,13 +45,14 @@ void setup()

// The time spent can be very short (4-5ms) if the EEPROM is not dirty.
// For F767ZI, the time is around 1.1s for 16384 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. **/
}
4 changes: 3 additions & 1 deletion examples/EEPROM_get/EEPROM_get.ino
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,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_STM32_VERSION);

Serial.print("EEPROM length: ");
Expand Down
10 changes: 6 additions & 4 deletions examples/EEPROM_iteration/EEPROM_iteration.ino
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,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_STM32_VERSION);

Serial.print("EEPROM length: ");
Expand All @@ -42,7 +44,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 @@ -58,7 +60,7 @@ void setup()

int index = 0;

while (index < EEPROM.length())
while (index < EEPROM.length())
{
//Add one to each cell in the EEPROM
// Add one to each cell in the EEPROM
Expand Down Expand Up @@ -86,7 +88,7 @@ void setup()
EEPROM.commit();

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

} //End of setup function.

void loop() {}
4 changes: 3 additions & 1 deletion examples/EEPROM_put/EEPROM_put.ino
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@ struct MyObject
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_STM32_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 @@ -28,18 +28,20 @@ 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_STM32_VERSION);

Serial.print("EEPROM length: ");
Serial.println(EEPROM.length());
}

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

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

while (!Serial);

delay(200);

Serial.print(F("\nStart EEPROM_update on ")); Serial.println(BOARD_NAME);
Serial.print(F("\nStart EEPROM_update on "));
Serial.println(BOARD_NAME);
Serial.println(FLASH_STORAGE_STM32_VERSION);

Serial.print("EEPROM length: ");
Expand All @@ -63,7 +65,8 @@ void loop()

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);
}
17 changes: 10 additions & 7 deletions examples/EEPROM_write/EEPROM_write.ino
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/*
EEPROM Write
Stores values read from analog input 0 into the EEPROM. These values will stay in the EEPROM
Stores values read from analog input 0 into the EEPROM. These values will stay in the EEPROM
when the board is turned off and may be retrieved later by another sketch.
*/

Expand All @@ -27,11 +27,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_STM32_VERSION);

Serial.print("EEPROM length: ");
Expand All @@ -41,23 +43,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.write(i, (uint8_t) analogRead(0));
}

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);
}
7 changes: 5 additions & 2 deletions examples/EmulateEEPROM/EmulateEEPROM.ino
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ const int WRITTEN_SIGNATURE = 0xBEEFDEED;
void setup()
{
Serial.begin(115200);

while (!Serial);

delay(200);

Serial.print(F("\nStart EmulatedEEPROM on ")); Serial.println(BOARD_NAME);
Serial.print(F("\nStart EmulatedEEPROM on "));
Serial.println(BOARD_NAME);
Serial.println(FLASH_STORAGE_STM32_VERSION);

Serial.print("EEPROM length: ");
Expand Down Expand Up @@ -67,7 +69,8 @@ void setup()
{
EEPROM.get(0, signature);

Serial.print("EEPROM has been written.Signature = 0x"); Serial.println(signature, HEX);
Serial.print("EEPROM has been written.Signature = 0x");
Serial.println(signature, HEX);

Serial.println("Here is the content of the next 16 bytes:");

Expand Down
Loading

0 comments on commit bb0dd71

Please sign in to comment.