Implement sampling ADC and printing over VSP
This commit is contained in:
21
AdaptiveBrightnessFirmware/Inc/utils.hpp
Normal file
21
AdaptiveBrightnessFirmware/Inc/utils.hpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
namespace util {
|
||||
|
||||
template<typename Fn, size_t... Ints>
|
||||
auto for_constexpr(Fn&& func, std::index_sequence<Ints...>)
|
||||
{
|
||||
if constexpr(std::is_void_v<std::invoke_result_t<Fn, std::integral_constant<size_t, 0>>>) {
|
||||
(func(std::integral_constant<size_t, Ints>{}), ...);
|
||||
}
|
||||
else {
|
||||
if((func(std::integral_constant<size_t, Ints>{}) && ...))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace util
|
||||
Reference in New Issue
Block a user