Added float map (might need debugging)

This commit is contained in:
CommanderRedYT
2022-03-03 22:41:39 +01:00
parent cb1065ccb4
commit 177220df6b
2 changed files with 9 additions and 0 deletions

View File

@ -330,3 +330,11 @@ std::string get_wifi_security_string(wifi_auth_mode_t authMode)
return "unknown";
}
}
float float_map(float x, float in_min, float in_max, float out_min, float out_max) {
const float dividend = out_max - out_min;
const float divisor = in_max - in_min;
const float delta = x - in_min;
return (delta * dividend + (divisor / 2.f)) / divisor + out_min;
}

View File

@ -79,3 +79,4 @@ inline CRGB UINT32_TO_CRGB(uint32_t color)
}
std::string get_wifi_security_string(wifi_auth_mode_t authMode);
float float_map(float x, float in_min, float in_max, float out_min, float out_max);