Skip to content

Commit 7fb8b1c

Browse files
update firmware to 4.3.2
- minor fixes to the TRNG code - reduce overlock image frequency to 225 - update ArduinoJSON and arduino-pico - Disable unused Serial1 (UART0)
1 parent 94c949a commit 7fb8b1c

File tree

5 files changed

+24
-22
lines changed

5 files changed

+24
-22
lines changed
-412 KB
Binary file not shown.

software/ogd_pico-4.3.1.uf2

-411 KB
Binary file not shown.
413 KB
Binary file not shown.

software/ogd_pico-4.3.2.uf2

412 KB
Binary file not shown.

software/ogd_pico/ogd_pico.ino

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
## Flash with default settings and
1515
## Flash Size: "4MB (Sketch: 1MB, FS: 3MB)"
1616
17-
17+
1818
TODO: Add cps line trend to geiger mode
1919
TODO: Add custom display font
2020
@@ -47,7 +47,6 @@
4747
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
4848
#define SCREEN_ADDRESS 0x3C // See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
4949
#define EVENT_BUFFER 50000 // Buffer this many events for Serial.print
50-
#define TRNG_BITS 8 // Number of bits for each random number, max 8
5150
#define BASELINE_NUM 101 // Number of measurements taken to determine the DC baseline
5251
#define CONFIG_FILE "/config.json" // File to store the settings
5352
#define DEBUG_FILE "/debug.json" // File to store some misc debug info
@@ -82,7 +81,7 @@ struct Config {
8281
=================
8382
*/
8483

85-
const String FW_VERSION = "4.3.1"; // Firmware Version Code
84+
const String FW_VERSION = "4.3.2"; // Firmware Version Code
8685

8786
const uint8_t GND_PIN = A2; // GND meas pin
8887
const uint8_t VSYS_MEAS = A3; // VSYS/3
@@ -116,12 +115,13 @@ volatile unsigned long start_time = 0; // Time in ms when the spectrum collect
116115
volatile unsigned long last_time = 0; // Last time the display has been refreshed
117116
volatile uint32_t last_total = 0; // Last total pulse count for display
118117

119-
volatile unsigned long trng_stamps[3]; // Timestamps for True Random Number Generator
120-
volatile uint8_t random_num = 0b00000000; // Generated random bits that form a byte together
121-
volatile uint8_t bit_index = 0; // Bit index for the generated number
122-
volatile uint32_t trng_nums[1000]; // TRNG number output array
123-
volatile uint16_t number_index = 0; // Amount of saved numbers to the TRNG array
124-
volatile uint32_t total_events = 0; // Total number of all registered pulses
118+
const uint16_t TRNG_STORAGE_SIZE = 1024; // Number of trng bytes stored in memory
119+
volatile unsigned long trng_stamps[3]; // Timestamps for True Random Number Generator
120+
volatile uint8_t random_num = 0b00000000; // Generated random bits that form a byte together
121+
volatile uint8_t bit_index = 0; // Bit index for the generated number
122+
volatile uint8_t trng_nums[TRNG_STORAGE_SIZE]; // TRNG number output array
123+
volatile uint16_t number_index = 0; // Amount of saved numbers to the TRNG array
124+
volatile size_t total_events = 0; // Total number of all registered pulses
125125

126126
RunningMedian baseline(BASELINE_NUM); // Array of a number of baseline (DC bias) measurements at the SiPM input
127127
uint16_t current_baseline = 0; // Median value of the input baseline voltage
@@ -820,7 +820,7 @@ void writeDebugFileTime() {
820820

821821
debugFile.close();
822822

823-
const uint32_t temp = doc.containsKey("power_on_hours") ? doc["power_on_hours"] : 0;
823+
const uint32_t temp = doc["power_on_hours"].is<uint32_t>() ? doc["power_on_hours"] : 0;
824824
doc["power_on_hours"] = temp + 1;
825825

826826
debugFile = LittleFS.open(DEBUG_FILE, "w"); // Open read and write
@@ -848,7 +848,7 @@ void writeDebugFileBoot() {
848848

849849
debugFile.close();
850850

851-
const uint32_t temp = doc.containsKey("power_cycle_count") ? doc["power_cycle_count"] : 0;
851+
const uint32_t temp = doc["power_cycle_count"].is<uint32_t>() ? doc["power_cycle_count"] : 0;
852852
doc["power_cycle_count"] = temp + 1;
853853

854854
debugFile = LittleFS.open(DEBUG_FILE, "w"); // Open read and write
@@ -881,31 +881,31 @@ Config loadSettings(bool msg = true) {
881881
return new_conf;
882882
}
883883

884-
if (doc.containsKey("ser_output")) {
884+
if (doc["ser_output"].is<bool>()) {
885885
new_conf.ser_output = doc["ser_output"];
886886
}
887-
if (doc.containsKey("geiger_mode")) {
887+
if (doc["geiger_mode"].is<bool>()) {
888888
new_conf.geiger_mode = doc["geiger_mode"];
889889
}
890-
if (doc.containsKey("print_spectrum")) {
890+
if (doc["print_spectrum"].is<bool>()) {
891891
new_conf.print_spectrum = doc["print_spectrum"];
892892
}
893-
if (doc.containsKey("meas_avg")) {
893+
if (doc["meas_avg"].is<size_t>()) {
894894
new_conf.meas_avg = doc["meas_avg"];
895895
}
896-
if (doc.containsKey("enable_display")) {
896+
if (doc["enable_display"].is<bool>()) {
897897
new_conf.enable_display = doc["enable_display"];
898898
}
899-
if (doc.containsKey("enable_trng")) {
899+
if (doc["enable_trng"].is<bool>()) {
900900
new_conf.enable_trng = doc["enable_trng"];
901901
}
902-
if (doc.containsKey("subtract_baseline")) {
902+
if (doc["subtract_baseline"].is<bool>()) {
903903
new_conf.subtract_baseline = doc["subtract_baseline"];
904904
}
905-
if (doc.containsKey("enable_ticker")) {
905+
if (doc["enable_ticker"].is<bool>()) {
906906
new_conf.enable_ticker = doc["enable_ticker"];
907907
}
908-
if (doc.containsKey("tick_rate")) {
908+
if (doc["tick_rate"].is<size_t>()) {
909909
new_conf.tick_rate = doc["tick_rate"];
910910
}
911911

@@ -1242,12 +1242,12 @@ void eventInt() {
12421242

12431243
bitWrite(random_num, bit_index, (delta0 < delta1));
12441244

1245-
if (bit_index < TRNG_BITS - 1) {
1245+
if (bit_index < 7) { // Check if still less than a byte
12461246
bit_index++;
12471247
} else {
12481248
trng_nums[number_index] = random_num;
12491249

1250-
if (number_index < 999) {
1250+
if (number_index < TRNG_STORAGE_SIZE - 1) { // Check if TRNG byte storage array is full
12511251
number_index++;
12521252
} else {
12531253
number_index = 0; // Catch overflow
@@ -1367,6 +1367,8 @@ void setup1() {
13671367
saveSettings(); // Create settings file if none is present
13681368
writeDebugFileBoot(); // Update power cycle count
13691369

1370+
// Disable unused UART0
1371+
Serial1.end();
13701372
// Set the correct SPI pins
13711373
SPI.setRX(4);
13721374
SPI.setTX(3);

0 commit comments

Comments
 (0)