mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-12-03 17:59:16 +00:00
Notification settings: correctly count values with a zero index (#621)
This commit is contained in:
parent
bf6c9fe114
commit
15592682ad
1 changed files with 3 additions and 3 deletions
|
@ -74,7 +74,7 @@ uint8_t float_value_index(const float value, const float values[], uint8_t value
|
|||
const float epsilon = 0.01f;
|
||||
float last_value = values[0];
|
||||
uint8_t index = 0;
|
||||
for(uint8_t i = 1; i < values_count; i++) {
|
||||
for(uint8_t i = 0; i < values_count; i++) {
|
||||
if((value >= last_value - epsilon) && (value <= values[i] + epsilon)) {
|
||||
index = i;
|
||||
break;
|
||||
|
@ -85,9 +85,9 @@ uint8_t float_value_index(const float value, const float values[], uint8_t value
|
|||
}
|
||||
|
||||
uint8_t uint32_value_index(const uint32_t value, const uint32_t values[], uint8_t values_count) {
|
||||
float last_value = values[0];
|
||||
int64_t last_value = INT64_MIN;
|
||||
uint8_t index = 0;
|
||||
for(uint8_t i = 1; i < values_count; i++) {
|
||||
for(uint8_t i = 0; i < values_count; i++) {
|
||||
if((value >= last_value) && (value <= values[i])) {
|
||||
index = i;
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue