2020-06-22 14:06:02 -07:00
|
|
|
#pragma once
|
2024-08-09 01:43:13 -05:00
|
|
|
#include "DebugConfiguration.h"
|
|
|
|
|
#include <stdint.h>
|
2020-06-22 14:06:02 -07:00
|
|
|
|
|
|
|
|
/// C++ v17+ clamp function, limits a given value to a range defined by lo and hi
|
2023-01-21 14:34:29 +01:00
|
|
|
template <class T> constexpr const T &clamp(const T &v, const T &lo, const T &hi)
|
|
|
|
|
{
|
2020-06-22 14:06:02 -07:00
|
|
|
return (v < lo) ? lo : (hi < v) ? hi : v;
|
2023-08-28 11:13:17 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if (defined(ARCH_PORTDUINO) && !defined(STRNSTR))
|
|
|
|
|
#define STRNSTR
|
2024-01-12 02:00:31 -06:00
|
|
|
#include <string.h>
|
2023-08-28 11:13:17 -05:00
|
|
|
char *strnstr(const char *s, const char *find, size_t slen);
|
2024-08-10 13:45:41 -05:00
|
|
|
#endif
|
|
|
|
|
|
2024-08-13 22:34:21 -05:00
|
|
|
void printBytes(const char *label, const uint8_t *p, size_t numbytes);
|
|
|
|
|
|
|
|
|
|
// is the memory region filled with a single character?
|
|
|
|
|
bool memfll(const uint8_t *mem, uint8_t find, size_t numbytes);
|