minor progress

This commit is contained in:
Andrey 2021-11-24 22:17:29 -05:00
parent 83fc9e21bd
commit 4e45297145
2 changed files with 13 additions and 13 deletions

View File

@ -157,7 +157,7 @@ void prepareEventAngles(TriggerWaveform *shape,
if (triggerShapeSynchPointIndex == EFI_ERROR_CODE) {
return;
}
float firstAngle = shape->getAngle(triggerShapeSynchPointIndex);
angle_t firstAngle = shape->getAngle(triggerShapeSynchPointIndex);
assertAngleRange(firstAngle, "firstAngle", CUSTOM_TRIGGER_SYNC_ANGLE);
int riseOnlyIndex = 0;

View File

@ -28,10 +28,10 @@ class cyclic_buffer
public:
void add(T value);
T get(int index) const;
T sum(int length) const;
T maxValue(int length) const;
T minValue(int length) const;
void setSize(unsigned int size);
T sum(size_t length) const;
T maxValue(size_t length) const;
T minValue(size_t length) const;
void setSize(size_t size);
bool contains(T value) const;
int getSize() const;
int getCount() const;
@ -44,7 +44,7 @@ class cyclic_buffer
/**
* number of elements added into this buffer, would be eventually bigger then size
*/
volatile unsigned count;
volatile size_t count;
};
template<typename T, size_t maxSize>
@ -83,7 +83,7 @@ bool cyclic_buffer<T, maxSize>::contains(T value) const {
}
template<typename T, size_t maxSize>
void cyclic_buffer<T, maxSize>::setSize(unsigned int size) {
void cyclic_buffer<T, maxSize>::setSize(size_t size) {
clear();
this->size = size < maxSize ? size : maxSize;
}
@ -110,14 +110,14 @@ T cyclic_buffer<T, maxSize>::get(int index) const {
}
template<typename T, size_t maxSize>
T cyclic_buffer<T, maxSize>::maxValue(int length) const {
T cyclic_buffer<T, maxSize>::maxValue(size_t length) const {
if (length > count) {
// not enough data in buffer
length = count;
}
int ci = currentIndex; // local copy to increase thread-safety
T result = std::numeric_limits<T>::min();
for (int i = 0; i < length; ++i) {
for (size_t i = 0; i < length; ++i) {
int index = ci - i - 1;
while (index < 0) {
index += size;
@ -131,13 +131,13 @@ T cyclic_buffer<T, maxSize>::maxValue(int length) const {
}
template<typename T, size_t maxSize>
T cyclic_buffer<T, maxSize>::minValue(int length) const {
T cyclic_buffer<T, maxSize>::minValue(size_t length) const {
if (length > count) {
length = count;
}
int ci = currentIndex; // local copy to increase thread-safety
T result = std::numeric_limits<T>::max();
for (int i = 0; i < length; ++i) {
for (size_t i = 0; i < length; ++i) {
int index = ci - i - 1;
while (index < 0) {
index += size;
@ -151,7 +151,7 @@ T cyclic_buffer<T, maxSize>::minValue(int length) const {
}
template<typename T, size_t maxSize>
T cyclic_buffer<T, maxSize>::sum(int length) const {
T cyclic_buffer<T, maxSize>::sum(size_t length) const {
if (length > count) {
length = count;
}
@ -159,7 +159,7 @@ T cyclic_buffer<T, maxSize>::sum(int length) const {
int ci = currentIndex; // local copy to increase thread-safety
T result = 0;
for (int i = 0; i < length; ++i) {
for (size_t i = 0; i < length; ++i) {
int index = ci - i - 1;
while (index < 0) {
index += size;