Skip to content
This repository has been archived by the owner on Jan 29, 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 c4a16bb commit 102e13e
Show file tree
Hide file tree
Showing 24 changed files with 354 additions and 190 deletions.
29 changes: 25 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
* `SAMD` Core Version (e.g. Arduino SAMD core v1.8.12, Adafruit SAMD core v1.7.7, Seeed Studio SAMD v1.8.2)
* `SAMD` Core Version (e.g. Arduino SAMD core v1.8.13, Adafruit SAMD core v1.7.11, Seeed Studio SAMD v1.8.3)
* 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 SAMD Core Version 1.8.12
Arduino SAMD Core Version 1.8.13
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:
I encountered a crash while trying to use the Timer Interrupt.
I encountered a crash while using this library
Steps to reproduce:
1. ...
Expand All @@ -41,12 +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_SAMD/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_SAMD_GitHub/
xy@xy-Inspiron-3593:~/Arduino/xy/FlashStorage_SAMD_GitHub$
```

2. Issue astyle command

```
xy@xy-Inspiron-3593:~/Arduino/xy/FlashStorage_SAMD_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_SAMD.svg)](http://github.com/khoih-prog/FlashStorage_SAMD/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_SAMD/count.svg" title="FlashStorage_SAMD Visitor count"><img src="https://profile-counter.glitch.me/khoih-prog-FlashStorage_SAMD/count.svg" style="height: 30px;width: 200px;"></a>


---
---

Expand Down
18 changes: 10 additions & 8 deletions examples/EEPROM_CRC/EEPROM_CRC.ino
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
Built by Khoi Hoang https://github.com/khoih-prog/FlashStorage_SAMD
Licensed under LGPLv3 license
Orginally written by A. Christian
Copyright (c) 2015-2016 Arduino LLC. All right reserved.
Copyright (c) 2020 Khoi Hoang.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
as published bythe Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this library.
You should have received a copy of the GNU Lesser General Public License along with this library.
If not, see (https://www.gnu.org/licenses/)
******************************************************************************************************************************************/
/***
Expand All @@ -39,7 +39,7 @@
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#include <FlashStorage_SAMD.h>

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

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

void loop()
void loop()
{
/* Empty loop */
}
30 changes: 17 additions & 13 deletions examples/EEPROM_Clear/EEPROM_Clear.ino
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
Built by Khoi Hoang https://github.com/khoih-prog/FlashStorage_SAMD
Licensed under LGPLv3 license
Orginally written by A. Christian
Copyright (c) 2015-2016 Arduino LLC. All right reserved.
Copyright (c) 2020 Khoi Hoang.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
as published bythe Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this library.
You should have received a copy of the GNU Lesser General Public License along with this library.
If not, see (https://www.gnu.org/licenses/)
******************************************************************************************************************************************/

Expand All @@ -31,25 +31,28 @@
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#include <FlashStorage_SAMD.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_SAMD_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 @@ -58,13 +61,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 @@ -58,15 +58,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 @@ -78,11 +82,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_SAMD_VERSION);

Serial.print("EEPROM length: ");
Expand Down
24 changes: 13 additions & 11 deletions examples/EEPROM_iteration/EEPROM_iteration.ino
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
Built by Khoi Hoang https://github.com/khoih-prog/FlashStorage_SAMD
Licensed under LGPLv3 license
Orginally written by A. Christian
Copyright (c) 2015-2016 Arduino LLC. All right reserved.
Copyright (c) 2020 Khoi Hoang.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
as published bythe Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this library.
You should have received a copy of the GNU Lesser General Public License along with this library.
If not, see (https://www.gnu.org/licenses/)
******************************************************************************************************************************************/
/***
Expand All @@ -44,11 +44,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_SAMD_VERSION);

Serial.print("EEPROM length: ");
Expand All @@ -58,9 +60,9 @@ 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
// Add one to each cell in the EEPROM
EEPROM.write(index, EEPROM.read(index) + 1);
}

Expand All @@ -74,9 +76,9 @@ 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
EEPROM.write(index, EEPROM.read(index) + 1);
index++;
}
Expand All @@ -101,7 +103,7 @@ void setup()
EEPROM.commit();

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

} //End of setup function.

void loop() {}
23 changes: 14 additions & 9 deletions examples/EEPROM_put/EEPROM_put.ino
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
Built by Khoi Hoang https://github.com/khoih-prog/FlashStorage_SAMD
Licensed under LGPLv3 license
Orginally written by A. Christian
Copyright (c) 2015-2016 Arduino LLC. All right reserved.
Copyright (c) 2020 Khoi Hoang.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
as published bythe Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this library.
You should have received a copy of the GNU Lesser General Public License along with this library.
If not, see (https://www.gnu.org/licenses/)
******************************************************************************************************************************************/
/***
Expand Down Expand Up @@ -56,20 +56,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_SAMD_VERSION);

Serial.print("EEPROM length: ");
Expand Down
Loading

0 comments on commit 102e13e

Please sign in to comment.