mirror of
https://github.com/okalachev/flix.git
synced 2025-07-27 09:39:33 +00:00
Improve RC reading in calibration process
This commit is contained in:
parent
ce1223e82d
commit
083db659c6
@ -25,13 +25,15 @@ void setupRC() {
|
|||||||
RC.begin();
|
RC.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
void readRC() {
|
bool readRC() {
|
||||||
if (RC.read()) {
|
if (RC.read()) {
|
||||||
SBUSData data = RC.data();
|
SBUSData data = RC.data();
|
||||||
memcpy(channels, data.ch, sizeof(channels)); // copy channels data
|
memcpy(channels, data.ch, sizeof(channels)); // copy channels data
|
||||||
normalizeRC();
|
normalizeRC();
|
||||||
controlsTime = t;
|
controlsTime = t;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void normalizeRC() {
|
void normalizeRC() {
|
||||||
@ -45,14 +47,14 @@ void calibrateRC() {
|
|||||||
Serial.println("Calibrate RC: move all sticks to maximum positions in 4 seconds");
|
Serial.println("Calibrate RC: move all sticks to maximum positions in 4 seconds");
|
||||||
Serial.println("··o ··o\n··· ···\n··· ···");
|
Serial.println("··o ··o\n··· ···\n··· ···");
|
||||||
delay(4000);
|
delay(4000);
|
||||||
for (int i = 0; i < 30; i++) readRC(); // ensure the values are updated
|
while (!readRC());
|
||||||
for (int i = 0; i < 16; i++) {
|
for (int i = 0; i < 16; i++) {
|
||||||
channelMax[i] = channels[i];
|
channelMax[i] = channels[i];
|
||||||
}
|
}
|
||||||
Serial.println("Calibrate RC: move all sticks to neutral positions in 4 seconds");
|
Serial.println("Calibrate RC: move all sticks to neutral positions in 4 seconds");
|
||||||
Serial.println("··· ···\n··· ·o·\n·o· ···");
|
Serial.println("··· ···\n··· ·o·\n·o· ···");
|
||||||
delay(4000);
|
delay(4000);
|
||||||
for (int i = 0; i < 30; i++) readRC(); // ensure the values are updated
|
while (!readRC());
|
||||||
for (int i = 0; i < 16; i++) {
|
for (int i = 0; i < 16; i++) {
|
||||||
channelNeutral[i] = channels[i];
|
channelNeutral[i] = channels[i];
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user