Add debug view
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
#define DATAFIELD_HPP
|
||||
|
||||
#include "touchgfx/TypedText.hpp"
|
||||
#include "touchgfx/Unicode.hpp"
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
@ -20,17 +21,51 @@ CountedEnum(DataFieldType, size_t, DF_TSState, DF_ASState, DF_ActiveMission,
|
||||
DF_TSSoC, DF_LVSoC, DF_TSCurrent, DF_TSVoltageBat, DF_TSVoltageVeh,
|
||||
DF_Speed, DF_BBal);
|
||||
|
||||
enum class DataFieldKind { Numeric, Bool, Text };
|
||||
enum class DataFieldKind { Float, Bool, Text, Int };
|
||||
|
||||
struct DataFieldDescription {
|
||||
DataFieldKind kind;
|
||||
touchgfx::TypedText title;
|
||||
const char *title;
|
||||
size_t int_digits;
|
||||
size_t decimal_digits;
|
||||
|
||||
void* (*getValue)(void);
|
||||
void *(*getValue)(void);
|
||||
};
|
||||
|
||||
extern DataFieldDescription dataFieldDescs[];
|
||||
|
||||
class DataField {
|
||||
public:
|
||||
virtual ~DataField() {}
|
||||
|
||||
void setType(DataFieldType type);
|
||||
DataFieldType getType();
|
||||
|
||||
virtual void updateValue();
|
||||
|
||||
protected:
|
||||
touchgfx::Unicode::UnicodeChar titleBuffer[16];
|
||||
touchgfx::Unicode::UnicodeChar valueBuffer[16];
|
||||
|
||||
DataFieldType type;
|
||||
const DataFieldDescription *desc;
|
||||
union {
|
||||
float f;
|
||||
int b;
|
||||
int i;
|
||||
} fieldValue;
|
||||
|
||||
virtual void typeUpdated() = 0;
|
||||
virtual void titleBufferUpdated() = 0;
|
||||
virtual void valueBufferUpdated() = 0;
|
||||
|
||||
private:
|
||||
void setFloatValue(float floatValue);
|
||||
void setBoolValue(int boolValue);
|
||||
void setIntValue(int intValue);
|
||||
void setStrValue(const char *strValue);
|
||||
|
||||
void updateValueBuffer();
|
||||
};
|
||||
|
||||
#endif // DATAFIELD_HPP
|
||||
|
||||
20
TouchGFX/gui/include/gui/containers/DebugViewItem.hpp
Normal file
20
TouchGFX/gui/include/gui/containers/DebugViewItem.hpp
Normal file
@ -0,0 +1,20 @@
|
||||
#ifndef DEBUGVIEWITEM_HPP
|
||||
#define DEBUGVIEWITEM_HPP
|
||||
|
||||
#include "gui/common/DataField.hpp"
|
||||
#include <gui_generated/containers/DebugViewItemBase.hpp>
|
||||
|
||||
class DebugViewItem : public DebugViewItemBase, public DataField {
|
||||
public:
|
||||
DebugViewItem();
|
||||
virtual ~DebugViewItem() {}
|
||||
|
||||
virtual void initialize() override;
|
||||
|
||||
protected:
|
||||
virtual void typeUpdated() override;
|
||||
virtual void titleBufferUpdated() override;
|
||||
virtual void valueBufferUpdated() override;
|
||||
};
|
||||
|
||||
#endif // DEBUGVIEWITEM_HPP
|
||||
27
TouchGFX/gui/include/gui/containers/DebugViewLine.hpp
Normal file
27
TouchGFX/gui/include/gui/containers/DebugViewLine.hpp
Normal file
@ -0,0 +1,27 @@
|
||||
#ifndef DEBUGVIEWLINE_HPP
|
||||
#define DEBUGVIEWLINE_HPP
|
||||
|
||||
#include "gui/common/DataField.hpp"
|
||||
#include "gui/containers/DebugViewItem.hpp"
|
||||
#include <gui_generated/containers/DebugViewLineBase.hpp>
|
||||
|
||||
class DebugViewLine : public DebugViewLineBase {
|
||||
public:
|
||||
DebugViewLine();
|
||||
virtual ~DebugViewLine() {}
|
||||
|
||||
virtual void initialize();
|
||||
|
||||
void setFieldType(size_t i, DataFieldType type);
|
||||
void setFieldVisible(size_t i, int visible);
|
||||
void updateFieldValues();
|
||||
void setLightBG(int light);
|
||||
|
||||
static constexpr size_t NUM_FIELDS = 2;
|
||||
|
||||
protected:
|
||||
private:
|
||||
DebugViewItem *fields[NUM_FIELDS];
|
||||
};
|
||||
|
||||
#endif // DEBUGVIEWLINE_HPP
|
||||
@ -7,31 +7,20 @@
|
||||
|
||||
#include "gui/common/DataField.hpp"
|
||||
|
||||
class DriverViewField : public DriverViewFieldBase {
|
||||
class DriverViewField : public DriverViewFieldBase, public DataField {
|
||||
public:
|
||||
DriverViewField();
|
||||
virtual ~DriverViewField() {}
|
||||
|
||||
virtual void initialize();
|
||||
|
||||
void setType(const DataFieldDescription &desc);
|
||||
void setValue(float newValue);
|
||||
void setValue(const char *str);
|
||||
void setValue(int boolValue);
|
||||
virtual void initialize() override;
|
||||
|
||||
void setSelected(int selected);
|
||||
|
||||
protected:
|
||||
private:
|
||||
Unicode::UnicodeChar valueBuffer[16];
|
||||
|
||||
DataFieldKind fieldKind;
|
||||
size_t intDigits;
|
||||
size_t decimalDigits;
|
||||
float floatValue;
|
||||
int boolValue;
|
||||
|
||||
void updateValueBuffer();
|
||||
virtual void typeUpdated() override;
|
||||
virtual void titleBufferUpdated() override;
|
||||
virtual void valueBufferUpdated() override;
|
||||
};
|
||||
|
||||
#endif // DRIVERVIEWFIELD_HPP
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
#define DRIVERVIEWFIELDSELECTION_HPP
|
||||
|
||||
#include "touchgfx/TypedText.hpp"
|
||||
#include "touchgfx/Unicode.hpp"
|
||||
#include <gui_generated/containers/DriverViewFieldSelectionBase.hpp>
|
||||
|
||||
class DriverViewFieldSelection : public DriverViewFieldSelectionBase {
|
||||
@ -11,10 +12,12 @@ public:
|
||||
|
||||
virtual void initialize();
|
||||
|
||||
void setName(const touchgfx::TypedText &name);
|
||||
void setName(const char *name);
|
||||
void setSelected(int selected);
|
||||
|
||||
protected:
|
||||
private:
|
||||
Unicode::UnicodeChar nameBuffer[16];
|
||||
};
|
||||
|
||||
#endif // DRIVERVIEWFIELDSELECTION_HPP
|
||||
|
||||
@ -0,0 +1,38 @@
|
||||
#ifndef DEBUGVIEWPRESENTER_HPP
|
||||
#define DEBUGVIEWPRESENTER_HPP
|
||||
|
||||
#include <gui/model/ModelListener.hpp>
|
||||
#include <mvp/Presenter.hpp>
|
||||
|
||||
using namespace touchgfx;
|
||||
|
||||
class DebugViewView;
|
||||
|
||||
class DebugViewPresenter : public touchgfx::Presenter, public ModelListener {
|
||||
public:
|
||||
DebugViewPresenter(DebugViewView &v);
|
||||
|
||||
/**
|
||||
* The activate function is called automatically when this screen is "switched
|
||||
* in" (ie. made active). Initialization logic can be placed here.
|
||||
*/
|
||||
virtual void activate() override;
|
||||
|
||||
/**
|
||||
* The deactivate function is called automatically when this screen is
|
||||
* "switched out" (ie. made inactive). Teardown functionality can be placed
|
||||
* here.
|
||||
*/
|
||||
virtual void deactivate() override;
|
||||
|
||||
virtual ~DebugViewPresenter(){};
|
||||
|
||||
virtual void vehicleStateUpdated() override;
|
||||
|
||||
private:
|
||||
DebugViewPresenter();
|
||||
|
||||
DebugViewView &view;
|
||||
};
|
||||
|
||||
#endif // DEBUGVIEWPRESENTER_HPP
|
||||
21
TouchGFX/gui/include/gui/debugview_screen/DebugViewView.hpp
Normal file
21
TouchGFX/gui/include/gui/debugview_screen/DebugViewView.hpp
Normal file
@ -0,0 +1,21 @@
|
||||
#ifndef DEBUGVIEWVIEW_HPP
|
||||
#define DEBUGVIEWVIEW_HPP
|
||||
|
||||
#include <gui/debugview_screen/DebugViewPresenter.hpp>
|
||||
#include <gui_generated/debugview_screen/DebugViewViewBase.hpp>
|
||||
|
||||
class DebugViewView : public DebugViewViewBase {
|
||||
public:
|
||||
DebugViewView();
|
||||
virtual ~DebugViewView() {}
|
||||
virtual void setupScreen() override;
|
||||
virtual void tearDownScreen() override;
|
||||
|
||||
virtual void listUpdateItem(DebugViewLine &line, int16_t itemIndex) override;
|
||||
|
||||
void updateFieldValues();
|
||||
|
||||
protected:
|
||||
};
|
||||
|
||||
#endif // DEBUGVIEWVIEW_HPP
|
||||
@ -18,19 +18,21 @@ public:
|
||||
* The activate function is called automatically when this screen is "switched
|
||||
* in" (ie. made active). Initialization logic can be placed here.
|
||||
*/
|
||||
virtual void activate();
|
||||
virtual void activate() override;
|
||||
|
||||
/**
|
||||
* The deactivate function is called automatically when this screen is
|
||||
* "switched out" (ie. made inactive). Teardown functionality can be placed
|
||||
* here.
|
||||
*/
|
||||
virtual void deactivate();
|
||||
virtual void deactivate() override;
|
||||
|
||||
virtual ~DriverViewPresenter(){};
|
||||
|
||||
void vehicleStateUpdated() override;
|
||||
|
||||
void setFieldType(size_t i, DataFieldType type);
|
||||
|
||||
private:
|
||||
DriverViewPresenter();
|
||||
|
||||
|
||||
@ -12,16 +12,14 @@ class DriverViewView : public DriverViewViewBase {
|
||||
public:
|
||||
DriverViewView();
|
||||
virtual ~DriverViewView() {}
|
||||
virtual void setupScreen();
|
||||
virtual void tearDownScreen();
|
||||
virtual void setupScreen() override;
|
||||
virtual void tearDownScreen() override;
|
||||
|
||||
void fieldTypeSelectionUpdateItem(DriverViewFieldSelection &item,
|
||||
int16_t itemIndex) override;
|
||||
|
||||
void setFieldType(size_t i, const DataFieldDescription &desc);
|
||||
void setFieldValue(size_t i, float value);
|
||||
void setFieldValue(size_t i, const char *value);
|
||||
void setFieldValue(size_t i, int value);
|
||||
void setFieldType(size_t i, DataFieldType type);
|
||||
void updateFieldValues();
|
||||
|
||||
void setTireTemps(const TireTemps &temps);
|
||||
void setTSSoC(uint8_t soc);
|
||||
@ -37,7 +35,6 @@ public:
|
||||
protected:
|
||||
private:
|
||||
DriverViewField &getField(size_t i);
|
||||
DriverViewFieldSelection *getFieldType(size_t i);
|
||||
|
||||
void updateSelectedField(size_t select);
|
||||
void updateSelectedFieldType(size_t select);
|
||||
|
||||
Reference in New Issue
Block a user