clangtidy corrections part 1

This commit is contained in:
2023-10-11 17:35:40 +02:00
parent 77a52b82c3
commit 23d854a826
36 changed files with 2383 additions and 1165 deletions
+38 -22
View File
@@ -1,37 +1,43 @@
/**
* @file controlPad.cpp
* @author Alexander Klein (alex@kleiax.de)
* @brief
* @brief
* @version 0.1
* @date 2023-03-30
*
*
* @copyright Copyright (c) 2023
*
*
*/
#include "controlPad.h"
ControlPad::ControlPad() {
this->loopDelay = 5;
}
ControlPad::ControlPad() : Component(5), controlInput{0, 0, 0, 0} {}
void ControlPad::run() {
if(!this->connected)
void ControlPad::run()
{
if (!this->connected)
{
return;
}
if (millis() - this->lastMessageReceive > this->disconnectTime) {
if (millis() - this->lastMessageReceive > this->disconnectTime)
{
this->connected = false;
this->controlInput.buttons = 0;
this->controlInput.x = 127;
this->controlInput.y = 127;
this->controlInput.x = UINT8_MAX / 2;
this->controlInput.y = UINT8_MAX / 2;
return;
}
if (this->lastButtons != controlInput.buttons)
{
this->updated = true;
}
if (this->menuControl && this->controlInput.buttons > 0 && this->updated) {
if (this->firstButtonPress) {
if (static_cast<bool>(this->menuControl) && this->controlInput.buttons > 0 && this->updated)
{
if (this->firstButtonPress)
{
this->menuControl->printMenu();
this->firstButtonPress = false;
std::cout << "ControlPad::loop - First menu print" << std::endl;
@@ -39,38 +45,48 @@ void ControlPad::run() {
}
if (ControlPadButton::isControlPadButtonPressed(&this->controlInput, ControlPadButton::PadButton::Left))
{
this->menuControl->left();
}
else if (ControlPadButton::isControlPadButtonPressed(&this->controlInput, ControlPadButton::PadButton::Right))
{
this->menuControl->right();
}
else if (ControlPadButton::isControlPadButtonPressed(&this->controlInput, ControlPadButton::PadButton::Up))
{
this->menuControl->up();
}
else if (ControlPadButton::isControlPadButtonPressed(&this->controlInput, ControlPadButton::PadButton::Down))
{
this->menuControl->down();
}
else if (ControlPadButton::isControlPadButtonPressed(&this->controlInput, ControlPadButton::PadButton::Yes))
{
this->menuControl->yes();
}
else if (ControlPadButton::isControlPadButtonPressed(&this->controlInput, ControlPadButton::PadButton::No))
{
this->menuControl->no();
}
this->updated = false;
this->lastButtons = controlInput.buttons;
}
return;
}
void ControlPad::insertData(const uint8_t *data) {
void ControlPad::insertData(const uint8_t *data)
{
this->connected = true;
this->lastMessageReceive = millis();
uint8_t lastCount = this->controlInput.counter + 1;
const uint8_t lastCount = this->controlInput.counter + 1;
memcpy(&(this->controlInput), data, sizeof(this->controlInput));
if (lastCount != this->controlInput.counter)
std::cout << "ControlPad::insertData counter wrong value" << std::endl;
if (this->controlInput.x > 127 - this->deadZoneX
&& this->controlInput.x < 127 + this->deadZoneX)
this->controlInput.x = 127;
if (this->controlInput.x > UINT8_MAX / 2 - this->deadZoneX && this->controlInput.x < UINT8_MAX / 2 + this->deadZoneX)
this->controlInput.x = UINT8_MAX / 2;
if (this->controlInput.y > 127 - this->deadZoneY
&& this->controlInput.y < 127 + this->deadZoneY)
this->controlInput.y = 127;
if (this->controlInput.y > UINT8_MAX / 2 - this->deadZoneY && this->controlInput.y < UINT8_MAX / 2 + this->deadZoneY)
this->controlInput.y = UINT8_MAX / 2;
}