Add debug view
This commit is contained in:
19
TouchGFX/gui/src/containers/DebugViewItem.cpp
Normal file
19
TouchGFX/gui/src/containers/DebugViewItem.cpp
Normal file
@ -0,0 +1,19 @@
|
||||
#include <gui/containers/DebugViewItem.hpp>
|
||||
|
||||
DebugViewItem::DebugViewItem() {}
|
||||
|
||||
void DebugViewItem::initialize() { DebugViewItemBase::initialize(); }
|
||||
|
||||
void DebugViewItem::typeUpdated() {
|
||||
// We don't really need to do anything
|
||||
}
|
||||
|
||||
void DebugViewItem::titleBufferUpdated() {
|
||||
label.setWildcard(titleBuffer);
|
||||
label.invalidate();
|
||||
}
|
||||
|
||||
void DebugViewItem::valueBufferUpdated() {
|
||||
value.setWildcard(valueBuffer);
|
||||
value.invalidate();
|
||||
}
|
||||
29
TouchGFX/gui/src/containers/DebugViewLine.cpp
Normal file
29
TouchGFX/gui/src/containers/DebugViewLine.cpp
Normal file
@ -0,0 +1,29 @@
|
||||
#include "gui/common/DataField.hpp"
|
||||
#include "touchgfx/Color.hpp"
|
||||
#include <gui/containers/DebugViewLine.hpp>
|
||||
|
||||
DebugViewLine::DebugViewLine() : fields{&item1, &item2} {}
|
||||
|
||||
void DebugViewLine::initialize() { DebugViewLineBase::initialize(); }
|
||||
|
||||
void DebugViewLine::setFieldType(size_t i, DataFieldType type) {
|
||||
assert(i < NUM_FIELDS);
|
||||
fields[i]->setType(type);
|
||||
}
|
||||
|
||||
void DebugViewLine::setFieldVisible(size_t i, int visible) {
|
||||
fields[i]->setVisible(visible);
|
||||
fields[i]->invalidate();
|
||||
}
|
||||
|
||||
void DebugViewLine::updateFieldValues() {
|
||||
for (size_t i = 0; i < NUM_FIELDS; i++) {
|
||||
fields[i]->updateValue();
|
||||
}
|
||||
}
|
||||
|
||||
void DebugViewLine::setLightBG(int light) {
|
||||
uint8_t val = light ? 0x33 : 0x00;
|
||||
bg.setColor(Color::getColorFromRGB(val, val, val));
|
||||
bg.invalidate();
|
||||
}
|
||||
@ -1,79 +1,40 @@
|
||||
#include "gui/common/DataField.hpp"
|
||||
#include "texts/TextKeysAndLanguages.hpp"
|
||||
#include "touchgfx/Color.hpp"
|
||||
#include "touchgfx/TypedText.hpp"
|
||||
#include "touchgfx/Unicode.hpp"
|
||||
#include <gui/containers/DriverViewField.hpp>
|
||||
|
||||
DriverViewField::DriverViewField()
|
||||
: intDigits{0}, decimalDigits{0}, floatValue{0}, boolValue{0} {}
|
||||
DriverViewField::DriverViewField() {}
|
||||
|
||||
void DriverViewField::initialize() { DriverViewFieldBase::initialize(); }
|
||||
|
||||
void DriverViewField::setType(const DataFieldDescription &desc) {
|
||||
title.setTypedText(desc.title);
|
||||
title.invalidate();
|
||||
fieldKind = desc.kind;
|
||||
switch (desc.kind) {
|
||||
case DataFieldKind::Numeric:
|
||||
value.setTypedText(T_NUMBERWILDCARD);
|
||||
break;
|
||||
case DataFieldKind::Bool:
|
||||
case DataFieldKind::Text:
|
||||
value.setTypedText(T_DEFAULTWILDCARD);
|
||||
break;
|
||||
}
|
||||
intDigits = desc.int_digits;
|
||||
decimalDigits = desc.decimal_digits;
|
||||
updateValueBuffer();
|
||||
}
|
||||
|
||||
void DriverViewField::setValue(float newValue) {
|
||||
floatValue = newValue;
|
||||
updateValueBuffer();
|
||||
}
|
||||
|
||||
void DriverViewField::setValue(const char *str) {
|
||||
Unicode::strncpy(valueBuffer, str,
|
||||
sizeof(valueBuffer) / sizeof(Unicode::UnicodeChar));
|
||||
value.setWildcard(valueBuffer);
|
||||
value.invalidate();
|
||||
}
|
||||
|
||||
void DriverViewField::setValue(int boolValue) {
|
||||
this->boolValue = boolValue;
|
||||
updateValueBuffer();
|
||||
}
|
||||
|
||||
void DriverViewField::setSelected(int selected) {
|
||||
uint8_t v = selected ? 0x44 : 0x00;
|
||||
box.setColor(touchgfx::Color::getColorFromRGB(v, v, v));
|
||||
box.invalidate();
|
||||
}
|
||||
|
||||
void DriverViewField::updateValueBuffer() {
|
||||
switch (fieldKind) {
|
||||
case DataFieldKind::Numeric: {
|
||||
size_t width = intDigits;
|
||||
if (decimalDigits != 0) {
|
||||
width += decimalDigits + 1; // 1 digit for the decimal point
|
||||
}
|
||||
float params[3] = {(float)width, (float)decimalDigits, floatValue};
|
||||
Unicode::snprintfFloats(valueBuffer,
|
||||
sizeof(valueBuffer) / sizeof(Unicode::UnicodeChar),
|
||||
"%*.*f", params);
|
||||
value.setWildcard(valueBuffer);
|
||||
void DriverViewField::typeUpdated() {
|
||||
switch (desc->kind) {
|
||||
case DataFieldKind::Float:
|
||||
case DataFieldKind::Int:
|
||||
value.setTypedText(T_NUMBERWILDCARD);
|
||||
break;
|
||||
}
|
||||
case DataFieldKind::Bool: {
|
||||
const char *str = boolValue ? "YES" : "NO";
|
||||
Unicode::strncpy(valueBuffer, str,
|
||||
sizeof(valueBuffer) / sizeof(valueBuffer[0]));
|
||||
value.setWildcard(valueBuffer);
|
||||
break;
|
||||
}
|
||||
case DataFieldKind::Bool:
|
||||
case DataFieldKind::Text:
|
||||
// This is updated directly in setValue()
|
||||
value.setTypedText(T_DEFAULTWILDCARD_CENTERED);
|
||||
break;
|
||||
}
|
||||
value.invalidate();
|
||||
}
|
||||
|
||||
void DriverViewField::titleBufferUpdated() {
|
||||
title.setWildcard(titleBuffer);
|
||||
title.invalidate();
|
||||
}
|
||||
|
||||
void DriverViewField::valueBufferUpdated() {
|
||||
value.setWildcard(valueBuffer);
|
||||
value.invalidate();
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
#include "touchgfx/Color.hpp"
|
||||
#include "touchgfx/Unicode.hpp"
|
||||
#include <gui/containers/DriverViewFieldSelection.hpp>
|
||||
|
||||
DriverViewFieldSelection::DriverViewFieldSelection() {}
|
||||
@ -7,8 +8,10 @@ void DriverViewFieldSelection::initialize() {
|
||||
DriverViewFieldSelectionBase::initialize();
|
||||
}
|
||||
|
||||
void DriverViewFieldSelection::setName(const touchgfx::TypedText &name) {
|
||||
this->name.setTypedText(name);
|
||||
void DriverViewFieldSelection::setName(const char *name) {
|
||||
Unicode::strncpy(nameBuffer, name, sizeof(nameBuffer) / sizeof(*nameBuffer));
|
||||
this->name.setWildcard(nameBuffer);
|
||||
this->name.invalidate();
|
||||
}
|
||||
|
||||
void DriverViewFieldSelection::setSelected(int selected) {
|
||||
|
||||
Reference in New Issue
Block a user