- added data validation in calibrate compass
- activatre auto load calibration data - give possibility to force update in navigation getCourseCorrection - added drive mode for compass calibration - removed compass calibration manualControl
This commit is contained in:
@@ -63,7 +63,7 @@ void CalibrateCompass::loop() {
|
||||
|
||||
if (millis() - this->lastChange > this->maxTimeWithoutChange) {
|
||||
this->state = State::Finished;
|
||||
this->newData = true;
|
||||
this->checkDataValidity();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,6 +78,11 @@ void CalibrateCompass::start() {
|
||||
}
|
||||
|
||||
void CalibrateCompass::useData() {
|
||||
if (!this->dataValid) {
|
||||
std::cout << "CalibrateCompass::useData - Data not valid" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
this->compass->setCalibration( this->data.data[0][0],
|
||||
this->data.data[0][1],
|
||||
this->data.data[1][0],
|
||||
@@ -89,8 +94,7 @@ void CalibrateCompass::useData() {
|
||||
std::cout << "CalibrateCompass::useData " << *this << std::endl;
|
||||
}
|
||||
|
||||
void CalibrateCompass::resetData() {
|
||||
this->reset();
|
||||
void CalibrateCompass::removeCalibration() {
|
||||
this->compass->removeCalibration();
|
||||
}
|
||||
|
||||
@@ -100,7 +104,7 @@ void CalibrateCompass::reset() {
|
||||
}
|
||||
|
||||
void CalibrateCompass::saveData() {
|
||||
if (!this->newData)
|
||||
if (!this->dataValid)
|
||||
return;
|
||||
|
||||
Preferences preferences;
|
||||
@@ -128,6 +132,7 @@ void CalibrateCompass::loadData() {
|
||||
this->data.data[2][1] = preferences.getInt("zHigh", 0);
|
||||
|
||||
preferences.end();
|
||||
this->checkDataValidity();
|
||||
}
|
||||
|
||||
void CalibrateCompass::clearData() {
|
||||
@@ -135,6 +140,22 @@ void CalibrateCompass::clearData() {
|
||||
this->data.data[i][0] = 0;
|
||||
this->data.data[i][1] = 0;
|
||||
}
|
||||
this->dataValid = false;
|
||||
}
|
||||
|
||||
void CalibrateCompass::checkDataValidity() {
|
||||
int sum = 0;
|
||||
for (uint8_t i = 0; i < 3; i++) {
|
||||
if (this->data.data[i][0] > INT16_MAX || this->data.data[i][0] < INT16_MIN
|
||||
|| this->data.data[i][1] > INT16_MAX || this->data.data[i][1] < INT16_MIN)
|
||||
{
|
||||
this->dataValid = false;
|
||||
return;
|
||||
}
|
||||
sum += this->data.data[i][0];
|
||||
sum += this->data.data[i][1];
|
||||
}
|
||||
this->dataValid = sum;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const CalibrateCompass& caliComp) {
|
||||
|
||||
Reference in New Issue
Block a user