rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
rusefi_config_generated_enums.h
Go to the documentation of this file.
1// Not yet generated
2
3#pragma once
4
5#include <cstdint>
6#include <cstring>
7#include <type_traits>
8
10{
11 template<typename T>
12 constexpr auto Enum2Underlying(T const e) requires std::is_enum_v<T> {
13 return static_cast<std::underlying_type_t<T>>(e);
14 }
15
16 template <typename T>
18 T const enumValue;
19 char const* const name;
20 };
21
22 template <typename T>
24
25 template <typename T>
26 constexpr char const* Enum2String(T const e) {
27 for (auto& entry : EnumLookUp<T>) {
28 if (entry.enumValue == e) {
29 return entry.name;
30 }
31 }
32 return "UNSUPPORTED_ENUM_VALUE";
33 }
34
35 template <typename T>
36 constexpr T String2Enum(char const* const s) {
37 for (auto& entry : EnumLookUp<T>) {
38 if (std::strncmp(entry.name, s, std::strlen(entry.name) + 1) == 0) {
39 return entry.enumValue;
40 }
41 }
42 return T::UNSUPPORTED_ENUM_VALUE; // Invalid value (may need adjustment)
43 }
44
45 /* This enum is used to select your desired Engine Load calculation algorithm */
46 enum class engine_load_mode_e: uint8_t {
47 /* Speed Density algorithm - Engine Load is a function of MAP, VE and target AFR
48 * http://articles.sae.org/8539/ */
50 /* MAF with a known kg/hour function */
51 LM_REAL_MAF = 1,
52 LM_ALPHA_N = 2,
53 LM_LUA = 3,
55 };
56
57 template<>
64}
constexpr char const * Enum2String(T const e)
constexpr EnumStringPair< engine_load_mode_e > EnumLookUp< engine_load_mode_e >[]
constexpr EnumStringPair< T > EnumLookUp[]
constexpr T String2Enum(char const *const s)
constexpr auto Enum2Underlying(T const e)