Add cpp clamp function to util.h, switched battery and signal strength percentage calcs to it #197

This commit is contained in:
Professr
2020-06-22 14:06:02 -07:00
parent 9061b3d8c3
commit 6a857b00db
3 changed files with 11 additions and 3 deletions

7
src/utils.h Normal file
View File

@@ -0,0 +1,7 @@
#pragma once
/// C++ v17+ clamp function, limits a given value to a range defined by lo and hi
template<class T>
constexpr const T& clamp( const T& v, const T& lo, const T& hi ) {
return (v < lo) ? lo : (hi < v) ? hi : v;
}