From 0d7cc03e02a34586d5da872bca88c5a246ca9344 Mon Sep 17 00:00:00 2001 From: "Jasper v. Blanckenburg" Date: Mon, 20 Mar 2023 23:31:28 +0100 Subject: [PATCH] Allow changing displayed fields in DriverView --- STM32Make.make | 2 + TouchGFX/App/app_touchgfx.c | 4 +- TouchGFX/assets/texts/texts.xml | 3 + .../common/FrontendApplicationBase.hpp | 8 +- .../gui_generated/common/FrontendHeapBase.hpp | 2 +- .../DriverViewFieldSelectionBase.hpp | 42 +++++ .../driverview_screen/DriverViewViewBase.hpp | 44 +++++ .../src/common/FrontendApplicationBase.cpp | 13 -- .../DriverViewFieldSelectionBase.cpp | 58 +++++++ .../driverview_screen/DriverViewViewBase.cpp | 80 ++++++++- .../texts/cache/LanguageCpp_Gb.cache | 2 +- .../texts/cache/TextKeysAndLanguages.cache | 2 +- TouchGFX/generated/texts/cache/TextsCpp.cache | 2 +- .../texts/cache/TypedTextDatabaseCpp.cache | 2 +- .../include/texts/TextKeysAndLanguages.hpp | 1 + TouchGFX/generated/texts/src/LanguageGb.cpp | 25 +-- TouchGFX/generated/texts/src/Texts.cpp | 23 +-- .../generated/texts/src/TypedTextDatabase.cpp | 1 + .../gui/containers/DriverViewField.hpp | 2 + .../containers/DriverViewFieldSelection.hpp | 20 +++ .../gui/driverview_screen/DriverViewView.hpp | 21 +++ .../gui/src/containers/DriverViewField.cpp | 7 + .../containers/DriverViewFieldSelection.cpp | 17 ++ .../driverview_screen/DriverViewPresenter.cpp | 24 +-- .../src/driverview_screen/DriverViewView.cpp | 96 ++++++++++- TouchGFX/simulator/msvs/Application.vcxproj | 4 + .../msvs/Application.vcxproj.filters | 12 ++ TouchGFX/steering-wheel.touchgfx | 154 +++++++++++++++++- 28 files changed, 603 insertions(+), 68 deletions(-) create mode 100644 TouchGFX/generated/gui_generated/include/gui_generated/containers/DriverViewFieldSelectionBase.hpp create mode 100644 TouchGFX/generated/gui_generated/src/containers/DriverViewFieldSelectionBase.cpp create mode 100644 TouchGFX/gui/include/gui/containers/DriverViewFieldSelection.hpp create mode 100644 TouchGFX/gui/src/containers/DriverViewFieldSelection.cpp diff --git a/STM32Make.make b/STM32Make.make index 34a24d9..966ef63 100644 --- a/STM32Make.make +++ b/STM32Make.make @@ -351,6 +351,7 @@ TouchGFX/generated/fonts/src/UnmappedDataFont.cpp \ TouchGFX/generated/gui_generated/src/ami_screen/AMIViewBase.cpp \ TouchGFX/generated/gui_generated/src/common/FrontendApplicationBase.cpp \ TouchGFX/generated/gui_generated/src/containers/DriverViewFieldBase.cpp \ +TouchGFX/generated/gui_generated/src/containers/DriverViewFieldSelectionBase.cpp \ TouchGFX/generated/gui_generated/src/containers/MissionSelectElementBase.cpp \ TouchGFX/generated/gui_generated/src/containers/TireTempBase.cpp \ TouchGFX/generated/gui_generated/src/driverview_screen/DriverViewViewBase.cpp \ @@ -372,6 +373,7 @@ TouchGFX/gui/src/ami_screen/AMIView.cpp \ TouchGFX/gui/src/common/DataField.cpp \ TouchGFX/gui/src/common/FrontendApplication.cpp \ TouchGFX/gui/src/containers/DriverViewField.cpp \ +TouchGFX/gui/src/containers/DriverViewFieldSelection.cpp \ TouchGFX/gui/src/containers/MissionSelectElement.cpp \ TouchGFX/gui/src/containers/TireTemp.cpp \ TouchGFX/gui/src/driverview_screen/DriverViewPresenter.cpp \ diff --git a/TouchGFX/App/app_touchgfx.c b/TouchGFX/App/app_touchgfx.c index dd89a97..ba105c9 100644 --- a/TouchGFX/App/app_touchgfx.c +++ b/TouchGFX/App/app_touchgfx.c @@ -32,7 +32,9 @@ #define TOUCHGFX_BYTE_POOL_SIZE (4096) /* USER CODE BEGIN PD */ - +// Redefine here so it doesn't get overwritten on code generation +#define TOUCHGFX_STACK_SIZE (8160) +#define TOUCHGFX_BYTE_POOL_SIZE (8192) /* USER CODE END PD */ /* Private macro -------------------------------------------------------------*/ diff --git a/TouchGFX/assets/texts/texts.xml b/TouchGFX/assets/texts/texts.xml index 16bb9f9..d4566d5 100644 --- a/TouchGFX/assets/texts/texts.xml +++ b/TouchGFX/assets/texts/texts.xml @@ -128,6 +128,9 @@ + + ???? + FIELD diff --git a/TouchGFX/generated/gui_generated/include/gui_generated/common/FrontendApplicationBase.hpp b/TouchGFX/generated/gui_generated/include/gui_generated/common/FrontendApplicationBase.hpp index 15702aa..0a0e096 100644 --- a/TouchGFX/generated/gui_generated/include/gui_generated/common/FrontendApplicationBase.hpp +++ b/TouchGFX/generated/gui_generated/include/gui_generated/common/FrontendApplicationBase.hpp @@ -17,12 +17,9 @@ public: virtual void changeToStartScreen() { - gotoMissionSelectScreenNoTransition(); + gotoDriverViewScreenNoTransition(); } - // MissionSelect - void gotoMissionSelectScreenNoTransition(); - // AMI void gotoAMIScreenNoTransition(); @@ -34,9 +31,6 @@ protected: FrontendHeap& frontendHeap; Model& model; - // MissionSelect - void gotoMissionSelectScreenNoTransitionImpl(); - // AMI void gotoAMIScreenNoTransitionImpl(); diff --git a/TouchGFX/generated/gui_generated/include/gui_generated/common/FrontendHeapBase.hpp b/TouchGFX/generated/gui_generated/include/gui_generated/common/FrontendHeapBase.hpp index f7f915e..a12a87c 100644 --- a/TouchGFX/generated/gui_generated/include/gui_generated/common/FrontendHeapBase.hpp +++ b/TouchGFX/generated/gui_generated/include/gui_generated/common/FrontendHeapBase.hpp @@ -81,7 +81,7 @@ public: virtual void gotoStartScreen(FrontendApplication& app) { - app.gotoMissionSelectScreenNoTransition(); + app.gotoDriverViewScreenNoTransition(); } protected: FrontendHeapBase(touchgfx::AbstractPartition& presenters, touchgfx::AbstractPartition& views, touchgfx::AbstractPartition& transitions, FrontendApplication& app) diff --git a/TouchGFX/generated/gui_generated/include/gui_generated/containers/DriverViewFieldSelectionBase.hpp b/TouchGFX/generated/gui_generated/include/gui_generated/containers/DriverViewFieldSelectionBase.hpp new file mode 100644 index 0000000..363b007 --- /dev/null +++ b/TouchGFX/generated/gui_generated/include/gui_generated/containers/DriverViewFieldSelectionBase.hpp @@ -0,0 +1,42 @@ +/*********************************************************************************/ +/********** THIS FILE IS GENERATED BY TOUCHGFX DESIGNER, DO NOT MODIFY ***********/ +/*********************************************************************************/ +#ifndef DRIVERVIEWFIELDSELECTIONBASE_HPP +#define DRIVERVIEWFIELDSELECTIONBASE_HPP + +#include +#include +#include +#include +#include +#include + +class DriverViewFieldSelectionBase : public touchgfx::Container +{ +public: + DriverViewFieldSelectionBase(); + virtual ~DriverViewFieldSelectionBase(); + virtual void initialize(); + +protected: + FrontendApplication& application() { + return *static_cast(touchgfx::Application::getInstance()); + } + + /* + * Member Declarations + */ + touchgfx::Box bg; + touchgfx::TextArea name; + touchgfx::Line line1; + touchgfx::PainterRGB565 line1Painter; + touchgfx::Line line2; + touchgfx::PainterRGB565 line2Painter; + touchgfx::Line line2_1; + touchgfx::PainterRGB565 line2_1Painter; + +private: + +}; + +#endif // DRIVERVIEWFIELDSELECTIONBASE_HPP diff --git a/TouchGFX/generated/gui_generated/include/gui_generated/driverview_screen/DriverViewViewBase.hpp b/TouchGFX/generated/gui_generated/include/gui_generated/driverview_screen/DriverViewViewBase.hpp index e7da2fb..10b8bd8 100644 --- a/TouchGFX/generated/gui_generated/include/gui_generated/driverview_screen/DriverViewViewBase.hpp +++ b/TouchGFX/generated/gui_generated/include/gui_generated/driverview_screen/DriverViewViewBase.hpp @@ -15,6 +15,8 @@ #include #include #include +#include +#include class DriverViewViewBase : public touchgfx::View { @@ -23,6 +25,36 @@ public: virtual ~DriverViewViewBase(); virtual void setupScreen(); + virtual void fieldTypeSelectionUpdateItem(DriverViewFieldSelection& item, int16_t itemIndex) + { + // Override and implement this function in DriverView + } + virtual void handleKeyEvent(uint8_t key); + + /* + * Virtual Action Handlers + */ + virtual void selectPrevField() + { + // Override and implement this function in DriverView + } + virtual void selectNextField() + { + // Override and implement this function in DriverView + } + virtual void selectPrevFieldType() + { + // Override and implement this function in DriverView + } + virtual void selectNextFieldType() + { + // Override and implement this function in DriverView + } + virtual void confirmFieldType() + { + // Override and implement this function in DriverView + } + protected: FrontendApplication& application() { return *static_cast(touchgfx::Application::getInstance()); @@ -51,6 +83,8 @@ protected: DriverViewField field1; DriverViewField field2; DriverViewField field3; + touchgfx::ScrollWheel fieldTypeSelection; + touchgfx::DrawableListItems fieldTypeSelectionListItems; private: @@ -60,6 +94,16 @@ private: static const uint32_t CANVAS_BUFFER_SIZE = 7200; uint8_t canvasBuffer[CANVAS_BUFFER_SIZE]; + /* + * Callback Declarations + */ + touchgfx::Callback updateItemCallback; + + /* + * Callback Handler Declarations + */ + void updateItemCallbackHandler(touchgfx::DrawableListItemsInterface* items, int16_t containerIndex, int16_t itemIndex); + }; #endif // DRIVERVIEWVIEWBASE_HPP diff --git a/TouchGFX/generated/gui_generated/src/common/FrontendApplicationBase.cpp b/TouchGFX/generated/gui_generated/src/common/FrontendApplicationBase.cpp index 3a69a14..a6b95a2 100644 --- a/TouchGFX/generated/gui_generated/src/common/FrontendApplicationBase.cpp +++ b/TouchGFX/generated/gui_generated/src/common/FrontendApplicationBase.cpp @@ -33,19 +33,6 @@ FrontendApplicationBase::FrontendApplicationBase(Model& m, FrontendHeap& heap) * Screen Transition Declarations */ -// MissionSelect - -void FrontendApplicationBase::gotoMissionSelectScreenNoTransition() -{ - transitionCallback = touchgfx::Callback(this, &FrontendApplication::gotoMissionSelectScreenNoTransitionImpl); - pendingScreenTransitionCallback = &transitionCallback; -} - -void FrontendApplicationBase::gotoMissionSelectScreenNoTransitionImpl() -{ - touchgfx::makeTransition(¤tScreen, ¤tPresenter, frontendHeap, ¤tTransition, &model); -} - // AMI void FrontendApplicationBase::gotoAMIScreenNoTransition() diff --git a/TouchGFX/generated/gui_generated/src/containers/DriverViewFieldSelectionBase.cpp b/TouchGFX/generated/gui_generated/src/containers/DriverViewFieldSelectionBase.cpp new file mode 100644 index 0000000..4408afd --- /dev/null +++ b/TouchGFX/generated/gui_generated/src/containers/DriverViewFieldSelectionBase.cpp @@ -0,0 +1,58 @@ +/*********************************************************************************/ +/********** THIS FILE IS GENERATED BY TOUCHGFX DESIGNER, DO NOT MODIFY ***********/ +/*********************************************************************************/ +#include +#include +#include + +DriverViewFieldSelectionBase::DriverViewFieldSelectionBase() +{ + setWidth(160); + setHeight(26); + bg.setPosition(0, 0, 160, 25); + bg.setColor(touchgfx::Color::getColorFromRGB(34, 34, 34)); + add(bg); + + name.setPosition(0, 0, 160, 25); + name.setColor(touchgfx::Color::getColorFromRGB(255, 255, 255)); + name.setLinespacing(0); + name.setTypedText(touchgfx::TypedText(T___SINGLEUSE_PNKR)); + add(name); + + line1.setPosition(0, 25, 160, 1); + line1Painter.setColor(touchgfx::Color::getColorFromRGB(255, 255, 255)); + line1.setPainter(line1Painter); + line1.setStart(0, 0); + line1.setEnd(160, 0); + line1.setLineWidth(10); + line1.setLineEndingStyle(touchgfx::Line::ROUND_CAP_ENDING); + add(line1); + + line2.setPosition(0, 0, 1, 26); + line2Painter.setColor(touchgfx::Color::getColorFromRGB(255, 255, 255)); + line2.setPainter(line2Painter); + line2.setStart(0, 0); + line2.setEnd(0, 26); + line2.setLineWidth(10); + line2.setLineEndingStyle(touchgfx::Line::ROUND_CAP_ENDING); + add(line2); + + line2_1.setPosition(159, 0, 1, 26); + line2_1Painter.setColor(touchgfx::Color::getColorFromRGB(255, 255, 255)); + line2_1.setPainter(line2_1Painter); + line2_1.setStart(0, 0); + line2_1.setEnd(0, 26); + line2_1.setLineWidth(10); + line2_1.setLineEndingStyle(touchgfx::Line::ROUND_CAP_ENDING); + add(line2_1); +} + +DriverViewFieldSelectionBase::~DriverViewFieldSelectionBase() +{ + +} + +void DriverViewFieldSelectionBase::initialize() +{ + +} diff --git a/TouchGFX/generated/gui_generated/src/driverview_screen/DriverViewViewBase.cpp b/TouchGFX/generated/gui_generated/src/driverview_screen/DriverViewViewBase.cpp index 8677596..d4cbe52 100644 --- a/TouchGFX/generated/gui_generated/src/driverview_screen/DriverViewViewBase.cpp +++ b/TouchGFX/generated/gui_generated/src/driverview_screen/DriverViewViewBase.cpp @@ -7,7 +7,8 @@ #include #include -DriverViewViewBase::DriverViewViewBase() +DriverViewViewBase::DriverViewViewBase() : + updateItemCallback(this, &DriverViewViewBase::updateItemCallbackHandler) { touchgfx::CanvasWidgetRenderer::setupBuffer(canvasBuffer, CANVAS_BUFFER_SIZE); @@ -101,6 +102,20 @@ DriverViewViewBase::DriverViewViewBase() field3.setXY(320, 0); add(field3); + + fieldTypeSelection.setPosition(0, 80, 160, 240); + fieldTypeSelection.setHorizontal(false); + fieldTypeSelection.setCircular(true); + fieldTypeSelection.setEasingEquation(touchgfx::EasingEquations::backEaseOut); + fieldTypeSelection.setSwipeAcceleration(10); + fieldTypeSelection.setDragAcceleration(10); + fieldTypeSelection.setNumberOfItems(1); + fieldTypeSelection.setSelectedItemOffset(94); + fieldTypeSelection.setDrawableSize(26, 0); + fieldTypeSelection.setDrawables(fieldTypeSelectionListItems, updateItemCallback); + fieldTypeSelection.animateToItem(0, 0); + fieldTypeSelection.setVisible(false); + add(fieldTypeSelection); } DriverViewViewBase::~DriverViewViewBase() @@ -117,4 +132,67 @@ void DriverViewViewBase::setupScreen() field1.initialize(); field2.initialize(); field3.initialize(); + fieldTypeSelection.initialize(); + for (int i = 0; i < fieldTypeSelectionListItems.getNumberOfDrawables(); i++) + { + fieldTypeSelectionListItems[i].initialize(); + } +} + +void DriverViewViewBase::handleKeyEvent(uint8_t key) +{ + if(22 == key) + { + //SelectPreviousField + //When hardware button 22 clicked call virtual function + //Call selectPrevField + selectPrevField(); + + } + + if(21 == key) + { + //SelectNextField + //When hardware button 21 clicked call virtual function + //Call selectNextField + selectNextField(); + + } + + if(24 == key) + { + //SelectPreviousFieldType + //When hardware button 24 clicked call virtual function + //Call selectPrevFieldType + selectPrevFieldType(); + + } + + if(23 == key) + { + //SelectNextFieldType + //When hardware button 23 clicked call virtual function + //Call selectNextFieldType + selectNextFieldType(); + + } + + if(6 == key) + { + //ConfirmFieldType + //When hardware button 6 clicked call virtual function + //Call confirmFieldType + confirmFieldType(); + + } +} + +void DriverViewViewBase::updateItemCallbackHandler(touchgfx::DrawableListItemsInterface* items, int16_t containerIndex, int16_t itemIndex) +{ + if (items == &fieldTypeSelectionListItems) + { + touchgfx::Drawable* d = items->getDrawable(containerIndex); + DriverViewFieldSelection* cc = (DriverViewFieldSelection*)d; + fieldTypeSelectionUpdateItem(*cc, itemIndex); + } } diff --git a/TouchGFX/generated/texts/cache/LanguageCpp_Gb.cache b/TouchGFX/generated/texts/cache/LanguageCpp_Gb.cache index 8fa622c..4799ec6 100644 --- a/TouchGFX/generated/texts/cache/LanguageCpp_Gb.cache +++ b/TouchGFX/generated/texts/cache/LanguageCpp_Gb.cache @@ -1 +1 @@ -{"remap":"yes","language":"GB","language_index":0,"indices":[["252","T_FIELD_BBAL"],["209","T_FIELD_TSVOLTVEH"],["202","T_FIELD_TSVOLTBAT"],["228","T_FIELD_LVSOC"],["246","T_FIELD_TSSOC"],["262","T_FIELD_MAXCELLTEMP"],["267","T_FIELD_TIREFL"],["272","T_FIELD_TIREFR"],["277","T_FIELD_TIRERL"],["282","T_FIELD_TIRERR"],["257","T_FIELD_LAPCOUNT"],["146","T_FIELD_INICHKSTATE"],["216","T_FIELD_ERR"],["296","T_FIELD_SDC"],["162","T_FIELD_INVRREADY"],["154","T_FIELD_INVLREADY"],["178","T_FIELD_R2DPROGRESS"],["170","T_FIELD_ACTIVEMISSION"],["138","T_FIELD_ASSTATE"],["194","T_FIELD_TSSTATE"],["136","T_NUMBERWILDCARD"],["136","T_DEFAULTWILDCARD"],["292","T_FIELD_TSCURRENT"],["287","T_FIELD_MINCELLVOLT"],["234","T_FIELD_SPEED"],["95","T_INSPECTION_HUGE"],["127","T_EBS_HUGE"],["106","T_TRACKDRIVE_HUGE"],["117","T_AUTOX_HUGE"],["186","T_SKIDPAD_HUGE"],["82","T_ACCEL_HUGE"],["34","T_INVALID_HUGE"],["67","T_MANUAL"],["95","T_INSPECTION"],["127","T_EBS"],["106","T_TRACKDRIVE"],["117","T_AUTOX"],["186","T_SKIDPAD"],["82","T_ACCEL"],["222","T___SINGLEUSE_0FBJ"],["300","T___SINGLEUSE_4OBM"],["293","T___SINGLEUSE_PHFD"],["240","T___SINGLEUSE_H6UX"],["136","T___SINGLEUSE_20H3"],["17","T___SINGLEUSE_SDGP"],["51","T___SINGLEUSE_M5X7"],["0","T___SINGLEUSE_6GPV"]]} \ No newline at end of file +{"remap":"yes","language":"GB","language_index":0,"indices":[["257","T_FIELD_BBAL"],["209","T_FIELD_TSVOLTVEH"],["202","T_FIELD_TSVOLTBAT"],["228","T_FIELD_LVSOC"],["246","T_FIELD_TSSOC"],["267","T_FIELD_MAXCELLTEMP"],["272","T_FIELD_TIREFL"],["277","T_FIELD_TIREFR"],["282","T_FIELD_TIRERL"],["287","T_FIELD_TIRERR"],["262","T_FIELD_LAPCOUNT"],["146","T_FIELD_INICHKSTATE"],["216","T_FIELD_ERR"],["301","T_FIELD_SDC"],["162","T_FIELD_INVRREADY"],["154","T_FIELD_INVLREADY"],["178","T_FIELD_R2DPROGRESS"],["170","T_FIELD_ACTIVEMISSION"],["138","T_FIELD_ASSTATE"],["194","T_FIELD_TSSTATE"],["136","T_NUMBERWILDCARD"],["136","T_DEFAULTWILDCARD"],["297","T_FIELD_TSCURRENT"],["292","T_FIELD_MINCELLVOLT"],["234","T_FIELD_SPEED"],["95","T_INSPECTION_HUGE"],["127","T_EBS_HUGE"],["106","T_TRACKDRIVE_HUGE"],["117","T_AUTOX_HUGE"],["186","T_SKIDPAD_HUGE"],["82","T_ACCEL_HUGE"],["34","T_INVALID_HUGE"],["67","T_MANUAL"],["95","T_INSPECTION"],["127","T_EBS"],["106","T_TRACKDRIVE"],["117","T_AUTOX"],["186","T_SKIDPAD"],["82","T_ACCEL"],["252","T___SINGLEUSE_PNKR"],["222","T___SINGLEUSE_0FBJ"],["305","T___SINGLEUSE_4OBM"],["298","T___SINGLEUSE_PHFD"],["240","T___SINGLEUSE_H6UX"],["136","T___SINGLEUSE_20H3"],["17","T___SINGLEUSE_SDGP"],["51","T___SINGLEUSE_M5X7"],["0","T___SINGLEUSE_6GPV"]]} \ No newline at end of file diff --git a/TouchGFX/generated/texts/cache/TextKeysAndLanguages.cache b/TouchGFX/generated/texts/cache/TextKeysAndLanguages.cache index e8251ef..d7e50c4 100644 --- a/TouchGFX/generated/texts/cache/TextKeysAndLanguages.cache +++ b/TouchGFX/generated/texts/cache/TextKeysAndLanguages.cache @@ -1 +1 @@ -{"languages":["GB"],"textids":["T_FIELD_BBAL","T_FIELD_TSVOLTVEH","T_FIELD_TSVOLTBAT","T_FIELD_LVSOC","T_FIELD_TSSOC","T_FIELD_MAXCELLTEMP","T_FIELD_TIREFL","T_FIELD_TIREFR","T_FIELD_TIRERL","T_FIELD_TIRERR","T_FIELD_LAPCOUNT","T_FIELD_INICHKSTATE","T_FIELD_ERR","T_FIELD_SDC","T_FIELD_INVRREADY","T_FIELD_INVLREADY","T_FIELD_R2DPROGRESS","T_FIELD_ACTIVEMISSION","T_FIELD_ASSTATE","T_FIELD_TSSTATE","T_NUMBERWILDCARD","T_DEFAULTWILDCARD","T_FIELD_TSCURRENT","T_FIELD_MINCELLVOLT","T_FIELD_SPEED","T_INSPECTION_HUGE","T_EBS_HUGE","T_TRACKDRIVE_HUGE","T_AUTOX_HUGE","T_SKIDPAD_HUGE","T_ACCEL_HUGE","T_INVALID_HUGE","T_MANUAL","T_INSPECTION","T_EBS","T_TRACKDRIVE","T_AUTOX","T_SKIDPAD","T_ACCEL","T___SINGLEUSE_0FBJ","T___SINGLEUSE_4OBM","T___SINGLEUSE_PHFD","T___SINGLEUSE_H6UX","T___SINGLEUSE_20H3","T___SINGLEUSE_SDGP","T___SINGLEUSE_M5X7","T___SINGLEUSE_6GPV"]} \ No newline at end of file +{"languages":["GB"],"textids":["T_FIELD_BBAL","T_FIELD_TSVOLTVEH","T_FIELD_TSVOLTBAT","T_FIELD_LVSOC","T_FIELD_TSSOC","T_FIELD_MAXCELLTEMP","T_FIELD_TIREFL","T_FIELD_TIREFR","T_FIELD_TIRERL","T_FIELD_TIRERR","T_FIELD_LAPCOUNT","T_FIELD_INICHKSTATE","T_FIELD_ERR","T_FIELD_SDC","T_FIELD_INVRREADY","T_FIELD_INVLREADY","T_FIELD_R2DPROGRESS","T_FIELD_ACTIVEMISSION","T_FIELD_ASSTATE","T_FIELD_TSSTATE","T_NUMBERWILDCARD","T_DEFAULTWILDCARD","T_FIELD_TSCURRENT","T_FIELD_MINCELLVOLT","T_FIELD_SPEED","T_INSPECTION_HUGE","T_EBS_HUGE","T_TRACKDRIVE_HUGE","T_AUTOX_HUGE","T_SKIDPAD_HUGE","T_ACCEL_HUGE","T_INVALID_HUGE","T_MANUAL","T_INSPECTION","T_EBS","T_TRACKDRIVE","T_AUTOX","T_SKIDPAD","T_ACCEL","T___SINGLEUSE_PNKR","T___SINGLEUSE_0FBJ","T___SINGLEUSE_4OBM","T___SINGLEUSE_PHFD","T___SINGLEUSE_H6UX","T___SINGLEUSE_20H3","T___SINGLEUSE_SDGP","T___SINGLEUSE_M5X7","T___SINGLEUSE_6GPV"]} \ No newline at end of file diff --git a/TouchGFX/generated/texts/cache/TextsCpp.cache b/TouchGFX/generated/texts/cache/TextsCpp.cache index 21c236a..0c74b16 100644 --- a/TouchGFX/generated/texts/cache/TextsCpp.cache +++ b/TouchGFX/generated/texts/cache/TextsCpp.cache @@ -1 +1 @@ -{"remap":"yes","languages":["Gb"],"characters":[67,104,111,111,115,101,32,97,32,109,105,115,115,105,111,110,0,67,117,114,114,101,110,116,32,77,105,115,115,105,111,110,58,0,73,110,118,97,108,105,100,32,77,105,115,115,105,111,110,33,0,73,110,118,97,108,105,100,32,77,105,115,115,105,111,110,0,77,97,110,117,97,108,32,68,114,105,118,105,110,103,0,65,99,99,101,108,101,114,97,116,105,111,110,0,73,110,115,112,101,99,116,105,111,110,0,84,114,97,99,107,100,114,105,118,101,0,65,117,116,111,99,114,111,115,115,0,69,66,83,32,84,101,115,116,0,2,0,65,83,83,84,65,84,69,0,73,67,83,84,65,84,69,0,73,78,86,76,82,68,89,0,73,78,86,82,82,68,89,0,77,73,83,83,73,79,78,0,82,50,68,80,82,79,71,0,83,107,105,100,112,97,100,0,84,83,83,84,65,84,69,0,84,83,86,66,65,84,0,84,83,86,86,69,72,0,69,82,82,79,82,0,70,73,69,76,68,0,76,86,83,79,67,0,83,80,69,69,68,0,84,73,82,69,83,0,84,83,83,79,67,0,66,66,65,76,0,76,65,80,83,0,84,77,65,88,0,84,84,70,76,0,84,84,70,82,0,84,84,82,76,0,84,84,82,82,0,86,77,73,78,0,73,84,83,0,83,68,67,0,76,86,0]} \ No newline at end of file +{"remap":"yes","languages":["Gb"],"characters":[67,104,111,111,115,101,32,97,32,109,105,115,115,105,111,110,0,67,117,114,114,101,110,116,32,77,105,115,115,105,111,110,58,0,73,110,118,97,108,105,100,32,77,105,115,115,105,111,110,33,0,73,110,118,97,108,105,100,32,77,105,115,115,105,111,110,0,77,97,110,117,97,108,32,68,114,105,118,105,110,103,0,65,99,99,101,108,101,114,97,116,105,111,110,0,73,110,115,112,101,99,116,105,111,110,0,84,114,97,99,107,100,114,105,118,101,0,65,117,116,111,99,114,111,115,115,0,69,66,83,32,84,101,115,116,0,2,0,65,83,83,84,65,84,69,0,73,67,83,84,65,84,69,0,73,78,86,76,82,68,89,0,73,78,86,82,82,68,89,0,77,73,83,83,73,79,78,0,82,50,68,80,82,79,71,0,83,107,105,100,112,97,100,0,84,83,83,84,65,84,69,0,84,83,86,66,65,84,0,84,83,86,86,69,72,0,69,82,82,79,82,0,70,73,69,76,68,0,76,86,83,79,67,0,83,80,69,69,68,0,84,73,82,69,83,0,84,83,83,79,67,0,63,63,63,63,0,66,66,65,76,0,76,65,80,83,0,84,77,65,88,0,84,84,70,76,0,84,84,70,82,0,84,84,82,76,0,84,84,82,82,0,86,77,73,78,0,73,84,83,0,83,68,67,0,76,86,0]} \ No newline at end of file diff --git a/TouchGFX/generated/texts/cache/TypedTextDatabaseCpp.cache b/TouchGFX/generated/texts/cache/TypedTextDatabaseCpp.cache index 1a32109..d7341d1 100644 --- a/TouchGFX/generated/texts/cache/TypedTextDatabaseCpp.cache +++ b/TouchGFX/generated/texts/cache/TypedTextDatabaseCpp.cache @@ -1 +1 @@ -{"databases":{"DEFAULT":[[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[4,"CENTER","LTR"],[0,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[3,"CENTER","LTR"],[3,"CENTER","LTR"],[3,"CENTER","LTR"],[3,"CENTER","LTR"],[3,"CENTER","LTR"],[3,"CENTER","LTR"],[3,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[4,"CENTER","LTR"],[1,"LEFT","LTR"],[2,"CENTER","LTR"],[1,"LEFT","LTR"]]},"database_list":["DEFAULT"],"fonts":{"getFont_verdana_20_4bpp":0,"getFont_CHINN____30_4bpp":1,"getFont_CHINN____20_4bpp":2,"getFont_CHINN____40_4bpp":3,"getFont_lucon_TTF_50_4bpp":4},"generate_font_format":"0"} \ No newline at end of file +{"databases":{"DEFAULT":[[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[4,"CENTER","LTR"],[0,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[3,"CENTER","LTR"],[3,"CENTER","LTR"],[3,"CENTER","LTR"],[3,"CENTER","LTR"],[3,"CENTER","LTR"],[3,"CENTER","LTR"],[3,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[2,"CENTER","LTR"],[4,"CENTER","LTR"],[1,"LEFT","LTR"],[2,"CENTER","LTR"],[1,"LEFT","LTR"]]},"database_list":["DEFAULT"],"fonts":{"getFont_verdana_20_4bpp":0,"getFont_CHINN____30_4bpp":1,"getFont_CHINN____20_4bpp":2,"getFont_CHINN____40_4bpp":3,"getFont_lucon_TTF_50_4bpp":4},"generate_font_format":"0"} \ No newline at end of file diff --git a/TouchGFX/generated/texts/include/texts/TextKeysAndLanguages.hpp b/TouchGFX/generated/texts/include/texts/TextKeysAndLanguages.hpp index 9532398..31058c4 100644 --- a/TouchGFX/generated/texts/include/texts/TextKeysAndLanguages.hpp +++ b/TouchGFX/generated/texts/include/texts/TextKeysAndLanguages.hpp @@ -51,6 +51,7 @@ enum TEXTS T_AUTOX, T_SKIDPAD, T_ACCEL, + T___SINGLEUSE_PNKR, T___SINGLEUSE_0FBJ, T___SINGLEUSE_4OBM, T___SINGLEUSE_PHFD, diff --git a/TouchGFX/generated/texts/src/LanguageGb.cpp b/TouchGFX/generated/texts/src/LanguageGb.cpp index f9f510e..9b36fd4 100644 --- a/TouchGFX/generated/texts/src/LanguageGb.cpp +++ b/TouchGFX/generated/texts/src/LanguageGb.cpp @@ -10,20 +10,20 @@ KEEP extern const uint32_t indicesGb[] TEXT_LOCATION_FLASH_ATTRIBUTE; // Remap all strings TEXT_LOCATION_FLASH_PRAGMA KEEP extern const uint32_t indicesGb[] TEXT_LOCATION_FLASH_ATTRIBUTE = { - 252, // T_FIELD_BBAL: "BBAL" + 257, // T_FIELD_BBAL: "BBAL" 209, // T_FIELD_TSVOLTVEH: "TSVVEH" 202, // T_FIELD_TSVOLTBAT: "TSVBAT" 228, // T_FIELD_LVSOC: "LVSOC" 246, // T_FIELD_TSSOC: "TSSOC" - 262, // T_FIELD_MAXCELLTEMP: "TMAX" - 267, // T_FIELD_TIREFL: "TTFL" - 272, // T_FIELD_TIREFR: "TTFR" - 277, // T_FIELD_TIRERL: "TTRL" - 282, // T_FIELD_TIRERR: "TTRR" - 257, // T_FIELD_LAPCOUNT: "LAPS" + 267, // T_FIELD_MAXCELLTEMP: "TMAX" + 272, // T_FIELD_TIREFL: "TTFL" + 277, // T_FIELD_TIREFR: "TTFR" + 282, // T_FIELD_TIRERL: "TTRL" + 287, // T_FIELD_TIRERR: "TTRR" + 262, // T_FIELD_LAPCOUNT: "LAPS" 146, // T_FIELD_INICHKSTATE: "ICSTATE" 216, // T_FIELD_ERR: "ERROR" - 296, // T_FIELD_SDC: "SDC" + 301, // T_FIELD_SDC: "SDC" 162, // T_FIELD_INVRREADY: "INVRRDY" 154, // T_FIELD_INVLREADY: "INVLRDY" 178, // T_FIELD_R2DPROGRESS: "R2DPROG" @@ -32,8 +32,8 @@ KEEP extern const uint32_t indicesGb[] TEXT_LOCATION_FLASH_ATTRIBUTE = { 194, // T_FIELD_TSSTATE: "TSSTATE" 136, // T_NUMBERWILDCARD: "<>" 136, // T_DEFAULTWILDCARD: "<>" - 292, // T_FIELD_TSCURRENT: "ITS" - 287, // T_FIELD_MINCELLVOLT: "VMIN" + 297, // T_FIELD_TSCURRENT: "ITS" + 292, // T_FIELD_MINCELLVOLT: "VMIN" 234, // T_FIELD_SPEED: "SPEED" 95, // T_INSPECTION_HUGE: "Inspection" 127, // T_EBS_HUGE: "EBS Test" @@ -49,9 +49,10 @@ KEEP extern const uint32_t indicesGb[] TEXT_LOCATION_FLASH_ATTRIBUTE = { 117, // T_AUTOX: "Autocross" 186, // T_SKIDPAD: "Skidpad" 82, // T_ACCEL: "Acceleration" + 252, // T___SINGLEUSE_PNKR: "????" 222, // T___SINGLEUSE_0FBJ: "FIELD" - 300, // T___SINGLEUSE_4OBM: "LV" - 293, // T___SINGLEUSE_PHFD: "TS" + 305, // T___SINGLEUSE_4OBM: "LV" + 298, // T___SINGLEUSE_PHFD: "TS" 240, // T___SINGLEUSE_H6UX: "TIRES" 136, // T___SINGLEUSE_20H3: "<>" 17, // T___SINGLEUSE_SDGP: "Current Mission:" diff --git a/TouchGFX/generated/texts/src/Texts.cpp b/TouchGFX/generated/texts/src/Texts.cpp index 5cf2c0a..92dcffe 100644 --- a/TouchGFX/generated/texts/src/Texts.cpp +++ b/TouchGFX/generated/texts/src/Texts.cpp @@ -87,17 +87,18 @@ KEEP extern const touchgfx::Unicode::UnicodeChar texts_all_languages[] TEXT_LOCA 0x53, 0x50, 0x45, 0x45, 0x44, 0x0, // @234 "SPEED" 0x54, 0x49, 0x52, 0x45, 0x53, 0x0, // @240 "TIRES" 0x54, 0x53, 0x53, 0x4f, 0x43, 0x0, // @246 "TSSOC" - 0x42, 0x42, 0x41, 0x4c, 0x0, // @252 "BBAL" - 0x4c, 0x41, 0x50, 0x53, 0x0, // @257 "LAPS" - 0x54, 0x4d, 0x41, 0x58, 0x0, // @262 "TMAX" - 0x54, 0x54, 0x46, 0x4c, 0x0, // @267 "TTFL" - 0x54, 0x54, 0x46, 0x52, 0x0, // @272 "TTFR" - 0x54, 0x54, 0x52, 0x4c, 0x0, // @277 "TTRL" - 0x54, 0x54, 0x52, 0x52, 0x0, // @282 "TTRR" - 0x56, 0x4d, 0x49, 0x4e, 0x0, // @287 "VMIN" - 0x49, 0x54, 0x53, 0x0, // @292 "ITS" - 0x53, 0x44, 0x43, 0x0, // @296 "SDC" - 0x4c, 0x56, 0x0 // @300 "LV" + 0x3f, 0x3f, 0x3f, 0x3f, 0x0, // @252 "????" + 0x42, 0x42, 0x41, 0x4c, 0x0, // @257 "BBAL" + 0x4c, 0x41, 0x50, 0x53, 0x0, // @262 "LAPS" + 0x54, 0x4d, 0x41, 0x58, 0x0, // @267 "TMAX" + 0x54, 0x54, 0x46, 0x4c, 0x0, // @272 "TTFL" + 0x54, 0x54, 0x46, 0x52, 0x0, // @277 "TTFR" + 0x54, 0x54, 0x52, 0x4c, 0x0, // @282 "TTRL" + 0x54, 0x54, 0x52, 0x52, 0x0, // @287 "TTRR" + 0x56, 0x4d, 0x49, 0x4e, 0x0, // @292 "VMIN" + 0x49, 0x54, 0x53, 0x0, // @297 "ITS" + 0x53, 0x44, 0x43, 0x0, // @301 "SDC" + 0x4c, 0x56, 0x0 // @305 "LV" }; TEXT_LOCATION_FLASH_PRAGMA diff --git a/TouchGFX/generated/texts/src/TypedTextDatabase.cpp b/TouchGFX/generated/texts/src/TypedTextDatabase.cpp index b43a37b..442cc95 100644 --- a/TouchGFX/generated/texts/src/TypedTextDatabase.cpp +++ b/TouchGFX/generated/texts/src/TypedTextDatabase.cpp @@ -67,6 +67,7 @@ const touchgfx::TypedText::TypedTextData typedText_database_DEFAULT[] TEXT_LOCAT { 2, touchgfx::CENTER, touchgfx::TEXT_DIRECTION_LTR }, { 2, touchgfx::CENTER, touchgfx::TEXT_DIRECTION_LTR }, { 2, touchgfx::CENTER, touchgfx::TEXT_DIRECTION_LTR }, + { 2, touchgfx::CENTER, touchgfx::TEXT_DIRECTION_LTR }, { 4, touchgfx::CENTER, touchgfx::TEXT_DIRECTION_LTR }, { 1, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR }, { 2, touchgfx::CENTER, touchgfx::TEXT_DIRECTION_LTR }, diff --git a/TouchGFX/gui/include/gui/containers/DriverViewField.hpp b/TouchGFX/gui/include/gui/containers/DriverViewField.hpp index 4b93e34..2ea5daa 100644 --- a/TouchGFX/gui/include/gui/containers/DriverViewField.hpp +++ b/TouchGFX/gui/include/gui/containers/DriverViewField.hpp @@ -19,6 +19,8 @@ public: void setValue(const char *str); void setValue(int boolValue); + void setSelected(int selected); + protected: private: Unicode::UnicodeChar valueBuffer[16]; diff --git a/TouchGFX/gui/include/gui/containers/DriverViewFieldSelection.hpp b/TouchGFX/gui/include/gui/containers/DriverViewFieldSelection.hpp new file mode 100644 index 0000000..fc003e2 --- /dev/null +++ b/TouchGFX/gui/include/gui/containers/DriverViewFieldSelection.hpp @@ -0,0 +1,20 @@ +#ifndef DRIVERVIEWFIELDSELECTION_HPP +#define DRIVERVIEWFIELDSELECTION_HPP + +#include "touchgfx/TypedText.hpp" +#include + +class DriverViewFieldSelection : public DriverViewFieldSelectionBase { +public: + DriverViewFieldSelection(); + virtual ~DriverViewFieldSelection() {} + + virtual void initialize(); + + void setName(const touchgfx::TypedText &name); + void setSelected(int selected); + +protected: +}; + +#endif // DRIVERVIEWFIELDSELECTION_HPP diff --git a/TouchGFX/gui/include/gui/driverview_screen/DriverViewView.hpp b/TouchGFX/gui/include/gui/driverview_screen/DriverViewView.hpp index d83e121..45bc14a 100644 --- a/TouchGFX/gui/include/gui/driverview_screen/DriverViewView.hpp +++ b/TouchGFX/gui/include/gui/driverview_screen/DriverViewView.hpp @@ -2,6 +2,8 @@ #define DRIVERVIEWVIEW_HPP #include "gui/common/DataField.hpp" +#include "gui/containers/DriverViewFieldSelection.hpp" +#include "touchgfx/containers/scrollers/DrawableList.hpp" #include "vehicle.h" #include #include @@ -13,6 +15,9 @@ public: virtual void setupScreen(); virtual void tearDownScreen(); + 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); @@ -21,9 +26,25 @@ public: void setTireTemps(const TireTemps &temps); void setTSSoC(uint8_t soc); + void selectPrevField() override; + void selectNextField() override; + void selectPrevFieldType() override; + void selectNextFieldType() override; + void confirmFieldType() override; + + static constexpr size_t NUM_FIELDS = 3; + protected: private: DriverViewField &getField(size_t i); + DriverViewFieldSelection *getFieldType(size_t i); + + void updateSelectedField(size_t select); + void updateSelectedFieldType(size_t select); + + size_t selectedField; + size_t selectedFieldType; + DataFieldType fieldTypes[NUM_FIELDS]; }; #endif // DRIVERVIEWVIEW_HPP diff --git a/TouchGFX/gui/src/containers/DriverViewField.cpp b/TouchGFX/gui/src/containers/DriverViewField.cpp index 5945e1a..affe396 100644 --- a/TouchGFX/gui/src/containers/DriverViewField.cpp +++ b/TouchGFX/gui/src/containers/DriverViewField.cpp @@ -1,5 +1,6 @@ #include "gui/common/DataField.hpp" #include "texts/TextKeysAndLanguages.hpp" +#include "touchgfx/Color.hpp" #include "touchgfx/Unicode.hpp" #include @@ -43,6 +44,12 @@ void DriverViewField::setValue(int 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: { diff --git a/TouchGFX/gui/src/containers/DriverViewFieldSelection.cpp b/TouchGFX/gui/src/containers/DriverViewFieldSelection.cpp new file mode 100644 index 0000000..23b6ac8 --- /dev/null +++ b/TouchGFX/gui/src/containers/DriverViewFieldSelection.cpp @@ -0,0 +1,17 @@ +#include "touchgfx/Color.hpp" +#include + +DriverViewFieldSelection::DriverViewFieldSelection() {} + +void DriverViewFieldSelection::initialize() { + DriverViewFieldSelectionBase::initialize(); +} + +void DriverViewFieldSelection::setName(const touchgfx::TypedText &name) { + this->name.setTypedText(name); +} + +void DriverViewFieldSelection::setSelected(int selected) { + int val = selected ? 0x66 : 0x22; + bg.setColor(touchgfx::Color::getColorFromRGB(val, val, val)); +} diff --git a/TouchGFX/gui/src/driverview_screen/DriverViewPresenter.cpp b/TouchGFX/gui/src/driverview_screen/DriverViewPresenter.cpp index 4355607..2834c83 100644 --- a/TouchGFX/gui/src/driverview_screen/DriverViewPresenter.cpp +++ b/TouchGFX/gui/src/driverview_screen/DriverViewPresenter.cpp @@ -21,17 +21,17 @@ void DriverViewPresenter::vehicleStateUpdated() { for (size_t i = 0; i < 3; i++) { DataFieldType field = fields[i]; - void *val = dataFieldDescs[field].getValue(); - switch (dataFieldDescs[field].kind) { - case DataFieldKind::Numeric: - view.setFieldValue(i, *((float *)val)); - break; - case DataFieldKind::Bool: - view.setFieldValue(i, *((int *)val)); - break; - case DataFieldKind::Text: - view.setFieldValue(i, (const char *)val); - break; - } + // void *val = dataFieldDescs[field].getValue(); + // switch (dataFieldDescs[field].kind) { + // case DataFieldKind::Numeric: + // view.setFieldValue(i, *((float *)val)); + // break; + // case DataFieldKind::Bool: + // view.setFieldValue(i, *((int *)val)); + // break; + // case DataFieldKind::Text: + // view.setFieldValue(i, (const char *)val); + // break; + // } } } diff --git a/TouchGFX/gui/src/driverview_screen/DriverViewView.cpp b/TouchGFX/gui/src/driverview_screen/DriverViewView.cpp index 9eea9a7..843a702 100644 --- a/TouchGFX/gui/src/driverview_screen/DriverViewView.cpp +++ b/TouchGFX/gui/src/driverview_screen/DriverViewView.cpp @@ -1,18 +1,27 @@ #include "gui/common/DataField.hpp" +#include "gui/containers/DriverViewField.hpp" #include "texts/TextKeysAndLanguages.hpp" #include -DriverViewView::DriverViewView() {} +DriverViewView::DriverViewView() + : fieldTypes{DF_MinCellVolt, DF_Speed, DF_TSCurrent} {} void DriverViewView::setupScreen() { DriverViewViewBase::setupScreen(); - field1.setType(dataFieldDescs[DF_MinCellVolt]); - field2.setType(dataFieldDescs[DF_Speed]); - field3.setType(dataFieldDescs[DF_TSCurrent]); + for (size_t i = 0; i < NUM_FIELDS; i++) { + getField(i).setType(dataFieldDescs[fieldTypes[i]]); + } + fieldTypeSelection.setNumberOfItems(DataFieldType_COUNT); } void DriverViewView::tearDownScreen() { DriverViewViewBase::tearDownScreen(); } +void DriverViewView::fieldTypeSelectionUpdateItem( + DriverViewFieldSelection &item, int16_t itemIndex) { + item.setName(dataFieldDescs[itemIndex].title); + item.setSelected(itemIndex == selectedFieldType); +} + void DriverViewView::setFieldType(size_t i, const DataFieldDescription &desc) { getField(i).setType(desc); } @@ -41,6 +50,59 @@ void DriverViewView::setTSSoC(uint8_t soc) { tsSoC.invalidate(); } +void DriverViewView::selectNextField() { + if (!fieldTypeSelection.isVisible()) { + fieldTypeSelection.setVisible(true); + updateSelectedField(0); + } else { + updateSelectedField((selectedField + 1) % NUM_FIELDS); + } +} + +void DriverViewView::selectPrevField() { + if (!fieldTypeSelection.isVisible()) { + fieldTypeSelection.setVisible(true); + updateSelectedField(NUM_FIELDS - 1); + } else { + if (selectedField == 0) { + updateSelectedField(NUM_FIELDS - 1); + } else { + updateSelectedField(selectedField - 1); + } + } +} + +void DriverViewView::selectNextFieldType() { + if (!fieldTypeSelection.isVisible()) { + return; + } + + updateSelectedFieldType((selectedFieldType + 1) % DataFieldType_COUNT); +} + +void DriverViewView::selectPrevFieldType() { + if (!fieldTypeSelection.isVisible()) { + return; + } + + if (selectedFieldType == 0) { + updateSelectedFieldType(DataFieldType_COUNT - 1); + } else { + updateSelectedFieldType(selectedFieldType - 1); + } +} + +void DriverViewView::confirmFieldType() { + if (!fieldTypeSelection.isVisible()) { + return; + } + + DriverViewField &field = getField(selectedField); + field.setType(dataFieldDescs[selectedFieldType]); + field.setSelected(false); + fieldTypeSelection.setVisible(false); +} + DriverViewField &DriverViewView::getField(size_t i) { switch (i) { case 0: @@ -51,3 +113,29 @@ DriverViewField &DriverViewView::getField(size_t i) { return field3; } } + +DriverViewFieldSelection *DriverViewView::getFieldType(size_t i) { + return static_cast( + fieldTypeSelectionListItems.getDrawable(i)); +} + +void DriverViewView::updateSelectedField(size_t selected) { + getField(selectedField).setSelected(false); + DriverViewField &field = getField(selected); + field.setSelected(true); + fieldTypeSelection.moveTo(field.getX(), fieldTypeSelection.getY()); + fieldTypeSelection.invalidate(); + selectedField = selected; + + updateSelectedFieldType(fieldTypes[selectedField]); +} + +void DriverViewView::updateSelectedFieldType(size_t selected) { + size_t previousSelected = selectedFieldType; + selectedFieldType = selected; + // Trigger update of the background + fieldTypeSelection.itemChanged(previousSelected); + fieldTypeSelection.itemChanged(selectedFieldType); + + fieldTypeSelection.animateToItem(selectedFieldType, 0); +} diff --git a/TouchGFX/simulator/msvs/Application.vcxproj b/TouchGFX/simulator/msvs/Application.vcxproj index 4b5521f..a349a42 100644 --- a/TouchGFX/simulator/msvs/Application.vcxproj +++ b/TouchGFX/simulator/msvs/Application.vcxproj @@ -37,6 +37,8 @@ + + @@ -203,6 +205,8 @@ + + diff --git a/TouchGFX/simulator/msvs/Application.vcxproj.filters b/TouchGFX/simulator/msvs/Application.vcxproj.filters index 64de93c..649d2ee 100644 --- a/TouchGFX/simulator/msvs/Application.vcxproj.filters +++ b/TouchGFX/simulator/msvs/Application.vcxproj.filters @@ -300,6 +300,12 @@ Source Files\gui\common + + Source Files\gui\containers + + + Source Files\generated\gui_generated\containers + @@ -790,6 +796,12 @@ Header Files\gui\common + + Header Files\gui\containers + + + Header Files\generated\gui_generated\containers + diff --git a/TouchGFX/steering-wheel.touchgfx b/TouchGFX/steering-wheel.touchgfx index ec96fcf..14beb34 100644 --- a/TouchGFX/steering-wheel.touchgfx +++ b/TouchGFX/steering-wheel.touchgfx @@ -403,9 +403,81 @@ "Width": 160, "Height": 80, "CustomContainerDefinitionName": "DriverViewField" + }, + { + "Type": "ScrollWheel", + "Name": "fieldTypeSelection", + "Y": 80, + "Width": 160, + "Height": 240, + "Visible": false, + "SelectedItemOffset": 94, + "IsCircular": true, + "ItemTemplateName": "DriverViewFieldSelection", + "NumberofItems": 1, + "Easing": "Back", + "EasingOption": "Out", + "SwipeAcceleration": 1.0, + "DragAcceleration": 1.0 } ], - "Interactions": [] + "Interactions": [ + { + "InteractionName": "SelectPreviousField", + "Trigger": { + "Type": "TriggerPhysicalButtonClicked", + "ButtonKey": 22 + }, + "Action": { + "Type": "ActionCustom", + "FunctionName": "selectPrevField" + } + }, + { + "InteractionName": "SelectNextField", + "Trigger": { + "Type": "TriggerPhysicalButtonClicked", + "ButtonKey": 21 + }, + "Action": { + "Type": "ActionCustom", + "FunctionName": "selectNextField" + } + }, + { + "InteractionName": "SelectPreviousFieldType", + "Trigger": { + "Type": "TriggerPhysicalButtonClicked", + "ButtonKey": 24 + }, + "Action": { + "Type": "ActionCustom", + "FunctionName": "selectPrevFieldType" + } + }, + { + "InteractionName": "SelectNextFieldType", + "Trigger": { + "Type": "TriggerPhysicalButtonClicked", + "ButtonKey": 23 + }, + "Action": { + "Type": "ActionCustom", + "FunctionName": "selectNextFieldType" + } + }, + { + "InteractionName": "ConfirmFieldType", + "Trigger": { + "Type": "TriggerPhysicalButtonClicked", + "ButtonKey": 6 + }, + "Action": { + "Type": "ActionCustom", + "FunctionName": "confirmFieldType" + } + } + ] } ], "CustomContainerDefinitions": [ @@ -537,6 +609,84 @@ } ], "Interactions": [] + }, + { + "Name": "DriverViewFieldSelection", + "X": 100, + "Y": 227, + "Width": 160, + "Height": 26, + "Components": [ + { + "Type": "Box", + "Name": "bg", + "Width": 160, + "Height": 25, + "Color": { + "Red": 34, + "Green": 34, + "Blue": 34 + } + }, + { + "Type": "TextArea", + "Name": "name", + "Width": 160, + "Height": 25, + "TextId": "__SingleUse_PNKR", + "TextRotation": "0", + "Color": { + "Red": 255, + "Green": 255, + "Blue": 255 + } + }, + { + "Type": "Line", + "Name": "line1", + "Y": 25, + "Width": 160, + "Height": 1, + "Color": { + "Red": 255, + "Green": 255, + "Blue": 255 + }, + "EndX": 160.0, + "LineWidth": 10.0, + "LineEndingStyle": "Round" + }, + { + "Type": "Line", + "Name": "line2", + "Width": 1, + "Height": 26, + "Color": { + "Red": 255, + "Green": 255, + "Blue": 255 + }, + "EndY": 26.0, + "LineWidth": 10.0, + "LineEndingStyle": "Round" + }, + { + "Type": "Line", + "Name": "line2_1", + "X": 159, + "Width": 1, + "Height": 26, + "Color": { + "Red": 255, + "Green": 255, + "Blue": 255 + }, + "EndY": 26.0, + "LineWidth": 10.0, + "LineEndingStyle": "Round" + } + ], + "Interactions": [] } ], "Name": "MyApplication", @@ -545,7 +695,7 @@ "Height": 480 }, "SelectedColorDepth": 16, - "StartupScreenName": "MissionSelect", + "StartupScreenName": "DriverView", "SelectedStartupLanguage": "GB", "TouchGfxPath": "../Middlewares/ST/touchgfx", "UIPath": ".",