Skip to content

Commit da486d9

Browse files
committed
0.2.1 DEVRANDOM
1 parent 08e1246 commit da486d9

File tree

7 files changed

+84
-39
lines changed

7 files changed

+84
-39
lines changed
Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
platforms:
2+
rpipico:
3+
board: rp2040:rp2040:rpipico
4+
package: rp2040:rp2040
5+
gcc:
6+
features:
7+
defines:
8+
- ARDUINO_ARCH_RP2040
9+
warnings:
10+
flags:
11+
12+
packages:
13+
rp2040:rp2040:
14+
url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
15+
116
compile:
217
# Choosing to run compilation tests on 2 different Arduino platforms
318
platforms:
@@ -7,5 +22,7 @@ compile:
722
# - leonardo
823
- m4
924
- esp32
10-
# - esp8266
11-
# - mega2560
25+
- esp8266
26+
# - mega2560
27+
- rpipico
28+

libraries/DEVRANDOM/CHANGELOG.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Change Log DEVRANDOM
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](http://keepachangelog.com/)
6+
and this project adheres to [Semantic Versioning](http://semver.org/).
7+
8+
9+
## [0.2.1] - 2022-10-31
10+
- add changelog.md
11+
- add rp2040 to build-CI
12+
13+
14+
## [0.2.0] - 2022-07-02
15+
- add Marsaglia PRNG, is portable over platforms, becomes mode 3
16+
- improved reseeding
17+
- split off .cpp file
18+
- add examples
19+
20+
----
21+
22+
## [0.1.3] - 2021-12-15
23+
- update library.json
24+
- license
25+
- minor edits
26+
27+
## [0.1.2] - 2021-01-15
28+
- add constructors with seed.
29+
30+
## [0.1.1] - 2022-07-01
31+
- add Arduino-CI + unit tests
32+
- add getMode()
33+
- add flush()
34+
35+
## [0.1.0] - 2020-06-23
36+
- initial version
37+

libraries/DEVRANDOM/DEVRANDOM.cpp

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,7 @@
55
// PURPOSE: Arduino library for a /dev/random stream - useful for testing
66
// URL: https://github.com/RobTillaart/DEVRANDOM
77
//
8-
// HISTORY:
9-
// 0.1.0 2020-06-23 initial version
10-
// 0.1.1 2020-12-18 add Arduino-CI + unit tests
11-
// + getMode() + flush()
12-
// 0.1.2 2021-01-15 add constructors with seed.
13-
// 0.1.3 2021-12-15 update library.json, license, minor edits
14-
//
15-
// 0.2.0 2022-07-02 add Marsaglia PRNG, is portable over platforms
16-
// becomes mode 3
17-
// improved reseeding
18-
// split off .cpp file
19-
// add examples
8+
// HISTORY: see changelog.md
209

2110

2211
#include "DEVRANDOM.h"
@@ -69,7 +58,7 @@ int DEVRANDOM::read()
6958
};
7059

7160

72-
// keep CI happy as parent class flush is virtual.
61+
// keep CI happy as parent class flush is virtual.
7362
void DEVRANDOM::flush()
7463
{
7564
};
@@ -168,9 +157,9 @@ int DEVRANDOM::_analogRead()
168157
}
169158

170159

171-
// An example of a simple pseudo-random number generator is the
172-
// Multiply-with-carry method invented by George Marsaglia.
173-
// two initializers (not null)
160+
// An example of a simple pseudo-random number generator is the
161+
// Multiply-with-carry method invented by George Marsaglia.
162+
// two initializers (not null)
174163
uint32_t DEVRANDOM::_marsaglia()
175164
{
176165
_m_z = 36969L * (_m_z & 65535L) + (_m_z >> 16);

libraries/DEVRANDOM/DEVRANDOM.h

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// FILE: DEVRANDOM.h
44
// AUTHOR: Rob Tillaart
5-
// VERSION: 0.2.0
5+
// VERSION: 0.2.1
66
// PURPOSE: Arduino library for a /dev/random stream - useful for testing
77
// URL: https://github.com/RobTillaart/DEVRANDOM
88
//
@@ -11,7 +11,7 @@
1111
#include "Arduino.h"
1212

1313

14-
#define DEVRANDOM_LIB_VERSION (F("0.2.0"))
14+
#define DEVRANDOM_LIB_VERSION (F("0.2.1"))
1515

1616

1717
#define DEVRANDOM_MODE_RANDOM 0
@@ -31,9 +31,11 @@ class DEVRANDOM : public Stream
3131
int available();
3232
int peek();
3333
int read();
34-
// keep CI happy as parent class flush is virtual.
34+
35+
// keep CI happy as parent class flush is virtual.
3536
void flush();
36-
// for reseeding, including via print() and println().
37+
38+
// for reseeding, including via print() and println().
3739
size_t write(const uint8_t data);
3840
size_t write(const uint8_t * buffer, size_t size);
3941

@@ -46,18 +48,19 @@ class DEVRANDOM : public Stream
4648
uint8_t getMode();
4749

4850

49-
// will be obsolete in future
50-
void useAR(uint8_t pin) { useAnalogRead(pin); };
51-
void useHW(uint8_t pin) { useDigitalRead(pin); };
52-
void useSW() { useRandom(); };
51+
// OBSOLETE
52+
// void useAR(uint8_t pin) { useAnalogRead(pin); };
53+
// void useHW(uint8_t pin) { useDigitalRead(pin); };
54+
// void useSW() { useRandom(); };
5355

5456

5557
private:
5658
uint8_t _next = 0;
5759
uint32_t _seed = 0;
5860
uint8_t _mode = 0;
5961
uint8_t _pin = 0;
60-
// Marsaglia 'constants'
62+
63+
// Marsaglia 'constants'
6164
uint32_t _m_w = 1;
6265
uint32_t _m_z = 2;
6366

libraries/DEVRANDOM/README.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ The seed value from the write is used as a XOR byte.
6565
This one is quite fast and good, and more important portable.
6666
- **uint8_t getMode()** returns the source of randomness.
6767

68-
| Mode | DEVRANDOM_MODE | Type |
69-
|:-------:|:----------------:|:----------------------|
70-
| 0 | build in random | depends on platform
71-
| 1 | digitalRead | hardware external
72-
| 2 | analogRead | hardware external
73-
| 3 | Marsaglia | software portable PRNG
68+
| Mode | DEVRANDOM_MODE | Type |
69+
|:-------:|:----------------:|:-----------------------|
70+
| 0 | build in random | depends on platform |
71+
| 1 | digitalRead | hardware external |
72+
| 2 | analogRead | hardware external |
73+
| 3 | Marsaglia | software portable PRNG |
7474

7575

7676
There might be other RNG's in the future.
@@ -79,8 +79,6 @@ If you have an interesting and fast PRNG to be included please let me know.
7979

8080
### Obsolete
8181

82-
To be obsolete in a next release.
83-
8482
- **useSW()** replaced by **useRandom()**.
8583
- **useHW(uint8_t pin)** replaced by **useDigitalRead()**.
8684
- **useAR(uint8_t pin)** replaced by **useAnalogRead()**.
@@ -93,15 +91,16 @@ See example sketches.
9391

9492
### Example
9593

96-
As shown in the example one can use fscanf to read larger datatypes,
94+
As shown in the example one can use fscanf() to read larger data types,
9795

9896
```cpp
9997
DEVRANDOM dr;
10098
uint32_t x;
10199
fscanf((FILE*) &dr, "%lu", &x);
102100
Serial.println(x);
103101
```
104-
However float is not supported standard in the fscanf by UNO and strings (%s) generate garbage.
102+
103+
However float is not supported standard in the fscanf() by UNO and strings (%s) generate garbage.
105104
So a password generator is a bit more difficult (and a good exercise).
106105
107106

libraries/DEVRANDOM/library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"type": "git",
1616
"url": "https://github.com/RobTillaart/DEVRANDOM.git"
1717
},
18-
"version": "0.2.0",
18+
"version": "0.2.1",
1919
"license": "MIT",
2020
"frameworks": "arduino",
2121
"platforms": "*",

libraries/DEVRANDOM/library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=DEVRANDOM
2-
version=0.2.0
2+
version=0.2.1
33
author=Rob Tillaart <[email protected]>
44
maintainer=Rob Tillaart <[email protected]>
55
sentence=Arduino library to wrap a random generator in a stream

0 commit comments

Comments
 (0)