From 083db659c6bf215feb6e9537fdee57cac423814f Mon Sep 17 00:00:00 2001 From: Oleg Kalachev Date: Wed, 12 Feb 2025 10:15:13 +0300 Subject: [PATCH] Improve RC reading in calibration process --- flix/rc.ino | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/flix/rc.ino b/flix/rc.ino index 8f13045..1c127b9 100644 --- a/flix/rc.ino +++ b/flix/rc.ino @@ -25,13 +25,15 @@ void setupRC() { RC.begin(); } -void readRC() { +bool readRC() { if (RC.read()) { SBUSData data = RC.data(); memcpy(channels, data.ch, sizeof(channels)); // copy channels data normalizeRC(); controlsTime = t; + return true; } + return false; } void normalizeRC() { @@ -45,14 +47,14 @@ void calibrateRC() { Serial.println("Calibrate RC: move all sticks to maximum positions in 4 seconds"); Serial.println("··o ··o\n··· ···\n··· ···"); delay(4000); - for (int i = 0; i < 30; i++) readRC(); // ensure the values are updated + while (!readRC()); for (int i = 0; i < 16; i++) { channelMax[i] = channels[i]; } Serial.println("Calibrate RC: move all sticks to neutral positions in 4 seconds"); Serial.println("··· ···\n··· ·o·\n·o· ···"); delay(4000); - for (int i = 0; i < 30; i++) readRC(); // ensure the values are updated + while (!readRC()); for (int i = 0; i < 16; i++) { channelNeutral[i] = channels[i]; }