ADD cpplint args in action file
This commit is contained in:
@@ -1,12 +1,25 @@
|
||||
// Copyright 2022 Haute école d'ingénierie et d'architecture de Fribourg
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
/****************************************************************************
|
||||
* @file pedal_device.cpp
|
||||
* @author Rémi Heredero <remi@heredero.ch>
|
||||
* @author Yann Sierro <yannsierro.pro@gmail.com>
|
||||
*
|
||||
* @brief Pedal Device implementation (static scheduling)
|
||||
* @date 2024-11-09
|
||||
* @version 0.1.0
|
||||
****************************************************************************/
|
||||
* @file pedal_device.cpp
|
||||
* @author Rémi Heredero <remi@heredero.ch>
|
||||
* @author Yann Sierro <yannsierro.pro@gmail.com>
|
||||
*
|
||||
* @brief Pedal Device implementation (static scheduling)
|
||||
* @date 2024-11-09
|
||||
* @version 0.1.0
|
||||
****************************************************************************/
|
||||
|
||||
#include "pedal_device.hpp"
|
||||
|
||||
@@ -22,51 +35,50 @@
|
||||
|
||||
namespace static_scheduling {
|
||||
|
||||
static constexpr std::chrono::microseconds kTaskRunTime = 200000us;
|
||||
static constexpr std::chrono::microseconds kTaskRunTime = 200000us;
|
||||
|
||||
PedalDevice::PedalDevice(Timer& timer) : _timer(timer) {}
|
||||
PedalDevice::PedalDevice(Timer& timer) : _timer(timer) {}
|
||||
|
||||
std::chrono::milliseconds PedalDevice::getCurrentRotationTime() {
|
||||
std::chrono::microseconds initialTime = _timer.elapsed_time();
|
||||
std::chrono::microseconds elapsedTime = std::chrono::microseconds::zero();
|
||||
// we bound the change to one increment/decrement per call
|
||||
bool hasChanged = false;
|
||||
while (elapsedTime < kTaskRunTime) {
|
||||
if (!hasChanged) {
|
||||
disco::Joystick::State joystickState =
|
||||
disco::Joystick::getInstance().getState();
|
||||
|
||||
std::chrono::milliseconds PedalDevice::getCurrentRotationTime() {
|
||||
// TODO
|
||||
std::chrono::microseconds initialTime = _timer.elapsed_time();
|
||||
std::chrono::microseconds elapsedTime = std::chrono::microseconds::zero();
|
||||
// we bound the change to one increment/decrement per call
|
||||
bool hasChanged = false;
|
||||
while (elapsedTime < kTaskRunTime) {
|
||||
if (!hasChanged) {
|
||||
disco::Joystick::State joystickState = disco::Joystick::getInstance().getState();
|
||||
switch (joystickState) {
|
||||
case disco::Joystick::State::LeftPressed:
|
||||
if (_pedalRotationTime < bike_computer::kMaxPedalRotationTime) {
|
||||
decreaseRotationSpeed();
|
||||
hasChanged = true;
|
||||
}
|
||||
break;
|
||||
|
||||
switch (joystickState) {
|
||||
case disco::Joystick::State::LeftPressed:
|
||||
if (_pedalRotationTime < bike_computer::kMaxPedalRotationTime) {
|
||||
decreaseRotationSpeed();
|
||||
hasChanged = true;
|
||||
}
|
||||
break;
|
||||
case disco::Joystick::State::DownPressed:
|
||||
if (_pedalRotationTime > bike_computer::kMinPedalRotationTime) {
|
||||
decreaseRotationSpeed();
|
||||
hasChanged = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case disco::Joystick::State::DownPressed:
|
||||
if (_pedalRotationTime > bike_computer::kMinPedalRotationTime) {
|
||||
decreaseRotationSpeed();
|
||||
hasChanged = true;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
elapsedTime = _timer.elapsed_time() - initialTime;
|
||||
}
|
||||
return _pedalRotationTime;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
elapsedTime = _timer.elapsed_time() - initialTime;
|
||||
}
|
||||
|
||||
void PedalDevice::increaseRotationSpeed() {
|
||||
_pedalRotationTime -= bike_computer::kDeltaPedalRotationTime;
|
||||
}
|
||||
|
||||
void PedalDevice::decreaseRotationSpeed() {
|
||||
_pedalRotationTime += bike_computer::kDeltaPedalRotationTime;
|
||||
}
|
||||
|
||||
return _pedalRotationTime;
|
||||
}
|
||||
|
||||
void PedalDevice::increaseRotationSpeed() {
|
||||
_pedalRotationTime -= bike_computer::kDeltaPedalRotationTime;
|
||||
}
|
||||
|
||||
void PedalDevice::decreaseRotationSpeed() {
|
||||
_pedalRotationTime += bike_computer::kDeltaPedalRotationTime;
|
||||
}
|
||||
|
||||
} // namespace static_scheduling
|
||||
|
||||
Reference in New Issue
Block a user