2019-06-01 23:31:32 +00:00
|
|
|
//
|
|
|
|
// DriveSpeedAccumulator.hpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 01/06/2019.
|
|
|
|
// Copyright © 2019 Thomas Harte. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef DriveSpeedAccumulator_hpp
|
|
|
|
#define DriveSpeedAccumulator_hpp
|
|
|
|
|
|
|
|
#include <array>
|
|
|
|
#include <cstddef>
|
|
|
|
#include <cstdint>
|
|
|
|
|
|
|
|
namespace Apple {
|
|
|
|
namespace Macintosh {
|
|
|
|
|
|
|
|
class DriveSpeedAccumulator {
|
|
|
|
public:
|
|
|
|
/*!
|
|
|
|
Accepts fetched motor control values.
|
|
|
|
*/
|
|
|
|
void post_sample(uint8_t sample);
|
|
|
|
|
2019-08-08 01:39:23 +00:00
|
|
|
struct Delegate {
|
|
|
|
virtual void drive_speed_accumulator_set_drive_speed(DriveSpeedAccumulator *, float speed) = 0;
|
|
|
|
};
|
2019-07-30 19:08:55 +00:00
|
|
|
/*!
|
2019-08-08 01:39:23 +00:00
|
|
|
Sets the delegate to receive drive speed changes.
|
2019-07-30 19:08:55 +00:00
|
|
|
*/
|
2019-08-08 01:39:23 +00:00
|
|
|
void set_delegate(Delegate *delegate) {
|
|
|
|
delegate_ = delegate;;
|
|
|
|
}
|
2019-07-30 19:08:55 +00:00
|
|
|
|
2019-06-01 23:31:32 +00:00
|
|
|
private:
|
2019-08-01 03:19:46 +00:00
|
|
|
std::array<uint8_t, 20> samples_;
|
2019-06-01 23:31:32 +00:00
|
|
|
std::size_t sample_pointer_ = 0;
|
2019-08-08 01:39:23 +00:00
|
|
|
Delegate *delegate_ = nullptr;
|
2019-06-01 23:31:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* DriveSpeedAccumulator_hpp */
|