ADD preparation for tests

This commit is contained in:
fastium
2025-01-04 16:41:02 +01:00
parent 3a3d27f93e
commit 55a6594646
6 changed files with 55 additions and 18 deletions

View File

@ -1,21 +1,37 @@
// 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 speedometer_device.cpp
* @author Serge Ayer <serge.ayer@hefr.ch>
*
* @brief WheelCounterDevice implementation (static scheduling)
*
* @date 2023-08-20
* @version 1.0.0
***************************************************************************/
#include "sensor_device.hpp"
namespace bike_computer {
SensorDevice::SensorDevice() : _hdc1000(I2C_SDA, I2C_SCL, STMOD_11)
{}
SensorDevice::SensorDevice() : _hdc1000(I2C_SDA, I2C_SCL, STMOD_11) {}
bool SensorDevice::init() {
return this->_hdc1000.probe();
}
bool SensorDevice::init() { return this->_hdc1000.probe(); }
float SensorDevice::readTemperature(void) {
return this->_hdc1000.getTemperature();
}
float SensorDevice::readTemperature(void) { return this->_hdc1000.getTemperature(); }
float SensorDevice::readHumidity(void) {
return this->_hdc1000.getHumidity();
}
} // bike_computer
float SensorDevice::readHumidity(void) { return this->_hdc1000.getHumidity(); }
} // namespace bike_computer

View File

@ -46,4 +46,4 @@ class SensorDevice {
advembsof::HDC1000 _hdc1000;
};
} // namespace bike_computer
} // namespace bike_computer

View File

@ -80,7 +80,6 @@ float Speedometer::getDistance() {
}
void Speedometer::reset() {
// TODO : done
this->_totalDistanceMutex.lock();
this->_totalDistance = 0.0f;
this->_totalDistanceMutex.unlock();
@ -96,6 +95,7 @@ float Speedometer::getTraySize() const { return kTraySize; }
std::chrono::milliseconds Speedometer::getCurrentPedalRotationTime() const {
return _pedalRotationTime;
}
void Speedometer::setOnResetCallback(mbed::Callback<void()> cb) { _cbOnReset = cb; }
#endif // defined(MBED_TEST_MODE)
@ -107,7 +107,6 @@ void Speedometer::computeSpeed() {
// = 6.99m If you ride at 80 pedal turns / min, you run a distance of 6.99 * 80 / min
// ~= 560 m / min = 33.6 km/h
// TODO : done
// Distance run with one pedal turn = tray size / rear gear size * circumference of
// the wheel
constexpr float ms_in_hour = static_cast<float>(3600 * 1000);
@ -129,7 +128,6 @@ void Speedometer::computeDistance() {
// ~= 560 m / min = 33.6 km/h. We then multiply the speed by the time for getting the
// distance traveled.
// TODO : done
Speedometer::computeSpeed();
// compute distance

View File

@ -55,6 +55,7 @@ class Speedometer {
float getTraySize() const;
std::chrono::milliseconds getCurrentPedalRotationTime() const;
void setOnResetCallback(mbed::Callback<void()> cb);
mbed::Callback<void()> _cbOnReset;
#endif // defined(MBED_TEST_MODE)
private: