Compare commits
No commits in common. "80caf298db17acaff4d49b6075146fdd2daf3cb3" and "a3265543a5f59d995f017d7f3efbf45d5f7a6c2f" have entirely different histories.
80caf298db
...
a3265543a5
@ -8,7 +8,7 @@
|
|||||||
#include <mvp/View.hpp>
|
#include <mvp/View.hpp>
|
||||||
#include <gui/debugview_screen/DebugViewPresenter.hpp>
|
#include <gui/debugview_screen/DebugViewPresenter.hpp>
|
||||||
#include <touchgfx/widgets/Box.hpp>
|
#include <touchgfx/widgets/Box.hpp>
|
||||||
#include <touchgfx/containers/scrollers/ScrollWheel.hpp>
|
#include <touchgfx/containers/scrollers/ScrollList.hpp>
|
||||||
#include <gui/containers/DebugViewLine.hpp>
|
#include <gui/containers/DebugViewLine.hpp>
|
||||||
#include <touchgfx/widgets/canvas/Line.hpp>
|
#include <touchgfx/widgets/canvas/Line.hpp>
|
||||||
#include <touchgfx/widgets/canvas/PainterRGB565.hpp>
|
#include <touchgfx/widgets/canvas/PainterRGB565.hpp>
|
||||||
@ -24,19 +24,6 @@ public:
|
|||||||
{
|
{
|
||||||
// Override and implement this function in DebugView
|
// Override and implement this function in DebugView
|
||||||
}
|
}
|
||||||
virtual void handleKeyEvent(uint8_t key);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Virtual Action Handlers
|
|
||||||
*/
|
|
||||||
virtual void scrollUp()
|
|
||||||
{
|
|
||||||
// Override and implement this function in DebugView
|
|
||||||
}
|
|
||||||
virtual void scrollDown()
|
|
||||||
{
|
|
||||||
// Override and implement this function in DebugView
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
FrontendApplication& application() {
|
FrontendApplication& application() {
|
||||||
@ -47,7 +34,7 @@ protected:
|
|||||||
* Member Declarations
|
* Member Declarations
|
||||||
*/
|
*/
|
||||||
touchgfx::Box __background;
|
touchgfx::Box __background;
|
||||||
touchgfx::ScrollWheel list;
|
touchgfx::ScrollList list;
|
||||||
touchgfx::DrawableListItems<DebugViewLine, 13> listListItems;
|
touchgfx::DrawableListItems<DebugViewLine, 13> listListItems;
|
||||||
touchgfx::Line line1;
|
touchgfx::Line line1;
|
||||||
touchgfx::PainterRGB565 line1Painter;
|
touchgfx::PainterRGB565 line1Painter;
|
||||||
|
@ -17,14 +17,14 @@ DebugViewViewBase::DebugViewViewBase() :
|
|||||||
list.setPosition(15, 15, 450, 290);
|
list.setPosition(15, 15, 450, 290);
|
||||||
list.setHorizontal(false);
|
list.setHorizontal(false);
|
||||||
list.setCircular(true);
|
list.setCircular(true);
|
||||||
list.setEasingEquation(touchgfx::EasingEquations::linearEaseOut);
|
list.setEasingEquation(touchgfx::EasingEquations::backEaseOut);
|
||||||
list.setSwipeAcceleration(10);
|
list.setSwipeAcceleration(10);
|
||||||
list.setDragAcceleration(10);
|
list.setDragAcceleration(10);
|
||||||
list.setNumberOfItems(1);
|
list.setNumberOfItems(1);
|
||||||
list.setSelectedItemOffset(0);
|
list.setPadding(0, 0);
|
||||||
|
list.setSnapping(false);
|
||||||
list.setDrawableSize(26, 0);
|
list.setDrawableSize(26, 0);
|
||||||
list.setDrawables(listListItems, updateItemCallback);
|
list.setDrawables(listListItems, updateItemCallback);
|
||||||
list.animateToItem(0, 0);
|
|
||||||
add(list);
|
add(list);
|
||||||
|
|
||||||
line1.setPosition(15, 15, 1, 290);
|
line1.setPosition(15, 15, 1, 290);
|
||||||
@ -69,27 +69,6 @@ void DebugViewViewBase::setupScreen()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebugViewViewBase::handleKeyEvent(uint8_t key)
|
|
||||||
{
|
|
||||||
if(104 == key)
|
|
||||||
{
|
|
||||||
//ScrollUp
|
|
||||||
//When hardware button 104 clicked call virtual function
|
|
||||||
//Call scrollUp
|
|
||||||
scrollUp();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if(108 == key)
|
|
||||||
{
|
|
||||||
//ScrollDown
|
|
||||||
//When hardware button 108 clicked call virtual function
|
|
||||||
//Call scrollDown
|
|
||||||
scrollDown();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DebugViewViewBase::updateItemCallbackHandler(touchgfx::DrawableListItemsInterface* items, int16_t containerIndex, int16_t itemIndex)
|
void DebugViewViewBase::updateItemCallbackHandler(touchgfx::DrawableListItemsInterface* items, int16_t containerIndex, int16_t itemIndex)
|
||||||
{
|
{
|
||||||
if (items == &listListItems)
|
if (items == &listListItems)
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#ifndef NAMEDFIELD_HPP
|
#ifndef NAMEDFIELD_HPP
|
||||||
#define NAMEDFIELD_HPP
|
#define NAMEDFIELD_HPP
|
||||||
|
|
||||||
#include "params.h"
|
|
||||||
#include "touchgfx/TypedText.hpp"
|
#include "touchgfx/TypedText.hpp"
|
||||||
#include "touchgfx/Unicode.hpp"
|
#include "touchgfx/Unicode.hpp"
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
@ -30,13 +29,6 @@ struct NamedFieldDescription {
|
|||||||
extern NamedFieldDescription dataFieldDescs[];
|
extern NamedFieldDescription dataFieldDescs[];
|
||||||
extern NamedFieldDescription paramFieldDescs[];
|
extern NamedFieldDescription paramFieldDescs[];
|
||||||
|
|
||||||
extern DataFieldType dataFieldByAlphaIndex[];
|
|
||||||
extern size_t dataFieldAlphaIndexByField[];
|
|
||||||
extern ParamType paramByAlphaIndex[];
|
|
||||||
extern size_t paramAlphaIndexByParam[];
|
|
||||||
|
|
||||||
void namedFieldSort();
|
|
||||||
|
|
||||||
template <class T> class NamedField {
|
template <class T> class NamedField {
|
||||||
public:
|
public:
|
||||||
NamedField(const NamedFieldDescription *fieldDescs);
|
NamedField(const NamedFieldDescription *fieldDescs);
|
||||||
|
@ -13,16 +13,9 @@ public:
|
|||||||
|
|
||||||
virtual void listUpdateItem(DebugViewLine &line, int16_t itemIndex) override;
|
virtual void listUpdateItem(DebugViewLine &line, int16_t itemIndex) override;
|
||||||
|
|
||||||
void scrollUp() override;
|
|
||||||
void scrollDown() override;
|
|
||||||
|
|
||||||
void updateFieldValues();
|
void updateFieldValues();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
private:
|
|
||||||
void updateScrollIndex(size_t index);
|
|
||||||
|
|
||||||
size_t scrollIndex;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DEBUGVIEWVIEW_HPP
|
#endif // DEBUGVIEWVIEW_HPP
|
||||||
|
@ -46,11 +46,10 @@ private:
|
|||||||
DriverViewField &getField(size_t i);
|
DriverViewField &getField(size_t i);
|
||||||
|
|
||||||
void updateSelectedField(size_t select);
|
void updateSelectedField(size_t select);
|
||||||
void updateSelectedFieldIndex(size_t index, bool animate = true);
|
void updateSelectedFieldType(size_t select, bool animate = true);
|
||||||
void updateSelectedFieldType(DataFieldType type, bool animate = true);
|
|
||||||
|
|
||||||
size_t selectedField;
|
size_t selectedField;
|
||||||
size_t selectedFieldIndex;
|
size_t selectedFieldType;
|
||||||
DataFieldType fieldTypes[NUM_FIELDS];
|
DataFieldType fieldTypes[NUM_FIELDS];
|
||||||
|
|
||||||
touchgfx::Unicode::UnicodeChar r2dProgBuffer[16];
|
touchgfx::Unicode::UnicodeChar r2dProgBuffer[16];
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
#include <gui/common/FrontendApplication.hpp>
|
#include <gui/common/FrontendApplication.hpp>
|
||||||
|
|
||||||
#include "gui/common/NamedField.hpp"
|
FrontendApplication::FrontendApplication(Model& m, FrontendHeap& heap)
|
||||||
|
: FrontendApplicationBase(m, heap)
|
||||||
|
{
|
||||||
|
|
||||||
FrontendApplication::FrontendApplication(Model &m, FrontendHeap &heap)
|
|
||||||
: FrontendApplicationBase(m, heap) {
|
|
||||||
namedFieldSort();
|
|
||||||
}
|
}
|
||||||
|
@ -6,9 +6,6 @@
|
|||||||
#include "params.h"
|
#include "params.h"
|
||||||
#include "vehicle_state.h"
|
#include "vehicle_state.h"
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
#define VEH_FIELD(FIELD) []() { return (void *)&vehicle_state.FIELD; }
|
#define VEH_FIELD(FIELD) []() { return (void *)&vehicle_state.FIELD; }
|
||||||
#define VEH_BIT_FIELD(FIELD) \
|
#define VEH_BIT_FIELD(FIELD) \
|
||||||
[]() { \
|
[]() { \
|
||||||
@ -303,42 +300,6 @@ static_assert(sizeof(paramFieldDescs) / sizeof(paramFieldDescs[0]) ==
|
|||||||
ParamType_COUNT,
|
ParamType_COUNT,
|
||||||
"Incorrect number of param field descriptions");
|
"Incorrect number of param field descriptions");
|
||||||
|
|
||||||
DataFieldType dataFieldByAlphaIndex[DataFieldType_COUNT];
|
|
||||||
size_t dataFieldAlphaIndexByField[DataFieldType_COUNT];
|
|
||||||
ParamType paramByAlphaIndex[ParamType_COUNT];
|
|
||||||
size_t paramAlphaIndexByParam[ParamType_COUNT];
|
|
||||||
|
|
||||||
template <class T> struct NFAlphabeticComp {
|
|
||||||
NFAlphabeticComp(const NamedFieldDescription *fieldDescs)
|
|
||||||
: fieldDescs{fieldDescs} {}
|
|
||||||
|
|
||||||
const NamedFieldDescription *fieldDescs;
|
|
||||||
|
|
||||||
bool operator()(const T &a, const T &b) const {
|
|
||||||
return strcmp(fieldDescs[a].title, fieldDescs[b].title) < 0;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
void namedFieldSort(const NamedFieldDescription *fieldDescs, T *fieldByAlpha,
|
|
||||||
size_t *alphaIndexByField, size_t numFields) {
|
|
||||||
for (size_t i = 0; i < numFields; i++) {
|
|
||||||
fieldByAlpha[i] = static_cast<T>(i);
|
|
||||||
}
|
|
||||||
std::sort(fieldByAlpha, fieldByAlpha + numFields,
|
|
||||||
NFAlphabeticComp<T>(fieldDescs));
|
|
||||||
for (size_t i = 0; i < numFields; i++) {
|
|
||||||
alphaIndexByField[fieldByAlpha[i]] = i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void namedFieldSort() {
|
|
||||||
namedFieldSort(dataFieldDescs, dataFieldByAlphaIndex,
|
|
||||||
dataFieldAlphaIndexByField, DataFieldType_COUNT);
|
|
||||||
namedFieldSort(paramFieldDescs, paramByAlphaIndex, paramAlphaIndexByParam,
|
|
||||||
ParamType_COUNT);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
NamedField<T>::NamedField(const NamedFieldDescription *fieldDescs)
|
NamedField<T>::NamedField(const NamedFieldDescription *fieldDescs)
|
||||||
: fieldDescs{fieldDescs} {}
|
: fieldDescs{fieldDescs} {}
|
||||||
|
@ -16,10 +16,10 @@ void DebugViewView::tearDownScreen() { DebugViewViewBase::tearDownScreen(); }
|
|||||||
|
|
||||||
void DebugViewView::listUpdateItem(DebugViewLine &line, int16_t itemIndex) {
|
void DebugViewView::listUpdateItem(DebugViewLine &line, int16_t itemIndex) {
|
||||||
size_t idx = itemIndex * 2;
|
size_t idx = itemIndex * 2;
|
||||||
line.setFieldType(0, dataFieldByAlphaIndex[idx]);
|
line.setFieldType(0, static_cast<DataFieldType>(idx));
|
||||||
idx++;
|
idx++;
|
||||||
if (idx < DataFieldType_COUNT) {
|
if (idx < DataFieldType_COUNT) {
|
||||||
line.setFieldType(1, dataFieldByAlphaIndex[idx]);
|
line.setFieldType(1, static_cast<DataFieldType>(idx));
|
||||||
line.setFieldVisible(1, true);
|
line.setFieldVisible(1, true);
|
||||||
} else {
|
} else {
|
||||||
line.setFieldVisible(1, false);
|
line.setFieldVisible(1, false);
|
||||||
@ -32,26 +32,3 @@ void DebugViewView::updateFieldValues() {
|
|||||||
el.updateFieldValues();
|
el.updateFieldValues();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebugViewView::scrollUp() {
|
|
||||||
if (scrollIndex == 0) {
|
|
||||||
updateScrollIndex(list.getNumberOfItems() - 1);
|
|
||||||
} else {
|
|
||||||
updateScrollIndex(scrollIndex - 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DebugViewView::scrollDown() {
|
|
||||||
updateScrollIndex((scrollIndex + 1) % list.getNumberOfItems());
|
|
||||||
}
|
|
||||||
|
|
||||||
void DebugViewView::updateScrollIndex(size_t index) {
|
|
||||||
scrollIndex = index;
|
|
||||||
if (scrollIndex == 0) {
|
|
||||||
// Just animating to 0 looks very broken when scrolling forwards. Animating
|
|
||||||
// to numItems looks good in both directions.
|
|
||||||
list.animateToItem(list.getNumberOfItems(), 2);
|
|
||||||
} else {
|
|
||||||
list.animateToItem(scrollIndex, 2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -58,9 +58,8 @@ void DriverViewView::tearDownScreen() { DriverViewViewBase::tearDownScreen(); }
|
|||||||
|
|
||||||
void DriverViewView::fieldTypeSelectionUpdateItem(
|
void DriverViewView::fieldTypeSelectionUpdateItem(
|
||||||
DriverViewFieldSelection &item, int16_t itemIndex) {
|
DriverViewFieldSelection &item, int16_t itemIndex) {
|
||||||
DataFieldType fieldType = dataFieldByAlphaIndex[itemIndex];
|
item.setName(dataFieldDescs[itemIndex].title);
|
||||||
item.setName(dataFieldDescs[fieldType].title);
|
item.setSelected(itemIndex == (int)selectedFieldType);
|
||||||
item.setSelected(itemIndex == (int)selectedFieldIndex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DriverViewView::setFieldType(size_t i, DataFieldType type) {
|
void DriverViewView::setFieldType(size_t i, DataFieldType type) {
|
||||||
@ -187,7 +186,7 @@ void DriverViewView::selectNextFieldType() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateSelectedFieldIndex((selectedFieldIndex + 1) % DataFieldType_COUNT);
|
updateSelectedFieldType((selectedFieldType + 1) % DataFieldType_COUNT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DriverViewView::selectPrevFieldType() {
|
void DriverViewView::selectPrevFieldType() {
|
||||||
@ -195,10 +194,10 @@ void DriverViewView::selectPrevFieldType() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selectedFieldIndex == 0) {
|
if (selectedFieldType == 0) {
|
||||||
updateSelectedFieldIndex(DataFieldType_COUNT - 1);
|
updateSelectedFieldType(DataFieldType_COUNT - 1);
|
||||||
} else {
|
} else {
|
||||||
updateSelectedFieldIndex(selectedFieldIndex - 1);
|
updateSelectedFieldType(selectedFieldType - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,11 +206,11 @@ void DriverViewView::confirmFieldType() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DataFieldType fieldType = dataFieldByAlphaIndex[selectedFieldIndex];
|
|
||||||
DriverViewField &field = getField(selectedField);
|
DriverViewField &field = getField(selectedField);
|
||||||
presenter->setFieldType(selectedField, fieldType);
|
presenter->setFieldType(selectedField,
|
||||||
|
static_cast<DataFieldType>(selectedFieldType));
|
||||||
field.setSelected(false);
|
field.setSelected(false);
|
||||||
fieldTypes[selectedField] = fieldType;
|
fieldTypes[selectedField] = static_cast<DataFieldType>(selectedFieldType);
|
||||||
fieldTypeSelection.setVisible(false);
|
fieldTypeSelection.setVisible(false);
|
||||||
fieldTypeSelection.invalidate();
|
fieldTypeSelection.invalidate();
|
||||||
}
|
}
|
||||||
@ -238,23 +237,19 @@ void DriverViewView::updateSelectedField(size_t selected) {
|
|||||||
updateSelectedFieldType(fieldTypes[selectedField], false);
|
updateSelectedFieldType(fieldTypes[selectedField], false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DriverViewView::updateSelectedFieldType(DataFieldType type, bool animate) {
|
void DriverViewView::updateSelectedFieldType(size_t selected, bool animate) {
|
||||||
updateSelectedFieldIndex(dataFieldAlphaIndexByField[type], animate);
|
size_t previousSelected = selectedFieldType;
|
||||||
}
|
selectedFieldType = selected;
|
||||||
|
|
||||||
void DriverViewView::updateSelectedFieldIndex(size_t selected, bool animate) {
|
|
||||||
size_t previousSelected = selectedFieldIndex;
|
|
||||||
selectedFieldIndex = selected;
|
|
||||||
// Trigger update of the background
|
// Trigger update of the background
|
||||||
fieldTypeSelection.itemChanged(previousSelected);
|
fieldTypeSelection.itemChanged(previousSelected);
|
||||||
fieldTypeSelection.itemChanged(selectedFieldIndex);
|
fieldTypeSelection.itemChanged(selectedFieldType);
|
||||||
|
|
||||||
int16_t steps = animate ? 2 : 0;
|
int16_t steps = animate ? 2 : 0;
|
||||||
if (selectedFieldIndex == 0) {
|
if (selectedFieldType == 0) {
|
||||||
// Just animating to 0 looks very broken when scrolling forwards. Animating
|
// Just animating to 0 looks very broken when scrolling forwards. Animating
|
||||||
// to DataFieldType_COUNT looks good in both directions.
|
// to DataFieldType_COUNT looks good in both directions.
|
||||||
fieldTypeSelection.animateToItem(DataFieldType_COUNT, steps);
|
fieldTypeSelection.animateToItem(DataFieldType_COUNT, steps);
|
||||||
} else {
|
} else {
|
||||||
fieldTypeSelection.animateToItem(selectedFieldIndex, steps);
|
fieldTypeSelection.animateToItem(selectedFieldType, steps);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -854,7 +854,7 @@
|
|||||||
"CanvasBufferSize": 7200,
|
"CanvasBufferSize": 7200,
|
||||||
"Components": [
|
"Components": [
|
||||||
{
|
{
|
||||||
"Type": "ScrollWheel",
|
"Type": "ScrollList",
|
||||||
"Name": "list",
|
"Name": "list",
|
||||||
"X": 15,
|
"X": 15,
|
||||||
"Y": 15,
|
"Y": 15,
|
||||||
@ -863,7 +863,7 @@
|
|||||||
"IsCircular": true,
|
"IsCircular": true,
|
||||||
"ItemTemplateName": "DebugViewLine",
|
"ItemTemplateName": "DebugViewLine",
|
||||||
"NumberofItems": 1,
|
"NumberofItems": 1,
|
||||||
"Easing": "Linear",
|
"Easing": "Back",
|
||||||
"EasingOption": "Out",
|
"EasingOption": "Out",
|
||||||
"SwipeAcceleration": 1.0,
|
"SwipeAcceleration": 1.0,
|
||||||
"DragAcceleration": 1.0
|
"DragAcceleration": 1.0
|
||||||
@ -917,30 +917,7 @@
|
|||||||
"LineEndingStyle": "Round"
|
"LineEndingStyle": "Round"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"Interactions": [
|
"Interactions": []
|
||||||
{
|
|
||||||
"InteractionName": "ScrollUp",
|
|
||||||
"Trigger": {
|
|
||||||
"Type": "TriggerPhysicalButtonClicked",
|
|
||||||
"ButtonKey": 104
|
|
||||||
},
|
|
||||||
"Action": {
|
|
||||||
"Type": "ActionCustom",
|
|
||||||
"FunctionName": "scrollUp"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"InteractionName": "ScrollDown",
|
|
||||||
"Trigger": {
|
|
||||||
"Type": "TriggerPhysicalButtonClicked",
|
|
||||||
"ButtonKey": 108
|
|
||||||
},
|
|
||||||
"Action": {
|
|
||||||
"Type": "ActionCustom",
|
|
||||||
"FunctionName": "scrollDown"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Name": "VehicleConfig",
|
"Name": "VehicleConfig",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user