Make DriverView fields more modular
This commit is contained in:
36
TouchGFX/gui/include/gui/common/DataField.hpp
Normal file
36
TouchGFX/gui/include/gui/common/DataField.hpp
Normal file
@ -0,0 +1,36 @@
|
||||
#ifndef DATAFIELD_HPP
|
||||
#define DATAFIELD_HPP
|
||||
|
||||
#include "touchgfx/TypedText.hpp"
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
// We want to automatically count the number of data field types for the
|
||||
// description array. This is wacky preprocessor magic that allows us to do just
|
||||
// that. Unfortunately, it doesn't work with enum classes, so we have to use
|
||||
// C-style enums.
|
||||
#define CountedEnum(NAME, TYPE, ...) \
|
||||
enum NAME : TYPE { __VA_ARGS__ }; \
|
||||
constexpr size_t NAME##_COUNT = sizeof((int[]){__VA_ARGS__}) / sizeof(int);
|
||||
|
||||
CountedEnum(DataFieldType, size_t, DF_TSState, DF_ASState, DF_ActiveMission,
|
||||
DF_R2DProgress, DF_INVLReady, DF_INVRReady, DF_SDC, DF_ERR,
|
||||
DF_IniChkState, DF_LapCount, DF_TireTempFL, DF_TireTempFR,
|
||||
DF_TireTempRL, DF_TireTempRR, DF_MinCellVolt, DF_MaxCellTemp,
|
||||
DF_TSSoC, DF_LVSoC, DF_TSCurrent, DF_TSVoltageBat, DF_TSVoltageVeh,
|
||||
DF_Speed, DF_BBal);
|
||||
|
||||
enum class DataFieldKind { Numeric, Bool, Text };
|
||||
|
||||
struct DataFieldDescription {
|
||||
DataFieldKind kind;
|
||||
touchgfx::TypedText title;
|
||||
size_t int_digits;
|
||||
size_t decimal_digits;
|
||||
|
||||
void* (*getValue)(void);
|
||||
};
|
||||
|
||||
extern DataFieldDescription dataFieldDescs[];
|
||||
|
||||
#endif // DATAFIELD_HPP
|
||||
Reference in New Issue
Block a user