mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-22 18:52:30 +00:00
Add cpp clamp function to util.h, switched battery and signal strength percentage calcs to it #197
This commit is contained in:
7
src/utils.h
Normal file
7
src/utils.h
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user