From a43e2db92bd0a4f40009f73cfdf4522935c4b8c3 Mon Sep 17 00:00:00 2001 From: Alexander Klein Date: Thu, 12 Oct 2023 00:44:27 +0200 Subject: [PATCH] clangtidy corrections part 2 --- clangtidy.txt | 687 ------------------ lib/MQTT/debugMqtt.cpp | 30 +- lib/MQTT/debugMqtt.h | 8 +- lib/MotorControl/motorControl.cpp | 153 ++-- lib/MotorControl/motorControl.h | 162 ++--- lib/Navigation/navigation.cpp | 127 ++-- lib/Navigation/navigation.h | 223 +++--- lib/Network/network.cpp | 124 ++-- lib/Network/network.h | 87 +-- lib/NtripClient/ntripClient.cpp | 326 +++++---- lib/NtripClient/ntripClient.h | 176 ++--- lib/Point/point.cpp | 100 +-- lib/Point/point.h | 213 +++--- lib/Route/route.cpp | 68 +- lib/Route/route.h | 5 - lib/Sensors/sensorData.cpp | 209 ++++-- lib/Sensors/sensorData.h | 140 ++-- lib/Speedometer/speedometer.cpp | 128 ++-- lib/Speedometer/speedometer.h | 185 ++--- lib/Times/debugTimes.cpp | 35 +- lib/Times/debugTimes.h | 83 +-- lib/calibrateCompass/calibrateCompass.cpp | 42 +- lib/calibrateCompass/calibrateCompass.h | 71 +- src/OutputBuf/outputBuf.cpp | 61 +- .../CalibrateBattery/menuCalibrateBattery.cpp | 63 +- .../CalibrateBattery/menuCalibrateBattery.h | 31 +- src/SpecialMenus/PID/menuPidSettings.cpp | 15 +- src/SpecialMenus/Route/menuRoute.cpp | 26 +- src/SpecialMenus/Route/menuRoute.h | 210 +++--- src/SpecialMenus/Route/menuRoutePoints.cpp | 63 +- .../SensorData/menuSensorData.cpp | 214 +++--- src/SpecialMenus/Speed/menuSpeed.cpp | 7 +- .../menuSysteminformatio.cpp | 3 +- .../driveModi/Autopilot/menuAutopilot.cpp | 435 ++++++----- .../CalibrateCompass/menuCalibrateCompass.cpp | 2 +- .../CalibrateCompass/menuCalibrateCompass.h | 6 +- .../CaptureRoute/menuCaptureRoute.cpp | 218 +++--- .../driveModi/CaptureRoute/menuCaptureRoute.h | 4 +- .../driveModi/ManualDrive/menuManualDrive.cpp | 10 +- .../driveModi/ManualDrive/menuManualDrive.h | 7 +- .../driveModi/TestMode/menuTestMode.cpp | 2 +- 41 files changed, 2274 insertions(+), 2485 deletions(-) diff --git a/clangtidy.txt b/clangtidy.txt index 06f3caa..d6d4dfe 100644 --- a/clangtidy.txt +++ b/clangtidy.txt @@ -1,691 +1,4 @@ -lib/MQTT/debugMqtt.cpp:22: [medium:warning] 'name' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/MQTT/debugMqtt.cpp:23: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/MQTT/debugMqtt.cpp:32: [medium:warning] 2 adjacent parameters of 'sendMsg' of similar type ('String') are easily swapped by mistake [bugprone-easily-swappable-parameters] -lib/MQTT/debugMqtt.cpp:32: [medium:warning] the parameter 'msg' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param] -lib/MQTT/debugMqtt.cpp:33: [medium:warning] the value returned by this function should be used [cert-err33-c] -lib/MQTT/debugMqtt.cpp:33: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/MQTT/debugMqtt.cpp:34: [medium:warning] parameter 'topic' is passed by value and only copied once; consider moving it to avoid unnecessary copies [performance-unnecessary-value-param] -lib/MQTT/debugMqtt.cpp:34: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/MQTT/debugMqtt.cpp:38: [medium:warning] parameter 'msg' is passed by value and only copied once; consider moving it to avoid unnecessary copies [performance-unnecessary-value-param] -lib/MQTT/debugMqtt.cpp:41: [medium:warning] method 'sendData' can be made static [readability-convert-member-functions-to-static] -lib/MQTT/debugMqtt.cpp:41: [medium:warning] the parameter 'topic' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param] -lib/MQTT/debugMqtt.cpp:41: [medium:warning] the parameter 'data' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param] -lib/MQTT/debugMqtt.cpp:47: [medium:warning] the value returned by this function should be used [cert-err33-c] -lib/MQTT/debugMqtt.cpp:47: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/MQTT/debugMqtt.cpp:48: [medium:warning] the value returned by this function should be used [cert-err33-c] -lib/MQTT/debugMqtt.cpp:48: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/MQTT/debugMqtt.cpp:49: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/MQTT/debugMqtt.cpp:49: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/MQTT/debugMqtt.cpp:54: [medium:warning] parameter 'data' is passed by value and only copied once; consider moving it to avoid unnecessary copies [performance-unnecessary-value-param] -lib/MQTT/debugMqtt.cpp:57: [medium:warning] the parameter 'measurement_name' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param] -lib/MQTT/debugMqtt.cpp:57: [medium:warning] the parameter 'field_set' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param] -lib/MQTT/debugMqtt.cpp:60: [medium:warning] the value returned by this function should be used [cert-err33-c] -lib/MQTT/debugMqtt.cpp:60: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/MQTT/debugMqtt.cpp:61: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/MQTT/debugMqtt.cpp:64: [medium:warning] parameter name 'c' is too short, expected at least 3 characters [readability-identifier-length] -lib/Menu/src/menu.cpp:13: [medium:warning] constructor does not initialize these fields: entrys, selectedEntry [cppcoreguidelines-pro-type-member-init,hicpp-member-init] -lib/Menu/src/menu.cpp:18: [medium:warning] variable 'iter' is not initialized [cppcoreguidelines-init-variables] -lib/Menu/src/menu.cpp:18: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menu.cpp:25: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menu.cpp:29: [medium:warning] method 'isInSubmenu' can be made const [readability-make-member-function-const] -lib/Menu/src/menu.cpp:34: [medium:warning] variable 'iter' is not initialized [cppcoreguidelines-init-variables] -lib/Menu/src/menu.cpp:43: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menu.cpp:63: [medium:warning] missing username/bug in TODO [google-readability-todo] -lib/Menu/src/menu.cpp:64: [medium:warning] variable 'iter' is not initialized [cppcoreguidelines-init-variables] -lib/Menu/src/menu.cpp:66: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menu.cpp:68: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menu.cpp:78: [medium:warning] variable 'iter' is not initialized [cppcoreguidelines-init-variables] -lib/Menu/src/menu.cpp:108: [medium:warning] implicit conversion 'MenuControl *' -> bool [readability-implicit-bool-conversion] -lib/Menu/src/menu.cpp:108: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuAction.cpp:13: [medium:warning] 2 adjacent parameters of 'MenuAction' of similar type ('void (*)()') are easily swapped by mistake [bugprone-easily-swappable-parameters] -lib/Menu/src/menuAction.cpp:14: [medium:warning] 'name' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Menu/src/menuAction.cpp:15: [medium:warning] 'function' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Menu/src/menuAction.cpp:16: [medium:warning] 'callback' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Menu/src/menuAction.cpp:20: [medium:warning] 'name' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Menu/src/menuAction.cpp:21: [medium:warning] 'menu' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Menu/src/menuAction.cpp:22: [medium:warning] 'isMenu' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Menu/src/menuAction.cpp:26: [medium:warning] 'name' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Menu/src/menuAction.cpp:27: [medium:warning] 'action' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Menu/src/menuAction.cpp:31: [medium:warning] 'if' statement is unnecessary; deleting null pointer has no effect [readability-delete-null-pointer] -lib/Menu/src/menuAction.cpp:31: [medium:warning] implicit conversion 'MenuControl *' -> bool [readability-implicit-bool-conversion] -lib/Menu/src/menuAction.cpp:31: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuAction.cpp:34: [medium:warning] 'if' statement is unnecessary; deleting null pointer has no effect [readability-delete-null-pointer] -lib/Menu/src/menuAction.cpp:34: [medium:warning] implicit conversion 'MenuActionWrapper *' -> bool [readability-implicit-bool-conversion] -lib/Menu/src/menuAction.cpp:34: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuAction.cpp:39: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuAction.cpp:42: [medium:warning] implicit conversion 'void (*)()' -> bool [readability-implicit-bool-conversion] -lib/Menu/src/menuAction.cpp:42: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuAction.cpp:44: [medium:warning] implicit conversion 'MenuActionWrapper *' -> bool [readability-implicit-bool-conversion] -lib/Menu/src/menuAction.cpp:44: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuAction.cpp:46: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuAction.cpp:50: [medium:warning] implicit conversion 'void (*)()' -> bool [readability-implicit-bool-conversion] -lib/Menu/src/menuAction.cpp:50: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuAction.cpp:58: [medium:warning] method 'getIsMenu' can be made const [readability-make-member-function-const] -lib/Menu/src/menuAction.cpp:63: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuAction.cpp:65: [medium:warning] do not use 'else' after 'return' [readability-else-after-return] -lib/Menu/src/menuAction.cpp:65: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuControl.cpp:14: [medium:warning] the parameter 'lineOne' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param] -lib/Menu/src/menuControl.cpp:14: [medium:warning] the parameter 'lineTwo' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param] -lib/Menu/src/menuControl.cpp:15: [medium:warning] implicit conversion 'DisplayWrapper *' -> bool [readability-implicit-bool-conversion] -lib/Menu/src/menuControl.cpp:27: [medium:warning] implicit conversion 'DisplayWrapper *' -> bool [readability-implicit-bool-conversion] -lib/Menu/src/menuControl.cpp:27: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuInformationSites.cpp:15: [medium:warning] 'countPages' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Menu/src/menuInformationSites.cpp:16: [medium:warning] 'currentPage' should be initialized in an in-class default member initializer [cppcoreguidelines-prefer-member-initializer] -lib/Menu/src/menuInformationSites.cpp:17: [medium:warning] 'lastMillis' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Menu/src/menuInformationSites.cpp:21: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuInformationSites.cpp:23: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuInformationSites.cpp:29: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuInformationSites.cpp:31: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuInformationSites.cpp:41: [medium:warning] implicit conversion 'MenuControl *' -> bool [readability-implicit-bool-conversion] -lib/Menu/src/menuInformationSites.cpp:92: [medium:warning] variable 'lineOne' of type 'String' can be declared 'const' [misc-const-correctness] -lib/Menu/src/menuInformationSites.cpp:93: [medium:warning] variable 'lineTwo' of type 'String' can be declared 'const' [misc-const-correctness] -lib/Menu/src/menuIntInput.cpp:15: [medium:warning] 'values' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Menu/src/menuIntInput.cpp:16: [medium:warning] 'names' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Menu/src/menuIntInput.cpp:17: [medium:warning] 'length' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Menu/src/menuIntInput.cpp:18: [medium:warning] 'wrapper' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Menu/src/menuIntInput.cpp:20: [medium:warning] 'min' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Menu/src/menuIntInput.cpp:21: [medium:warning] 'max' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Menu/src/menuIntInput.cpp:22: [medium:warning] 'originalValues' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Menu/src/menuIntInput.cpp:23: [medium:warning] 'stepsPerInput' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Menu/src/menuIntInput.cpp:34: [medium:warning] 'length' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Menu/src/menuIntInput.cpp:35: [medium:warning] 'wrapper' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Menu/src/menuIntInput.cpp:37: [medium:warning] 'values' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Menu/src/menuIntInput.cpp:38: [medium:warning] 'names' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Menu/src/menuIntInput.cpp:38: [medium:warning] do not use C-style cast to convert between unrelated types [cppcoreguidelines-pro-type-cstyle-cast] -lib/Menu/src/menuIntInput.cpp:38: [medium:warning] C-style casts are discouraged; use reinterpret_cast [google-readability-casting] -lib/Menu/src/menuIntInput.cpp:39: [medium:warning] 'min' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Menu/src/menuIntInput.cpp:40: [medium:warning] 'max' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Menu/src/menuIntInput.cpp:41: [medium:warning] 'originalValues' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Menu/src/menuIntInput.cpp:42: [medium:warning] 'stepsPerInput' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Menu/src/menuIntInput.cpp:50: [medium:warning] result of multiplication in type 'int' is used as a pointer offset after an implicit widening conversion to type 'ptrdiff_t' [bugprone-implicit-widening-of-multiplication-result] -lib/Menu/src/menuIntInput.cpp:65: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuIntInput.cpp:68: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuIntInput.cpp:72: [medium:warning] result of multiplication in type 'int' is used as a pointer offset after an implicit widening conversion to type 'ptrdiff_t' [bugprone-implicit-widening-of-multiplication-result] -lib/Menu/src/menuIntInput.cpp:78: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuIntInput.cpp:85: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuIntInput.cpp:91: [medium:warning] 2 adjacent parameters of 'setMinMax' of similar type ('int16_t') are easily swapped by mistake [bugprone-easily-swappable-parameters] -lib/Menu/src/menuIntInput.cpp:97: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuIntInput.cpp:102: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuIntInput.cpp:106: [medium:warning] 2 adjacent parameters of 'setMinMax' of similar type ('int16_t') are easily swapped by mistake [bugprone-easily-swappable-parameters] -lib/Menu/src/menuIntInput.cpp:111: [medium:warning] 3 adjacent parameters of 'setMinMaxSteps' of convertible types are easily swapped by mistake [bugprone-easily-swappable-parameters] -lib/Menu/src/menuIntInput.cpp:117: [medium:warning] 3 adjacent parameters of 'setMinMaxSteps' of convertible types are easily swapped by mistake [bugprone-easily-swappable-parameters] -lib/Menu/src/menuIntInput.cpp:124: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuIntInput.cpp:131: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuIntInput.cpp:162: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuIntInput.cpp:164: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuIntInput.cpp:171: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuIntInput.cpp:173: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuIntInput.cpp:180: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuIntInput.cpp:184: [medium:warning] implicit conversion 'MenuControl *' -> bool [readability-implicit-bool-conversion] -lib/Menu/src/menuIntInput.cpp:192: [medium:warning] implicit conversion 'MenuControl *' -> bool [readability-implicit-bool-conversion] -lib/Menu/src/menuIntInput.cpp:199: [medium:warning] 17 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Menu/src/menuIntInput.cpp:203: [medium:warning] the value returned by this function should be used [cert-err33-c] -lib/Menu/src/menuIntInput.cpp:203: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/Menu/src/menuIntInput.cpp:203: [medium:warning] result of multiplication in type 'int' is used as a pointer offset after an implicit widening conversion to type 'ptrdiff_t' [bugprone-implicit-widening-of-multiplication-result] -lib/Menu/src/menuIntInput.cpp:206: [medium:warning] the value returned by this function should be used [cert-err33-c] -lib/Menu/src/menuIntInput.cpp:206: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/Menu/src/menuIntInput.cpp:206: [medium:warning] result of multiplication in type 'int' is used as a pointer offset after an implicit widening conversion to type 'ptrdiff_t' [bugprone-implicit-widening-of-multiplication-result] -lib/Menu/src/menuIntInput.cpp:209: [medium:warning] the value returned by this function should be used [cert-err33-c] -lib/Menu/src/menuIntInput.cpp:209: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/Menu/src/menuIntInput.cpp:209: [medium:warning] result of multiplication in type 'int' is used as a pointer offset after an implicit widening conversion to type 'ptrdiff_t' [bugprone-implicit-widening-of-multiplication-result] -lib/Menu/src/menuIntInput.cpp:212: [medium:warning] the value returned by this function should be used [cert-err33-c] -lib/Menu/src/menuIntInput.cpp:212: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/Menu/src/menuIntInput.cpp:212: [medium:warning] result of multiplication in type 'int' is used as a pointer offset after an implicit widening conversion to type 'ptrdiff_t' [bugprone-implicit-widening-of-multiplication-result] -lib/Menu/src/menuIntInput.cpp:215: [medium:warning] 17 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Menu/src/menuIntInput.cpp:216: [medium:warning] implicit conversion 'int16_t' (aka 'short') -> bool [readability-implicit-bool-conversion] -lib/Menu/src/menuIntInput.cpp:216: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuIntInput.cpp:217: [medium:warning] the value returned by this function should be used [cert-err33-c] -lib/Menu/src/menuIntInput.cpp:217: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/Menu/src/menuIntInput.cpp:218: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Menu/src/menuIntInput.cpp:219: [medium:warning] the value returned by this function should be used [cert-err33-c] -lib/Menu/src/menuIntInput.cpp:219: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/Menu/src/menuIntInput.cpp:221: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/Menu/src/menuIntInput.cpp:221: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/MotorControl/motorControl.cpp:15: [medium:warning] constructor does not initialize these fields: pwmPin, pwmChannel, dutycycleMin, dutycycleMax, dir_1, dir_2 [cppcoreguidelines-pro-type-member-init,hicpp-member-init] -lib/MotorControl/motorControl.cpp:21: [medium:warning] 3 adjacent parameters of 'init' of similar type ('uint8_t') are easily swapped by mistake [bugprone-easily-swappable-parameters] -lib/MotorControl/motorControl.cpp:40: [medium:warning] variable 'abs_difference' of type 'uint8_t' (aka 'unsigned char') can be declared 'const' [misc-const-correctness] -lib/MotorControl/motorControl.cpp:43: [medium:warning] variable 'difference' of type 'int16_t' (aka 'short') can be declared 'const' [misc-const-correctness] -lib/MotorControl/motorControl.cpp:84: [medium:warning] 80 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/MotorControl/motorControl.cpp:84: [medium:warning] statement should be inside braces [hicpp-braces-around-statements,readability-braces-around-statements] -lib/MotorControl/motorControl.cpp:84: [medium:warning] 80 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/MotorControl/motorControl.cpp:86: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] -lib/MotorControl/motorControl.cpp:86: [medium:warning] use of a signed integer operand with a binary bitwise operator [hicpp-signed-bitwise] -lib/MotorControl/motorControl.cpp:91: [medium:warning] 100 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/MotorControl/motorControl.cpp:91: [medium:warning] statement should be inside braces [hicpp-braces-around-statements,readability-braces-around-statements] -lib/MotorControl/motorControl.cpp:91: [medium:warning] 100 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/MotorControl/motorControl.cpp:93: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] -lib/MotorControl/motorControl.cpp:93: [medium:warning] use of a signed integer operand with a binary bitwise operator [hicpp-signed-bitwise] -lib/MotorControl/motorControl.cpp:98: [medium:warning] 100 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/MotorControl/motorControl.cpp:98: [medium:warning] 100 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/MotorControl/motorControl.cpp:98: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/MotorControl/motorControl.cpp:100: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/MotorControl/motorControl.cpp:113: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/MotorControl/motorControl.cpp:114: [medium:warning] redundant boolean literal in conditional return statement [readability-simplify-boolean-expr] -lib/MotorControl/motorControl.cpp:119: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/MotorControl/motorControl.cpp:120: [medium:warning] redundant boolean literal in conditional return statement [readability-simplify-boolean-expr] -lib/MotorControl/motorControl.cpp:125: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/MotorControl/motorControl.cpp:126: [medium:warning] redundant boolean literal in conditional return statement [readability-simplify-boolean-expr] -lib/MotorControl/motorControl.cpp:131: [medium:warning] missing username/bug in TODO [google-readability-todo] -lib/MotorControl/motorControl.cpp:132: [medium:warning] 100 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/MotorControl/motorControl.cpp:132: [medium:warning] 100 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/MotorControl/motorControl.cpp:147: [medium:warning] variable 'pwm_val' of type 'uint8_t' (aka 'unsigned char') can be declared 'const' [misc-const-correctness] -lib/MotorControl/motorControl.cpp:147: [medium:warning] 100 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/MotorControl/motorControl.cpp:164: [medium:warning] missing username/bug in TODO [google-readability-todo] -lib/MotorControl/motorControl.cpp:165: [medium:warning] missing username/bug in TODO [google-readability-todo] -lib/Navigation/navigation.cpp:15: [medium:warning] 'sensorData' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Navigation/navigation.cpp:20: [medium:warning] implicit conversion 'Route *' -> bool [readability-implicit-bool-conversion] -lib/Navigation/navigation.cpp:20: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Navigation/navigation.cpp:22: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Navigation/navigation.cpp:35: [medium:warning] 'if' statement is unnecessary; deleting null pointer has no effect [readability-delete-null-pointer] -lib/Navigation/navigation.cpp:35: [medium:warning] implicit conversion 'Route *' -> bool [readability-implicit-bool-conversion] -lib/Navigation/navigation.cpp:35: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Navigation/navigation.cpp:41: [medium:warning] variable 'newTargetPoint' of type 'Point' can be declared 'const' [misc-const-correctness] -lib/Navigation/navigation.cpp:43: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Navigation/navigation.cpp:49: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Navigation/navigation.cpp:52: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Navigation/navigation.cpp:55: [medium:warning] 2.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Navigation/navigation.cpp:65: [medium:warning] redundant boolean literal supplied to boolean operator [readability-simplify-boolean-expr] -lib/Navigation/navigation.cpp:81: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Navigation/navigation.cpp:92: [medium:warning] variable 'distance' of type 'double' can be declared 'const' [misc-const-correctness] -lib/Navigation/navigation.cpp:117: [medium:warning] variable 'targetCourse' of type 'int16_t' (aka 'short') can be declared 'const' [misc-const-correctness] -lib/Navigation/navigation.cpp:118: [medium:warning] variable 'correctionCourse' is not initialized [cppcoreguidelines-init-variables] -lib/Navigation/navigation.cpp:134: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Navigation/navigation.cpp:148: [medium:warning] 180 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Navigation/navigation.cpp:148: [medium:warning] 180 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Navigation/navigation.cpp:149: [medium:warning] 180 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Navigation/navigation.cpp:149: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Navigation/navigation.cpp:150: [medium:warning] 360 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Navigation/navigation.cpp:151: [medium:warning] 180 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Navigation/navigation.cpp:151: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Navigation/navigation.cpp:152: [medium:warning] 360 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Navigation/navigation.h:86: [medium:warning] missing username/bug in TODO [google-readability-todo] -lib/Navigation/navigation.h:99: [medium:warning] missing username/bug in TODO [google-readability-todo] -lib/Network/network.cpp:14: [medium:warning] constructor does not initialize these fields: mqttUser, mqttPassphrase [cppcoreguidelines-pro-type-member-init,hicpp-member-init] -lib/Network/network.cpp:15: [medium:warning] static member accessed through instance [readability-static-accessed-through-instance] -lib/Network/network.cpp:15: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Network/network.cpp:21: [medium:warning] constructor does not initialize these fields: mqttUser, mqttPassphrase [cppcoreguidelines-pro-type-member-init,hicpp-member-init] -lib/Network/network.cpp:22: [medium:warning] 'adresses' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Network/network.cpp:22: [medium:warning] parameter 'adresses' is passed by value and only copied once; consider moving it to avoid unnecessary copies [performance-unnecessary-value-param] -lib/Network/network.cpp:24: [medium:warning] static member accessed through instance [readability-static-accessed-through-instance] -lib/Network/network.cpp:24: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Network/network.cpp:39: [medium:warning] 'if' statement is unnecessary; deleting null pointer has no effect [readability-delete-null-pointer] -lib/Network/network.cpp:39: [medium:warning] implicit conversion 'PubSubClient *' -> bool [readability-implicit-bool-conversion] -lib/Network/network.cpp:39: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Network/network.cpp:52: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/Network/network.cpp:52: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/Network/network.cpp:52: [medium:warning] 6 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Network/network.cpp:65: [medium:warning] 2 adjacent parameters of 'activateMqtt' of similar type ('const char *') are easily swapped by mistake [bugprone-easily-swappable-parameters] -lib/Network/network.cpp:73: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Network/network.cpp:78: [medium:warning] method 'printIPs' can be made const [readability-make-member-function-const] -lib/Network/network.cpp:91: [medium:warning] variable 'channel' is not initialized [cppcoreguidelines-init-variables] -lib/Network/network.cpp:92: [medium:warning] variable 'secondChannel' is not initialized [cppcoreguidelines-init-variables] -lib/Network/network.cpp:102: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Network/network.cpp:107: [medium:warning] implicit conversion 'PubSubClient *' -> bool [readability-implicit-bool-conversion] -lib/Network/network.cpp:107: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Network/network.cpp:116: [medium:warning] static member accessed through instance [readability-static-accessed-through-instance] -lib/Network/network.cpp:132: [medium:warning] static member accessed through instance [readability-static-accessed-through-instance] -lib/Network/network.cpp:150: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Network/network.cpp:156: [medium:warning] 0xffff is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Network/network.cpp:158: [medium:warning] implicit conversion 'const char *' -> bool [readability-implicit-bool-conversion] -lib/Network/network.cpp:159: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Network/network.cpp:162: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/NtripClient/ntripClient.cpp:15: [medium:warning] constructor does not initialize these fields: host, mountPoint, user, password [cppcoreguidelines-pro-type-member-init,hicpp-member-init] -lib/NtripClient/ntripClient.cpp:16: [medium:warning] 'gps' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/NtripClient/ntripClient.cpp:17: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/NtripClient/ntripClient.cpp:18: [medium:warning] 'port' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/NtripClient/ntripClient.cpp:19: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/NtripClient/ntripClient.cpp:20: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/NtripClient/ntripClient.cpp:21: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/NtripClient/ntripClient.cpp:23: [medium:warning] 'ntripClient' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/NtripClient/ntripClient.cpp:24: [medium:warning] 'state' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/NtripClient/ntripClient.cpp:26: [medium:warning] 20 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/NtripClient/ntripClient.cpp:53: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/NtripClient/ntripClient.cpp:64: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/NtripClient/ntripClient.cpp:66: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/NtripClient/ntripClient.cpp:86: [medium:warning] use of a signed integer operand with a binary bitwise operator [hicpp-signed-bitwise] -lib/NtripClient/ntripClient.cpp:90: [medium:warning] 10 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/NtripClient/ntripClient.cpp:95: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/NtripClient/ntripClient.cpp:97: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/NtripClient/ntripClient.cpp:122: [medium:warning] implicit conversion 'int' -> bool [readability-implicit-bool-conversion] -lib/NtripClient/ntripClient.cpp:122: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/NtripClient/ntripClient.cpp:125: [medium:warning] do not use 'else' after 'return' [readability-else-after-return] -lib/NtripClient/ntripClient.cpp:130: [medium:warning] the value returned by this function should be used [cert-err33-c] -lib/NtripClient/ntripClient.cpp:130: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/NtripClient/ntripClient.cpp:133: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/NtripClient/ntripClient.cpp:136: [medium:warning] variable 'userCredentialsLength' of type 'uint8_t' (aka 'unsigned char') can be declared 'const' [misc-const-correctness] -lib/NtripClient/ntripClient.cpp:136: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/NtripClient/ntripClient.cpp:136: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/NtripClient/ntripClient.cpp:138: [medium:warning] the value returned by this function should be used [cert-err33-c] -lib/NtripClient/ntripClient.cpp:138: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/NtripClient/ntripClient.cpp:138: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/NtripClient/ntripClient.cpp:143: [medium:warning] variable 'b' of type 'base64' can be declared 'const' [misc-const-correctness] -lib/NtripClient/ntripClient.cpp:143: [medium:warning] variable name 'b' is too short, expected at least 3 characters [readability-identifier-length] -lib/NtripClient/ntripClient.cpp:144: [medium:warning] variable 'strEncodedCredentials' of type 'String' can be declared 'const' [misc-const-correctness] -lib/NtripClient/ntripClient.cpp:144: [medium:warning] static member accessed through instance [readability-static-accessed-through-instance] -lib/NtripClient/ntripClient.cpp:147: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/NtripClient/ntripClient.cpp:149: [medium:warning] the value returned by this function should be used [cert-err33-c] -lib/NtripClient/ntripClient.cpp:149: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/NtripClient/ntripClient.cpp:149: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/NtripClient/ntripClient.cpp:153: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/NtripClient/ntripClient.cpp:153: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/NtripClient/ntripClient.cpp:154: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/NtripClient/ntripClient.cpp:157: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/NtripClient/ntripClient.cpp:165: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/NtripClient/ntripClient.cpp:168: [medium:warning] variable 'lastMillis' of type 'uint32_t' (aka 'unsigned int') can be declared 'const' [misc-const-correctness] -lib/NtripClient/ntripClient.cpp:169: [medium:warning] implicit conversion 'int' -> bool [readability-implicit-bool-conversion] -lib/NtripClient/ntripClient.cpp:175: [medium:warning] 10 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/NtripClient/ntripClient.cpp:182: [medium:warning] implicit conversion 'int' -> bool [readability-implicit-bool-conversion] -lib/NtripClient/ntripClient.cpp:183: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/NtripClient/ntripClient.cpp:189: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/NtripClient/ntripClient.cpp:189: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/NtripClient/ntripClient.cpp:190: [medium:warning] 200 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/NtripClient/ntripClient.cpp:191: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/NtripClient/ntripClient.cpp:191: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/NtripClient/ntripClient.cpp:192: [medium:warning] 401 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/NtripClient/ntripClient.cpp:199: [medium:warning] 200 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/NtripClient/ntripClient.cpp:200: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] -lib/NtripClient/ntripClient.cpp:203: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/NtripClient/ntripClient.cpp:205: [medium:warning] 401 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/NtripClient/ntripClient.cpp:205: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/NtripClient/ntripClient.cpp:216: [medium:warning] implicit conversion 'uint8_t' (aka 'unsigned char') -> bool [readability-implicit-bool-conversion] -lib/NtripClient/ntripClient.cpp:216: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/NtripClient/ntripClient.cpp:223: [medium:warning] implicit conversion 'uint8_t' (aka 'unsigned char') -> bool [readability-implicit-bool-conversion] -lib/NtripClient/ntripClient.cpp:224: [medium:warning] 8 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/NtripClient/ntripClient.cpp:227: [medium:warning] implicit conversion 'int' -> bool [readability-implicit-bool-conversion] -lib/NtripClient/ntripClient.cpp:229: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/NtripClient/ntripClient.cpp:235: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/NtripClient/ntripClient.cpp:252: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/NtripClient/ntripClient.cpp:255: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/NtripClient/ntripClient.cpp:269: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/NtripClient/ntripClient.cpp:272: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/NtripClient/ntripClient.cpp:276: [medium:warning] implicit conversion 'uint8_t' (aka 'unsigned char') -> bool [readability-implicit-bool-conversion] -lib/NtripClient/ntripClient.cpp:276: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/NtripClient/ntripClient.cpp:279: [medium:warning] use auto when initializing with new to avoid duplicating the type name [hicpp-use-auto,modernize-use-auto] -lib/NtripClient/ntripClient.cpp:280: [medium:warning] variable 'res' of type 'uint8_t' (aka 'unsigned char') can be declared 'const' [misc-const-correctness] -lib/NtripClient/ntripClient.cpp:281: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/NtripClient/ntripClient.cpp:282: [medium:warning] do not use C-style cast to convert between unrelated types [cppcoreguidelines-pro-type-cstyle-cast] -lib/NtripClient/ntripClient.cpp:282: [medium:warning] C-style casts are discouraged; use reinterpret_cast [google-readability-casting] -lib/NtripClient/ntripClient.cpp:287: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/NtripClient/ntripClient.cpp:288: [medium:warning] redundant boolean literal in conditional return statement [readability-simplify-boolean-expr] -lib/Point/point.cpp:14: [medium:warning] constructor does not initialize these fields: coordinates [cppcoreguidelines-pro-type-member-init,hicpp-member-init] -lib/Point/point.cpp:14: [medium:warning] 3 adjacent parameters of 'Point' of convertible types are easily swapped by mistake [bugprone-easily-swappable-parameters] -lib/Point/point.cpp:20: [medium:warning] constructor does not initialize these fields: coordinates [cppcoreguidelines-pro-type-member-init,hicpp-member-init] -lib/Point/point.cpp:20: [medium:warning] 3 adjacent parameters of 'Point' of convertible types are easily swapped by mistake [bugprone-easily-swappable-parameters] -lib/Point/point.cpp:21: [medium:warning] 10000000.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Point/point.cpp:22: [medium:warning] 10000000.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Point/point.cpp:26: [medium:warning] constructor does not initialize these fields: coordinates [cppcoreguidelines-pro-type-member-init,hicpp-member-init] -lib/Point/point.cpp:27: [medium:warning] 'coordinates' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Point/point.cpp:31: [medium:warning] constructor does not initialize these fields: coordinates [cppcoreguidelines-pro-type-member-init,hicpp-member-init] -lib/Point/point.cpp:32: [medium:warning] 'coordinates' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Point/point.cpp:33: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Point/point.cpp:35: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Point/point.cpp:39: [medium:warning] constructor does not initialize these fields: coordinates [cppcoreguidelines-pro-type-member-init,hicpp-member-init] -lib/Point/point.cpp:56: [medium:warning] variable 'begin' of type 'Point::Coordinates' can be declared 'const' [misc-const-correctness] -lib/Point/point.cpp:57: [medium:warning] variable 'end' of type 'Point::Coordinates' can be declared 'const' [misc-const-correctness] -lib/Point/point.cpp:59: [medium:warning] variable 'lat' of type 'double' can be declared 'const' [misc-const-correctness] -lib/Point/point.cpp:60: [medium:warning] variable 'dy' of type 'double' can be declared 'const' [misc-const-correctness] -lib/Point/point.cpp:60: [medium:warning] variable name 'dy' is too short, expected at least 3 characters [readability-identifier-length] -lib/Point/point.cpp:61: [medium:warning] variable 'dx' of type 'double' can be declared 'const' [misc-const-correctness] -lib/Point/point.cpp:61: [medium:warning] variable name 'dx' is too short, expected at least 3 characters [readability-identifier-length] -lib/Point/point.cpp:71: [medium:warning] variable 'begin' of type 'Point::Coordinates' can be declared 'const' [misc-const-correctness] -lib/Point/point.cpp:72: [medium:warning] variable 'end' of type 'Point::Coordinates' can be declared 'const' [misc-const-correctness] -lib/Point/point.cpp:74: [medium:warning] variable 'phi' of type 'double' can be declared 'const' [misc-const-correctness] -lib/Point/point.cpp:75: [medium:warning] variable 'lon' of type 'double' can be declared 'const' [misc-const-correctness] -lib/Point/point.cpp:77: [medium:warning] variable 'res' of type 'int16_t' (aka 'short') can be declared 'const' [misc-const-correctness] -lib/Point/point.cpp:89: [medium:warning] 2 adjacent parameters of 'init' of similar type ('uint32_t') are easily swapped by mistake [bugprone-easily-swappable-parameters] -lib/Point/point.cpp:92: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Point/point.cpp:94: [medium:warning] 9999 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Point/point.cpp:94: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Point/point.cpp:96: [medium:warning] 999 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Point/point.cpp:96: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Point/point.cpp:98: [medium:warning] 99 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Point/point.cpp:98: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Point/point.cpp:100: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Point/point.cpp:102: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Route/route.cpp:14: [medium:warning] use '= default' to define a trivial default constructor [hicpp-use-equals-default,modernize-use-equals-default] -lib/Route/route.cpp:29: [medium:warning] the 'empty' method should be used to check for emptiness instead of 'size' [readability-container-size-empty] -lib/Route/route.cpp:31: [medium:warning] avoid repeating the return type from the declaration; use a braced initializer list instead [modernize-return-braced-init-list] -lib/Route/route.cpp:41: [medium:warning] the 'empty' method should be used to check for emptiness instead of 'size' [readability-container-size-empty] -lib/Route/route.cpp:43: [medium:warning] avoid repeating the return type from the declaration; use a braced initializer list instead [modernize-return-braced-init-list] -lib/Route/route.cpp:47: [medium:warning] missing username/bug in TODO [google-readability-todo] -lib/Route/route.cpp:55: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Route/route.cpp:56: [medium:warning] avoid repeating the return type from the declaration; use a braced initializer list instead [modernize-return-braced-init-list] -lib/Route/route.cpp:67: [medium:warning] avoid repeating the return type from the declaration; use a braced initializer list instead [modernize-return-braced-init-list] -lib/Route/route.cpp:71: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Route/route.cpp:72: [medium:warning] avoid repeating the return type from the declaration; use a braced initializer list instead [modernize-return-braced-init-list] -lib/Route/route.cpp:78: [medium:warning] do not use 'else' after 'return' [readability-else-after-return] -lib/Route/route.cpp:79: [medium:warning] avoid repeating the return type from the declaration; use a braced initializer list instead [modernize-return-braced-init-list] -lib/Route/route.cpp:84: [medium:warning] uninitialized record type: 'info' [cppcoreguidelines-pro-type-member-init,hicpp-member-init] -lib/Sensors/sensorData.cpp:18: [medium:warning] constructor does not initialize these fields: gnssData, host, mountPoint, user, password, gyroBuffer, port [cppcoreguidelines-pro-type-member-init,hicpp-member-init] -lib/Sensors/sensorData.cpp:19: [medium:warning] 50 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Sensors/sensorData.cpp:23: [medium:warning] 'if' statement is unnecessary; deleting null pointer has no effect [readability-delete-null-pointer] -lib/Sensors/sensorData.cpp:23: [medium:warning] implicit conversion 'NTRIPClient *' -> bool [readability-implicit-bool-conversion] -lib/Sensors/sensorData.cpp:23: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Sensors/sensorData.cpp:27: [medium:warning] the parameter 'host' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param] -lib/Sensors/sensorData.cpp:27: [medium:warning] the parameter 'mountPoint' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param] -lib/Sensors/sensorData.cpp:27: [medium:warning] the parameter 'user' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param] -lib/Sensors/sensorData.cpp:27: [medium:warning] the parameter 'password' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param] -lib/Sensors/sensorData.cpp:38: [medium:warning] 4000000 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Sensors/sensorData.cpp:38: [medium:warning] redundant boolean literal supplied to boolean operator [readability-simplify-boolean-expr] -lib/Sensors/sensorData.cpp:40: [medium:warning] converting integer literal to bool, use bool literal instead [modernize-use-bool-literals] -lib/Sensors/sensorData.cpp:40: [medium:warning] implicit conversion 'int' -> bool [readability-implicit-bool-conversion] -lib/Sensors/sensorData.cpp:40: [medium:warning] statement should be inside braces [hicpp-braces-around-statements,readability-braces-around-statements] -lib/Sensors/sensorData.cpp:47: [medium:warning] redundant boolean literal supplied to boolean operator [readability-simplify-boolean-expr] -lib/Sensors/sensorData.cpp:49: [medium:warning] converting integer literal to bool, use bool literal instead [modernize-use-bool-literals] -lib/Sensors/sensorData.cpp:49: [medium:warning] implicit conversion 'int' -> bool [readability-implicit-bool-conversion] -lib/Sensors/sensorData.cpp:49: [medium:warning] statement should be inside braces [hicpp-braces-around-statements,readability-braces-around-statements] -lib/Sensors/sensorData.cpp:57: [medium:warning] 0x0d is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Sensors/sensorData.cpp:58: [medium:warning] 0x0b is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Sensors/sensorData.cpp:61: [medium:warning] 0x0C is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Sensors/sensorData.cpp:61: [medium:warning] 0x10 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Sensors/sensorData.cpp:76: [medium:warning] statement should be inside braces [hicpp-braces-around-statements,readability-braces-around-statements] -lib/Sensors/sensorData.cpp:79: [medium:warning] variable 'deviceStatus' of type 'uint8_t' (aka 'unsigned char') can be declared 'const' [misc-const-correctness] -lib/Sensors/sensorData.cpp:81: [medium:warning] 220 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Sensors/sensorData.cpp:82: [medium:warning] 76 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Sensors/sensorData.cpp:83: [medium:warning] 85 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Sensors/sensorData.cpp:84: [medium:warning] 1788 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Sensors/sensorData.cpp:87: [medium:warning] 6 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Sensors/sensorData.cpp:88: [medium:warning] 6 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Sensors/sensorData.cpp:96: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] -lib/Sensors/sensorData.cpp:97: [medium:warning] statement should be inside braces [hicpp-braces-around-statements,readability-braces-around-statements] -lib/Sensors/sensorData.cpp:102: [medium:warning] implicit conversion 'CalcAzimuth *' -> bool [readability-implicit-bool-conversion] -lib/Sensors/sensorData.cpp:102: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Sensors/sensorData.cpp:108: [medium:warning] implicit conversion 'NTRIPClient *' -> bool [readability-implicit-bool-conversion] -lib/Sensors/sensorData.cpp:108: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Sensors/sensorData.cpp:114: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Sensors/sensorData.cpp:117: [medium:warning] variable 'latitude' of type 'double' can be declared 'const' [misc-const-correctness] -lib/Sensors/sensorData.cpp:117: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] -lib/Sensors/sensorData.cpp:117: [medium:warning] 10000000.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Sensors/sensorData.cpp:118: [medium:warning] variable 'longitude' of type 'double' can be declared 'const' [misc-const-correctness] -lib/Sensors/sensorData.cpp:118: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] -lib/Sensors/sensorData.cpp:118: [medium:warning] 10000000.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Sensors/sensorData.cpp:119: [medium:warning] variable 'altitude' of type 'double' can be declared 'const' [misc-const-correctness] -lib/Sensors/sensorData.cpp:119: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] -lib/Sensors/sensorData.cpp:119: [medium:warning] 1000.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Sensors/sensorData.cpp:121: [medium:warning] variable 'fixType' of type 'uint8_t' (aka 'unsigned char') can be declared 'const' [misc-const-correctness] -lib/Sensors/sensorData.cpp:122: [medium:warning] 32 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Sensors/sensorData.cpp:123: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Sensors/sensorData.cpp:124: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/Sensors/sensorData.cpp:125: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Sensors/sensorData.cpp:126: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/Sensors/sensorData.cpp:127: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Sensors/sensorData.cpp:128: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/Sensors/sensorData.cpp:129: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Sensors/sensorData.cpp:130: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/Sensors/sensorData.cpp:131: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Sensors/sensorData.cpp:132: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/Sensors/sensorData.cpp:133: [medium:warning] 5 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Sensors/sensorData.cpp:133: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Sensors/sensorData.cpp:134: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/Sensors/sensorData.cpp:135: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Sensors/sensorData.cpp:136: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/Sensors/sensorData.cpp:138: [medium:warning] variable 'carrSoln' of type 'uint8_t' (aka 'unsigned char') can be declared 'const' [misc-const-correctness] -lib/Sensors/sensorData.cpp:138: [medium:warning] do not access members of unions; use (boost::)variant instead [cppcoreguidelines-pro-type-union-access] -lib/Sensors/sensorData.cpp:139: [medium:warning] 16 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Sensors/sensorData.cpp:140: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Sensors/sensorData.cpp:141: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/Sensors/sensorData.cpp:142: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Sensors/sensorData.cpp:143: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/Sensors/sensorData.cpp:144: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Sensors/sensorData.cpp:145: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/Sensors/sensorData.cpp:146: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Sensors/sensorData.cpp:147: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/Sensors/sensorData.cpp:149: [medium:warning] variable 'hAcc' of type 'uint32_t' (aka 'unsigned int') can be declared 'const' [misc-const-correctness] -lib/Sensors/sensorData.cpp:172: [medium:warning] implicit conversion 'QMC5883LCompass *' -> bool [readability-implicit-bool-conversion] -lib/Sensors/sensorData.cpp:177: [medium:warning] implicit conversion 'MPU6050 *' (aka 'MPU6050_6Axis_MotionApps20 *') -> bool [readability-implicit-bool-conversion] -lib/Sensors/sensorData.cpp:178: [medium:warning] implicit conversion 'uint8_t' (aka 'unsigned char') -> bool [readability-implicit-bool-conversion] -lib/Sensors/sensorData.cpp:178: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/Sensors/sensorData.cpp:180: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/Sensors/sensorData.cpp:182: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -lib/Sensors/sensorData.cpp:187: [medium:warning] implicit conversion 'SFE_UBLOX_GNSS *' -> bool [readability-implicit-bool-conversion] -lib/Sensors/sensorData.cpp:190: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Sensors/sensorData.cpp:196: [medium:warning] variable 'versionHigh' of type 'uint8_t' (aka 'unsigned char') can be declared 'const' [misc-const-correctness] -lib/Sensors/sensorData.cpp:197: [medium:warning] variable 'versionLow' of type 'uint8_t' (aka 'unsigned char') can be declared 'const' [misc-const-correctness] -lib/Sensors/sensorData.cpp:198: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] -lib/Sensors/sensorData.cpp:198: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] -lib/Sensors/sensorData.cpp:201: [medium:warning] 10 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Sensors/sensorData.cpp:213: [medium:warning] uninitialized record type: 'coords' [cppcoreguidelines-pro-type-member-init,hicpp-member-init] -lib/Sensors/sensorData.cpp:214: [medium:warning] 10000000.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Sensors/sensorData.cpp:215: [medium:warning] 10000000.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Speedometer/speedometer.cpp:14: [medium:warning] constructor does not initialize these fields: buf [cppcoreguidelines-pro-type-member-init,hicpp-member-init] -lib/Speedometer/speedometer.cpp:14: [medium:warning] 3 adjacent parameters of 'Speedometer' of convertible types are easily swapped by mistake [bugprone-easily-swappable-parameters] -lib/Speedometer/speedometer.cpp:15: [medium:warning] 'diameter' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Speedometer/speedometer.cpp:16: [medium:warning] 'steps' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Speedometer/speedometer.cpp:18: [medium:warning] 'pulseCounter' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Speedometer/speedometer.cpp:19: [medium:warning] 1023 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Speedometer/speedometer.cpp:34: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Speedometer/speedometer.cpp:37: [medium:warning] variable 'time' of type 'uint32_t' (aka 'unsigned int') can be declared 'const' [misc-const-correctness] -lib/Speedometer/speedometer.cpp:39: [medium:warning] variable 'elapsedTime' of type 'uint16_t' (aka 'unsigned short') can be declared 'const' [misc-const-correctness] -lib/Speedometer/speedometer.cpp:42: [medium:warning] variable 'pulse' of type 'int16_t' (aka 'short') can be declared 'const' [misc-const-correctness] -lib/Speedometer/speedometer.cpp:47: [medium:warning] variable 'n' of type 'double' can be declared 'const' [misc-const-correctness] -lib/Speedometer/speedometer.cpp:47: [medium:warning] variable name 'n' is too short, expected at least 3 characters [readability-identifier-length] -lib/Speedometer/speedometer.cpp:47: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] -lib/Speedometer/speedometer.cpp:48: [medium:warning] variable 'u' of type 'double' can be declared 'const' [misc-const-correctness] -lib/Speedometer/speedometer.cpp:48: [medium:warning] variable name 'u' is too short, expected at least 3 characters [readability-identifier-length] -lib/Speedometer/speedometer.cpp:48: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] -lib/Speedometer/speedometer.cpp:48: [medium:warning] 1000 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Speedometer/speedometer.cpp:49: [medium:warning] variable 'ms' of type 'double' can be declared 'const' [misc-const-correctness] -lib/Speedometer/speedometer.cpp:49: [medium:warning] variable name 'ms' is too short, expected at least 3 characters [readability-identifier-length] -lib/Speedometer/speedometer.cpp:52: [medium:warning] 0.1 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Speedometer/speedometer.cpp:78: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Speedometer/speedometer.cpp:85: [medium:warning] 1023 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Speedometer/speedometer.cpp:85: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Speedometer/speedometer.cpp:86: [medium:warning] 1023 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -lib/Speedometer/speedometer.cpp:91: [medium:warning] variable 'avg' of type 'int16_t' (aka 'short') can be declared 'const' [misc-const-correctness] -lib/Speedometer/speedometer.cpp:92: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] -lib/Speedometer/speedometer.cpp:105: [medium:warning] variable 'res' of type 'uint16_t' (aka 'unsigned short') can be declared 'const' [misc-const-correctness] -lib/Speedometer/speedometer.cpp:113: [medium:warning] use range-based for loop instead [modernize-loop-convert] -lib/Speedometer/speedometer.cpp:113: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Speedometer/speedometer.cpp:121: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Speedometer/speedometer.cpp:127: [medium:warning] static member accessed through instance [readability-static-accessed-through-instance] -lib/Speedometer/speedometer.cpp:127: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Speedometer/speedometer.cpp:129: [medium:warning] static member accessed through instance [readability-static-accessed-through-instance] -lib/Times/debugTimes.cpp:17: [medium:warning] 'startTime' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/Times/debugTimes.cpp:29: [medium:warning] method 'stop' can be made const [readability-make-member-function-const] -lib/Times/debugTimes.cpp:33: [medium:warning] method 'stopConsol' can be made const [readability-make-member-function-const] -lib/Times/debugTimes.cpp:34: [medium:warning] variable 'time' of type 'uint64_t' (aka 'unsigned long long') can be declared 'const' [misc-const-correctness] -lib/Times/debugTimes.cpp:35: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/Times/debugTimes.cpp:41: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/calibrateCompass/calibrateCompass.cpp:14: [medium:warning] constructor does not initialize these fields: data [cppcoreguidelines-pro-type-member-init,hicpp-member-init] -lib/calibrateCompass/calibrateCompass.cpp:16: [medium:warning] 'compass' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/calibrateCompass/calibrateCompass.cpp:17: [medium:warning] 'state' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -lib/calibrateCompass/calibrateCompass.cpp:32: [medium:warning] variable 'xAxis' of type 'int' can be declared 'const' [misc-const-correctness] -lib/calibrateCompass/calibrateCompass.cpp:33: [medium:warning] variable 'yAxis' of type 'int' can be declared 'const' [misc-const-correctness] -lib/calibrateCompass/calibrateCompass.cpp:34: [medium:warning] variable 'zAxis' of type 'int' can be declared 'const' [misc-const-correctness] -lib/calibrateCompass/calibrateCompass.cpp:72: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -lib/calibrateCompass/calibrateCompass.cpp:164: [medium:warning] use range-based for loop instead [modernize-loop-convert] -lib/calibrateCompass/calibrateCompass.cpp:175: [medium:warning] use range-based for loop instead [modernize-loop-convert] -lib/calibrateCompass/calibrateCompass.cpp:185: [medium:warning] implicit conversion 'int' -> bool [readability-implicit-bool-conversion] -lib/calibrateCompass/calibrateCompass.cpp:188: [medium:warning] parameter name 'os' is too short, expected at least 3 characters [readability-identifier-length] -lib/calibrateCompass/calibrateCompass.cpp:191: [medium:warning] use of a signed integer operand with a binary bitwise operator [hicpp-signed-bitwise] -lib/calibrateCompass/calibrateCompass.cpp:193: [medium:warning] use of a signed integer operand with a binary bitwise operator [hicpp-signed-bitwise] -lib/calibrateCompass/calibrateCompass.cpp:195: [medium:warning] use of a signed integer operand with a binary bitwise operator [hicpp-signed-bitwise] -lib/calibrateCompass/calibrateCompass.cpp:197: [medium:warning] use of a signed integer operand with a binary bitwise operator [hicpp-signed-bitwise] -lib/calibrateCompass/calibrateCompass.cpp:199: [medium:warning] use of a signed integer operand with a binary bitwise operator [hicpp-signed-bitwise] -lib/calibrateCompass/calibrateCompass.cpp:201: [medium:warning] use of a signed integer operand with a binary bitwise operator [hicpp-signed-bitwise] -src/OutputBuf/outputBuf.cpp:15: [medium:warning] initializer for base class 'std::streambuf' (aka 'basic_streambuf') is redundant [readability-redundant-member-init] -src/OutputBuf/outputBuf.cpp:16: [medium:warning] 'debugMqtt' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -src/OutputBuf/outputBuf.cpp:17: [medium:warning] 'serialBT' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -src/OutputBuf/outputBuf.cpp:19: [medium:warning] implicit conversion 'DebugMqtt *' -> bool [readability-implicit-bool-conversion] -src/OutputBuf/outputBuf.cpp:19: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/OutputBuf/outputBuf.cpp:22: [medium:warning] implicit conversion 'BluetoothSerial *' -> bool [readability-implicit-bool-conversion] -src/OutputBuf/outputBuf.cpp:22: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/OutputBuf/outputBuf.cpp:27: [medium:warning] implicit conversion 'DebugMqtt *' -> bool [readability-implicit-bool-conversion] -src/OutputBuf/outputBuf.cpp:27: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/OutputBuf/outputBuf.cpp:32: [medium:warning] implicit conversion 'BluetoothSerial *' -> bool [readability-implicit-bool-conversion] -src/OutputBuf/outputBuf.cpp:32: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/OutputBuf/outputBuf.cpp:46: [medium:warning] parameter name 'c' is too short, expected at least 3 characters [readability-identifier-length] -src/OutputBuf/outputBuf.cpp:50: [medium:warning] implicit conversion 'DebugMqtt *' -> bool [readability-implicit-bool-conversion] -src/OutputBuf/outputBuf.cpp:50: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/OutputBuf/outputBuf.cpp:51: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] -src/OutputBuf/outputBuf.cpp:53: [medium:warning] implicit conversion 'BluetoothSerial *' -> bool [readability-implicit-bool-conversion] -src/OutputBuf/outputBuf.cpp:53: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/OutputBuf/outputBuf.cpp:54: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] -src/OutputBuf/outputBuf.cpp:56: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] -src/SpecialMenus/CalibrateBattery/menuCalibrateBattery.cpp:15: [medium:warning] 400 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/CalibrateBattery/menuCalibrateBattery.cpp:16: [medium:warning] 'battery' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -src/SpecialMenus/CalibrateBattery/menuCalibrateBattery.cpp:20: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/CalibrateBattery/menuCalibrateBattery.cpp:52: [medium:warning] implicit conversion 'MenuControl *' -> bool [readability-implicit-bool-conversion] -src/SpecialMenus/CalibrateBattery/menuCalibrateBattery.cpp:52: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/CalibrateBattery/menuCalibrateBattery.cpp:57: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/PID/menuPidSettings.cpp:15: [medium:warning] 'pid' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -src/SpecialMenus/PID/menuPidSettings.cpp:19: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/Route/menuRoute.cpp:16: [medium:warning] 'menuRoute' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -src/SpecialMenus/Route/menuRoute.cpp:17: [medium:warning] 'dataFunction' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -src/SpecialMenus/Route/menuRoute.cpp:25: [medium:warning] constructor does not initialize these fields: mainMenu [cppcoreguidelines-pro-type-member-init,hicpp-member-init] -src/SpecialMenus/Route/menuRoute.cpp:27: [medium:warning] 'route' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -src/SpecialMenus/Route/menuRoute.cpp:163: [medium:warning] static member accessed through instance [readability-static-accessed-through-instance] -src/SpecialMenus/Route/menuRoute.cpp:188: [medium:warning] variable 'httpResponseCode' of type 'int' can be declared 'const' [misc-const-correctness] -src/SpecialMenus/Route/menuRoute.cpp:193: [medium:warning] 202 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/Route/menuRoute.cpp:216: [medium:warning] uninitialized record type: 'coords' [cppcoreguidelines-pro-type-member-init,hicpp-member-init] -src/SpecialMenus/Route/menuRoute.cpp:229: [medium:warning] variable 'totalPoints' of type 'uint16_t' (aka 'unsigned short') can be declared 'const' [misc-const-correctness] -src/SpecialMenus/Route/menuRoute.cpp:234: [medium:warning] static member accessed through instance [readability-static-accessed-through-instance] -src/SpecialMenus/Route/menuRoute.cpp:273: [medium:warning] variable 'httpResponseCode' of type 'int' can be declared 'const' [misc-const-correctness] -src/SpecialMenus/Route/menuRoute.cpp:275: [medium:warning] 201 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/Route/menuRoute.cpp:298: [medium:warning] static member accessed through instance [readability-static-accessed-through-instance] -src/SpecialMenus/Route/menuRoute.cpp:323: [medium:warning] variable 'httpResponseCode' of type 'int' can be declared 'const' [misc-const-correctness] -src/SpecialMenus/Route/menuRoute.cpp:328: [medium:warning] 202 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/Route/menuRoutePoints.cpp:14: [medium:warning] initializer for base class 'MenuInformationSites' is redundant [readability-redundant-member-init] -src/SpecialMenus/Route/menuRoutePoints.cpp:15: [medium:warning] 'route' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -src/SpecialMenus/Route/menuRoutePoints.cpp:19: [medium:warning] variable 'amountPoints' of type 'uint16_t' (aka 'unsigned short') can be declared 'const' [misc-const-correctness] -src/SpecialMenus/Route/menuRoutePoints.cpp:20: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/Route/menuRoutePoints.cpp:22: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/Route/menuRoutePoints.cpp:27: [medium:warning] variable 'currentPage' of type 'uint8_t' (aka 'unsigned char') can be declared 'const' [misc-const-correctness] -src/SpecialMenus/Route/menuRoutePoints.cpp:28: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/Route/menuRoutePoints.cpp:49: [medium:warning] variable name 'p' is too short, expected at least 3 characters [readability-identifier-length] -src/SpecialMenus/Route/menuRoutePoints.cpp:50: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/Route/menuRoutePoints.cpp:52: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/Route/menuRoutePoints.cpp:54: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/Route/menuRoutePoints.cpp:56: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/Route/menuRoutePoints.cpp:58: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/Route/menuRoutePoints.cpp:61: [medium:warning] 20 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/Route/menuRoutePoints.cpp:62: [medium:warning] variable 'string' is not initialized [cppcoreguidelines-init-variables] -src/SpecialMenus/Route/menuRoutePoints.cpp:65: [medium:warning] 9 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/Route/menuRoutePoints.cpp:65: [medium:warning] 7 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/Route/menuRoutePoints.cpp:65: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -src/SpecialMenus/Route/menuRoutePoints.cpp:70: [medium:warning] 9 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/Route/menuRoutePoints.cpp:70: [medium:warning] 7 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/Route/menuRoutePoints.cpp:70: [medium:warning] do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay] -src/SpecialMenus/SensorData/menuSensorData.cpp:15: [medium:warning] 7 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/SensorData/menuSensorData.cpp:16: [medium:warning] 'sensorData' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -src/SpecialMenus/SensorData/menuSensorData.cpp:20: [medium:warning] function 'printPage' has cognitive complexity of 26 (threshold 25) [readability-function-cognitive-complexity] -src/SpecialMenus/SensorData/menuSensorData.cpp:23: [medium:warning] implicit conversion 'const UBX_NAV_PVT_data_t *' -> bool [readability-implicit-bool-conversion] -src/SpecialMenus/SensorData/menuSensorData.cpp:23: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/SensorData/menuSensorData.cpp:54: [medium:warning] variable 'pos' of type 'Point' can be declared 'const' [misc-const-correctness] -src/SpecialMenus/SensorData/menuSensorData.cpp:63: [medium:warning] implicit conversion 'uint8_t' (aka 'unsigned char') -> bool [readability-implicit-bool-conversion] -src/SpecialMenus/SensorData/menuSensorData.cpp:64: [medium:warning] 10 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/SensorData/menuSensorData.cpp:64: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/SensorData/menuSensorData.cpp:68: [medium:warning] 10 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/SensorData/menuSensorData.cpp:68: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/SensorData/menuSensorData.cpp:72: [medium:warning] 10 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/SensorData/menuSensorData.cpp:72: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/SensorData/menuSensorData.cpp:75: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/SensorData/menuSensorData.cpp:80: [medium:warning] 5 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/SensorData/menuSensorData.cpp:83: [medium:warning] variable 'carrSoln' of type 'uint8_t' (aka 'unsigned char') can be declared 'const' [misc-const-correctness] -src/SpecialMenus/SensorData/menuSensorData.cpp:83: [medium:warning] do not access members of unions; use (boost::)variant instead [cppcoreguidelines-pro-type-union-access] -src/SpecialMenus/SensorData/menuSensorData.cpp:84: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/SensorData/menuSensorData.cpp:86: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/SensorData/menuSensorData.cpp:88: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/SensorData/menuSensorData.cpp:90: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/SensorData/menuSensorData.cpp:92: [medium:warning] variable 'status' of type 'NTRIPClientStates' can be declared 'const' [misc-const-correctness] -src/SpecialMenus/SensorData/menuSensorData.cpp:93: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/SensorData/menuSensorData.cpp:95: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/SensorData/menuSensorData.cpp:97: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/SensorData/menuSensorData.cpp:102: [medium:warning] 6 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/SensorData/menuSensorData.cpp:105: [medium:warning] implicit conversion 'uint8_t' (aka 'unsigned char') -> bool [readability-implicit-bool-conversion] -src/SpecialMenus/Speed/menuSpeed.cpp:15: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/Speed/menuSpeed.cpp:17: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] -src/SpecialMenus/Speed/menuSpeed.cpp:17: [medium:warning] 10.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/Speed/menuSpeed.cpp:18: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] -src/SpecialMenus/Speed/menuSpeed.cpp:18: [medium:warning] 10.0 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/Systeminformation/menuSysteminformatio.cpp:15: [medium:warning] 8 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/Systeminformation/menuSysteminformatio.cpp:16: [medium:warning] 'mainBattery' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer] -src/SpecialMenus/Systeminformation/menuSysteminformatio.cpp:36: [medium:warning] 1000 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/Systeminformation/menuSysteminformatio.cpp:53: [medium:warning] 5 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/Systeminformation/menuSysteminformatio.cpp:58: [medium:warning] 6 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/Systeminformation/menuSysteminformatio.cpp:60: [medium:warning] 16 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/Systeminformation/menuSysteminformatio.cpp:63: [medium:warning] 7 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:14: [medium:warning] function 'printPage' has cognitive complexity of 36 (threshold 25) [readability-function-cognitive-complexity] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:15: [medium:warning] variable 'correction' of type 'CourseCorrection' can be declared 'const' [misc-const-correctness] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:17: [medium:warning] variable 'navigationStarted' of type 'bool' can be declared 'const' [misc-const-correctness] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:23: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:23: [medium:warning] 100 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:26: [medium:warning] 1000 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:27: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:31: [medium:warning] C-style casts are discouraged; use static_cast [google-readability-casting] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:31: [medium:warning] 1000 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:108: [medium:warning] variable 'carrSoln' of type 'uint8_t' (aka 'unsigned char') can be declared 'const' [misc-const-correctness] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:108: [medium:warning] do not access members of unions; use (boost::)variant instead [cppcoreguidelines-pro-type-union-access] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:111: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:112: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:114: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:116: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:118: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:120: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:122: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:126: [medium:warning] implicit conversion 'uint8_t' (aka 'unsigned char') -> bool [readability-implicit-bool-conversion] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:126: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:128: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:173: [medium:warning] 5 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:175: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:177: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:181: [medium:warning] 6 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:183: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:185: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:189: [medium:warning] 7 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:206: [medium:warning] 5 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:210: [medium:warning] 6 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:220: [medium:warning] 7 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:231: [medium:warning] 7 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:241: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp:249: [medium:warning] 8 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp:13: [medium:warning] constructor does not initialize these fields: caliCompassMode, caliCompass [cppcoreguidelines-pro-type-member-init,hicpp-member-init] -src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp:67: [medium:warning] 5 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp:72: [medium:warning] 6 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp:77: [medium:warning] 7 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp:82: [medium:warning] 8 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp:89: [medium:warning] 9 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp:96: [medium:warning] 10 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp:116: [medium:warning] 11 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp:117: [medium:warning] 500 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp:147: [medium:warning] 5 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp:151: [medium:warning] 6 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp:155: [medium:warning] 7 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:14: [medium:warning] variable 'routeInfo' of type 'RouteInfo' can be declared 'const' [misc-const-correctness] -src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:62: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:64: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:66: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:71: [medium:warning] 5 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:73: [medium:warning] variable 'carrSoln' of type 'uint8_t' (aka 'unsigned char') can be declared 'const' [misc-const-correctness] -src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:73: [medium:warning] do not access members of unions; use (boost::)variant instead [cppcoreguidelines-pro-type-union-access] -src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:74: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:76: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:78: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:80: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:85: [medium:warning] 6 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:89: [medium:warning] implicit conversion 'uint8_t' (aka 'unsigned char') -> bool [readability-implicit-bool-conversion] -src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:89: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:91: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:95: [medium:warning] 7 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:97: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:99: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:112: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:120: [medium:warning] 7 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:121: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:123: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:133: [medium:warning] 8 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp:134: [medium:warning] 500 is a magic number; consider replacing it with a named constant [cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers] -src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.cpp:13: [medium:warning] constructor does not initialize these fields: manualControl, caliCompass [cppcoreguidelines-pro-type-member-init,hicpp-member-init] -src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.cpp:17: [medium:warning] use '= default' to define a trivial destructor [hicpp-use-equals-default,modernize-use-equals-default] -src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.cpp:31: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.cpp:33: [medium:warning] statement should be inside braces [google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements] -src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.cpp:58: [medium:warning] 500 is a magic number; consider replacing it with a named constant - - - - - ========================= [PASSED] Took 541.63 seconds ========================= Component HIGH MEDIUM LOW diff --git a/lib/MQTT/debugMqtt.cpp b/lib/MQTT/debugMqtt.cpp index 44a2fe9..3de8e95 100644 --- a/lib/MQTT/debugMqtt.cpp +++ b/lib/MQTT/debugMqtt.cpp @@ -18,10 +18,12 @@ char DebugMqtt::msg[MQTT_BUFFER_SIZE]; char DebugMqtt::topic[MQTT_BUFFER_SIZE]; -DebugMqtt::DebugMqtt(const char* name, uint8_t bufSize) { - this->name = name; - if (bufSize != 0) +DebugMqtt::DebugMqtt(const char* name, uint8_t bufSize) + : name {name} +{ + if (bufSize != 0) { this->bufSize = bufSize; + } this->buf = new char[this->bufSize]; } @@ -30,8 +32,8 @@ DebugMqtt::~DebugMqtt() { } void DebugMqtt::sendMsg(Loglevel loglevel, String topic, String msg) { - snprintf (DebugMqtt::msg, MQTT_BUFFER_SIZE, "%s: %s",this->name ,msg.c_str()); - this->sendData(loglevel, topic, DebugMqtt::msg); + snprintf (static_cast(DebugMqtt::msg), MQTT_BUFFER_SIZE, static_cast("%s: %s"),this->name ,msg.c_str()); + this->sendData(loglevel, topic, static_cast(DebugMqtt::msg)); } void DebugMqtt::sendMsg(Loglevel loglevel, String msg) { @@ -44,27 +46,27 @@ void DebugMqtt::sendData(Loglevel loglevel, String topic, String data) { } if (loglevel <= DebugMqtt::loglevel && loglevel > Loglevel::none) { - snprintf (DebugMqtt::topic, MQTT_BUFFER_SIZE, "%s%s", DebugMqtt::enum_to_string(loglevel).c_str(), topic.c_str()); - snprintf (DebugMqtt::msg, MQTT_BUFFER_SIZE, "%s", data.c_str()); - client->publish(DebugMqtt::topic, DebugMqtt::msg); + snprintf (static_cast(DebugMqtt::topic), MQTT_BUFFER_SIZE, static_cast("%s%s"), DebugMqtt::enum_to_string(loglevel).c_str(), topic.c_str()); + snprintf (static_cast(DebugMqtt::msg), MQTT_BUFFER_SIZE, static_cast("%s"), data.c_str()); + client->publish(DebugMqtt::topic, static_cast(DebugMqtt::msg)); } } void DebugMqtt::sendData(Loglevel loglevel, String data){ - this->sendData(loglevel, "", data); + DebugMqtt::sendData(loglevel, "", data); } void DebugMqtt::writeToInflux(String measurement_name, String field_set, float measurement, uint64_t nanos) { // Example String: "weather temperature=82 1465839830100400200"; - snprintf(DebugMqtt::msg, MQTT_BUFFER_SIZE, "%s %s=%f %llu", measurement_name.c_str(), field_set.c_str(), measurement, nanos); - this->sendData(Loglevel::influx, DebugMqtt::msg); + snprintf(static_cast(DebugMqtt::msg), MQTT_BUFFER_SIZE, static_cast("%s %s=%f %llu"), measurement_name.c_str(), field_set.c_str(), measurement, nanos); + this->sendData(Loglevel::influx, static_cast(DebugMqtt::msg)); } -void DebugMqtt::addCharacter(char c) { - this->buf[this->bufPos] = c; +void DebugMqtt::addCharacter(char character) { + this->buf[this->bufPos] = character; this->bufPos++; - if (c == '\n' || this->bufPos >= this->bufSize - 1) { + if (character == '\n' || this->bufPos >= this->bufSize - 1) { this->buf[this->bufPos - 1] = '\0'; this->sendMsg(Loglevel::info, buf); this->bufPos = 0; diff --git a/lib/MQTT/debugMqtt.h b/lib/MQTT/debugMqtt.h index a93f783..194fd14 100644 --- a/lib/MQTT/debugMqtt.h +++ b/lib/MQTT/debugMqtt.h @@ -108,8 +108,8 @@ class DebugMqtt { * @param topic Additional topic behind loglevel * @param data The message to send as String */ - void sendData(Loglevel loglevel, String topic, String data); - void sendData(Loglevel loglevel, String data); + static void sendData(Loglevel loglevel, String topic, String data); + static void sendData(Loglevel loglevel, String data); /** * @brief Send a Message via MQTT for InfluxDB @@ -132,9 +132,9 @@ class DebugMqtt { * 1. when the buffer is full * 2. when the character is '\n' * - * @param c + * @param character */ - void addCharacter(char c); + void addCharacter(char character); /** * @brief Initialize debugMQTT for all instances diff --git a/lib/MotorControl/motorControl.cpp b/lib/MotorControl/motorControl.cpp index de366e9..6ff901f 100644 --- a/lib/MotorControl/motorControl.cpp +++ b/lib/MotorControl/motorControl.cpp @@ -5,20 +5,20 @@ * @see motorControl.h * @version 0.1 * @date 2021-12-13 - * + * * @copyright Copyright (c) 2021 - * + * */ #include "motorControl.h" -MotorControl::MotorControl() { - this->setMinPwm(MotorControl::pwmMin); - this->setMaxPwm(MotorControl::pwmMax); +MotorControl::MotorControl() +{ Component::loopDelay = MotorControl::loopDelay; } -void MotorControl::init(uint8_t pwmPin, uint8_t pwmChannel, uint8_t dir_1, uint8_t dir_2) { +void MotorControl::init(uint8_t pwmPin, uint8_t pwmChannel, uint8_t dir_1, uint8_t dir_2) +{ this->pwmPin = pwmPin; this->pwmChannel = pwmChannel; this->dir_1 = dir_1; @@ -35,107 +35,141 @@ void MotorControl::init(uint8_t pwmPin, uint8_t pwmChannel, uint8_t dir_1, uint8 ledcWrite(this->pwmChannel, 0); } -void MotorControl::run() { +void MotorControl::run() +{ // Absolute difference between targetPower and power - uint8_t abs_difference = abs(this->targetPower - this->power); + const uint8_t abs_difference = abs(this->targetPower - this->power); // Difference between targetPower and power - int16_t difference = this->targetPower - this->power; + const int16_t difference = this->targetPower - this->power; // Check that the target speed is close to 0 and that the abs_difference is lower than MotorControl::powerSteps - if (abs(this->targetPower) < MotorControl::powerSteps && abs_difference < MotorControl::powerSteps) { + if (abs(this->targetPower) < MotorControl::powerSteps && abs_difference < MotorControl::powerSteps) + { this->setRealPower(0); return; } // Correct speed - if (abs_difference < MotorControl::powerSteps) { + if (abs_difference < MotorControl::powerSteps) + { return; } // Positive or negative tagret speed - if (this->targetPower >= 0) { + if (this->targetPower >= 0) + { // Positive or negative speed - if (this->power >= 0) { - if (difference > 0) { + if (this->power >= 0) + { + if (difference > 0) + { this->increasePower(MotorControl::powerSteps); - } else { + } + else + { this->increasePower(-MotorControl::powerSteps); } - } else { + } + else + { this->increasePower(MotorControl::powerSteps); } - - } else { + } + else + { // Positive or negative speed - if (this->power >= 0) { + if (this->power >= 0) + { this->increasePower(-MotorControl::powerSteps); - } else { - if (difference > 0) { + } + else + { + if (difference > 0) + { this->increasePower(MotorControl::powerSteps); - } else { + } + else + { this->increasePower(-MotorControl::powerSteps); } } } } -void MotorControl::setMinPwm(uint8_t min) { - if (min > 80) min = 80; - //transform percentage to real pwm value - min = (uint8_t) (((1 << pwmRes) - 1) * (min / 100.0)); +void MotorControl::setMinPwm(uint8_t min) +{ + if (min > MotorControl::maxPwmMin) + { + min = MotorControl::maxPwmMin; + } + // transform percentage to real pwm value + min = static_cast(((static_cast(1) << pwmRes) - 1) * (min / 100.0)); this->dutycycleMin = min; } -void MotorControl::setMaxPwm(uint8_t max) { - if (max > 100) max = 100; - //transform percentage to real pwm value - max = (uint8_t) (((1 << pwmRes) - 1) * (max / 100.0)); +void MotorControl::setMaxPwm(uint8_t max) +{ + if (max > 100) + { + max = 100; + } + // transform percentage to real pwm value + max = static_cast(((static_cast(1) << pwmRes) - 1) * (max / 100.0)); this->dutycycleMax = max; } -void MotorControl::setTargetPower(int8_t power) { +void MotorControl::setTargetPower(int8_t power) +{ if (power <= 100 && power >= -100) + { this->targetPower = power; + } else + { std::cout << " MotorControl::setTargetPower: Invalid Argument - Power: " << power << std::endl; + } } -void MotorControl::stop() { +void MotorControl::stop() +{ this->targetPower = 0; } -void MotorControl::emergencyStop() { +void MotorControl::emergencyStop() +{ setRealPower(0); } -bool MotorControl::isTargetPowerReached() const { - if (this->targetPower == this->power) - return true; - return false; +bool MotorControl::isTargetPowerReached() const +{ + return this->targetPower == this->power; } -bool MotorControl::isAccelerationPositive() const { - if (power < targetPower) - return true; - return false; +bool MotorControl::isAccelerationPositive() const +{ + return power < targetPower; } -bool MotorControl::isAccelerationNegative() const { - if (power > targetPower) - return true; - return false; +bool MotorControl::isAccelerationNegative() const +{ + return power > targetPower; } -void MotorControl::setRealPower(int8_t power) { - //TODO: Exceptionhandling - if (power <= 100 && power >= -100) { +void MotorControl::setRealPower(int8_t power) +{ + // TODO: Exceptionhandling + if (power <= 100 && power >= -100) + { this->power = power; - } else { + } + else + { return; } - if (this->power == 0) { + if (this->power == 0) + { this->direction = 0; digitalWrite(this->dir_1, LOW); digitalWrite(this->dir_2, LOW); @@ -144,13 +178,16 @@ void MotorControl::setRealPower(int8_t power) { return; } - uint8_t pwm_val = map(abs(power), 0, 100, this->dutycycleMin, this->dutycycleMax); + const uint8_t pwm_val = map(abs(power), 0, 100, this->dutycycleMin, this->dutycycleMax); - if ((this->direction == 1 || this->direction == 0) && power < 0){ // new direction backward + if ((this->direction == 1 || this->direction == 0) && power < 0) + { // new direction backward this->direction = 2; digitalWrite(this->dir_1, LOW); digitalWrite(this->dir_2, HIGH); - } else if ((this->direction == 2 || this->direction == 0) && power > 0){ // new direction forward + } + else if ((this->direction == 2 || this->direction == 0) && power > 0) + { // new direction forward this->direction = 1; digitalWrite(this->dir_1, HIGH); digitalWrite(this->dir_2, LOW); @@ -160,10 +197,12 @@ void MotorControl::setRealPower(int8_t power) { this->dutycycle = pwm_val; } -void MotorControl::increasePower(int8_t power) { - //TODO: Exceptionhandling - //TODO: make a stop befor a direction change - if (abs(power) > 2 * MotorControl::powerSteps) { +void MotorControl::increasePower(int8_t power) +{ + // TODO: Exceptionhandling + // TODO: make a stop befor a direction change + if (abs(power) > 2 * MotorControl::powerSteps) + { Serial.println("Invalid Argument in MotorControl::increasePower"); return; } diff --git a/lib/MotorControl/motorControl.h b/lib/MotorControl/motorControl.h index 3294960..fc576cd 100644 --- a/lib/MotorControl/motorControl.h +++ b/lib/MotorControl/motorControl.h @@ -4,9 +4,9 @@ * @brief Inherits a class to control a motor with pwm signal. * @version 0.1 * @date 2021-12-09 - * + * * @copyright Copyright (c) 2021 - * + * */ #ifndef MOTOR_CONTROL_H #define MOTOR_CONTROL_H @@ -23,98 +23,98 @@ * You can control the acceleration of the motor, for example to * prevent a damage on your H-Bridge. */ -class MotorControl : public Component { - public: - MotorControl(); +class MotorControl : public Component +{ +public: + MotorControl(); - /** - * @brief Initialize the motorController - * - * @param pwmPin The output pin for the signal on the esp. - * @param pwmChannel One of the pwm channels from the esp. - * @param dir_1 First direction pin for the H-Bridge. - * @param dir_2 Second direction pin for the H-Bridge. - */ - void init(uint8_t pwmPin, uint8_t pwmChannel, uint8_t dir_1, uint8_t dir_2); + /** + * @brief Initialize the motorController + * + * @param pwmPin The output pin for the signal on the esp. + * @param pwmChannel One of the pwm channels from the esp. + * @param dir_1 First direction pin for the H-Bridge. + * @param dir_2 Second direction pin for the H-Bridge. + */ + void init(uint8_t pwmPin, uint8_t pwmChannel, uint8_t dir_1, uint8_t dir_2); - /** - * @brief Set the minimum duty cycle - * - * @param min duty cycle in percent - */ - void setMinPwm(uint8_t min); + /** + * @brief Set the minimum duty cycle + * + * @param min duty cycle in percent + */ + void setMinPwm(uint8_t min); - /** - * @brief Set the maximum duty cycle - * - * @param max duty cycle in percent - */ - void setMaxPwm(uint8_t max); + /** + * @brief Set the maximum duty cycle + * + * @param max duty cycle in percent + */ + void setMaxPwm(uint8_t max); - /** - * @brief Set the Target Power - * - * If the given power is greater than 100 or smaller than -100, then - * this function only print an error to consol. - * - * @param power power in percent - */ - void setTargetPower(int8_t power); + /** + * @brief Set the Target Power + * + * If the given power is greater than 100 or smaller than -100, then + * this function only print an error to consol. + * + * @param power power in percent + */ + void setTargetPower(int8_t power); - /** - * @brief Stops the motor like setTargetPower() to 0 - * - */ - void stop(); + /** + * @brief Stops the motor like setTargetPower() to 0 + * + */ + void stop(); - /** - * @brief Stops the motor immediately - * - */ - void emergencyStop(); + /** + * @brief Stops the motor immediately + * + */ + void emergencyStop(); - /** - * @brief Get the current power - * - * @return int8_t percent of power (-100 to 100) - */ - int8_t getPower() const { return this->power; }; + /** + * @brief Get the current power + * + * @return int8_t percent of power (-100 to 100) + */ + int8_t getPower() const { return this->power; }; - /** - * @brief Get the target power - * - * @return int8_t percent of power (-100 to 100) - */ - int8_t getTargetPower() const { return this->targetPower; }; + /** + * @brief Get the target power + * + * @return int8_t percent of power (-100 to 100) + */ + int8_t getTargetPower() const { return this->targetPower; }; - uint16_t getDutycycle() const { return this->dutycycle; } - bool isTargetPowerReached() const; - bool isAccelerationPositive() const; - bool isAccelerationNegative() const; + uint16_t getDutycycle() const { return this->dutycycle; } + bool isTargetPowerReached() const; + bool isAccelerationPositive() const; + bool isAccelerationNegative() const; - private: - void run() override; - void setRealPower(int8_t power); - void increasePower(int8_t power); +private: + void run() override; + void setRealPower(int8_t power); + void increasePower(int8_t power); - static constexpr uint8_t loopDelay = 10; - static constexpr uint16_t pwmFreq = 16000; - static constexpr uint8_t pwmRes = 8; - static constexpr uint8_t powerSteps = 2; // A total of 20 levels ( 100 / SPEED_STEPS ) * RUN_MOTOR_CONTROL_DELAY = 500ms - static constexpr uint8_t pwmMin = 55; - static constexpr uint8_t pwmMax = 98; // Max 98% of 2^PWM_RES + static constexpr uint8_t loopDelay = 10; + static constexpr uint16_t pwmFreq = 16000; + static constexpr uint8_t pwmRes = 8; + static constexpr uint8_t powerSteps = 2; // A total of 20 levels ( 100 / SPEED_STEPS ) * RUN_MOTOR_CONTROL_DELAY = 500ms + static constexpr uint8_t maxPwmMin = 80; - int8_t targetPower = 0; - int8_t power = 0; - uint8_t direction = 0; // 0 = stop, 1 = forward, 2 = backward + int8_t targetPower = 0; + int8_t power = 0; + uint8_t direction = 0; // 0 = stop, 1 = forward, 2 = backward - uint8_t pwmPin; - uint8_t pwmChannel; - uint16_t dutycycle = 0; - uint8_t dutycycleMin; - uint8_t dutycycleMax; - uint8_t dir_1; - uint8_t dir_2; + uint8_t pwmPin = 0; + uint8_t pwmChannel = 0; + uint16_t dutycycle = 0; + uint8_t dutycycleMin = 55; + uint8_t dutycycleMax = 98; // Max 98% of 2^PWM_RES + uint8_t dir_1 = 0; + uint8_t dir_2 = 0; }; #endif // MOTOR_CONTROL_H diff --git a/lib/Navigation/navigation.cpp b/lib/Navigation/navigation.cpp index fec6397..ac48865 100644 --- a/lib/Navigation/navigation.cpp +++ b/lib/Navigation/navigation.cpp @@ -4,56 +4,72 @@ * @brief Contains the implementation of the class Navigation * @version 0.1 * @date 2022-01-31 - * + * * @copyright Copyright (c) 2022 - * + * */ #include "navigation.h" -Navigation::Navigation(const SensorData* sensorData, Route* route) { - this->sensorData = sensorData; +Navigation::Navigation(const SensorData *sensorData, Route *route) + : sensorData{sensorData} +{ this->init(route); } -void Navigation::init(Route* route) { - if (route) +void Navigation::init(Route *route) +{ + if (static_cast(route)) + { this->route = route; + } else + { this->route = new Route(); + } Component::loopDelay = Navigation::loopDelay; } -Navigation::~Navigation() { +Navigation::~Navigation() +{ delete this->route; } void Navigation::run() {} -void Navigation::newRoute() { - if (this->route) - delete this->route; +void Navigation::newRoute() +{ + delete this->route; this->route = new Route(); } -bool Navigation::startNavigation() { - Point newTargetPoint = this->route->startRoute(); +bool Navigation::startNavigation() +{ + const Point newTargetPoint = this->route->startRoute(); this->navigationStarted = this->setTargetPoint(newTargetPoint); if (this->navigationStarted) + { this->navigationFinished = false; + } return this->navigationStarted; } -Navigation::Status Navigation::getCourseCorrection(CourseCorrection& correction, bool forceUpdate) { +Navigation::Status Navigation::getCourseCorrection(CourseCorrection &correction, bool forceUpdate) +{ if (this->navigationFinished) + { return Status::Complete; + } if (this->currentPosition.getAccuracy() <= this->minAccuracy) + { return Status::InsufficientAccuracy; + } - if (this->currentPosition.distanceTo(this->lastPointCalcCorrection) < (this->minDistanceToReachPoint / 2.0) - && !forceUpdate) { + // Check if the Rover has moved, if the Rover hasnt moved this function will be return. + if (this->currentPosition.distanceTo(this->lastPointCalcCorrection) < (this->minDistanceToReachPoint) / 2 && !forceUpdate) + { correction.correction = this->calculateCourseCorrection(this->lastPointCalcCorrection); correction.distance = this->lastPointCalcCorrection.distanceTo(this->targetPoint); return Status::Unchanged; @@ -62,8 +78,10 @@ Navigation::Status Navigation::getCourseCorrection(CourseCorrection& correction, double distance = this->currentPosition.distanceTo(this->targetPoint); // Check if I need a new Point - if (distance < this->minDistanceToReachPoint && this->preventNextPoint == false) { - if (!this->nextPoint()) { + if (distance < this->minDistanceToReachPoint && this->preventNextPoint == false) + { + if (!this->nextPoint()) + { this->navigationFinished = true; this->navigationStarted = false; return Status::Complete; // End of navigation @@ -77,21 +95,25 @@ Navigation::Status Navigation::getCourseCorrection(CourseCorrection& correction, return Status::Updated; } -Navigation::Status Navigation::addCurrentPosToRoute() { +Navigation::Status Navigation::addCurrentPosToRoute() +{ if (this->currentPosition.getAccuracy() <= this->minAccuracy) + { return Status::InsufficientAccuracy; + } // First Point - if (this->route->getRouteInfo().totalPoints == 0) { + if (this->route->getRouteInfo().totalPoints == 0) + { this->route->addPointToRoute(this->currentPosition); this->lastPointRouteInsert = this->currentPosition; return Status::Updated; } // Every Point after the first - double distance = this->currentPosition.distanceTo(this->lastPointRouteInsert); - if (Navigation::minDisBetweenPoints <= distance - && Navigation::maxDisBetweenPoints >= distance){ + const double distance = this->currentPosition.distanceTo(this->lastPointRouteInsert); + if (Navigation::minDisBetweenPoints <= distance && Navigation::maxDisBetweenPoints >= distance) + { this->route->addPointToRoute(this->currentPosition); this->lastPointRouteInsert = this->currentPosition; return Status::Updated; @@ -99,57 +121,58 @@ Navigation::Status Navigation::addCurrentPosToRoute() { return Status::Unchanged; } -// void Navigation::updateCurrentLocation() { -// if (Navigation::ubxUpdateTimeStatic == this->ubxUpdateTime) -// return; +int16_t Navigation::calculateCourseCorrection(Point &point) +{ + const int16_t targetCourse = point.courseTo(this->targetPoint); + int16_t correctionCourse = 0; -// this->ubxData = Navigation::ubxDataStatic; -// this->ubxUpdateTime = Navigation::ubxUpdateTimeStatic; - -// Point::Coordinates coords; -// coords.lat = this->ubxData->lat / 10000000.0; -// coords.lon = this->ubxData->lon / 10000000.0; - -// this->currentPosition = Point(coords, this->ubxData->hAcc); -// } - -int16_t Navigation::calculateCourseCorrection(Point& point) { - int16_t targetCourse = point.courseTo(this->targetPoint); - int16_t correctionCourse; - - if (this->sensorData->getCalcAzimuthState() == CalcAzimuth::State::Good - || this->sensorData->getCalcAzimuthState() == CalcAzimuth::State::Super) + if (this->sensorData->getCalcAzimuthState() == CalcAzimuth::State::Good || this->sensorData->getCalcAzimuthState() == CalcAzimuth::State::Super) { correctionCourse = targetCourse - this->sensorData->getCalcAzimuth(); this->lastUsedCalcAzimuth = true; - } else { + } + else + { correctionCourse = targetCourse - this->sensorData->getRealAzimuth(); this->lastUsedCalcAzimuth = false; } - + return Navigation::fixDegree(correctionCourse); } -bool Navigation::nextPoint() { +bool Navigation::nextPoint() +{ if (!this->navigationStarted) + { return false; + } return this->setTargetPoint(this->route->getNextPoint()); } -bool Navigation::setTargetPoint(Point target) { - if (target.isInit()) { +bool Navigation::setTargetPoint(Point target) +{ + if (target.isInit()) + { this->targetPoint = target; return true; } return false; } -int16_t Navigation::fixDegree(int16_t degree) { - while (degree < -180 || degree > 180) { - if (degree > 180) - degree -= 360; - else if (degree < -180) - degree += 360; +int16_t Navigation::fixDegree(int16_t degree) +{ + static constexpr uint16_t fullCircle = 360; + + while (degree < -fullCircle / 2 || degree > fullCircle / 2) + { + if (degree > fullCircle / 2) + { + degree -= fullCircle; + } + else if (degree < -fullCircle / 2) + { + degree += fullCircle; + } } return degree; } diff --git a/lib/Navigation/navigation.h b/lib/Navigation/navigation.h index 55ae3ee..cfe7ed6 100644 --- a/lib/Navigation/navigation.h +++ b/lib/Navigation/navigation.h @@ -4,9 +4,9 @@ * @brief Contains a class which navigate an object by the given route * @version 0.1 * @date 2022-01-10 - * + * * @copyright Copyright (c) 2022 - * + * */ #ifndef NAVIGATION_H @@ -21,143 +21,144 @@ /** * @brief This struct inherits the result of the navigation - * + * * The drive get objects of this struct and should * correct the direction in dependency on this. - * + * */ -struct CourseCorrection { +struct CourseCorrection +{ int16_t correction; double distance; }; /** * @brief This class navigate an object - * + * * The class use the given Route and the gps device * to tell the driver in which direction he have to * be drive and the distance to the next checkpoint. - * + * */ -class Navigation : public Component { - public: - enum Status { - InsufficientAccuracy, - Unchanged, - Updated, - Complete - }; +class Navigation : public Component +{ +public: + enum Status + { + InsufficientAccuracy, + Unchanged, + Updated, + Complete + }; - /** - * @brief Construct a new Navigation object and using I2C - * - * @param route with which to navigate - */ - Navigation(const SensorData* sensorData, Route* route = nullptr); + /** + * @brief Construct a new Navigation object and using I2C + * + * @param route with which to navigate + */ + Navigation(const SensorData *sensorData, Route *route = nullptr); - /** - * @brief Destroy the Navigation object - * - */ - ~Navigation(); + /** + * @brief Destroy the Navigation object + * + */ + ~Navigation(); - /** - * @brief creates a new empty route - * - */ - void newRoute(); + /** + * @brief creates a new empty route + * + */ + void newRoute(); - /** - * @brief Tries to start the route - * - * For example the route can not be started - * if there are no Points or wrong Points. - * - * @return true route is started - * @return false route can not be started - */ - bool startNavigation(); - void freezeTargetPoint(bool val = true) { this->preventNextPoint = val; }; - - - double increaseMinDistanceToReachPoint() { return this->minDistanceToReachPoint += 0.1; } - double decreaseMinDistanceToReachPoint() { return this->minDistanceToReachPoint -= 0.1; } + /** + * @brief Tries to start the route + * + * For example the route can not be started + * if there are no Points or wrong Points. + * + * @return true route is started + * @return false route can not be started + */ + bool startNavigation(); + void freezeTargetPoint(bool val = true) { this->preventNextPoint = val; }; - // TODO: Dokumentation korrigieren. - /** - * @brief Get the Course Correction object - * - * This should be called by the driver to get new instructions. - * - * @param correction passed as refernce to get the data - * @return true if new correction data provided - * @return false if route is finished - */ - Status getCourseCorrection(CourseCorrection& correction, bool forceUpdate = false); + double increaseMinDistanceToReachPoint() { return this->minDistanceToReachPoint += 0.1; } + double decreaseMinDistanceToReachPoint() { return this->minDistanceToReachPoint -= 0.1; } + // TODO: Dokumentation korrigieren. + /** + * @brief Get the Course Correction object + * + * This should be called by the driver to get new instructions. + * + * @param correction passed as refernce to get the data + * @return true if new correction data provided + * @return false if route is finished + */ + Status getCourseCorrection(CourseCorrection &correction, bool forceUpdate = false); - // TODO: Dokumentation korrigieren. - /** - * @brief Tries to add the current Position to the route - * - * This can be go wrong if there is no valid GPS signal - * - * @return true successful added point - * @return false no point added to route - */ - Status addCurrentPosToRoute(); + // TODO: Dokumentation korrigieren. + /** + * @brief Tries to add the current Position to the route + * + * This can be go wrong if there is no valid GPS signal + * + * @return true successful added point + * @return false no point added to route + */ + Status addCurrentPosToRoute(); - /** - * @brief Get the Route Info object - * - * This object contains information about the route. - * For example the stored points. - * - * @return RouteInfo - */ - RouteInfo getRouteInfo() const { return this->route->getRouteInfo(); } - Route* getRoute() const { return this->route; } - Point getCurrentPosition() const { return this->currentPosition; } + /** + * @brief Get the Route Info object + * + * This object contains information about the route. + * For example the stored points. + * + * @return RouteInfo + */ + RouteInfo getRouteInfo() const { return this->route->getRouteInfo(); } + Route *getRoute() const { return this->route; } + Point getCurrentPosition() const { return this->currentPosition; } - Point::Accuracy getMinAccuracy() const { return this->minAccuracy; } - void setMinAccuracy(Point::Accuracy accuracy) { this->minAccuracy = accuracy; } + Point::Accuracy getMinAccuracy() const { return this->minAccuracy; } + void setMinAccuracy(Point::Accuracy accuracy) { this->minAccuracy = accuracy; } - // map input in range from -180 to 180 degree - static int16_t fixDegree(int16_t degree); + // map input in range from -180 to 180 degree + static int16_t fixDegree(int16_t degree); - private: - void run() override; - void init(Route* route); - bool nextPoint(); - bool setTargetPoint(Point target); - int16_t calculateCourseCorrection(Point& point); +private: + void run() override; + void init(Route *route); + bool nextPoint(); + bool setTargetPoint(Point target); + int16_t calculateCourseCorrection(Point &point); - static constexpr uint8_t loopDelay = 20; - static constexpr uint8_t maxDisBetweenPoints = 10; - static constexpr float minDisBetweenPoints = 0.3; - - const SensorData* sensorData; - Route* route = nullptr; + static constexpr uint8_t loopDelay = 20; + static constexpr uint8_t maxDisBetweenPoints = 10; + static constexpr float minDisBetweenPoints = 0.3; - Point lastPointRouteInsert; - Point lastPointCalcCorrection; - Point lastPointDrivingDirectionChange; - Point targetPoint; - Point currentPosition; - Point::Accuracy minAccuracy = Point::Accuracy::twoDigOfCM; - - bool navigationStarted = false; - bool navigationFinished = false; - bool isNtripInit = false; - bool preventNextPoint = false; - bool directionChangeMode = false; - bool lastUsedCalcAzimuth = false; + const SensorData *sensorData; + Route *route = nullptr; - uint8_t timeToWait = 200; - uint32_t lastMillis = 0; - uint32_t ubxUpdateTime = 0; + Point lastPointRouteInsert; + Point lastPointCalcCorrection; + Point lastPointDrivingDirectionChange; + Point targetPoint; + Point currentPosition; + Point::Accuracy minAccuracy = Point::Accuracy::twoDigOfCM; - double minDistanceToReachPoint = 0.5; + bool navigationStarted = false; + bool navigationFinished = false; + bool isNtripInit = false; + bool preventNextPoint = false; + bool directionChangeMode = false; + bool lastUsedCalcAzimuth = false; + + uint8_t timeToWait = 200; + uint32_t lastMillis = 0; + uint32_t ubxUpdateTime = 0; + + double minDistanceToReachPoint = 0.5; }; #endif // NAVIGATION_H diff --git a/lib/Network/network.cpp b/lib/Network/network.cpp index 40456e0..3479e3e 100644 --- a/lib/Network/network.cpp +++ b/lib/Network/network.cpp @@ -1,33 +1,38 @@ /** * @file network.cpp * @author Alexander Klein (alex@kleiax.de) - * @brief + * @brief * @version 0.1 * @date 2023-09-18 - * + * * @copyright Copyright (c) 2023 - * + * */ #include "network.h" -Network::Network(const char *ssid, const char *passphrase) { - if (!WiFi.mode(WIFI_AP_STA)) +Network::Network(const char *ssid, const char *passphrase) +{ + if (!WiFiGenericClass::mode(WIFI_AP_STA)) + { std::cout << "Network::connectWiFi failed WiFi.mode" << std::endl; + } this->init(ssid, passphrase); } -Network::Network(const char *ssid, const char *passphrase, NetworkAdresses adresses) { - this->adresses = adresses; - - if (!WiFi.mode(WIFI_AP_STA)) +Network::Network(const char *ssid, const char *passphrase, NetworkAdresses adresses) + : adresses{adresses} +{ + if (!WiFiGenericClass::mode(WIFI_AP_STA)) + { std::cout << "Network::connectWiFi failed WiFi.mode" << std::endl; + } if (!WiFi.config(this->adresses.localIP, this->adresses.gateway, this->adresses.subnet, - this->adresses.dnsServer)) + this->adresses.dnsServer)) { std::cout << "STA Failed to configure" << std::endl; } @@ -35,13 +40,15 @@ Network::Network(const char *ssid, const char *passphrase, NetworkAdresses adres this->init(ssid, passphrase); } -Network::~Network() { - if (this->mqttClient) - delete mqttClient; +Network::~Network() +{ + delete mqttClient; } -bool Network::activateEspNow(recieveCallbackPtr reci, sendCallbackPtr send) { - if (esp_now_init() != ESP_OK) { +bool Network::activateEspNow(recieveCallbackPtr reci, sendCallbackPtr send) +{ + if (esp_now_init() != ESP_OK) + { std::cout << "Network::activateEspNow - Error initializing ESP-NOW" << std::endl; return false; } @@ -49,11 +56,12 @@ bool Network::activateEspNow(recieveCallbackPtr reci, sendCallbackPtr send) { esp_now_register_send_cb(send); esp_now_peer_info_t peerInfo = {}; - memcpy(peerInfo.peer_addr, this->broadcastAddress, 6); - peerInfo.channel = 0; + memcpy(static_cast(peerInfo.peer_addr), static_cast(this->broadcastAddress), 6); + peerInfo.channel = 0; peerInfo.encrypt = false; - if (esp_now_add_peer(&peerInfo) != ESP_OK) { + if (esp_now_add_peer(&peerInfo) != ESP_OK) + { std::cout << "Network::connectEspNow - Failed to add peer" << std::endl; return false; } @@ -62,7 +70,8 @@ bool Network::activateEspNow(recieveCallbackPtr reci, sendCallbackPtr send) { return true; } -bool Network::activateMqtt(const char *user, const char *passphrase) { +bool Network::activateMqtt(const char *user, const char *passphrase) +{ this->mqttUser = user; this->mqttPassphrase = passphrase; @@ -71,53 +80,68 @@ bool Network::activateMqtt(const char *user, const char *passphrase) { this->mqttClient->setSocketTimeout(1); if (this->wifiConnected) + { return this->connectMqtt(); + } return false; } -void Network::printIPs() { +const void Network::printIPs() +{ std::cout << std::endl; - if (!this->wifiConnected) { + if (!this->wifiConnected) + { std::cout << "WiFi is not connected." << std::endl; return; } std::cout << "WiFi is connected to" << std::endl; std::cout << "IP address: " << std::endl; std::cout << WiFi.localIP().toString().c_str() << std::endl; - std::cout << "WiFi MAC Address: " << WiFi.macAddress().c_str() << std::endl << std::endl; + std::cout << "WiFi MAC Address: " << WiFi.macAddress().c_str() << std::endl + << std::endl; } -uint8_t Network::getCurrentChannel() { - uint8_t channel; - wifi_second_chan_t secondChannel; - if (esp_wifi_get_channel(&channel, &secondChannel) != ESP_OK) { +uint8_t Network::getCurrentChannel() +{ + uint8_t channel = 0; + wifi_second_chan_t secondChannel = WIFI_SECOND_CHAN_NONE; + if (esp_wifi_get_channel(&channel, &secondChannel) != ESP_OK) + { std::cout << "Network::getCurrentChannel - Error!" << std::endl; return -1; } - + return channel; } -void Network::runAsChild() { +void Network::runAsChild() +{ if (!this->initSucessful) + { return; + } this->checkWifi(); - if (this->wifiConnected && this->mqttClient) + if (this->wifiConnected && static_cast(this->mqttClient)) + { this->checkMqtt(); + } } -void Network::init(const char *ssid, const char *passphrase) { +void Network::init(const char *ssid, const char *passphrase) +{ // Connect to Wi-Fi network with SSID and password std::cout << "Connecting to " << ssid << std::endl; WiFi.begin(ssid, passphrase); uint8_t timeout = Network::wifiConnectTimeout; - while (WiFi.status() != WL_CONNECTED) { + while (WiFiSTAClass::status() != WL_CONNECTED) + { delay(Network::wifiConnectLoopTime); std::cout << "." << std::flush; timeout--; - if (timeout == 0) { + if (timeout == 0) + { std::cout << std::endl; std::cout << "WiFi NOT connected." << std::endl; return; @@ -128,9 +152,9 @@ void Network::init(const char *ssid, const char *passphrase) { this->printIPs(); } -void Network::checkWifi() { - if ((WiFi.status() != WL_CONNECTED) - && (millis() - this->lastWifiRecoonectAttemp >= Network::wifiReconnectDelay)) +void Network::checkWifi() +{ + if ((WiFiSTAClass::status() != WL_CONNECTED) && (millis() - this->lastWifiRecoonectAttemp >= Network::wifiReconnectDelay)) { std::cout << "Reconnecting to WiFi..." << std::endl; WiFi.disconnect(); @@ -139,29 +163,39 @@ void Network::checkWifi() { } } -void Network::checkMqtt() { - if (!this->mqttClient->connected() - && millis() - this->lastMqttReconnectAttemp > Network::mqttReconnectDelay) +void Network::checkMqtt() +{ + if (!this->mqttClient->connected() && millis() - this->lastMqttReconnectAttemp > Network::mqttReconnectDelay) { this->mqttConnected = this->connectMqtt(); this->lastMqttReconnectAttemp = millis(); } if (this->mqttConnected) + { this->mqttClient->loop(); + } } -bool Network::connectMqtt() { +bool Network::connectMqtt() +{ String clientId = "ESP32Rover-"; - clientId += String(random(0xffff), HEX); + clientId += String(random(), HEX); - if (this->mqttUser) { + if (static_cast(this->mqttUser)) + { if (this->mqttClient->connect(clientId.c_str(), this->mqttUser, this->mqttPassphrase)) + { this->mqttClient->publish("Rover/Info", "Connected to Mqtt-Broker"); - } else { - if (this->mqttClient->connect(clientId.c_str())) - this->mqttClient->publish("Rover/Info", "Connected to Mqtt-Broker"); + } } - + else + { + if (this->mqttClient->connect(clientId.c_str())) + { + this->mqttClient->publish("Rover/Info", "Connected to Mqtt-Broker"); + } + } + return this->mqttClient->connected(); } diff --git a/lib/Network/network.h b/lib/Network/network.h index 355ebd9..acd7841 100644 --- a/lib/Network/network.h +++ b/lib/Network/network.h @@ -1,12 +1,12 @@ /** * @file network.h * @author Alexander Klein (alex@kleiax.de) - * @brief + * @brief * @version 0.1 * @date 2023-09-18 - * + * * @copyright Copyright (c) 2023 - * + * */ #ifndef NETWORK_H @@ -20,10 +20,11 @@ #include #include -typedef void (*recieveCallbackPtr) (const uint8_t * mac, const uint8_t *incomingData, int len); -typedef void (*sendCallbackPtr) (const uint8_t *mac_addr, esp_now_send_status_t status); +typedef void (*recieveCallbackPtr)(const uint8_t *mac, const uint8_t *incomingData, int len); +typedef void (*sendCallbackPtr)(const uint8_t *mac_addr, esp_now_send_status_t status); -struct NetworkAdresses { +struct NetworkAdresses +{ IPAddress localIP; IPAddress gateway; IPAddress subnet; @@ -32,53 +33,53 @@ struct NetworkAdresses { uint16_t mqttPort = 1883; }; -class Network : public Component { - public: - Network(const char *ssid, const char *passphrase); - Network(const char *ssid, const char *passphrase, NetworkAdresses adresses); +class Network : public Component +{ +public: + Network(const char *ssid, const char *passphrase); + Network(const char *ssid, const char *passphrase, NetworkAdresses adresses); - ~Network(); + ~Network(); - bool activateEspNow(recieveCallbackPtr reci, sendCallbackPtr send); - bool activateMqtt(const char *user = nullptr, const char *passphrase = nullptr); + bool activateEspNow(recieveCallbackPtr reci, sendCallbackPtr send); + bool activateMqtt(const char *user = nullptr, const char *passphrase = nullptr); - void printIPs(); + const void printIPs(); - bool isWifiConnected() const { return this->wifiConnected; } - bool isMqttConnected() const { return this->mqttConnected; } - const uint8_t* getBroadcastAddress() const { return this->broadcastAddress; } - PubSubClient* getMqttClient() const { return this->mqttClient; } + bool isWifiConnected() const { return this->wifiConnected; } + bool isMqttConnected() const { return this->mqttConnected; } + const uint8_t *getBroadcastAddress() const { return this->broadcastAddress; } + PubSubClient *getMqttClient() const { return this->mqttClient; } - static uint8_t getCurrentChannel(); - - private: - void run() override {}; - void runAsChild() override; - void init(const char *ssid, const char *passphrase); - void checkWifi(); - void checkMqtt(); - bool connectMqtt(); + static uint8_t getCurrentChannel(); - NetworkAdresses adresses; - WiFiClient wifiClient; - PubSubClient* mqttClient = nullptr; +private: + void run() override{}; + void runAsChild() override; + void init(const char *ssid, const char *passphrase); + void checkWifi(); + void checkMqtt(); + bool connectMqtt(); - bool initSucessful = false; - bool wifiConnected = false; - bool mqttConnected = false; + NetworkAdresses adresses; + WiFiClient wifiClient; + PubSubClient *mqttClient = nullptr; - const char *mqttUser; - const char *mqttPassphrase; + bool initSucessful = false; + bool wifiConnected = false; + bool mqttConnected = false; - uint8_t broadcastAddress[6] = {0xC8, 0xC9, 0xA3, 0xC8, 0x57, 0x10}; - uint32_t lastWifiRecoonectAttemp = 0; - uint32_t lastMqttReconnectAttemp = 0; + const char *mqttUser = nullptr; + const char *mqttPassphrase = nullptr; - static constexpr uint8_t wifiConnectTimeout = 20; - static constexpr uint16_t wifiConnectLoopTime = 500; - static constexpr uint16_t wifiReconnectDelay = 5000; - static constexpr uint16_t mqttReconnectDelay = 2500; + uint8_t broadcastAddress[6] = {0xC8, 0xC9, 0xA3, 0xC8, 0x57, 0x10}; + uint32_t lastWifiRecoonectAttemp = 0; + uint32_t lastMqttReconnectAttemp = 0; + static constexpr uint8_t wifiConnectTimeout = 20; + static constexpr uint16_t wifiConnectLoopTime = 500; + static constexpr uint16_t wifiReconnectDelay = 5000; + static constexpr uint16_t mqttReconnectDelay = 2500; }; -#endif //NETWORK_H +#endif // NETWORK_H diff --git a/lib/NtripClient/ntripClient.cpp b/lib/NtripClient/ntripClient.cpp index 847f877..731442c 100644 --- a/lib/NtripClient/ntripClient.cpp +++ b/lib/NtripClient/ntripClient.cpp @@ -4,84 +4,90 @@ * @brief Contains the implementation of the class NTRIPClient. * @version 0.1 * @date 2022-09-18 - * + * * @copyright Copyright (c) 2022 - * + * */ #include "ntripClient.h" - -NTRIPClient::NTRIPClient(SFE_UBLOX_GNSS* gps, const char* host, uint16_t port, const char* mountPoint, const char* user, const char* password) { - this->gps = gps; - strcpy(this->host, host); - this->port = port; - strcpy(this->mountPoint, mountPoint); - strcpy(this->user, user); - strcpy(this->password, password); - - this->ntripClient = new WiFiClient; - this->state = NTRIPClientStates::closeConnection; - - this->loopDelay = 20; +NTRIPClient::NTRIPClient(SFE_UBLOX_GNSS *gps, const char *host, uint16_t port, const char *mountPoint, const char *user, const char *password) + : gps{gps}, port{port}, host{host}, mountPoint{mountPoint}, user{user}, password{password}, ntripClient{new WiFiClient}, state{NTRIPClientStates::closeConnection} +{ + Component::loopDelay = NTRIPClient::loopDelay; } -NTRIPClient::~NTRIPClient() { +NTRIPClient::~NTRIPClient() +{ delete this->ntripClient; } -void NTRIPClient::run() { - switch (this->state) { - case NTRIPClientStates::openConnection: - if (!this->activated) { - this->state = NTRIPClientStates::closeConnection; - break; - } - - std::cout << "Connecting to the NTRIP caster..." << std::endl; - if (this->beginClient()) { - std::cout << "Connected to the NTRIP caster!" << std::endl; - this->state = NTRIPClientStates::pushData; - } else { - std::cout << "Failed!" << std::endl; - this->state = NTRIPClientStates::wait; - this->activated = false; - } - break; - - case NTRIPClientStates::pushData: - if (!processConnection() || !this->activated) - this->state = NTRIPClientStates::closeConnection; - break; - - case NTRIPClientStates::closeConnection: - std::cout << "Closing the connection to the NTRIP caster..." << std::endl; - this->closeConnection(); - state = NTRIPClientStates::wait; - break; - - case NTRIPClientStates::wait: - if (this->activated) - this->state = NTRIPClientStates::openConnection; - else - this->checkAutoReconnect(); - break; - - case NTRIPClientStates::notAvailable: - break; - - default: - std::cout << "Wrong state in NTRIPClient.cpp..." << std::endl; +void NTRIPClient::run() +{ + switch (this->state) + { + case NTRIPClientStates::openConnection: + if (!this->activated) + { this->state = NTRIPClientStates::closeConnection; break; + } + + std::cout << "Connecting to the NTRIP caster..." << std::endl; + if (this->beginClient()) + { + std::cout << "Connected to the NTRIP caster!" << std::endl; + this->state = NTRIPClientStates::pushData; + } + else + { + std::cout << "Failed!" << std::endl; + this->state = NTRIPClientStates::wait; + this->activated = false; + } + break; + + case NTRIPClientStates::pushData: + if (!processConnection() || !this->activated) + { + this->state = NTRIPClientStates::closeConnection; + } + break; + + case NTRIPClientStates::closeConnection: + std::cout << "Closing the connection to the NTRIP caster..." << std::endl; + this->closeConnection(); + state = NTRIPClientStates::wait; + break; + + case NTRIPClientStates::wait: + if (this->activated) + { + this->state = NTRIPClientStates::openConnection; + } + else + { + this->checkAutoReconnect(); + } + break; + + case NTRIPClientStates::notAvailable: + break; + + default: + std::cout << "Wrong state in NTRIPClient.cpp..." << std::endl; + this->state = NTRIPClientStates::closeConnection; + break; } } -void NTRIPClient::runAsChild() { +void NTRIPClient::runAsChild() +{ this->pushGPGGA(); } -void NTRIPClient::gpsConfiguration() { +void NTRIPClient::gpsConfiguration() +{ this->gps->setSPIOutput(COM_TYPE_UBX | COM_TYPE_NMEA); this->gps->setPortInput(COM_PORT_SPI, COM_TYPE_UBX | COM_TYPE_NMEA | COM_TYPE_RTCM3); // Set the differential mode - ambiguities are fixed whenever possible @@ -90,21 +96,28 @@ void NTRIPClient::gpsConfiguration() { this->gps->enableNMEAMessage(UBX_NMEA_GGA, COM_PORT_SPI, 10); } -bool NTRIPClient::setActivated(bool state) { - // std::cout << "NTRIPClient::setActivated: b - " << b << std::endl; +bool NTRIPClient::setActivated(bool state) +{ if (state && this->state != NTRIPClientStates::notAvailable) + { this->activated = true; + } else if (state) + { return false; - else { + } + else + { this->activated = false; this->autoReconnect = false; } return true; } -void NTRIPClient::setAutoReconnect(bool state) { - if (state) { +void NTRIPClient::setAutoReconnect(bool state) +{ + if (state) + { this->reconnectAttemps = 0; this->autoReconnect = true; return; @@ -113,61 +126,67 @@ void NTRIPClient::setAutoReconnect(bool state) { this->autoReconnect = false; } -bool NTRIPClient::beginClient() { +bool NTRIPClient::beginClient() +{ + static constexpr uint16_t httpError = 401; + static constexpr uint16_t httpCheck = 200; + std::cout << "Opening socket to " << this->host << std::endl; char serverRequest[this->bufferSize]; char credentials[this->bufferSize]; - if (!this->ntripClient->connect(this->host, this->port)) { + if (!static_cast(this->ntripClient->connect(static_cast(this->host), this->port))) + { std::cout << "Connection to caster failed" << std::endl; return false; - } else { - std::cout << "Connected to " << this->host << " : " << this->port << std::endl; - std::cout << "Requesting NTRIP Data from mount point " << this->mountPoint << std::endl; - - // Generate the server request (GET) - snprintf(serverRequest, - this->bufferSize, - "GET /%s HTTP/1.0\r\nUser-Agent: NTRIP SparkFun u-blox Client v1.0\r\n", - this->mountPoint); - - // Credentials - uint8_t userCredentialsLength = strlen(this->user) + strlen(this->password) + 2; - char* userCredentials = new char[userCredentialsLength]; - snprintf(userCredentials, userCredentialsLength, "%s:%s", this->user, this->password); - - std::cout << "Sending credentials: " << userCredentials << std::endl; - - //Encode - base64 b; - String strEncodedCredentials = b.encode(userCredentials); - delete userCredentials; - char encodedCredentials[strEncodedCredentials.length() + 1]; - strEncodedCredentials.toCharArray(encodedCredentials, sizeof(encodedCredentials)); - - snprintf(credentials, sizeof(credentials), "Authorization: Basic %s\r\n", encodedCredentials); } + std::cout << "Connected to " << this->host << " : " << this->port << std::endl; + std::cout << "Requesting NTRIP Data from mount point " << this->mountPoint << std::endl; + + // Generate the server request (GET) + snprintf(static_cast(serverRequest), + this->bufferSize, + static_cast("GET /%s HTTP/1.0\r\nUser-Agent: NTRIP SparkFun u-blox Client v1.0\r\n"), + this->mountPoint); + + // Credentials + const uint8_t userCredentialsLength = strlen(this->user) + strlen(this->password) + 2; + auto *userCredentials = new char[userCredentialsLength]; + snprintf(static_cast(userCredentials), userCredentialsLength, static_cast("%s:%s"), this->user, this->password); + + std::cout << "Sending credentials: " << userCredentials << std::endl; + + // Encode + const base64 base; + const String strEncodedCredentials = base64::encode(userCredentials); + delete userCredentials; + char encodedCredentials[strEncodedCredentials.length() + 1]; + strEncodedCredentials.toCharArray(static_cast(encodedCredentials), sizeof(encodedCredentials)); + + snprintf(credentials, sizeof(credentials), static_cast("Authorization: Basic %s\r\n"), static_cast(encodedCredentials)); // Add the encoded credentials to the server request - strncat(serverRequest, credentials, this->bufferSize); - strncat(serverRequest, "\r\n", this->bufferSize); + strncat(static_cast(serverRequest), static_cast(credentials), this->bufferSize); + strncat(static_cast(serverRequest), static_cast("\r\n"), this->bufferSize); - std::cout << "serverRequest size: " - << strlen(serverRequest) - << " of " - << this->bufferSize - << " bytes available" - << std::endl; + std::cout << static_cast("serverRequest size: ") + << strlen(serverRequest) + << static_cast(" of ") + << this->bufferSize + << static_cast(" bytes available") + << std::endl; // Send the server request std::cout << "Sending server request: " << serverRequest << std::endl; this->ntripClient->write(serverRequest, strlen(serverRequest)); - //Wait up to 5 seconds for response - uint32_t lastMillis = millis(); - while (!ntripClient->available()) { - if (millis() - lastMillis > this->timeOut) { + // Wait up to 5 seconds for response + const uint32_t lastMillis = millis(); + while (static_cast(!ntripClient->available())) + { + if (millis() - lastMillis > this->timeOut) + { std::cout << "Caster timed out!" << std::endl; this->ntripClient->stop(); return false; @@ -175,35 +194,48 @@ bool NTRIPClient::beginClient() { delay(10); } - //Check reply + // Check reply uint16_t httpStatusCode = 0; char response[this->bufferSize]; uint16_t responseIndex = 0; - while (this->ntripClient->available()) { + while (static_cast(this->ntripClient->available())) + { if (responseIndex == sizeof(response)) + { break; + } response[responseIndex++] = ntripClient->read(); - if (httpStatusCode == 0) { - if (strstr(response, "200") != nullptr) - httpStatusCode = 200; - if (strstr(response, "401") != nullptr) - httpStatusCode = 401; + if (httpStatusCode == 0) + { + if (strstr(response, static_cast("200")) != nullptr) + { + httpStatusCode = httpCheck; + } + if (strstr(response, static_cast("401")) != nullptr) + { + httpStatusCode = httpError; + } } } response[responseIndex] = '\0'; // std::cout << "Caster response: " << response << std::endl; - if (httpStatusCode != 200) { - std::cout << "Failed to connect to " << this->host << " - HTTP Code: " << (int) httpStatusCode + if (httpStatusCode != httpCheck) + { + std::cout << "Failed to connect to " << this->host << " - HTTP Code: " << (int)httpStatusCode << " Length of Response: " << responseIndex << std::endl; if (httpStatusCode == 0) + { std::cout << "Response: " << response << std::endl; - else if (httpStatusCode == 401) + } + else if (httpStatusCode == httpError) + { std::cout << "Statuscode 401 - Unauthorized" << std::endl; + } return false; } @@ -212,35 +244,47 @@ bool NTRIPClient::beginClient() { return true; } -void NTRIPClient::closeConnection() { - if (this->ntripClient->connected()) +void NTRIPClient::closeConnection() +{ + if (static_cast(this->ntripClient->connected())) + { this->ntripClient->stop(); + } this->activated = false; std::cout << "NtripClient disconnected from: " << this->host << std::endl; } -bool NTRIPClient::processConnection() { - if (this->ntripClient->connected()) { +bool NTRIPClient::processConnection() +{ + if (static_cast(this->ntripClient->connected())) + { uint8_t rtcmData[this->bufferSize * 8]; uint16_t rtcmCount = 0; - while (this->ntripClient->available()) { + while (static_cast(this->ntripClient->available())) + { rtcmData[rtcmCount++] = ntripClient->read(); if (rtcmCount == sizeof(rtcmData)) + { break; + } } - if (rtcmCount > 0) { + if (rtcmCount > 0) + { this->lastReceivedRtcmTime = millis(); - this->gps->pushRawData(rtcmData, rtcmCount); + this->gps->pushRawData(static_cast(rtcmData), rtcmCount); // std::cout << "Pushed " << rtcmCount << " RTCM bytes to ZED." << std::endl; } - } else { + } + else + { std::cout << "Connection to " << this->host << " dropped!" << std::endl; return false; } - if (millis() - this->lastReceivedRtcmTime > this->timeOut) { + if (millis() - this->lastReceivedRtcmTime > this->timeOut) + { std::cout << "RTCM timeout!" << std::endl; return false; } @@ -248,15 +292,21 @@ bool NTRIPClient::processConnection() { return true; } -void NTRIPClient::checkAutoReconnect() { +void NTRIPClient::checkAutoReconnect() +{ if (!this->autoReconnect) + { return; + } if (millis() - this->lastReconnectTime < this->reconnectDelayTime) + { return; + } this->lastReconnectTime = millis(); - if (this->reconnectAttemps >= this->maxReconnectAttemps) { + if (this->reconnectAttemps >= this->maxReconnectAttemps) + { this->autoReconnect = false; return; } @@ -265,26 +315,34 @@ void NTRIPClient::checkAutoReconnect() { this->reconnectAttemps++; } -void NTRIPClient::pushGPGGA() { +void NTRIPClient::pushGPGGA() +{ if (!this->transmitLocation && !this->activated) + { return; + } if (millis() - this->lastGPGGAPushTime < this->pushGPGGATime) + { return; + } this->lastGPGGAPushTime = millis(); if (!this->ntripClient->connected()) + { std::cout << "Failed to pushing GGA to server: " << std::endl; - - NMEA_GGA_data_t *data = new NMEA_GGA_data_t; - uint8_t res = this->gps->getLatestNMEAGPGGA(data); + } + + auto *data = new NMEA_GGA_data_t; + const uint8_t res = this->gps->getLatestNMEAGPGGA(data); if (res == 2) - this->ntripClient->print((const char *)data); + { + this->ntripClient->print(reinterpret_cast(data)); + } delete data; } -bool NTRIPClient::isConnected() { - if (this->state == NTRIPClientStates::pushData) - return true; - return false; +bool NTRIPClient::isConnected() +{ + return this->state == NTRIPClientStates::pushData; } diff --git a/lib/NtripClient/ntripClient.h b/lib/NtripClient/ntripClient.h index 577bbfa..9c2fded 100644 --- a/lib/NtripClient/ntripClient.h +++ b/lib/NtripClient/ntripClient.h @@ -4,9 +4,9 @@ * @brief Contains the class NTRIPClient * @version 0.1 * @date 2023-02-13 - * + * * @copyright Copyright (c) 2023 - * + * */ #ifndef NTRIP_CLIENT @@ -22,109 +22,113 @@ #include "component.h" /** - * @brief States for the state machine. - * + * @brief States for the state machine. + * */ -enum NTRIPClientStates { - openConnection, - pushData, - closeConnection, - wait, - notAvailable +enum NTRIPClientStates +{ + openConnection, + pushData, + closeConnection, + wait, + notAvailable }; /** * @brief Ntrip Client - * + * * This class can connect to a ntrip server to pull correction * data and push it to a given gnss module. This module have to be compatible * with the SparkFun u-blox GNSS Arduino Library. */ -class NTRIPClient : public Component { - public: - /** - * @brief Construct a new NTRIPClient object - * - * @param gps The Gnss module - * @param host - * @param port - * @param mountPoint - * @param user - * @param password - */ - NTRIPClient(SFE_UBLOX_GNSS* gps, const char* host, uint16_t port, const char* mountPoint, const char* user, const char* password); - ~NTRIPClient(); +class NTRIPClient : public Component +{ +public: + /** + * @brief Construct a new NTRIPClient object + * + * @param gps The Gnss module + * @param host + * @param port + * @param mountPoint + * @param user + * @param password + */ + NTRIPClient(SFE_UBLOX_GNSS *gps, const char *host, uint16_t port, const char *mountPoint, const char *user, const char *password); + ~NTRIPClient(); - /** - * @brief Configure the Gnss module to accept correction data - * - */ - void gpsConfiguration(); + /** + * @brief Configure the Gnss module to accept correction data + * + */ + void gpsConfiguration(); - /** - * @brief Activate or deactivate the location transmission - * - * Some server need the position of the Gnss module to send the - * right correction data. - * - * @param b - */ - void setTransmitLocation(bool b) { this->transmitLocation = b; } + /** + * @brief Activate or deactivate the location transmission + * + * Some server need the position of the Gnss module to send the + * right correction data. + * + * @param b + */ + void setTransmitLocation(bool b) { this->transmitLocation = b; } - /** - * @brief Activate or deactivate the connection to the server. - * - * @param state - * @return true success - * @return false failure - */ - bool setActivated(bool state); - void setAutoReconnect(bool state); + /** + * @brief Activate or deactivate the connection to the server. + * + * @param state + * @return true success + * @return false failure + */ + bool setActivated(bool state); + void setAutoReconnect(bool state); - bool isConnected(); + bool isConnected(); - /** - * @brief Get the Client State object - * - * Returns the state of the State machine - * - * @return NTRIPClientStates - */ - NTRIPClientStates getClientState() { return this->state; } + /** + * @brief Get the Client State object + * + * Returns the state of the State machine + * + * @return NTRIPClientStates + */ + NTRIPClientStates getClientState() { return this->state; } - private: - void run() override; - void runAsChild() override; - void pushGPGGA(); - bool beginClient(); - void closeConnection(); - bool processConnection(); - void checkAutoReconnect(); +private: + void run() override; + void runAsChild() override; + void pushGPGGA(); + bool beginClient(); + void closeConnection(); + bool processConnection(); + void checkAutoReconnect(); - SFE_UBLOX_GNSS* gps; - WiFiClient* ntripClient; - NTRIPClientStates state = NTRIPClientStates::notAvailable; + SFE_UBLOX_GNSS *gps; + WiFiClient *ntripClient; + NTRIPClientStates state = NTRIPClientStates::notAvailable; - bool transmitLocation = false; - bool activated = true; - bool autoReconnect = false; + bool transmitLocation = false; + bool activated = true; + bool autoReconnect = false; - uint8_t reconnectAttemps = 0; - uint16_t port; - uint32_t lastReceivedRtcmTime = 0; - // uint32_t lastNtripConnectTime = 0; // can deleted? - uint32_t lastGPGGAPushTime = 0; - uint32_t lastReconnectTime = 0; + uint8_t reconnectAttemps = 0; + uint16_t port; + uint32_t lastReceivedRtcmTime = 0; + // uint32_t lastNtripConnectTime = 0; // can deleted? + uint32_t lastGPGGAPushTime = 0; + uint32_t lastReconnectTime = 0; - char host[128]; - char mountPoint[128]; - char user[128]; - char password[128]; - const uint8_t maxReconnectAttemps = 10; - const uint16_t reconnectDelayTime = 1000; - const uint16_t timeOut = 10000; - const uint16_t bufferSize = 512; - const uint16_t pushGPGGATime = 10000; + const char *host; + const char *mountPoint; + const char *user; + const char *password; + const uint8_t maxReconnectAttemps = 10; + const uint16_t reconnectDelayTime = 1000; + const uint16_t timeOut = 10000; + const uint16_t bufferSize = 512; + const uint16_t pushGPGGATime = 10000; + + static constexpr uint8_t loopDelay = 20; }; #endif diff --git a/lib/Point/point.cpp b/lib/Point/point.cpp index eee438e..a87be22 100644 --- a/lib/Point/point.cpp +++ b/lib/Point/point.cpp @@ -1,104 +1,118 @@ /** * @file point.cpp * @author Alexander Klein (alex@kleiax.de) - * @brief + * @brief * @version 0.1 * @date 2023-09-03 - * + * * @copyright Copyright (c) 2023 - * + * */ #include "point.h" -Point::Point(double lat, double lon, uint32_t horizontalAccuracy, uint32_t creationTime) { - this->coordinates.lat = lat; - this->coordinates.lon = lon; +Point::Point(double lat, double lon, uint32_t horizontalAccuracy, uint32_t creationTime) + : coordinates{lat, lon} +{ this->init(horizontalAccuracy, creationTime); } -Point::Point(int32_t lat, int32_t lon, uint32_t horizontalAccuracy, uint32_t creationTime) { - this->coordinates.lat = lat / 10000000.0; - this->coordinates.lon = lon / 10000000.0; +Point::Point(int32_t lat, int32_t lon, uint32_t horizontalAccuracy, uint32_t creationTime) + : coordinates{lat / 10000000.0, lon / 10000000.0} +{ this->init(horizontalAccuracy, creationTime); } -Point::Point(Coordinates coords, uint32_t horizontalAccuracy, uint32_t creationTime) { - this->coordinates = coords; +Point::Point(Coordinates coords, uint32_t horizontalAccuracy, uint32_t creationTime) + : coordinates{coords} +{ this->init(horizontalAccuracy, creationTime); } -Point::Point(Coordinates coords, bool imported) { +Point::Point(Coordinates coords, bool imported) +{ this->coordinates = coords; if (imported) + { this->init(UINT32_MAX, 0); + } else + { this->init(0, 0); + } } -Point::Point() { +Point::Point() +{ this->coordinates.lat = 0; - this->coordinates.lon = 0; + this->coordinates.lon = 0; this->init(0, 0); } -bool Point::operator==(const Point& rhs) const { +bool Point::operator==(const Point &rhs) const +{ return this->coordinates == rhs.getCoordinates(); } - // distance = sqrt(dx * dx + dy * dy) - // mit distance: Entfernung in km - // dx = 111.3 * cos(lat) * (lon1 - lon2) - // lat = (lat1 + lat2) / 2 * 0.01745 - // dy = 111.3 * (lat1 - lat2) - // lat1, lat2, lon1, lon2: Breite, Länge in Grad -double Point::distanceTo(const Coordinates& point) const { - Coordinates begin = this->coordinates; - Coordinates end = point; +double Point::distanceTo(const Coordinates &point) const +{ + const Coordinates begin = this->coordinates; + const Coordinates end = point; - double lat = (begin.lat + end.lat) / 2 * ROUTE_DEGREE_TO_RADIANT; - double dy = ROUTE_DISTANCE_BETWEEN_LATITUDE * (begin.lat - end.lat); - double dx = ROUTE_DISTANCE_BETWEEN_LATITUDE * cos(lat) * (begin.lon - end.lon); + const double lat = (begin.lat + end.lat) / 2 * ROUTE_DEGREE_TO_RADIANT; + const double dy = ROUTE_DISTANCE_BETWEEN_LATITUDE * (begin.lat - end.lat); + const double dx = ROUTE_DISTANCE_BETWEEN_LATITUDE * cos(lat) * (begin.lon - end.lon); return sqrt(dx * dx + dy * dy); } -double Point::distanceTo(const Point &point) const { +double Point::distanceTo(const Point &point) const +{ return this->distanceTo(point.getCoordinates()); } -int16_t Point::courseTo(const Coordinates& point) const { - Coordinates begin = this->coordinates; - Coordinates end = point; +int16_t Point::courseTo(const Coordinates &point) const +{ + const Coordinates begin = this->coordinates; + const Coordinates end = point; - double phi = log( tan(end.lat * ROUTE_DEGREE_TO_RADIANT / 2 + M_PI / 4) / tan(begin.lat * ROUTE_DEGREE_TO_RADIANT / 2 + M_PI / 4) ); - double lon = (begin.lon * ROUTE_DEGREE_TO_RADIANT - end.lon * ROUTE_DEGREE_TO_RADIANT); + const double phi = log(tan(end.lat * ROUTE_DEGREE_TO_RADIANT / 2 + M_PI / 4) / tan(begin.lat * ROUTE_DEGREE_TO_RADIANT / 2 + M_PI / 4)); + const double lon = (begin.lon * ROUTE_DEGREE_TO_RADIANT - end.lon * ROUTE_DEGREE_TO_RADIANT); - int16_t res = static_cast(atan2(lon, phi) / ROUTE_DEGREE_TO_RADIANT) * -1; - - // if (res < 0) - // res += 360; - - return res; + return static_cast(atan2(lon, phi) / ROUTE_DEGREE_TO_RADIANT) * -1; } -int16_t Point::courseTo(const Point &point) const { +int16_t Point::courseTo(const Point &point) const +{ return this->courseTo(point.getCoordinates()); } -void Point::init(uint32_t horizontalAccuracy, uint32_t creationTime) { +void Point::init(uint32_t horizontalAccuracy, uint32_t creationTime) +{ this->creationTime = creationTime; if (horizontalAccuracy == UINT32_MAX) + { this->accuracy = Accuracy::imported; + } else if (horizontalAccuracy > 9999) + { this->accuracy = Accuracy::fourDigOfCM; + } else if (horizontalAccuracy > 999) + { this->accuracy = Accuracy::threeDigOfCM; + } else if (horizontalAccuracy > 99) + { this->accuracy = Accuracy::twoDigOfCM; + } else if (horizontalAccuracy > 1) + { this->accuracy = Accuracy::oneDigOfCM; - else - this->accuracy = Accuracy::none; + } + else + { + this->accuracy = Accuracy::none; + } } diff --git a/lib/Point/point.h b/lib/Point/point.h index 9b7072e..3cc4862 100644 --- a/lib/Point/point.h +++ b/lib/Point/point.h @@ -1,139 +1,142 @@ /** * @file point.h * @author Alexander Klein (alex@kleiax.de) - * @brief + * @brief * @version 0.1 * @date 2023-09-03 - * + * * @copyright Copyright (c) 2023 - * + * */ #ifndef POINT_H #define POINT_H -#include +#include #define ROUTE_DEGREE_TO_RADIANT 0.01745 #define ROUTE_DISTANCE_BETWEEN_LATITUDE 111300 /** * @brief A to handle points on the earth - * + * * The points inherits latidue and longitude as doubles - * + * */ -class Point{ - public: - /** - * @brief Hold the data longitude and latitude - * - */ - struct Coordinates { - double lon; - double lat; +class Point +{ +public: + /** + * @brief Hold the data longitude and latitude + * + */ + struct Coordinates + { + double lon; + double lat; - bool operator==(const Coordinates rhs) const { - return ( this->lon == rhs.lon ) && ( this->lon == rhs.lon ); - } - }; + bool operator==(const Coordinates rhs) const + { + return (this->lon == rhs.lon) && (this->lon == rhs.lon); + } + }; - /** - * @brief The Accuracy is set by the constructor - * - */ - enum Accuracy { - none, - fourDigOfCM, - threeDigOfCM, - twoDigOfCM, - oneDigOfCM, - imported - }; + /** + * @brief The Accuracy is set by the constructor + * + */ + enum Accuracy + { + none, + fourDigOfCM, + threeDigOfCM, + twoDigOfCM, + oneDigOfCM, + imported + }; + /** + * @brief Construct a new Point object + * + * @param lat latitude + * @param lon longitude + * @param horizontalAccuracy mm + * @param coords Coordinates + * @param imported if true than highest accuracy + */ + Point(double lat, double lon, uint32_t horizontalAccuracy = 0, uint32_t creationTime = 0); + Point(int32_t lat, int32_t lon, uint32_t horizontalAccuracy = 0, uint32_t creationTime = 0); + Point(Coordinates coords, uint32_t horizontalAccuracy = 0, uint32_t creationTime = 0); + Point(Coordinates coords, bool imported); + Point(); - /** - * @brief Construct a new Point object - * - * @param lat latitude - * @param lon longitude - * @param horizontalAccuracy mm - * @param coords Coordinates - * @param imported if true than highest accuracy - */ - Point(double lat, double lon, uint32_t horizontalAccuracy = 0, uint32_t creationTime = 0); - Point(int32_t lat, int32_t lon, uint32_t horizontalAccuracy = 0, uint32_t creationTime = 0); - Point(Coordinates coords, uint32_t horizontalAccuracy = 0, uint32_t creationTime = 0); - Point(Coordinates coords, bool imported); - Point(); + /** + * @brief Checks if to points are equal. + * + * @param rhs + * @return true + * @return false + */ + bool operator==(const Point &rhs) const; - /** - * @brief Checks if to points are equal. - * - * @param rhs - * @return true - * @return false - */ - bool operator==(const Point& rhs) const; + /** + * @brief Checks if the point is initalized. + * + * @return true + * @return false + */ + bool isInit() const { return this->coordinates.lat + this->coordinates.lon; } - /** - * @brief Checks if the point is initalized. - * - * @return true - * @return false - */ - bool isInit() const { return this->coordinates.lat + this->coordinates.lon; } + /** + * @brief Checks if the point is valid. + * + * If the accuracy is higher than zero, true will be returned. + * + * @return true + * @return false + */ + bool isValid() const { return (this->accuracy > 0) ? true : false; } - /** - * @brief Checks if the point is valid. - * - * If the accuracy is higher than zero, true will be returned. - * - * @return true - * @return false - */ - bool isValid() const { return (this->accuracy > 0) ? true : false; } + /** + * @brief Calculates the distance between to points. + * + * @param point + * @return double meter + */ + double distanceTo(const Coordinates &point) const; + double distanceTo(const Point &point) const; - /** - * @brief Calculates the distance between to points. - * - * @param point - * @return double meter - */ - double distanceTo(const Coordinates& point) const; - double distanceTo(const Point& point) const; + /** + * @brief Calculates the course to an other point. + * + * @param point + * @return int16_t degree + */ + int16_t courseTo(const Coordinates &point) const; + int16_t courseTo(const Point &point) const; - /** - * @brief Calculates the course to an other point. - * - * @param point - * @return int16_t degree - */ - int16_t courseTo(const Coordinates& point) const; - int16_t courseTo(const Point& point) const; + uint32_t getCreationTime() const { return this->creationTime; } + double getLongitude() const { return this->coordinates.lon; } + double getLatitude() const { return this->coordinates.lat; } + Coordinates getCoordinates() const { return this->coordinates; } - uint32_t getCreationTime() const { return this->creationTime; } - double getLongitude() const { return this->coordinates.lon; } - double getLatitude() const { return this->coordinates.lat; } - Coordinates getCoordinates() const { return this->coordinates; } + /** + * @brief Get the Accuracy object + * + * The higher the value, the greater the accuracy. + * You can check it by Accuracy. + * + * @return Accuracy + */ + Accuracy getAccuracy() const { return this->accuracy; } - /** - * @brief Get the Accuracy object - * - * The higher the value, the greater the accuracy. - * You can check it by Accuracy. - * - * @return Accuracy - */ - Accuracy getAccuracy() const { return this->accuracy; } +private: + void init(uint32_t horizontalAccuracy, uint32_t creationTime); - private: - void init(uint32_t horizontalAccuracy, uint32_t creationTime); + Accuracy accuracy = Accuracy::none; + Coordinates coordinates{0, 0}; - Accuracy accuracy = Accuracy::none; - Coordinates coordinates; - - uint32_t creationTime = 0; + uint32_t creationTime = 0; }; -#endif //POINT_H +#endif // POINT_H diff --git a/lib/Route/route.cpp b/lib/Route/route.cpp index 65d2cf2..d79b5e8 100644 --- a/lib/Route/route.cpp +++ b/lib/Route/route.cpp @@ -4,29 +4,29 @@ * @brief Implements the class Route and Point * @version 0.1 * @date 2022-01-31 - * + * * @copyright Copyright (c) 2022 - * + * */ #include "route.h" -Route::Route() { - -} - -void Route::addPointToRoute(Point point) { +void Route::addPointToRoute(Point point) +{ this->points.push_back(point); } -void Route::clear() { +void Route::clear() +{ this->points.clear(); this->currentPoint = 0; this->started = false; } -Point Route::startRoute() { - if (this->points.size() < 1) { +Point Route::startRoute() +{ + if (this->points.empty()) + { this->started = false; return Point(); } @@ -37,8 +37,10 @@ Point Route::startRoute() { return *this->it; } -Point Route::endRoute() { - if (this->points.size() < 1) { +Point Route::endRoute() +{ + if (this->points.empty()) + { this->started = false; return Point(); } @@ -51,37 +53,47 @@ Point Route::endRoute() { return *this->it; } -Point Route::getNextPoint() { +Point Route::getNextPoint() +{ + Point point; if (!this->started) - return Point(); + { + return point; + } - if (this->it != --this->points.end()) { + if (this->it != --this->points.end()) + { this->it++; this->currentPoint++; return *this->it; - // } else if (this->it == this->points.end() && this->currentPoint != this->points.size()) { - // this->currentPoint++; - // return *this->it; + // } else if (this->it == this->points.end() && this->currentPoint != this->points.size()) { + // this->currentPoint++; + // return *this->it; } - - return Point(); + + return point; } -Point Route::getPreviousPoint() { +Point Route::getPreviousPoint() +{ + Point point; if (!this->started) - return Point(); - - if (this->it != this->points.begin()) { + { + return point; + } + + if (this->it != this->points.begin()) + { this->it--; this->currentPoint--; return *this->it; - } else { - return Point(); } + return point; } -RouteInfo Route::getRouteInfo() { - RouteInfo info; +RouteInfo Route::getRouteInfo() +{ + RouteInfo info{0, 0}; info.totalPoints = this->points.size(); info.currentPoint = this->currentPoint; return info; diff --git a/lib/Route/route.h b/lib/Route/route.h index ab751b7..7b38315 100644 --- a/lib/Route/route.h +++ b/lib/Route/route.h @@ -40,11 +40,6 @@ struct RouteInfo{ */ class Route { public: - /** - * @brief Construct a new Route object. - */ - Route(); - /** * @brief Adds a point to the list. * diff --git a/lib/Sensors/sensorData.cpp b/lib/Sensors/sensorData.cpp index 7c62193..b80c8ac 100644 --- a/lib/Sensors/sensorData.cpp +++ b/lib/Sensors/sensorData.cpp @@ -1,30 +1,32 @@ /** * @file senors.cpp * @author Alexander Klein (alex@kleiax.de) - * @brief + * @brief * @version 0.1 * @date 2023-09-02 - * + * * @copyright Copyright (c) 2023 - * + * */ #include "sensorData.h" bool SensorData::outputStatusPrintPVTdata = false; uint32_t SensorData::ubxUpdateTimeStatic = 0; -UBX_NAV_PVT_data_t* SensorData::ubxDataStatic = nullptr; +UBX_NAV_PVT_data_t *SensorData::ubxDataStatic = nullptr; -SensorData::SensorData() { - this->loopDelay = 50; +SensorData::SensorData() +{ + Component::loopDelay = SensorData::loopDelay; } -SensorData::~SensorData() { - if (this->ntripClient) - delete this->ntripClient; +SensorData::~SensorData() +{ + delete this->ntripClient; } -void SensorData::enableNtrip(String host, uint16_t port, String mountPoint, String user, String password) { +void SensorData::enableNtrip(String host, uint16_t port, String mountPoint, String user, String password) +{ this->ntripClient = new NTRIPClient(this->gnss, host.c_str(), port, mountPoint.c_str(), user.c_str(), password.c_str()); this->ntripClient->gpsConfiguration(); this->ntripClient->loop(); @@ -33,120 +35,176 @@ void SensorData::enableNtrip(String host, uint16_t port, String mountPoint, Stri this->addChildComponent(this->ntripClient); } -void SensorData::enableGnss(SPIClass* spiPort, uint8_t csPin) { +void SensorData::enableGnss(SPIClass *spiPort, uint8_t csPin) +{ this->gnss = new SFE_UBLOX_GNSS(); - if (this->gnss->begin(*spiPort, csPin, 4000000) == false) { + if (this->gnss->begin(*spiPort, csPin, 4000000) == false) + { std::cout << "u-blox GNSS not detected on SPI bus. Please check wiring. Freezing." << std::endl; - while (1); + while (true) + { + } } this->initGnss(); } -void SensorData::enableGnss() { +void SensorData::enableGnss() +{ this->gnss = new SFE_UBLOX_GNSS(); - if (this->gnss->begin() == false) { + if (this->gnss->begin() == false) + { std::cout << "u-blox GNSS not detected at default I2C address. Please check wiring. Freezing." << std::endl; - while (1); + while (true) + { + } } this->initGnss(); } -void SensorData::enableRealCompass() { +void SensorData::enableRealCompass() +{ + static constexpr byte address = 0x0d; + this->realCompass = new QMC5883LCompass(); // Init Compass - Wire.beginTransmission(0x0d); + Wire.beginTransmission(address); + // TODO: describe Bytes !!! Wire.write(0x0b); Wire.write(0x01); Wire.endTransmission(); - this->realCompass->setMode(0x01,0x0C,0x10,0X00); + this->realCompass->setMode(0x01, 0x0C, 0x10, 0X00); CalibrateCompass caliCompass(this->realCompass); caliCompass.loadData(); caliCompass.useData(); } -void SensorData::enableCalcCompass() { - +void SensorData::enableCalcCompass() +{ + // TODO: !!! implementieren } -void SensorData::enableGyroskop() { +void SensorData::enableGyroskop() +{ this->gyroskop = new MPU6050(); this->gyroskop->initialize(); - if (!this->gyroskop->testConnection()) { + if (!this->gyroskop->testConnection()) + { std::cout << "SensorData::enableGyroskop: Gyroskop is not conntected. Freeze!" << std::endl; - while (true); + while (true) + { + } } - uint8_t deviceStatus = this->gyroskop->dmpInitialize(); + const uint8_t deviceStatus = this->gyroskop->dmpInitialize(); + // TODO: !!! MagicNumer 6x this->gyroskop->setXGyroOffset(220); this->gyroskop->setYGyroOffset(76); this->gyroskop->setZGyroOffset(-85); this->gyroskop->setZAccelOffset(1788); - - if (deviceStatus == 0) { + + if (deviceStatus == 0) + { this->gyroskop->CalibrateAccel(6); this->gyroskop->CalibrateGyro(6); this->gyroskop->PrintActiveOffsets(); this->gyroskop->setDMPEnabled(true); - } else { + } + else + { // ERROR! // 1 = initial memory load failed // 2 = DMP configuration updates failed // (if it's going to break, usually the code will be 1) - std::cout << "SensorData::enableGyroskop: DMP Initialization failed (code" << (int) deviceStatus <<"). Freeze!" << std::endl; - while (true); + std::cout << "SensorData::enableGyroskop: DMP Initialization failed (code" << static_cast(deviceStatus) << "). Freeze!" << std::endl; + while (true) + { + } } } -CalcAzimuth::State SensorData::getCalcAzimuthState() const { - if (this->calcCompass) +CalcAzimuth::State SensorData::getCalcAzimuthState() const +{ + if (static_cast(this->calcCompass)) + { return this->calcCompass->getState(); + } return CalcAzimuth::State::Invalid; } -NTRIPClientStates SensorData::getNtripState() const { - if (this->ntripClient) +NTRIPClientStates SensorData::getNtripState() const +{ + if (static_cast(this->ntripClient)) + { return this->ntripClient->getClientState(); + } return NTRIPClientStates::notAvailable; } -void SensorData::printPVTdata(UBX_NAV_PVT_data_t *ubxDataStruct) { +void SensorData::printPVTdata(UBX_NAV_PVT_data_t *ubxDataStruct) +{ + static constexpr uint8_t stringSize = 32; + if (!SensorData::outputStatusPrintPVTdata) + { return; + } - double latitude = (double) ubxDataStruct->lat / 10000000.0; - double longitude = (double) ubxDataStruct->lon / 10000000.0; - double altitude = (double) ubxDataStruct->hMSL / 1000.0; + const double latitude = ubxDataStruct->lat / 10000000.0; + const double longitude = ubxDataStruct->lon / 10000000.0; + const double altitude = ubxDataStruct->hMSL / 1000.0; - uint8_t fixType = ubxDataStruct->fixType; - char fixTypeString[32]; + const uint8_t fixType = ubxDataStruct->fixType; + char fixTypeString[stringSize]; if (fixType == 0) - strcpy(fixTypeString, "None"); + { + strcpy(fixTypeString, static_cast("None")); + } else if (fixType == 1) - strcpy(fixTypeString, "Dead Reckoning"); + { + strcpy(fixTypeString, static_cast("Dead Reckoning")); + } else if (fixType == 2) - strcpy(fixTypeString, "2D"); + { + strcpy(fixTypeString, static_cast("2D")); + } else if (fixType == 3) - strcpy(fixTypeString, "3D"); + { + strcpy(fixTypeString, static_cast("3D")); + } else if (fixType == 3) - strcpy(fixTypeString, "GNSS + Dead Reckoning"); + { + strcpy(fixTypeString, static_cast("GNSS + Dead Reckoning")); + } else if (fixType == 5) - strcpy(fixTypeString, "Time Only"); + { + strcpy(fixTypeString, static_cast("Time Only")); + } else - strcpy(fixTypeString, "UNKNOWN"); + { + strcpy(fixTypeString, static_cast("UNKNOWN")); + } - uint8_t carrSoln = ubxDataStruct->flags.bits.carrSoln; - char carrSolnString[16]; + const uint8_t carrSoln = ubxDataStruct->flags.bits.carrSoln; + char carrSolnString[stringSize]; if (carrSoln == 0) - strcpy(carrSolnString, "None"); + { + strcpy(carrSolnString, static_cast("None")); + } else if (carrSoln == 1) - strcpy(carrSolnString, "Floating"); + { + strcpy(carrSolnString, static_cast("Floating")); + } else if (carrSoln == 2) - strcpy(carrSolnString, "Fixed"); + { + strcpy(carrSolnString, static_cast("Fixed")); + } else - strcpy(carrSolnString, "UNKNOWN"); + { + strcpy(carrSolnString, static_cast("UNKNOWN")); + } - uint32_t hAcc = ubxDataStruct->hAcc; + const uint32_t hAcc = ubxDataStruct->hAcc; std::cout << "Lat: " << latitude << " Lng: " << longitude @@ -157,45 +215,53 @@ void SensorData::printPVTdata(UBX_NAV_PVT_data_t *ubxDataStruct) { << " Horizontal Accuracy Estimate: " << hAcc << " mm" << std::endl; } -void SensorData::savePVTdata(UBX_NAV_PVT_data_t *ubxDataStruct) { +void SensorData::savePVTdata(UBX_NAV_PVT_data_t *ubxDataStruct) +{ SensorData::printPVTdata(ubxDataStruct); SensorData::ubxDataStatic = ubxDataStruct; SensorData::ubxUpdateTimeStatic = millis(); } -void SensorData::setOutputStatusPrintPVTdata(bool status) { +void SensorData::setOutputStatusPrintPVTdata(bool status) +{ SensorData::outputStatusPrintPVTdata = status; } -void SensorData::run() { - if (this->realCompass) { +void SensorData::run() +{ + if (static_cast(this->realCompass)) + { this->realCompass->read(); this->realAzimuth = this->realCompass->getAzimuth(); } - if (this->gyroskop - && this->gyroskop->dmpGetCurrentFIFOPacket(this->gyroBuffer)) + if (static_cast(this->gyroskop) && this->gyroskop->dmpGetCurrentFIFOPacket(static_cast(this->gyroBuffer))) { - this->gyroskop->dmpGetQuaternion(&this->quaternion, this->gyroBuffer); + this->gyroskop->dmpGetQuaternion(&this->quaternion, static_cast(this->gyroBuffer)); this->gyroskop->dmpGetGravity(&this->gravity, &this->quaternion); - this->gyroskop->dmpGetYawPitchRoll(this->yawPitchRoll, &this->quaternion, &this->gravity); + this->gyroskop->dmpGetYawPitchRoll(static_cast(this->yawPitchRoll), &this->quaternion, &this->gravity); } } -void SensorData::runAsChild() { - if (this->gnss) { +void SensorData::runAsChild() +{ + if (static_cast(this->gnss)) + { this->gnss->checkUblox(); this->gnss->checkCallbacks(); if (SensorData::ubxUpdateTimeStatic != this->lastUbxUpdate) + { this->updateUbxData(); - } + } + } } -void SensorData::initGnss() { - uint8_t versionHigh = this->gnss->getProtocolVersionHigh(); - uint8_t versionLow = this->gnss->getProtocolVersionLow(); - std::cout << "u-blox protocol version: " << unsigned(versionHigh) << "." << unsigned(versionLow) << std::endl; +void SensorData::initGnss() +{ + const uint8_t versionHigh = this->gnss->getProtocolVersionHigh(); + const uint8_t versionLow = this->gnss->getProtocolVersionLow(); + std::cout << "u-blox protocol version: " << static_cast(versionHigh) << "." << static_cast(versionLow) << std::endl; this->gnss->setSPIOutput(COM_TYPE_UBX); this->gnss->enableNMEAMessage(UBX_NMEA_GGA, COM_PORT_SPI, 10); @@ -206,11 +272,12 @@ void SensorData::initGnss() { this->gnss->setAutoPVT(true); } -void SensorData::updateUbxData() { +void SensorData::updateUbxData() +{ this->gnssData = SensorData::ubxDataStatic; this->lastUbxUpdate = SensorData::ubxUpdateTimeStatic; - Point::Coordinates coords; + Point::Coordinates coords{0, 0}; coords.lat = this->gnssData->lat / 10000000.0; coords.lon = this->gnssData->lon / 10000000.0; diff --git a/lib/Sensors/sensorData.h b/lib/Sensors/sensorData.h index 29656e1..598e42c 100644 --- a/lib/Sensors/sensorData.h +++ b/lib/Sensors/sensorData.h @@ -1,12 +1,12 @@ /** * @file sensorData.h * @author Alexander Klein (alex@kleiax.de) - * @brief + * @brief * @version 0.1 * @date 2023-09-02 - * + * * @copyright Copyright (c) 2023 - * + * */ #ifndef SENSOR_DATA_H @@ -28,84 +28,86 @@ #include "point.h" class Sensors; -class SensorData : public Component { - public: - SensorData(); - ~SensorData(); - - void enableNtrip(String host, uint16_t port, String mountPoint, String user, String password); - void enableGnss(SPIClass* spiPort, uint8_t csPin); - void enableGnss(); - void enableRealCompass(); - void enableCalcCompass(); - void enableGyroskop(); +class SensorData : public Component +{ +public: + SensorData(); + ~SensorData(); - // Interface Const kram - int16_t getRealAzimuth() const { return this->realAzimuth; } - int16_t getCalcAzimuth() const { return this->calcAzimuth; } - CalcAzimuth::State getCalcAzimuthState() const; + void enableNtrip(String host, uint16_t port, String mountPoint, String user, String password); + void enableGnss(SPIClass *spiPort, uint8_t csPin); + void enableGnss(); + void enableRealCompass(); + void enableCalcCompass(); + void enableGyroskop(); - Point getCurrentPos() const { return this->currentPosition; } - const UBX_NAV_PVT_data_t* getGnssData() const { return this->gnssData; }; - NTRIPClientStates getNtripState() const; - const float* getGyroData() const { return this->yawPitchRoll; } + // Interface Const kram + int16_t getRealAzimuth() const { return this->realAzimuth; } + int16_t getCalcAzimuth() const { return this->calcAzimuth; } + CalcAzimuth::State getCalcAzimuthState() const; - CalcAzimuth* getCalcCompass() const { return this->calcCompass; } - QMC5883LCompass* getRealCompass() const { return this->realCompass; } - NTRIPClient* getNtripClient() const { return this->ntripClient; } - MPU6050* getGyroskop() const { return this->gyroskop; } + Point getCurrentPos() const { return this->currentPosition; } + const UBX_NAV_PVT_data_t *getGnssData() const { return this->gnssData; }; + NTRIPClientStates getNtripState() const; + const float *getGyroData() const { return this->yawPitchRoll; } - // static - /** - * @brief Set the output status for PVTdata. - * - * If this is true, a lot of information from the gnss module will be printed in - * the interval of navigation frequency. - * - * @param status - */ - static void setOutputStatusPrintPVTdata(bool status); + CalcAzimuth *getCalcCompass() const { return this->calcCompass; } + QMC5883LCompass *getRealCompass() const { return this->realCompass; } + NTRIPClient *getNtripClient() const { return this->ntripClient; } + MPU6050 *getGyroskop() const { return this->gyroskop; } - private: - void run() override; - void runAsChild() override; - void initGnss(); - void updateUbxData(); + // static + /** + * @brief Set the output status for PVTdata. + * + * If this is true, a lot of information from the gnss module will be printed in + * the interval of navigation frequency. + * + * @param status + */ + static void setOutputStatusPrintPVTdata(bool status); +private: + void run() override; + void runAsChild() override; + void initGnss(); + void updateUbxData(); - QMC5883LCompass* realCompass = nullptr; - CalcAzimuth* calcCompass = nullptr; - SFE_UBLOX_GNSS* gnss = nullptr; - NTRIPClient* ntripClient = nullptr; - MPU6050* gyroskop = nullptr; + QMC5883LCompass *realCompass = nullptr; + CalcAzimuth *calcCompass = nullptr; + SFE_UBLOX_GNSS *gnss = nullptr; + NTRIPClient *ntripClient = nullptr; + MPU6050 *gyroskop = nullptr; - UBX_NAV_PVT_data_t* gnssData; - Point currentPosition; - Quaternion quaternion; - VectorFloat gravity; + UBX_NAV_PVT_data_t *gnssData = nullptr; + Point currentPosition; + Quaternion quaternion; + VectorFloat gravity; - char* host; - char* mountPoint; - char* user; - char* password; - - bool isNtripInit = false; + char *host = nullptr; + char *mountPoint = nullptr; + char *user = nullptr; + char *password = nullptr; - uint8_t gyroBuffer[64]; - uint16_t port; - int16_t realAzimuth = INT16_MAX; - int16_t calcAzimuth = INT16_MAX; - uint32_t lastUbxUpdate = 0; + bool isNtripInit = false; - float yawPitchRoll[3] {0, 0, 0}; + uint8_t gyroBuffer[64]; + uint16_t port = 0; + int16_t realAzimuth = INT16_MAX; + int16_t calcAzimuth = INT16_MAX; + uint32_t lastUbxUpdate = 0; - // static - static void printPVTdata(UBX_NAV_PVT_data_t *ubxDataStruct); - static void savePVTdata(UBX_NAV_PVT_data_t *ubxDataStruct); + float yawPitchRoll[3]{0, 0, 0}; - static UBX_NAV_PVT_data_t* ubxDataStatic; - static uint32_t ubxUpdateTimeStatic; - static bool outputStatusPrintPVTdata; + // static + static void printPVTdata(UBX_NAV_PVT_data_t *ubxDataStruct); + static void savePVTdata(UBX_NAV_PVT_data_t *ubxDataStruct); + + static UBX_NAV_PVT_data_t *ubxDataStatic; + static uint32_t ubxUpdateTimeStatic; + static bool outputStatusPrintPVTdata; + + static constexpr uint8_t loopDelay = 50; }; -#endif //SENSOR_DATA_H +#endif // SENSOR_DATA_H diff --git a/lib/Speedometer/speedometer.cpp b/lib/Speedometer/speedometer.cpp index 7132b56..703aa13 100644 --- a/lib/Speedometer/speedometer.cpp +++ b/lib/Speedometer/speedometer.cpp @@ -5,18 +5,16 @@ * @see speedometer.h * @version 0.1 * @date 2021-12-13 - * + * * @copyright Copyright (c) 2021 - * + * */ #include "speedometer.h" -Speedometer::Speedometer(uint8_t pin, double diameter, uint16_t steps) { - this->diameter = diameter; - this->steps = steps; - - this->pulseCounter = new Counter(pin); - this->pulseCounter->setFilterValue(1023); // ignore pulses less than 1000 x 2.5ns +Speedometer::Speedometer(uint8_t pin, double diameter, uint16_t steps) + : pulseCounter{new Counter(pin)}, diameter{diameter}, steps{steps}, buf{} +{ + this->pulseCounter->setFilterValue(Speedometer::maxFilterValue); // ignore pulses less than 1000 x 2.5ns this->pulseCounter->clear(); this->pulseCounter->resume(); @@ -26,105 +24,131 @@ Speedometer::Speedometer(uint8_t pin, double diameter, uint16_t steps) { this->clearAvgBuf(); } -Speedometer::~Speedometer() { +Speedometer::~Speedometer() +{ delete this->pulseCounter; } -void Speedometer::run() { +void Speedometer::run() +{ + static constexpr float minimalSpeed = 0.1; + if (this->calibrationRunning) + { return; + } - uint32_t time = millis(); + const uint32_t time = millis(); - uint16_t elapsedTime = time - this->lastMillisCalc; + const uint16_t elapsedTime = time - this->lastMillisCalc; this->lastMillisCalc = time; - int16_t pulse = this->pulseCounter->getValue(); + const double pulse = this->pulseCounter->getValue(); this->pulseCounter->clear(); this->pulseCounter->resume(); - - double n = (double)pulse / this->steps; // Wheel revolutions in absolute time - double u = n / ((double)elapsedTime / 1000); // Wheel revolutions per second - double ms = u * (diameter * PI); // Speed in m/s - double rad = u * 2 * PI; + const double wheelRevolutionsAbsolute = pulse / this->steps; + const double wheelRevolutionsRelativ = wheelRevolutionsAbsolute / (elapsedTime / 1000.0); - if (speed < 0.1) { - speed = 0; - rad = 0; + double meterPerSecond = wheelRevolutionsRelativ * (diameter * PI); + double radPerSecond = wheelRevolutionsRelativ * 2 * PI; + + if (meterPerSecond < minimalSpeed) + { + meterPerSecond = 0; + radPerSecond = 0; } - switch (this->currentDirection) { - case Direction::Forward : - this->speed = ms; - this->rad = rad; - break; - - case Direction::Backward : - this->speed = -ms; - this->rad = -rad; - break; + switch (this->currentDirection) + { + case Direction::Forward: + this->speed = meterPerSecond; + this->rad = radPerSecond; + break; - case Direction::None : - this->speed = 0; - this->rad = 0; - break; + case Direction::Backward: + this->speed = -meterPerSecond; + this->rad = -radPerSecond; + break; + + case Direction::None: + this->speed = 0; + this->rad = 0; + break; } this->addValToBuf(static_cast(this->speed * Speedometer::conversionFactor)); } -void Speedometer::setDirection(Direction dir) { +void Speedometer::setDirection(Direction dir) +{ if (this->currentDirection == dir) + { return; + } this->currentDirection = dir; this->clearAvgBuf(); } -void Speedometer::setEncFilter(uint16_t val) { - if (val > 1023) - val = 1023; +void Speedometer::setEncFilter(uint16_t val) +{ + if (val > Speedometer::maxFilterValue) + { + val = Speedometer::maxFilterValue; + } this->pulseCounter->setFilterValue(val); } -double Speedometer::getAvgSpeed() const { - int16_t avg = this->calcAverage(); - return (float)avg / Speedometer::conversionFactor; +double Speedometer::getAvgSpeed() const +{ + const double avg = this->calcAverage(); + return avg / Speedometer::conversionFactor; } -void Speedometer::calibrationMeasurementStart() { +void Speedometer::calibrationMeasurementStart() +{ std::cout << "Start" << std::endl; this->calibrationRunning = true; this->pulseCounter->clear(); this->pulseCounter->resume(); } -uint16_t Speedometer::calibrationMeasurementStop() { +uint16_t Speedometer::calibrationMeasurementStop() +{ std::cout << "Ende" << std::endl; this->calibrationRunning = false; - uint16_t res = abs(this->pulseCounter->getValue()); + const uint16_t res = abs(this->pulseCounter->getValue()); this->pulseCounter->clear(); this->pulseCounter->resume(); std::cout << "Result: " << res << std::endl; return res; } -void Speedometer::clearAvgBuf() { - for (uint8_t i = 0; i < bufSize; i++) +void Speedometer::clearAvgBuf() +{ + for (uint8_t i = 0; i < bufSize; i++) + { this->buf[i] = 0; + } } -void Speedometer::addValToBuf(int16_t val) { +void Speedometer::addValToBuf(int16_t val) +{ this->buf[this->bufPos] = val; this->bufPos++; if (bufPos == bufSize) - bufPos = 0; + { + bufPos = 0; + } } -int16_t Speedometer::calcAverage() const { +int16_t Speedometer::calcAverage() const +{ int16_t sum = 0; - for (int i = 0; i < this->bufSize; i++) + for (int i = 0; i < Speedometer::bufSize; i++) + { sum += this->buf[i]; - return sum / this->bufSize; + } + return sum / Speedometer::bufSize; } diff --git a/lib/Speedometer/speedometer.h b/lib/Speedometer/speedometer.h index a1635fb..87ff979 100644 --- a/lib/Speedometer/speedometer.h +++ b/lib/Speedometer/speedometer.h @@ -4,9 +4,9 @@ * @brief A implementation to measure wheel speeds with an encoder. * @version 0.1 * @date 2021-12-09 - * + * * @copyright Copyright (c) 2021 - * + * */ #ifndef SPEEDOMETER_H @@ -21,114 +21,115 @@ /** * @brief A class which use a encoder to calc the speed - * + * * This class use ESP32 pulse counter hardware peripheral. * The calculated speed is the average of an amount of last measurements. - * + * */ -class Speedometer : public Component { - public: - /** - * @brief Enum to control the direction. - * - * If the Direction is Forward, the internal counter counts up and a positiv speed will be returned. - * If the Direction is Backward, the internal counter counts down and a negativ speed will be returned. - * If the Direction is None, no measurement will be taken. - */ - enum Direction { - None, - Forward, - Backward - }; +class Speedometer : public Component +{ +public: + /** + * @brief Enum to control the direction. + * + * If the Direction is Forward, the internal counter counts up and a positiv speed will be returned. + * If the Direction is Backward, the internal counter counts down and a negativ speed will be returned. + * If the Direction is None, no measurement will be taken. + */ + enum Direction + { + None, + Forward, + Backward + }; - /** - * @brief Construct a new Speedometer object - * - * @param pin Pin on the Esp from the encoder. - * @param diameter Diameter of the wheel in meters. - * @param steps Encodersteps for a complete wheel rotation. - */ - Speedometer(uint8_t pin, double diameter, uint16_t steps); + /** + * @brief Construct a new Speedometer object + * + * @param pin Pin on the Esp from the encoder. + * @param diameter Diameter of the wheel in meters. + * @param steps Encodersteps for a complete wheel rotation. + */ + Speedometer(uint8_t pin, double diameter, uint16_t steps); - ~Speedometer(); + ~Speedometer(); - /** - * @brief Set the direction - * - * @param dir Direction - */ - void setDirection(Direction dir); + /** + * @brief Set the direction + * + * @param dir Direction + */ + void setDirection(Direction dir); - /** - * @brief Set the Enc Filter to prevent bouncing - * - * ignore pulses less than val x 2.5ns - * - * @param val default = 1000, max = 1023 - */ - void setEncFilter(uint16_t val); + /** + * @brief Set the Enc Filter to prevent bouncing + * + * ignore pulses less than val x 2.5ns + * + * @param val default = 1000, max = 1023 + */ + void setEncFilter(uint16_t val); - /** - * @brief Get the Direction - * - * @return Direction - */ - Direction getDirection() const { return this->currentDirection; } + /** + * @brief Get the Direction + * + * @return Direction + */ + Direction getDirection() const { return this->currentDirection; } - /** - * @brief Get the calculated speed of the Wheel - * - * @return double speed in m/s - */ - double getSpeed() const { return this->speed; } - double getSpeedRad() const { return this->rad; }; - double getAvgSpeed() const; + /** + * @brief Get the calculated speed of the Wheel + * + * @return double speed in m/s + */ + double getSpeed() const { return this->speed; } + double getSpeedRad() const { return this->rad; }; + double getAvgSpeed() const; - /** - * @brief Start calibration - * - * This functions stops the loop. So that steps of one manual wheel turn - * can measured. Call calibrationMeasurementStop to start the loop and get - * the result. - */ - void calibrationMeasurementStart(); + /** + * @brief Start calibration + * + * This functions stops the loop. So that steps of one manual wheel turn + * can measured. Call calibrationMeasurementStop to start the loop and get + * the result. + */ + void calibrationMeasurementStart(); - /** - * @brief Stop calibration - * - * Start the loop function and read the past steps. - * - * @return uint16_t steps since calibrationMeasurementStart was called - */ - uint16_t calibrationMeasurementStop(); + /** + * @brief Stop calibration + * + * Start the loop function and read the past steps. + * + * @return uint16_t steps since calibrationMeasurementStart was called + */ + uint16_t calibrationMeasurementStop(); +private: + void run() override; + void clearAvgBuf(); + void addValToBuf(int16_t val); + int16_t calcAverage() const; - private: - void run() override; - void clearAvgBuf(); - void addValToBuf(int16_t val); - int16_t calcAverage() const; + static constexpr uint8_t loopDelay = 30; + static constexpr uint8_t bufSize = 5; + static constexpr uint8_t conversionFactor = 100; - static constexpr uint8_t loopDelay = 30; - static constexpr uint8_t bufSize = 5; - static constexpr uint8_t conversionFactor = 100; + Counter *pulseCounter; + Direction currentDirection = Direction::None; - Counter* pulseCounter; - Direction currentDirection = Direction::None; + bool calibrationRunning = false; - bool calibrationRunning = false; + double speed = 0; + double rad = 0; + double diameter; - double speed = 0; - double rad = 0; - double diameter; + uint8_t printCounter = 0; + uint8_t bufPos = 0; + uint16_t steps; + int16_t buf[Speedometer::bufSize]; + uint32_t lastMillisCalc = 0; - uint8_t printCounter = 0; - uint8_t bufPos = 0; - uint16_t steps; - - int16_t buf[Speedometer::bufSize]; - - uint32_t lastMillisCalc = 0; + static constexpr uint16_t maxFilterValue = 1023; }; #endif // SPEEDOMETER_H diff --git a/lib/Times/debugTimes.cpp b/lib/Times/debugTimes.cpp index 7490f5d..d94e856 100644 --- a/lib/Times/debugTimes.cpp +++ b/lib/Times/debugTimes.cpp @@ -4,42 +4,53 @@ * @brief Implemention of the class debugTimes.h. * @version 0.1 * @date 2021-12-13 - * + * * @copyright Copyright (c) 2021 - * + * */ #include "debugTimes.h" bool DebugTimes::print = false; bool DebugTimes::printWarning = true; -DebugTimes::DebugTimes() { - this->startTime = millis(); - - if (DebugTimes::printWarning) { - std::cout << std::endl << "Warning: DebugTimes is muuted, no times are be shown." << std::endl << std::endl; +DebugTimes::DebugTimes() + : startTime{millis()} +{ + if (DebugTimes::printWarning) + { + std::cout << std::endl + << "Warning: DebugTimes is muuted, no times are be shown." << std::endl + << std::endl; DebugTimes::printWarning = false; } } -void DebugTimes::restart() { +void DebugTimes::restart() +{ this->startTime = millis(); } -uint16_t DebugTimes::stop() { +const uint16_t DebugTimes::stop() +{ return millis() - this->startTime; } -uint16_t DebugTimes::stopConsol(const char* name, uint16_t minTime) { - uint64_t time = millis() - this->startTime; +const uint16_t DebugTimes::stopConsol(const char *name, uint16_t minTime) +{ + const uint64_t time = millis() - this->startTime; if (time > minTime && DebugTimes::print) + { std::cout << name << " needs " << time << " ms" << std::endl; + } return time; } -void DebugTimes::setConsolOutput(bool enable) { +void DebugTimes::setConsolOutput(bool enable) +{ if (enable == DebugTimes::print) + { return; + } DebugTimes::print = enable; DebugTimes::printWarning = !enable; diff --git a/lib/Times/debugTimes.h b/lib/Times/debugTimes.h index 9155429..5327a94 100644 --- a/lib/Times/debugTimes.h +++ b/lib/Times/debugTimes.h @@ -4,9 +4,9 @@ * @brief Inherits a class to measure times of functions. * @version 0.1 * @date 2021-12-13 - * + * * @copyright Copyright (c) 2021 - * + * */ #ifndef DEBUG_TIMES_H @@ -20,57 +20,58 @@ /** * @brief A class to measure times of functions. - * + * * This simple class only save the value of the millis() * function when you call the constructor or restart(). * To get the elapsed time call stop() or stopConsol(). - * + * * @warning This class is not very accurate * It only give you the time in milliseconds. */ -class DebugTimes { - public: - /** - * @brief Construct a new Debug Times object - * Starts to count milliseconds - */ +class DebugTimes +{ +public: + /** + * @brief Construct a new Debug Times object + * Starts to count milliseconds + */ - DebugTimes(); - /** - * @brief Set the counter to 0 - */ + DebugTimes(); + /** + * @brief Set the counter to 0 + */ - void restart(); + void restart(); - /** - * @brief Give the elapsed time - * - * @return uint16_t elapsed milliseconds - */ - uint16_t stop(); + /** + * @brief Give the elapsed time + * + * @return uint16_t elapsed milliseconds + */ + const uint16_t stop(); - /** - * @brief Print the elapsed time to consol - * - * @param name Functionname to print - * @param minTime A minimum time before printing - * - * @return uint16_t elapsed milliseconds - */ - uint16_t stopConsol(const char* name, uint16_t minTime = 0); + /** + * @brief Print the elapsed time to consol + * + * @param name Functionname to print + * @param minTime A minimum time before printing + * + * @return uint16_t elapsed milliseconds + */ + const uint16_t stopConsol(const char *name, uint16_t minTime = 0); - /** - * @brief Sets if the result should be printed. - * - * @param enable - */ - static void setConsolOutput(bool enable); + /** + * @brief Sets if the result should be printed. + * + * @param enable + */ + static void setConsolOutput(bool enable); - private: - uint64_t startTime; +private: + uint64_t startTime; - static bool print; - static bool printWarning; + static bool print; + static bool printWarning; }; -#endif //DEBUG_TIMES_H +#endif // DEBUG_TIMES_H diff --git a/lib/calibrateCompass/calibrateCompass.cpp b/lib/calibrateCompass/calibrateCompass.cpp index 43e3326..d618f38 100644 --- a/lib/calibrateCompass/calibrateCompass.cpp +++ b/lib/calibrateCompass/calibrateCompass.cpp @@ -12,8 +12,8 @@ #include "calibrateCompass.h" CalibrateCompass::CalibrateCompass(QMC5883LCompass *compass) + : compass{compass} { - this->compass = compass; this->state = State::Ready; this->clearData(); this->activateOnlyChilds(); @@ -29,9 +29,9 @@ void CalibrateCompass::runAsChild() bool changed = false; this->compass->read(); - int xAxis = this->compass->getX(); - int yAxis = this->compass->getY(); - int zAxis = this->compass->getZ(); + const int xAxis = this->compass->getX(); + const int yAxis = this->compass->getY(); + const int zAxis = this->compass->getZ(); if (xAxis < this->data.data[0][0]) { @@ -70,7 +70,9 @@ void CalibrateCompass::runAsChild() } if (changed) + { this->lastChange = millis(); + } if (millis() - this->lastChange > this->maxTimeWithoutChange) { @@ -182,23 +184,23 @@ void CalibrateCompass::checkDataValidity() sum += this->data.data[i][0]; sum += this->data.data[i][1]; } - this->dataValid = sum; + this->dataValid = static_cast(sum); } -std::ostream &operator<<(std::ostream &os, const CalibrateCompass &caliComp) +std::ostream &operator<<(std::ostream &stream, const CalibrateCompass &caliComp) { - os << "("; - os << caliComp.data.data[0][0]; - os << ", "; - os << caliComp.data.data[0][1]; - os << ", "; - os << caliComp.data.data[1][0]; - os << ", "; - os << caliComp.data.data[1][1]; - os << ", "; - os << caliComp.data.data[2][0]; - os << ", "; - os << caliComp.data.data[2][1]; - os << ")"; - return os; + stream << "("; + stream << caliComp.data.data[0][0]; + stream << ", "; + stream << caliComp.data.data[0][1]; + stream << ", "; + stream << caliComp.data.data[1][0]; + stream << ", "; + stream << caliComp.data.data[1][1]; + stream << ", "; + stream << caliComp.data.data[2][0]; + stream << ", "; + stream << caliComp.data.data[2][1]; + stream << ")"; + return stream; } diff --git a/lib/calibrateCompass/calibrateCompass.h b/lib/calibrateCompass/calibrateCompass.h index 72bffb0..9fc953c 100644 --- a/lib/calibrateCompass/calibrateCompass.h +++ b/lib/calibrateCompass/calibrateCompass.h @@ -1,12 +1,12 @@ /** * @file calibrateCompass.h * @author Alexander Klein (alex@kleiax.de) - * @brief + * @brief * @version 0.1 * @date 2023-05-23 - * + * * @copyright Copyright (c) 2023 - * + * */ #pragma once @@ -17,44 +17,47 @@ #include "component.h" -class CalibrateCompass : public Component { - public: - enum State { - Ready, - Calibrating, - Finished - }; +class CalibrateCompass : public Component +{ +public: + enum State + { + Ready, + Calibrating, + Finished + }; - struct CallibrationData { - int data[3][2]; - }; + struct CallibrationData + { + int data[3][2]; + }; - CalibrateCompass(QMC5883LCompass* compass); + CalibrateCompass(QMC5883LCompass *compass); - void start(); - void useData(); - void removeCalibration(); - void reset(); - void saveData(); - void loadData(); + void start(); + void useData(); + void removeCalibration(); + void reset(); + void saveData(); + void loadData(); - State getState() const { return this->state; } - CallibrationData getCallibrationData() const { return this->data; } + State getState() const { return this->state; } + CallibrationData getCallibrationData() const { return this->data; } - friend std::ostream& operator<<(std::ostream& os, const CalibrateCompass& caliComp); + friend std::ostream &operator<<(std::ostream &stream, const CalibrateCompass &caliComp); - private: - void runAsChild() override; - void run() override; - void checkDataValidity(); +private: + void runAsChild() override; + void run() override; + void checkDataValidity(); - QMC5883LCompass* compass; - State state; - CallibrationData data; + QMC5883LCompass *compass; + State state = State::Ready; + CallibrationData data{}; - void clearData(); + void clearData(); - bool dataValid = false; - const uint16_t maxTimeWithoutChange = 10000; - uint32_t lastChange = 0; + bool dataValid = false; + const uint16_t maxTimeWithoutChange = 10000; + uint32_t lastChange = 0; }; diff --git a/src/OutputBuf/outputBuf.cpp b/src/OutputBuf/outputBuf.cpp index 1e761d0..c33c288 100644 --- a/src/OutputBuf/outputBuf.cpp +++ b/src/OutputBuf/outputBuf.cpp @@ -4,56 +4,73 @@ * @brief Contains the implementation of the class OutputBufMqtt * @version 0.1 * @date 2022-02-14 - * + * * @copyright Copyright (c) 2022 - * + * */ #include "OutputBuf/outputBuf.h" -OutputBuf::OutputBuf(DebugMqtt* debugMqtt, BluetoothSerial* serialBT) - : std::streambuf() { - this->debugMqtt = debugMqtt; - this->serialBT = serialBT; - - if (debugMqtt) +OutputBuf::OutputBuf(DebugMqtt *debugMqtt, BluetoothSerial *serialBT) + : debugMqtt{debugMqtt}, serialBT{serialBT} +{ + if (static_cast(debugMqtt)) + { this->isMqttActive = true; + } - if (serialBT) + if (static_cast(serialBT)) + { this->isMqttActive = true; + } } -void OutputBuf::activateMqtt(bool status) { - if (debugMqtt) +void OutputBuf::activateMqtt(bool status) +{ + if (static_cast(debugMqtt)) + { this->isMqttActive = status; + } } -void OutputBuf::activateSerialBT(bool status) { - if (serialBT) +void OutputBuf::activateSerialBT(bool status) +{ + if (static_cast(serialBT)) + { this->isSerialBTActive = status; + } } -void OutputBuf::setDebugMqtt(DebugMqtt* debugMqtt) { +void OutputBuf::setDebugMqtt(DebugMqtt *debugMqtt) +{ this->debugMqtt = debugMqtt; this->isMqttActive = true; } -void OutputBuf::setSerialBT(BluetoothSerial* serialBT) { +void OutputBuf::setSerialBT(BluetoothSerial *serialBT) +{ this->serialBT = serialBT; - this->isSerialBTActive = true;; + this->isSerialBTActive = true; + ; } -std::streambuf::int_type OutputBuf::overflow(std::streambuf::int_type c) { - if (c != EOF) { +std::streambuf::int_type OutputBuf::overflow(std::streambuf::int_type character) +{ + if (character != EOF) + { // c = std::toupper(static_cast(c), getloc()); if (this->debugMqtt && this->isMqttActive) - this->debugMqtt->addCharacter((char) c); + { + this->debugMqtt->addCharacter(static_cast(character)); + } if (this->serialBT && this->isSerialBTActive && this->serialBT->connected()) - this->serialBT->print((char) c); + { + this->serialBT->print(static_cast(character)); + } - Serial.print((char) c); + Serial.print(static_cast(character)); } - return c; + return character; } diff --git a/src/SpecialMenus/CalibrateBattery/menuCalibrateBattery.cpp b/src/SpecialMenus/CalibrateBattery/menuCalibrateBattery.cpp index b9ded0a..ca8b0ff 100644 --- a/src/SpecialMenus/CalibrateBattery/menuCalibrateBattery.cpp +++ b/src/SpecialMenus/CalibrateBattery/menuCalibrateBattery.cpp @@ -1,59 +1,70 @@ /** * @file menuCalibrateBattery.cpp * @author Alexander Klein (alex@kleiax.de) - * @brief + * @brief * @version 0.1 * @date 2023-09-26 - * + * * @copyright Copyright (c) 2023 - * + * */ #include "menuCalibrateBattery.h" -MenuCalibrateBattery::MenuCalibrateBattery(Battery* battery) { - this->setUpdateDelay(400); - this->battery = battery; +MenuCalibrateBattery::MenuCalibrateBattery(Battery *battery) + : battery{battery} +{ + this->setUpdateDelay(MenuCalibrateBattery::updateDelay); } -void MenuCalibrateBattery::printMenu() { +void MenuCalibrateBattery::printMenu() +{ if (this->battery->getCalibrationState() == Battery::CalibrationState::None) + { this->battery->startCalibration(); + } String lineOne = ""; String lineTwo = ""; - switch (this->battery->getCalibrationState()) { - case Battery::CalibrationState::Waiting: - lineOne = "Target Voltage:"; - lineTwo = "7 + "; - lineTwo.concat(this->battery->getCurrentCalibrationVoltage()); - lineTwo.concat(" / 10"); - break; + switch (this->battery->getCalibrationState()) + { + case Battery::CalibrationState::Waiting: + lineOne = "Target Voltage:"; + lineTwo = "7 + "; + lineTwo.concat(this->battery->getCurrentCalibrationVoltage()); + lineTwo.concat(" / 10"); + break; - case Battery::CalibrationState::Reading: - lineOne = "Reading..."; - break; + case Battery::CalibrationState::Reading: + lineOne = "Reading..."; + break; - case Battery::CalibrationState::Finished: - lineOne = "Finished!"; - break; - - default: - break; + case Battery::CalibrationState::Finished: + lineOne = "Finished!"; + break; + + default: + break; } this->print(lineOne, lineTwo); } -void MenuCalibrateBattery::left() { +void MenuCalibrateBattery::left() +{ this->battery->finishCalibration(); - if (parentMenu) + if (static_cast(parentMenu)) + { this->parentMenu->printMenu(); + } } -void MenuCalibrateBattery::right() { +void MenuCalibrateBattery::right() +{ if (this->battery->getCalibrationState() == Battery::CalibrationState::Waiting) + { this->battery->nextVoltageIsReady(); + } } diff --git a/src/SpecialMenus/CalibrateBattery/menuCalibrateBattery.h b/src/SpecialMenus/CalibrateBattery/menuCalibrateBattery.h index 89758eb..28ca45d 100644 --- a/src/SpecialMenus/CalibrateBattery/menuCalibrateBattery.h +++ b/src/SpecialMenus/CalibrateBattery/menuCalibrateBattery.h @@ -1,12 +1,12 @@ /** * @file menuCalibrateBattery.h * @author Alexander Klein (alex@kleiax.de) - * @brief + * @brief * @version 0.1 * @date 2023-09-26 - * + * * @copyright Copyright (c) 2023 - * + * */ #ifndef MENU_CALIBRATE_BATTERY_H @@ -15,19 +15,22 @@ #include "menuControl.h" #include "battery.h" -class MenuCalibrateBattery : public MenuControl { - public: - MenuCalibrateBattery(Battery* battery); +class MenuCalibrateBattery : public MenuControl +{ +public: + MenuCalibrateBattery(Battery *battery); - void printMenu() override; + void printMenu() override; - void left() override; - void no() override { this->left(); } - void right() override; - void yes() override { this->right(); } + void left() override; + void no() override { this->left(); } + void right() override; + void yes() override { this->right(); } - private: - Battery* battery; +private: + Battery *battery; + + static constexpr uint16_t updateDelay = 400; }; -#endif //MENU_CALIBRATE_BATTERY_H +#endif // MENU_CALIBRATE_BATTERY_H diff --git a/src/SpecialMenus/PID/menuPidSettings.cpp b/src/SpecialMenus/PID/menuPidSettings.cpp index f5f5c00..d85c9ac 100644 --- a/src/SpecialMenus/PID/menuPidSettings.cpp +++ b/src/SpecialMenus/PID/menuPidSettings.cpp @@ -4,19 +4,20 @@ * @brief Contains an implementation of the class MenuPidSettings * @version 0.1 * @date 2022-01-19 - * + * * @copyright Copyright (c) 2022 - * + * */ #include "menuPidSettings.h" -MenuPidSettings::MenuPidSettings(PID* pid) { - this->pid = pid; -} +MenuPidSettings::MenuPidSettings(PID *pid) : pid{pid} {} -void MenuPidSettings::action(int16_t* values, uint8_t length) { - if (length != 3) +void MenuPidSettings::action(int16_t *values, uint8_t length) +{ + if (length != 3) + { return; + } this->pid->SetTunings(values[0], values[1], values[2]); } diff --git a/src/SpecialMenus/Route/menuRoute.cpp b/src/SpecialMenus/Route/menuRoute.cpp index 875d505..183e17f 100644 --- a/src/SpecialMenus/Route/menuRoute.cpp +++ b/src/SpecialMenus/Route/menuRoute.cpp @@ -12,9 +12,8 @@ #include "menuRoute.h" MenuActionRoute::MenuActionRoute(MenuRoute *menuRoute, DataFunction dataFunction) + : menuRoute{menuRoute}, dataFunction{dataFunction} { - this->menuRoute = menuRoute; - this->dataFunction = dataFunction; } void MenuActionRoute::action() @@ -23,8 +22,8 @@ void MenuActionRoute::action() } MenuRoute::MenuRoute(Route *route) + : route{route} { - this->route = route; } MenuRoute::~MenuRoute() @@ -185,12 +184,12 @@ void MenuRoute::importRoute(uint8_t routeNumber) String host = "http://rover.kleiax.de/api/"; host.concat(routeNumber); http.begin(client, host); - int httpResponseCode = http.GET(); + const int httpResponseCode = http.GET(); lineOne = "Import complete"; lineTwo = "Code: "; - if (httpResponseCode == 202) + if (httpResponseCode == MenuRoute::httpValidImport) { deserializeJson(doc, http.getStream()); } @@ -231,7 +230,7 @@ void MenuRoute::exportRoute(uint8_t routeNumber) String lineOne = ""; String lineTwo = ""; - if (WiFi.status() != WL_CONNECTED) + if (WiFiSTAClass::status() != WL_CONNECTED) { lineOne = "Not connected to"; lineTwo = "the WiFi."; @@ -270,9 +269,9 @@ void MenuRoute::exportRoute(uint8_t routeNumber) http.begin(client, "http://rover.kleiax.de/api/"); http.addHeader("Content-Type", "application/json"); - int httpResponseCode = http.POST(jsonData); + const int httpResponseCode = http.POST(jsonData); - if (httpResponseCode == 201) + if (httpResponseCode == MenuRoute::httpValidExport) { lineOne = "Export complete"; } @@ -295,7 +294,7 @@ void MenuRoute::deleteRoute(uint8_t routeNumber) String lineOne = ""; String lineTwo = ""; - if (WiFi.status() != WL_CONNECTED) + if (WiFiSTAClass::status() != WL_CONNECTED) { lineOne = "Not connected to"; lineTwo = "the WiFi."; @@ -320,12 +319,12 @@ void MenuRoute::deleteRoute(uint8_t routeNumber) String host = "http://rover.kleiax.de/api/"; host.concat(routeNumber); http.begin(client, host); - int httpResponseCode = http.sendRequest("DELETE"); + const int httpResponseCode = http.sendRequest("DELETE"); lineOne = "Delete complete"; lineTwo = "Code: "; - if (httpResponseCode == 202) + if (httpResponseCode == MenuRoute::httpValidDelete) { deserializeJson(doc, http.getStream()); } @@ -343,16 +342,15 @@ void MenuRoute::deleteRoute(uint8_t routeNumber) void MenuRoute::clearRoute(uint8_t none) { - //The parameter exist only for compability + // The parameter exist only for compability none; this->route->clear(); this->print("Currente route", "deleted..."); } MenuRouteWrapper::MenuRouteWrapper(MenuRoute *menuRoute, DataFunction dataFunction) - : menuRoute {menuRoute}, dataFunction {dataFunction} + : menuRoute{menuRoute}, dataFunction{dataFunction} { - } void MenuRouteWrapper::action(int16_t *values, uint8_t length) diff --git a/src/SpecialMenus/Route/menuRoute.h b/src/SpecialMenus/Route/menuRoute.h index b53437b..7d6072f 100644 --- a/src/SpecialMenus/Route/menuRoute.h +++ b/src/SpecialMenus/Route/menuRoute.h @@ -4,9 +4,9 @@ * @brief Contains a classes to handles routes with the user input. * @version 0.1 * @date 2022-12-28 - * + * * @copyright Copyright (c) 2022 - * + * */ #ifndef MENU_ROUTE_H @@ -30,135 +30,137 @@ typedef void (MenuRoute::*DataFunction)(uint8_t); /** * @brief MenuActionWrapper to call DataFunctions - * + * * This class should be used to call importRoute, * exportRoute and clearRoute over the Menu. */ -class MenuActionRoute : public MenuActionWrapper { - public: - /** - * @brief Construct a new Menu Action Route object - * - * @param menuRoute - * @param dataFunction like exportRoute - */ - MenuActionRoute(MenuRoute* menuRoute, DataFunction dataFunction); +class MenuActionRoute : public MenuActionWrapper +{ +public: + /** + * @brief Construct a new Menu Action Route object + * + * @param menuRoute + * @param dataFunction like exportRoute + */ + MenuActionRoute(MenuRoute *menuRoute, DataFunction dataFunction); - /** - * @brief Runs the given DataFunction - */ - void action() override; + /** + * @brief Runs the given DataFunction + */ + void action() override; - private: - MenuRoute* menuRoute; - DataFunction dataFunction; +private: + MenuRoute *menuRoute; + DataFunction dataFunction; }; /** * @brief Handles routes - * - * With this menu the user can import, export and delete routes. + * + * With this menu the user can import, export and delete routes. */ -class MenuRoute : public MenuControl { - public: - /** - * @brief Construct a new Menu Route object - * - * @param route - */ - MenuRoute(Route* route); - ~MenuRoute(); +class MenuRoute : public MenuControl +{ +public: + /** + * @brief Construct a new Menu Route object + * + * @param route + */ + MenuRoute(Route *route); + ~MenuRoute(); - /** - * @brief Prints the last informations - * - * On first call this function calls the init function. - * On every call this functions call the printMenu function from - * the mainMenu of this class. - */ - void printMenu() override; + /** + * @brief Prints the last informations + * + * On first call this function calls the init function. + * On every call this functions call the printMenu function from + * the mainMenu of this class. + */ + void printMenu() override; - /** - * @name User Inputs - * @brief Inputs given by the parentMenu - */ - ///@{ - void down() override; - void up() override; - void right() override; - void left() override; - void yes() override; - void no() override; - ///@} + /** + * @name User Inputs + * @brief Inputs given by the parentMenu + */ + ///@{ + void down() override; + void up() override; + void right() override; + void left() override; + void yes() override; + void no() override; + ///@} - /** - * @brief Import a Route. - * - * The functions tries to pull the given route id from the RoverApi. - * - * @param routeNumber id - */ - void importRoute(uint8_t routeNumber); + /** + * @brief Import a Route. + * + * The functions tries to pull the given route id from the RoverApi. + * + * @param routeNumber id + */ + void importRoute(uint8_t routeNumber); - /** - * @brief Export a Route. - * - * The functions tries to push the current route to the RoverApi. - * - * @param routeNumber id - */ - void exportRoute(uint8_t routeNumber); + /** + * @brief Export a Route. + * + * The functions tries to push the current route to the RoverApi. + * + * @param routeNumber id + */ + void exportRoute(uint8_t routeNumber); - void deleteRoute(uint8_t routeNumber); + void deleteRoute(uint8_t routeNumber); - /** - * @brief Delete the current Route. - * - * @param none this param is not be used. - */ - void clearRoute(uint8_t none); - - private: - void init(); + /** + * @brief Delete the current Route. + * + * @param none this param is not be used. + */ + void clearRoute(uint8_t none); - Route* route; - Menu* mainMenu; +private: + void init(); - bool isInit = false; - bool blockInput = false; + Route *route; + Menu *mainMenu = nullptr; - static constexpr uint8_t maxRouteNumber = 100; - static constexpr uint16_t httpValidExport = 201; - static constexpr uint16_t httpValidImport = 202; - static constexpr uint16_t httpValidDelete = 202; + bool isInit = false; + bool blockInput = false; + static constexpr uint8_t maxRouteNumber = 100; + static constexpr uint16_t httpValidExport = 201; + static constexpr uint16_t httpValidImport = 202; + static constexpr uint16_t httpValidDelete = 202; }; /** * @brief MenuRouteWrapper to call DataFunctions with numeric user input - * + * */ -class MenuRouteWrapper : public MenuIntInputWrapper { - public: - /** - * @brief Construct a new Menu Route Wrapper object. - * - * @param menuRoute - * @param dataFunction - */ - MenuRouteWrapper(MenuRoute* menuRoute, DataFunction dataFunction); +class MenuRouteWrapper : public MenuIntInputWrapper +{ +public: + /** + * @brief Construct a new Menu Route Wrapper object. + * + * @param menuRoute + * @param dataFunction + */ + MenuRouteWrapper(MenuRoute *menuRoute, DataFunction dataFunction); - /** - * @brief Calls the given DataFunction. - * - * @param values The value to be given to the DataFunction. - * @param length Number of values, should be 1. - */ - void action(int16_t* values, uint8_t length) override; + /** + * @brief Calls the given DataFunction. + * + * @param values The value to be given to the DataFunction. + * @param length Number of values, should be 1. + */ + void action(int16_t *values, uint8_t length) override; - private: - MenuRoute* menuRoute; - DataFunction dataFunction = nullptr; +private: + MenuRoute *menuRoute; + DataFunction dataFunction = nullptr; }; #endif // MENU_ROUTE_H diff --git a/src/SpecialMenus/Route/menuRoutePoints.cpp b/src/SpecialMenus/Route/menuRoutePoints.cpp index 3fd14f4..f5241ce 100644 --- a/src/SpecialMenus/Route/menuRoutePoints.cpp +++ b/src/SpecialMenus/Route/menuRoutePoints.cpp @@ -4,34 +4,48 @@ * @brief Contains the implementation of the class MenuRoutePoints. * @version 0.1 * @date 2022-12-28 - * + * * @copyright Copyright (c) 2022 - * + * */ #include "menuRoutePoints.h" -MenuRoutePoints::MenuRoutePoints(Route *route) : MenuInformationSites() { - this->route = route; +MenuRoutePoints::MenuRoutePoints(Route *route) + : route{route} +{ } -void MenuRoutePoints::init() { - uint16_t amountPoints = this->route->getRouteInfo().totalPoints; +void MenuRoutePoints::init() +{ + const uint16_t amountPoints = this->route->getRouteInfo().totalPoints; if (amountPoints > UINT8_MAX) + { this->error = true; + } else + { this->setCountPages(amountPoints); + } } -void MenuRoutePoints::printPage() const { - uint8_t currentPage = this->getCurrentPage(); +void MenuRoutePoints::printPage() const +{ + static constexpr int8_t width = 9; + static constexpr int8_t prec = 7; + static constexpr int8_t bufSize = 20; + + const uint8_t currentPage = this->getCurrentPage(); if (this->lastPageNumber == currentPage) + { return; + } String lineOne = "N "; String lineTwo = "E "; - if (this->error) { + if (this->error) + { lineOne = "Error: To much"; lineTwo = "points are given"; this->print(lineOne, lineTwo); @@ -39,35 +53,46 @@ void MenuRoutePoints::printPage() const { } RouteInfo info = this->route->getRouteInfo(); - if (info.totalPoints == 0) { + if (info.totalPoints == 0) + { lineOne = "No Points are"; lineTwo = "available"; this->print(lineOne, lineTwo); return; } - Point p; + Point point; if (currentPage == 0) - p = this->route->startRoute(); + { + point = this->route->startRoute(); + } else if (this->lastPageNumber - 1 == currentPage) - p = this->route->getPreviousPoint(); + { + point = this->route->getPreviousPoint(); + } else if (this->lastPageNumber + 1 == currentPage) - p = this->route->getNextPoint(); + { + point = this->route->getNextPoint(); + } else if (currentPage == this->getCountPages() - 1) - p = this->route->endRoute(); + { + point = this->route->endRoute(); + } else + { std::cout << "Error in: MenuRoutePoints::printPage()" << std::endl; + } - char buf[20]; - char* string; + char buf[bufSize]; + char *string; info = this->route->getRouteInfo(); - string = dtostrf(p.getLatitude(), 9, 7, buf); + string = dtostrf(point.getLatitude(), width, prec, static_cast(buf)); lineOne.concat(string); lineOne.concat(" "); lineOne.concat(info.currentPoint); // lineOne.concat(currentPage); - string = dtostrf(p.getLongitude(), 9, 7, buf); + string = dtostrf(point.getLongitude(), width, prec, static_cast(buf)); lineTwo.concat(string); lineTwo.concat(" "); lineTwo.concat(info.totalPoints); diff --git a/src/SpecialMenus/SensorData/menuSensorData.cpp b/src/SpecialMenus/SensorData/menuSensorData.cpp index 2a6f86e..19ec032 100644 --- a/src/SpecialMenus/SensorData/menuSensorData.cpp +++ b/src/SpecialMenus/SensorData/menuSensorData.cpp @@ -1,119 +1,151 @@ /** * @file menuSensorData.cpp * @author Alexander Klein (alex@kleiax.de) - * @brief + * @brief * @version 0.1 * @date 2023-09-04 - * + * * @copyright Copyright (c) 2023 - * + * */ #include "menuSensorData.h" -MenuSensorData::MenuSensorData(SensorData* sensorData) : - MenuInformationSites(7) { - this->sensorData = sensorData; - this->noEqualLeft = true; +MenuSensorData::MenuSensorData(SensorData *sensorData) : MenuInformationSites(7), sensorData{sensorData} +{ + this->noEqualLeft = true; } -void MenuSensorData::printPage() const { - const UBX_NAV_PVT_data_t* gpsData = this->sensorData->getGnssData(); +void MenuSensorData::printPage() const +{ + const UBX_NAV_PVT_data_t *gpsData = this->sensorData->getGnssData(); uint8_t fixType = 0; - if (gpsData) + if (static_cast(gpsData)) + { fixType = gpsData->fixType; + } String lineOne = ""; String lineTwo = ""; - switch (this->getCurrentPage()) { - case 0: - lineOne = " Y P R :"; - lineTwo.concat(this->sensorData->getGyroData()[0]); - lineTwo.concat(" "); - lineTwo.concat(this->sensorData->getGyroData()[1]); - lineTwo.concat(" "); - lineTwo.concat(this->sensorData->getGyroData()[2]); - break; + switch (this->getCurrentPage()) + { + case 0: + lineOne = " Y P R :"; + lineTwo.concat(this->sensorData->getGyroData()[0]); + lineTwo.concat(" "); + lineTwo.concat(this->sensorData->getGyroData()[1]); + lineTwo.concat(" "); + lineTwo.concat(this->sensorData->getGyroData()[2]); + break; - case 1: - lineOne = "Real Azimuth:"; - lineTwo.concat(this->sensorData->getRealAzimuth()); - break; + case 1: + lineOne = "Real Azimuth:"; + lineTwo.concat(this->sensorData->getRealAzimuth()); + break; - case 2: - lineOne = "Calc Azimuth:"; - lineTwo.concat(this->sensorData->getCalcAzimuth()); - lineTwo.concat(" "); - lineTwo.concat(CalcAzimuth::stateToString(this->sensorData->getCalcAzimuthState())); - break; + case 2: + lineOne = "Calc Azimuth:"; + lineTwo.concat(this->sensorData->getCalcAzimuth()); + lineTwo.concat(" "); + lineTwo.concat(CalcAzimuth::stateToString(this->sensorData->getCalcAzimuthState())); + break; - case 3: { - lineOne = "Lat:"; - lineTwo = "Lon:"; - Point pos = this->sensorData->getCurrentPos(); - lineOne.concat(pos.getLatitude()); - lineTwo.concat(pos.getLongitude()); + case 3: + { + lineOne = "Lat:"; + lineTwo = "Lon:"; + const Point pos = this->sensorData->getCurrentPos(); + lineOne.concat(pos.getLatitude()); + lineTwo.concat(pos.getLongitude()); + } + break; + + case 4: + lineOne = "Time: "; + lineTwo = ""; + if (static_cast(fixType)) + { + if (gpsData->hour < 10) + { + lineTwo.concat("0"); } - break; - - case 4: - lineOne = "Time: "; - lineTwo = ""; - if (fixType) { - if (gpsData->hour < 10) - lineTwo.concat("0"); - lineTwo.concat(gpsData->hour); - lineTwo.concat(":"); - if (gpsData->min < 10) - lineTwo.concat("0"); - lineTwo.concat(gpsData->min); - lineTwo.concat(":"); - if (gpsData->sec < 10) - lineTwo.concat("0"); - lineTwo.concat(gpsData->sec); - } else - lineTwo = "00:00:00"; - - break; - - case 5: { - lineOne = "CarSol: "; - lineTwo = "Ntrip: "; - uint8_t carrSoln = gpsData->flags.bits.carrSoln; - if (carrSoln == 0) - lineOne.concat("None"); - else if (carrSoln == 1) - lineOne.concat("Floating"); - else if (carrSoln == 2) - lineOne.concat("Fixed"); - else - lineOne = "UNKNOWN"; - NTRIPClientStates status = this->sensorData->getNtripState(); - if (status == NTRIPClientStates::pushData) - lineTwo.concat("enabled"); - else if (status == NTRIPClientStates::notAvailable) - lineTwo.concat(" N/A"); - else - lineTwo.concat("disabled"); + lineTwo.concat(gpsData->hour); + lineTwo.concat(":"); + if (gpsData->min < 10) + { + lineTwo.concat("0"); } - break; - - case 6: - lineOne = "HAcc: "; - lineTwo = "Sats: "; - if (fixType) { - lineOne.concat(gpsData->hAcc); - lineTwo.concat(gpsData->numSV); - } else { - lineOne.concat("-/-"); - lineTwo.concat("-/-"); + lineTwo.concat(gpsData->min); + lineTwo.concat(":"); + if (gpsData->sec < 10) + { + lineTwo.concat("0"); } - break; + lineTwo.concat(gpsData->sec); + } + else + { + lineTwo = "00:00:00"; + } - default: - this->printDefault(); - return; + break; + + case 5: + { + lineOne = "CarSol: "; + lineTwo = "Ntrip: "; + const uint8_t carrSoln = gpsData->flags.bits.carrSoln; + if (carrSoln == 0) + { + lineOne.concat("None"); + } + else if (carrSoln == 1) + { + lineOne.concat("Floating"); + } + else if (carrSoln == 2) + { + lineOne.concat("Fixed"); + } + else + { + lineOne = "UNKNOWN"; + } + const NTRIPClientStates status = this->sensorData->getNtripState(); + if (status == NTRIPClientStates::pushData) + { + lineTwo.concat("enabled"); + } + else if (status == NTRIPClientStates::notAvailable) + { + lineTwo.concat(" N/A"); + } + else + { + lineTwo.concat("disabled"); + } + } + break; + + case 6: + lineOne = "HAcc: "; + lineTwo = "Sats: "; + if (static_cast(fixType)) + { + lineOne.concat(gpsData->hAcc); + lineTwo.concat(gpsData->numSV); + } + else + { + lineOne.concat("-/-"); + lineTwo.concat("-/-"); + } + break; + + default: + this->printDefault(); + return; } this->print(lineOne, lineTwo); diff --git a/src/SpecialMenus/Speed/menuSpeed.cpp b/src/SpecialMenus/Speed/menuSpeed.cpp index 1cb1736..dcb26d6 100644 --- a/src/SpecialMenus/Speed/menuSpeed.cpp +++ b/src/SpecialMenus/Speed/menuSpeed.cpp @@ -12,8 +12,9 @@ #include "menuSpeed.h" void MenuSpeed::action(int16_t* values, uint8_t length) { - if (length != 2) + if (length != 2) { return; - this->speeds.x = (double) values[0] / 10.0; - this->speeds.rot = (double) values[1] / 10.0; + } + this->speeds.x = values[0] / 10.0; + this->speeds.rot = values[1] / 10.0; } diff --git a/src/SpecialMenus/Systeminformation/menuSysteminformatio.cpp b/src/SpecialMenus/Systeminformation/menuSysteminformatio.cpp index 6706ae7..bbad40c 100644 --- a/src/SpecialMenus/Systeminformation/menuSysteminformatio.cpp +++ b/src/SpecialMenus/Systeminformation/menuSysteminformatio.cpp @@ -12,8 +12,7 @@ #include "menuSysteminformation.h" MenuSysteminformation::MenuSysteminformation(Battery* mainBattery) - : MenuInformationSites(8) { - this->mainBattery = mainBattery; + : MenuInformationSites(8), mainBattery {mainBattery} { this->noEqualLeft = true; } diff --git a/src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp b/src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp index 8447325..eb97490 100644 --- a/src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp +++ b/src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp @@ -4,31 +4,38 @@ * @brief Contains an implementation of the class MenuAutopilot * @version 0.1 * @date 2022-02-03 - * + * * @copyright Copyright (c) 2022 - * + * */ #include "menuAutopilot.h" -void MenuAutopilot::printPage() const { - CourseCorrection correction = this->autopilot->getCourseCorrection(); - const UBX_NAV_PVT_data_t* gpsData = this->autopilot->getSensorData()->getGnssData(); - bool navigationStarted = this->autopilot->getState() >= Autopilot::State::NavigationStarted; +void MenuAutopilot::printPage() const +{ + const CourseCorrection correction = this->autopilot->getCourseCorrection(); + const UBX_NAV_PVT_data_t *gpsData = this->autopilot->getSensorData()->getGnssData(); + const bool navigationStarted = this->autopilot->getState() >= Autopilot::State::NavigationStarted; String distanceString = ""; - if (navigationStarted) { + if (navigationStarted) + { uint16_t distance = 0; - if (correction.distance < 1) { - distance = (uint16_t) (correction.distance * 100); + if (correction.distance < 1) + { + distance = static_cast(correction.distance * 100); distanceString.concat(distance); distanceString.concat("cm"); - } else if (correction.distance < 1000) { - distance = (uint16_t) correction.distance; + } + else if (correction.distance < 1000) + { + distance = static_cast(correction.distance); distanceString.concat(distance); distanceString.concat("m"); - } else { - distance = (uint16_t) (correction.distance / 1000); + } + else + { + distance = static_cast(correction.distance / 1000); distanceString.concat(distance); distanceString.concat("km"); } @@ -37,221 +44,263 @@ void MenuAutopilot::printPage() const { String lineOne = "No information"; String lineTwo = "available"; - switch (this->getCurrentPage()) { - case 0: { - lineOne = "Status: "; - lineTwo = ""; - switch (this->autopilot->getState()) { - case Autopilot::State::InsufficientAccuracy : - lineTwo = "Err: LowAccuracy"; - break; - - case Autopilot::State::NoRoute : - lineTwo = "Err: No route"; - break; - - case Autopilot::State::NavigationStarted : - lineTwo = "Nav started"; - break; - - case Autopilot::State::GetToStartPoint : - lineTwo = "Drive to start"; - break; - - case Autopilot::State::SelfDrivingAvailable : - lineTwo = "Autopilot ready"; - break; - - case Autopilot::State::SelfDriving : - lineTwo = "Autopilot active"; - break; - - case Autopilot::State::SelfDrivingRotate : - lineTwo = "Rotating"; - break; - - case Autopilot::State::TargetReached : - lineTwo = "Target reached"; - break; - - default: - lineTwo = "UNKOWN - "; - lineTwo.concat(static_cast(this->autopilot->getState())); - - break; - } - break; - } - - case 1: - if (!navigationStarted) { - lineOne = "Navigation is"; - lineTwo = "not started"; - break; - } - lineOne = "Distance: "; - lineOne.concat(distanceString); - lineTwo = "Turn: "; - lineTwo.concat(correction.correction); + switch (this->getCurrentPage()) + { + case 0: + { + lineOne = "Status: "; + lineTwo = ""; + switch (this->autopilot->getState()) + { + case Autopilot::State::InsufficientAccuracy: + lineTwo = "Err: LowAccuracy"; break; - case 2: - lineOne = "Target waypoint"; - lineTwo = ""; - lineTwo.concat(this->autopilot->getRouteInfo().currentPoint); - lineTwo.concat(" from "); - lineTwo.concat(this->autopilot->getRouteInfo().totalPoints); + case Autopilot::State::NoRoute: + lineTwo = "Err: No route"; break; - case 3: { - NTRIPClientStates status = this->autopilot->getSensorData()->getNtripClient()->getClientState(); - uint8_t carrSoln = gpsData->flags.bits.carrSoln; - lineOne = "GNSS: "; - - if (status == NTRIPClientStates::pushData) - if (carrSoln == 0) - lineOne.concat("None"); - else if (carrSoln == 1) - lineOne.concat("Floating"); - else if (carrSoln == 2) - lineOne.concat("Fixed"); - else - lineOne.concat("UNKNOWN"); - else if (status == NTRIPClientStates::notAvailable) - lineOne.concat("No WiFi"); - else - lineOne.concat("Offline"); - - lineTwo = "hAcc: "; - if (gpsData->fixType) - lineTwo.concat(gpsData->hAcc); - else - lineTwo.concat("0"); - break; - } - - case 4: - - if (this->autopilot->getSensorData()->getCalcAzimuth() == CalcAzimuth::State::Good - ||this->autopilot->getSensorData()->getCalcAzimuth() == CalcAzimuth::State::Super) - { - lineOne = "Calc Azi: "; - lineTwo = "State: "; - lineOne.concat(this->autopilot->getSensorData()->getCalcAzimuth()); - switch (this->autopilot->getSensorData()->getCalcAzimuthState()) { - case CalcAzimuth::State::Bad : - lineTwo.concat("Bad"); - break; - - case CalcAzimuth::State::Good : - lineTwo.concat("Good"); - break; - - case CalcAzimuth::State::Invalid : - lineTwo.concat("Invalid"); - break; - - case CalcAzimuth::State::Ok : - lineTwo.concat("Ok"); - break; - - case CalcAzimuth::State::Super : - lineTwo.concat("Super"); - break; - - default: - lineTwo.concat("Unkown"); - break; - } - } else { - lineOne = "Real Azi: "; - lineTwo = ""; - lineOne.concat(this->autopilot->getSensorData()->getRealAzimuth()); - } + case Autopilot::State::NavigationStarted: + lineTwo = "Nav started"; break; - case 5: - lineOne = "Loop mode is"; - if (this->autopilot->getLoopMode()) - lineTwo = "enabled"; - else - lineTwo = "disabled"; + case Autopilot::State::GetToStartPoint: + lineTwo = "Drive to start"; break; - case 6: - lineOne = "Freeze target is"; - if (this->targetFreezed) - lineTwo = "activated"; - else - lineTwo = "deactivated"; + case Autopilot::State::SelfDrivingAvailable: + lineTwo = "Autopilot ready"; break; - case 7: - lineOne = "MinDisToPoint:"; - lineTwo = "<- "; - lineTwo.concat(this->minDistance); - lineTwo.concat(" ->"); + case Autopilot::State::SelfDriving: + lineTwo = "Autopilot active"; + break; + + case Autopilot::State::SelfDrivingRotate: + lineTwo = "Rotating"; + break; + + case Autopilot::State::TargetReached: + lineTwo = "Target reached"; break; default: - this->printDefault(); - return; + lineTwo = "UNKOWN - "; + lineTwo.concat(static_cast(this->autopilot->getState())); + + break; } + break; + } + + case 1: + if (!navigationStarted) + { + lineOne = "Navigation is"; + lineTwo = "not started"; + break; + } + lineOne = "Distance: "; + lineOne.concat(distanceString); + lineTwo = "Turn: "; + lineTwo.concat(correction.correction); + break; + + case 2: + lineOne = "Target waypoint"; + lineTwo = ""; + lineTwo.concat(this->autopilot->getRouteInfo().currentPoint); + lineTwo.concat(" from "); + lineTwo.concat(this->autopilot->getRouteInfo().totalPoints); + break; + + case 3: + { + NTRIPClientStates status = this->autopilot->getSensorData()->getNtripClient()->getClientState(); + const uint8_t carrSoln = gpsData->flags.bits.carrSoln; + lineOne = "GNSS: "; + + if (status == NTRIPClientStates::pushData) + { + if (carrSoln == 0) + { + lineOne.concat("None"); + } + else if (carrSoln == 1) + { + lineOne.concat("Floating"); + } + else if (carrSoln == 2) + { + lineOne.concat("Fixed"); + } + else + { + lineOne.concat("UNKNOWN"); + } + } + else if (status == NTRIPClientStates::notAvailable) + lineOne.concat("No WiFi"); + else + { + lineOne.concat("Offline"); + } + + lineTwo = "hAcc: "; + if (static_cast(gpsData->fixType)) + { + lineTwo.concat(gpsData->hAcc); + } + else + { + lineTwo.concat("0"); + } + break; + } + + case 4: + + if (this->autopilot->getSensorData()->getCalcAzimuth() == CalcAzimuth::State::Good || this->autopilot->getSensorData()->getCalcAzimuth() == CalcAzimuth::State::Super) + { + lineOne = "Calc Azi: "; + lineTwo = "State: "; + lineOne.concat(this->autopilot->getSensorData()->getCalcAzimuth()); + switch (this->autopilot->getSensorData()->getCalcAzimuthState()) + { + case CalcAzimuth::State::Bad: + lineTwo.concat("Bad"); + break; + + case CalcAzimuth::State::Good: + lineTwo.concat("Good"); + break; + + case CalcAzimuth::State::Invalid: + lineTwo.concat("Invalid"); + break; + + case CalcAzimuth::State::Ok: + lineTwo.concat("Ok"); + break; + + case CalcAzimuth::State::Super: + lineTwo.concat("Super"); + break; + + default: + lineTwo.concat("Unkown"); + break; + } + } + else + { + lineOne = "Real Azi: "; + lineTwo = ""; + lineOne.concat(this->autopilot->getSensorData()->getRealAzimuth()); + } + break; + + case 5: + lineOne = "Loop mode is"; + if (this->autopilot->getLoopMode()) + { + lineTwo = "enabled"; + } + else + { + lineTwo = "disabled"; + } + break; + + case 6: + lineOne = "Freeze target is"; + if (this->targetFreezed) + { + lineTwo = "activated"; + } + else + { + lineTwo = "deactivated"; + } + break; + + case 7: + lineOne = "MinDisToPoint:"; + lineTwo = "<- "; + lineTwo.concat(this->minDistance); + lineTwo.concat(" ->"); + break; + + default: + this->printDefault(); + return; + } this->print(lineOne, lineTwo); } -void MenuAutopilot::runCommand() { - switch (this->getCurrentPage()) { - case 5: - this->autopilot->switchLoopMode(); - break; - - case 6: - if (this->targetFreezed) { - this->targetFreezed = false; - this->autopilot->getNavigation()->freezeTargetPoint(false); - } else { - this->targetFreezed = true; - this->autopilot->getNavigation()->freezeTargetPoint(); - } - break; - - case 7: - this->minDistance = this->autopilot->getNavigation()->increaseMinDistanceToReachPoint(); - break; - - default: - break; - } -} - -void MenuAutopilot::runCommandNo() { - switch (this->getCurrentPage()) { - case 7: - this->minDistance = this->autopilot->getNavigation()->decreaseMinDistanceToReachPoint(); +void MenuAutopilot::runCommand() +{ + switch (this->getCurrentPage()) + { + case 5: + this->autopilot->switchLoopMode(); break; - + + case 6: + if (this->targetFreezed) + { + this->targetFreezed = false; + this->autopilot->getNavigation()->freezeTargetPoint(false); + } + else + { + this->targetFreezed = true; + this->autopilot->getNavigation()->freezeTargetPoint(); + } + break; + + case 7: + this->minDistance = this->autopilot->getNavigation()->increaseMinDistanceToReachPoint(); + break; + default: break; } } -void MenuAutopilot::update() { +void MenuAutopilot::runCommandNo() +{ + switch (this->getCurrentPage()) + { + case 7: + this->minDistance = this->autopilot->getNavigation()->decreaseMinDistanceToReachPoint(); + break; + + default: + break; + } +} + +void MenuAutopilot::update() +{ if (!this->autopilot->shouldUpdate()) + { return; + } this->routeInfo = this->autopilot->getRouteInfo(); this->printMenu(); } -void MenuAutopilot::init() { +void MenuAutopilot::init() +{ this->setCountPages(8); - this->autopilot = new Autopilot(); + this->autopilot = new Autopilot(); this->driveManager->changeModus(this->autopilot); this->routeInfo = this->autopilot->getRouteInfo(); - //dirty hack to get the val, can be better!!! TODO + // dirty hack to get the val, can be better!!! TODO this->autopilot->getNavigation()->increaseMinDistanceToReachPoint(); this->minDistance = this->autopilot->getNavigation()->decreaseMinDistanceToReachPoint(); diff --git a/src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp b/src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp index f709559..9715f31 100644 --- a/src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp +++ b/src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.cpp @@ -114,7 +114,7 @@ void MenuCalibrateCompass::init() { this->driveManager->changeModus(this->caliCompassMode); this->caliCompass = new CalibrateCompass(this->caliCompassMode->getSensorData()->getRealCompass()); this->setCountPages(11); - this->updateDelay = 500; + MenuDriveMode::updateDelay = MenuCalibrateCompass::updateDelay; } void MenuCalibrateCompass::runCommand() { diff --git a/src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.h b/src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.h index 010bbaf..91d54bc 100644 --- a/src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.h +++ b/src/SpecialMenus/driveModi/CalibrateCompass/menuCalibrateCompass.h @@ -45,8 +45,10 @@ class MenuCalibrateCompass : public MenuDriveMode { void runCommand() override; private: - CalibrateCompassM* caliCompassMode; - CalibrateCompass* caliCompass; + CalibrateCompassM* caliCompassMode = nullptr; + CalibrateCompass* caliCompass = nullptr; + + static constexpr uint16_t updateDelay = 500; }; #endif // MENU_CALIBRATE_COMPASS_H diff --git a/src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp b/src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp index f90f3a5..f5a46ed 100644 --- a/src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp +++ b/src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp @@ -4,134 +4,170 @@ * @brief Contains an implementation of the class MenuCaptureRoute * @version 0.1 * @date 2022-01-31 - * + * * @copyright Copyright (c) 2022 - * + * */ #include "menuCaptureRoute.h" -void MenuCaptureRoute::printPage() const { - RouteInfo routeInfo = this->captureRoute->getRouteInfo(); - const UBX_NAV_PVT_data_t* gpsData = this->captureRoute->getSensorData()->getGnssData(); +void MenuCaptureRoute::printPage() const +{ + const RouteInfo routeInfo = this->captureRoute->getRouteInfo(); + const UBX_NAV_PVT_data_t *gpsData = this->captureRoute->getSensorData()->getGnssData(); String lineOne = ""; String lineTwo = ""; - - switch (this->getCurrentPage()) { - case 0: - lineOne = "Capture Route"; - lineTwo = "You can drive"; + + switch (this->getCurrentPage()) + { + case 0: + lineOne = "Capture Route"; + lineTwo = "You can drive"; + break; + + case 1: + lineOne = "Saved waypoints"; + lineTwo.concat(routeInfo.totalPoints); + break; + + case 2: + lineOne = "Last status:"; + switch (this->captureRoute->getLastStatus()) + { + case Navigation::Status::InsufficientAccuracy: + lineTwo = "Poor Accuracy"; break; - case 1: - lineOne = "Saved waypoints"; - lineTwo.concat(routeInfo.totalPoints); + case Navigation::Status::Updated: + lineTwo = "Point added"; break; - case 2: - lineOne = "Last status:"; - switch (this->captureRoute->getLastStatus()) { - case Navigation::Status::InsufficientAccuracy: - lineTwo = "Poor Accuracy"; - break; - - case Navigation::Status::Updated: - lineTwo = "Point added"; - break; - - case Navigation::Status::Unchanged: - lineTwo = "Point too close"; - break; - - default: - lineTwo = "---"; - break; - } + case Navigation::Status::Unchanged: + lineTwo = "Point too close"; break; - case 3: - lineOne = "Distance to last"; - lineTwo = "point: "; - lineTwo.concat(this->captureRoute->getDistanceToLastPoint()); - break; - - case 4: { - NTRIPClientStates status = this->captureRoute->getSensorData()->getNtripClient()->getClientState(); - lineOne = "NTRIP Client is"; - - if (status == NTRIPClientStates::pushData) - lineTwo = "enabled"; - else if (status == NTRIPClientStates::notAvailable) - lineTwo = "not available"; - else - lineTwo = "disabled"; - break; - } - - case 5: { - lineOne = "Carrier Solution"; - uint8_t carrSoln = gpsData->flags.bits.carrSoln; - if (carrSoln == 0) - lineTwo = "None"; - else if (carrSoln == 1) - lineTwo = "Floating"; - else if (carrSoln == 2) - lineTwo = "Fixed"; - else - lineTwo = "UNKNOWN"; - break; - } - - case 6: - lineOne = "hAccuracy: "; - lineTwo = "Azimuth: "; - lineTwo.concat(this->captureRoute->getSensorData()->getRealAzimuth()); - if (gpsData->fixType) - lineOne.concat(gpsData->hAcc); - else - lineOne.concat("0"); - break; - - case 7: - lineOne = "Current minimal"; - if (this->captureRoute->getNavigation()->getMinAccuracy() >= Point::Accuracy::twoDigOfCM) - lineTwo = "accuracy is high"; - else - lineTwo = "accuracy is low"; - break; - default: - this->printDefault(); - return; + lineTwo = "---"; + break; + } + break; + + case 3: + lineOne = "Distance to last"; + lineTwo = "point: "; + lineTwo.concat(this->captureRoute->getDistanceToLastPoint()); + break; + + case 4: + { + NTRIPClientStates status = this->captureRoute->getSensorData()->getNtripClient()->getClientState(); + lineOne = "NTRIP Client is"; + + if (status == NTRIPClientStates::pushData) + { + lineTwo = "enabled"; + } + else if (status == NTRIPClientStates::notAvailable) + { + lineTwo = "not available"; + } + else + { + lineTwo = "disabled"; + } + break; + } + + case 5: + { + lineOne = "Carrier Solution"; + uint8_t carrSoln = gpsData->flags.bits.carrSoln; + if (carrSoln == 0) + { + lineTwo = "None"; + } + else if (carrSoln == 1) + { + lineTwo = "Floating"; + } + else if (carrSoln == 2) + { + lineTwo = "Fixed"; + } + else + { + lineTwo = "UNKNOWN"; + } + break; + } + + case 6: + lineOne = "hAccuracy: "; + lineTwo = "Azimuth: "; + lineTwo.concat(this->captureRoute->getSensorData()->getRealAzimuth()); + if (gpsData->fixType) + { + lineOne.concat(gpsData->hAcc); + } + else + { + lineOne.concat("0"); + } + break; + + case 7: + lineOne = "Current minimal"; + if (this->captureRoute->getNavigation()->getMinAccuracy() >= Point::Accuracy::twoDigOfCM) + { + lineTwo = "accuracy is high"; + } + else + { + lineTwo = "accuracy is low"; + } + break; + + default: + this->printDefault(); + return; } this->print(lineOne, lineTwo); } -void MenuCaptureRoute::update() { +void MenuCaptureRoute::update() +{ if (!this->captureRoute->shouldUpdate()) + { return; + } this->printMenu(); } -void MenuCaptureRoute::runCommand() { +void MenuCaptureRoute::runCommand() +{ switch (this->getCurrentPage()) { case 7: if (this->captureRoute->getNavigation()->getMinAccuracy() >= Point::Accuracy::twoDigOfCM) + { this->captureRoute->getNavigation()->setMinAccuracy(Point::Accuracy::none); - else + } + else + { this->captureRoute->getNavigation()->setMinAccuracy(Point::Accuracy::twoDigOfCM); + } break; - + default: break; } } -void MenuCaptureRoute::init() { +void MenuCaptureRoute::init() +{ this->setCountPages(8); - this->updateDelay = 500; + MenuDriveMode::updateDelay = MenuCaptureRoute::updateDelay; this->captureRoute = new CaptureRoute(); this->driveManager->changeModus(this->captureRoute); MenuDriveMode::init(); diff --git a/src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.h b/src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.h index 9c3ba8a..d4505ce 100644 --- a/src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.h +++ b/src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.h @@ -48,7 +48,9 @@ class MenuCaptureRoute : public MenuDriveMode { private: void init() override; - CaptureRoute* captureRoute; + CaptureRoute* captureRoute = nullptr; + + static constexpr uint16_t updateDelay = 500; }; #endif // MENU_MANUAL_DRIVE_H diff --git a/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.cpp b/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.cpp index 7f3cb5c..8a5d1b9 100644 --- a/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.cpp +++ b/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.cpp @@ -14,8 +14,6 @@ MenuManualControl::MenuManualControl(DriveManager* driveManager) : MenuDriveMode this->noEqualLeft = true; } -MenuManualControl::~MenuManualControl() { -} void MenuManualControl::printPage() const { String lineOne = ""; @@ -28,10 +26,12 @@ void MenuManualControl::printPage() const { case 1: lineOne = "Input mode:"; - if (this->manualControl->getInputMode() == ManualControl::InputMode::Analog) + if (this->manualControl->getInputMode() == ManualControl::InputMode::Analog) { lineTwo = "Analog"; - else + } + else { lineTwo = "Digital"; + } break; case 2: @@ -55,7 +55,7 @@ void MenuManualControl::init() { this->manualControl = new ManualControl(); this->driveManager->changeModus(this->manualControl); this->setCountPages(4); - this->updateDelay = 500; + MenuDriveMode::updateDelay = MenuManualControl::updateDelay; this->activateSpeedMenu(); MenuDriveMode::init(); } diff --git a/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.h b/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.h index 9f2f6d8..ee5eb0f 100644 --- a/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.h +++ b/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.h @@ -27,7 +27,6 @@ class MenuManualControl : public MenuDriveMode { * @param driveManager */ MenuManualControl(DriveManager* driveManager); - ~MenuManualControl(); /** * @brief Prints the Information to display and console @@ -44,8 +43,10 @@ class MenuManualControl : public MenuDriveMode { void runCommand() override; private: - ManualControl* manualControl; - CalibrateCompass* caliCompass; + ManualControl* manualControl = nullptr; + CalibrateCompass* caliCompass = nullptr; + + static constexpr uint16_t updateDelay = 500; }; #endif // MENU_MANUAL_DRIVE_H diff --git a/src/SpecialMenus/driveModi/TestMode/menuTestMode.cpp b/src/SpecialMenus/driveModi/TestMode/menuTestMode.cpp index 89d224f..7f88b5b 100644 --- a/src/SpecialMenus/driveModi/TestMode/menuTestMode.cpp +++ b/src/SpecialMenus/driveModi/TestMode/menuTestMode.cpp @@ -118,7 +118,7 @@ void MenuTestMode::init() { // Other menu config static constexpr uint8_t percentMax = 100; - static constexpr uint8_t degreeMax = 360; + static constexpr uint16_t degreeMax = 360; static constexpr uint8_t secondsMax = 120; static constexpr uint8_t steps = 5;