ADD part of mail for pedal device
This commit is contained in:
parent
36e4a07102
commit
946e86025c
@ -191,6 +191,7 @@ void BikeSystem::speedDistanceTask() {
|
||||
|
||||
const auto pedalRotationTime = _pedalDevice.getCurrentRotationTime();
|
||||
_speedometer.setCurrentRotationTime(pedalRotationTime);
|
||||
|
||||
_speedometer.setGearSize(getCurrentGearSize());
|
||||
|
||||
_currentSpeed = _speedometer.getCurrentSpeed();
|
||||
|
@ -82,6 +82,9 @@ class BikeSystem {
|
||||
uint8_t getCurrentGearSize();
|
||||
void setCurrentGear(uint8_t gear);
|
||||
|
||||
void dispatch_isr_events();
|
||||
void dispatch_events();
|
||||
|
||||
// timer instance used for loggint task time and used by ResetDevice
|
||||
std::chrono::microseconds _resetTime = std::chrono::microseconds::zero();
|
||||
std::chrono::microseconds _onGearUpTime = std::chrono::microseconds::zero();
|
||||
@ -90,16 +93,23 @@ class BikeSystem {
|
||||
Timer _timer;
|
||||
// data member that represents the device for manipulating the gear
|
||||
GearDevice _gearDevice;
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// shared resources between the main thread and the isr thread
|
||||
uint8_t _currentGear = bike_computer::kMinGear;
|
||||
uint8_t _currentGearSize = bike_computer::kMinGearSize;
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
// data member that represents the device for manipulating the pedal rotation
|
||||
// speed/time
|
||||
PedalDevice _pedalDevice;
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// shared resources between the main thread and the isr thread
|
||||
float _currentSpeed = 0.0f;
|
||||
float _traveledDistance = 0.0f;
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
// data member that represents the device used for resetting
|
||||
ResetDevice _resetDevice;
|
||||
// data member that represents the device display
|
||||
@ -126,9 +136,6 @@ class BikeSystem {
|
||||
|
||||
// Tread for isr events
|
||||
Thread _isrEventThread;
|
||||
|
||||
void dispatch_isr_events();
|
||||
void dispatch_events();
|
||||
};
|
||||
|
||||
} // namespace multi_tasking
|
||||
|
@ -36,10 +36,9 @@
|
||||
|
||||
namespace multi_tasking {
|
||||
|
||||
PedalDevice::PedalDevice() {
|
||||
disco::Joystick::getInstance().setLeftCallback(callback(this, &PedalDevice::onLeft));
|
||||
disco::Joystick::getInstance().setRightCallback(
|
||||
callback(this, &PedalDevice::onRight));
|
||||
PedalDevice::PedalDevice(Callback<void()> cbOnLeft, Callback<void()> cbOnRight) {
|
||||
disco::Joystick::getInstance().setLeftCallback(callback(cbOnLeft));
|
||||
disco::Joystick::getInstance().setRightCallback(callback(cbOnRight));
|
||||
}
|
||||
|
||||
std::chrono::milliseconds PedalDevice::getCurrentRotationTime() {
|
||||
|
@ -33,7 +33,8 @@ namespace multi_tasking {
|
||||
|
||||
class PedalDevice {
|
||||
public:
|
||||
PedalDevice(); // NOLINT(runtime/references)
|
||||
PedalDevice(Callback<void()> cbOnLeft,
|
||||
Callback<void()> cbOnRight); // NOLINT(runtime/references)
|
||||
|
||||
// make the class non copyable
|
||||
PedalDevice(PedalDevice&) = delete;
|
||||
@ -43,12 +44,6 @@ class PedalDevice {
|
||||
std::chrono::milliseconds getCurrentRotationTime();
|
||||
|
||||
private:
|
||||
// private methods
|
||||
void onLeft();
|
||||
void onRight();
|
||||
void increaseRotationSpeed();
|
||||
void decreaseRotationSpeed();
|
||||
|
||||
// data members
|
||||
volatile uint32_t _currentStep = static_cast<uint32_t>(
|
||||
(bike_computer::kInitialPedalRotationTime - bike_computer::kMinPedalRotationTime)
|
||||
|
Loading…
x
Reference in New Issue
Block a user