Skip to content

Commit

Permalink
🚧 (clang-tidy): Modernize code using clang-tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
ladislas committed May 5, 2021
1 parent f660b3d commit 066f414
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 18 deletions.
4 changes: 2 additions & 2 deletions drivers/LKCoreMotor/include/LKCoreMotor.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ class LKCoreMotor : public LKCoreMotorBase
_speed {mbed::PwmOut(speed)} {};

void spin(rotation_t rotation, float speed) override;
void stop(void) override;
void stop() override;

Status getStatus(void) const;
[[nodiscard]] auto getStatus() const -> Status;

private:
Status _status {0, 0, 0};
Expand Down
2 changes: 1 addition & 1 deletion drivers/LKCoreMotor/include/LKCoreMotorBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class LKCoreMotorBase
{
public:
virtual void spin(rotation_t rotation, float speed) = 0;
virtual void stop(void) = 0;
virtual void stop() = 0;
};

} // namespace leka
Expand Down
4 changes: 2 additions & 2 deletions drivers/LKCoreMotor/source/LKCoreMotor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ void LKCoreMotor::spin(rotation_t rotation, float speed)
setSpeed(speed);
}

void LKCoreMotor::stop(void)
void LKCoreMotor::stop()
{
setDirections(0, 0);
setSpeed(0);
}

LKCoreMotor::Status LKCoreMotor::getStatus(void) const
auto LKCoreMotor::getStatus() const -> LKCoreMotor::Status
{
return _status;
}
Expand Down
31 changes: 18 additions & 13 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,39 @@
// Copyright 2020 APF France handicap
// SPDX-License-Identifier: Apache-2.0

#include "mbed.h"
#include <chrono>

#include "HelloWorld.h"

using namespace leka;
#include "drivers/BufferedSerial.h"
#include "platform/platform.h"
#include "rtos/rtos.h"

HelloWorld hello;
#include "HelloWorld.h"
#include "ThisThread.h"

static BufferedSerial serial(USBTX, USBRX, 9600);
using namespace std::chrono_literals;

constexpr uint8_t buff_size = 128;
char buff[buff_size] {};

int main(void)
auto main() -> int
{
std::array<char, buff_size> buff {0};

leka::HelloWorld hello;
mbed::BufferedSerial serial(USBTX, USBRX, 9600);

auto start = Kernel::Clock::now();

printf("\nHello, Investigation Day!\n\n");

rtos::ThisThread::sleep_for(2s);
rtos::ThisThread::sleep_for(2s);

hello.start();

while (true) {
auto t = Kernel::Clock::now() - start;
int length = sprintf(buff, "A message from your board %s --> \"%s\" at %i s\n", MBED_CONF_APP_TARGET_NAME,
hello.world, int(t.count() / 1000));
serial.write(buff, length);
rtos::ThisThread::sleep_for(1s);
auto t = Kernel::Clock::now() - start;
auto length = sprintf(buff.data(), "A message from your board %s --> \"%s\" at %i s\n",
MBED_CONF_APP_TARGET_NAME, hello.world, int(t.count() / 1000));
serial.write(buff.data(), length);
}
}

0 comments on commit 066f414

Please sign in to comment.