From 1fc6ce8218c61776bd19c622c6e02fc85cc4ac2f Mon Sep 17 00:00:00 2001 From: Brendan <2bndy5@gmail.com> Date: Tue, 26 Nov 2024 01:14:41 -0800 Subject: [PATCH 1/2] fixes for STM32 resolves #1010 --- RF24.cpp | 5 +++++ examples/scanner/scanner.ino | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/RF24.cpp b/RF24.cpp index f0f7a0879..8c2bb77ac 100644 --- a/RF24.cpp +++ b/RF24.cpp @@ -1368,6 +1368,11 @@ bool RF24::startWrite(const void* buf, uint8_t len, const bool multicast) ce(HIGH); #if !defined(F_CPU) || F_CPU > 20000000 delayMicroseconds(10); +#endif +#ifdef ARDUINO_ARCH_STM32 + if (F_CPU > 20000000) { + delayMicroseconds(10); + } #endif ce(LOW); return !(status & _BV(TX_FULL)); diff --git a/examples/scanner/scanner.ino b/examples/scanner/scanner.ino index c8b800931..d6c7d4413 100644 --- a/examples/scanner/scanner.ino +++ b/examples/scanner/scanner.ino @@ -141,7 +141,7 @@ void loop(void) { if (Serial.available()) { int8_t c = Serial.parseInt(); if (c >= 0) { - c = min(125, max(0, c)); // clamp channel to supported range + c = min((int8_t)125, c); // clamp channel to supported range constCarrierMode = 1; radio.stopListening(); delay(2); @@ -199,7 +199,7 @@ void loop(void) { // Print out channel measurements, clamped to a single hex digit for (int i = 0; i < num_channels; ++i) { if (values[i]) - Serial.print(min(0xf, values[i]), HEX); + Serial.print(min((uint8_t)0xf, values[i]), HEX); else Serial.print(F("-")); } From 528a87198b4397ed69877a1a0bdcb654abd03ac5 Mon Sep 17 00:00:00 2001 From: Brendan <2bndy5@gmail.com> Date: Tue, 26 Nov 2024 02:16:20 -0800 Subject: [PATCH 2/2] fix scannerGraphic example also --- examples/scannerGraphic/scannerGraphic.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/scannerGraphic/scannerGraphic.ino b/examples/scannerGraphic/scannerGraphic.ino index e11ef6ea3..ddbed5a1b 100644 --- a/examples/scannerGraphic/scannerGraphic.ino +++ b/examples/scannerGraphic/scannerGraphic.ino @@ -89,7 +89,7 @@ struct ChannelHistory { sum += history[i]; } history[cacheMax - 1] = value; - maxPeak = max(sum * 2, maxPeak); // sum * 2 to allow half-step decay + maxPeak = max((uint8_t)(sum * 2), maxPeak); // sum * 2 to allow half-step decay return sum; }