Complexity of the cc measurement function reduced by using an early return.
This commit is contained in:
parent
075c570cae
commit
d12c75fa00
1 changed files with 85 additions and 87 deletions
|
@ -188,13 +188,22 @@ void cc_startMeasurement()
|
||||||
// MSG_TYPE_CONFIG
|
// MSG_TYPE_CONFIG
|
||||||
cc_getConfig();
|
cc_getConfig();
|
||||||
|
|
||||||
// 2. start a for loop from the frequence to start to the end frequence
|
if (start_freq == 0 || start_freq > 150000000 ||
|
||||||
if (start_freq > 0 && start_freq <= 150000000 &&
|
end_freq == 0 || end_freq > 150000000 ||
|
||||||
end_freq > 0 && end_freq <= 150000000 &&
|
step_freq == 0 || step_freq > 150000000 ||
|
||||||
start_freq < end_freq &&
|
start_freq >= end_freq ||
|
||||||
intervall > 0 &&
|
intervall == 0)
|
||||||
step_freq > 0)
|
|
||||||
{
|
{
|
||||||
|
// on error
|
||||||
|
|
||||||
|
sendSOM();
|
||||||
|
Serial.write(MSG_TYPE_ANSWER_NOK);
|
||||||
|
sendEOM();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. start a for loop from the frequence to start to the end frequence
|
||||||
si5351.drive_strength(SI5351_CLK0, drive_str); // 2 4 6 8ma
|
si5351.drive_strength(SI5351_CLK0, drive_str); // 2 4 6 8ma
|
||||||
|
|
||||||
uint8_t t = 0;
|
uint8_t t = 0;
|
||||||
|
@ -264,20 +273,9 @@ void cc_startMeasurement()
|
||||||
|
|
||||||
// 5. send a measurement end message to the host
|
// 5. send a measurement end message to the host
|
||||||
// MSG_TYPE_MEAS_END_INFO
|
// MSG_TYPE_MEAS_END_INFO
|
||||||
char* tmp = " ";
|
sendSOM();
|
||||||
sprintf(tmp, "%c%c%c%c%c", MSG_SOM1, MSG_SOM2,
|
Serial.write(MSG_TYPE_MEAS_END_INFO);
|
||||||
MSG_TYPE_MEAS_END_INFO,
|
sendEOM();
|
||||||
MSG_EOM1, MSG_EOM2);
|
|
||||||
Serial.write(tmp);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// on error
|
|
||||||
char* tmp = " ";
|
|
||||||
sprintf(tmp, "%c%c%c%c%c", MSG_SOM1, MSG_SOM2,
|
|
||||||
MSG_TYPE_ANSWER_NOK,
|
|
||||||
MSG_EOM1, MSG_EOM2);
|
|
||||||
Serial.write(tmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
si5351.output_enable(SI5351_CLK0, 0); // disable clock output 0
|
si5351.output_enable(SI5351_CLK0, 0); // disable clock output 0
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue