mirror of https://github.com/ARMmbed/mbed-os.git
BLE: Add explicit constructor for Duration that accepts millisecond in input.
parent
fa4aa8f068
commit
c165bd98b7
|
@ -18,6 +18,7 @@
|
|||
#define BLE_COMMON_DURATION_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "platform/mbed_assert.h"
|
||||
|
||||
namespace ble {
|
||||
|
@ -62,6 +63,11 @@ struct Duration {
|
|||
MBED_STATIC_ASSERT(OtherTB >= TB && (OtherTB % TB) == 0, "Incompatible units");
|
||||
}
|
||||
|
||||
template<typename OtherRep>
|
||||
explicit Duration(Duration<OtherRep, 1000> other_ms, void* = NULL) :
|
||||
duration(clamp(((other_ms.value() * 1000) + TB - 1) / TB))
|
||||
{ }
|
||||
|
||||
Rep value() {
|
||||
return duration;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue