Add screen for configuring vehicle parameters

This commit is contained in:
2023-04-04 20:58:34 +02:00
parent 09f65fcf22
commit a5f10be4fd
35 changed files with 1976 additions and 104 deletions

View File

@ -32,6 +32,9 @@ public:
// DebugView
void gotoDebugViewScreenNoTransition();
// VehicleConfig
void gotoVehicleConfigScreenNoTransition();
protected:
touchgfx::Callback<FrontendApplicationBase> transitionCallback;
FrontendHeap& frontendHeap;
@ -48,6 +51,9 @@ protected:
// DebugView
void gotoDebugViewScreenNoTransitionImpl();
// VehicleConfig
void gotoVehicleConfigScreenNoTransitionImpl();
};
#endif // FRONTENDAPPLICATIONBASE_HPP

View File

@ -20,6 +20,8 @@
#include <gui/driverview_screen/DriverViewPresenter.hpp>
#include <gui/debugview_screen/DebugViewView.hpp>
#include <gui/debugview_screen/DebugViewPresenter.hpp>
#include <gui/vehicleconfig_screen/VehicleConfigView.hpp>
#include <gui/vehicleconfig_screen/VehicleConfigPresenter.hpp>
/**
@ -46,7 +48,8 @@ public:
touchgfx::meta::TypeList< AMIView,
touchgfx::meta::TypeList< DriverViewView,
touchgfx::meta::TypeList< DebugViewView,
touchgfx::meta::Nil > > >
touchgfx::meta::TypeList< VehicleConfigView,
touchgfx::meta::Nil > > > >
> GeneratedViewTypes;
/**
@ -62,7 +65,8 @@ public:
touchgfx::meta::TypeList< AMIPresenter,
touchgfx::meta::TypeList< DriverViewPresenter,
touchgfx::meta::TypeList< DebugViewPresenter,
touchgfx::meta::Nil > > >
touchgfx::meta::TypeList< VehicleConfigPresenter,
touchgfx::meta::Nil > > > >
> GeneratedPresenterTypes;
/**

View File

@ -0,0 +1,41 @@
/*********************************************************************************/
/********** THIS FILE IS GENERATED BY TOUCHGFX DESIGNER, DO NOT MODIFY ***********/
/*********************************************************************************/
#ifndef CONFIGITEMBASE_HPP
#define CONFIGITEMBASE_HPP
#include <gui/common/FrontendApplication.hpp>
#include <touchgfx/containers/Container.hpp>
#include <touchgfx/widgets/Box.hpp>
#include <touchgfx/widgets/TextAreaWithWildcard.hpp>
#include <touchgfx/widgets/canvas/Line.hpp>
#include <touchgfx/widgets/canvas/PainterRGB565.hpp>
class ConfigItemBase : public touchgfx::Container
{
public:
ConfigItemBase();
virtual ~ConfigItemBase();
virtual void initialize();
protected:
FrontendApplication& application() {
return *static_cast<FrontendApplication*>(touchgfx::Application::getInstance());
}
/*
* Member Declarations
*/
touchgfx::Box bg;
touchgfx::TextAreaWithOneWildcard title;
touchgfx::Line line1;
touchgfx::PainterRGB565 line1Painter;
touchgfx::TextAreaWithOneWildcard value;
touchgfx::Line line2;
touchgfx::PainterRGB565 line2Painter;
private:
};
#endif // CONFIGITEMBASE_HPP

View File

@ -0,0 +1,89 @@
/*********************************************************************************/
/********** THIS FILE IS GENERATED BY TOUCHGFX DESIGNER, DO NOT MODIFY ***********/
/*********************************************************************************/
#ifndef VEHICLECONFIGVIEWBASE_HPP
#define VEHICLECONFIGVIEWBASE_HPP
#include <gui/common/FrontendApplication.hpp>
#include <mvp/View.hpp>
#include <gui/vehicleconfig_screen/VehicleConfigPresenter.hpp>
#include <touchgfx/widgets/Box.hpp>
#include <touchgfx/widgets/TextArea.hpp>
#include <touchgfx/containers/scrollers/ScrollWheel.hpp>
#include <gui/containers/ConfigItem.hpp>
#include <touchgfx/widgets/canvas/Line.hpp>
#include <touchgfx/widgets/canvas/PainterRGB565.hpp>
class VehicleConfigViewBase : public touchgfx::View<VehicleConfigPresenter>
{
public:
VehicleConfigViewBase();
virtual ~VehicleConfigViewBase();
virtual void setupScreen();
virtual void paramsUpdateItem(ConfigItem& item, int16_t itemIndex)
{
// Override and implement this function in VehicleConfig
}
virtual void handleKeyEvent(uint8_t key);
/*
* Virtual Action Handlers
*/
virtual void selectPrevParam()
{
// Override and implement this function in VehicleConfig
}
virtual void selectNextParam()
{
// Override and implement this function in VehicleConfig
}
virtual void decParam()
{
// Override and implement this function in VehicleConfig
}
virtual void incParam()
{
// Override and implement this function in VehicleConfig
}
virtual void confirmParam()
{
// Override and implement this function in VehicleConfig
}
protected:
FrontendApplication& application() {
return *static_cast<FrontendApplication*>(touchgfx::Application::getInstance());
}
/*
* Member Declarations
*/
touchgfx::Box __background;
touchgfx::TextArea title;
touchgfx::ScrollWheel params;
touchgfx::DrawableListItems<ConfigItem, 6> paramsListItems;
touchgfx::Line line1;
touchgfx::PainterRGB565 line1Painter;
private:
/*
* Canvas Buffer Size
*/
static const uint32_t CANVAS_BUFFER_SIZE = 7200;
uint8_t canvasBuffer[CANVAS_BUFFER_SIZE];
/*
* Callback Declarations
*/
touchgfx::Callback<VehicleConfigViewBase, touchgfx::DrawableListItemsInterface*, int16_t, int16_t> updateItemCallback;
/*
* Callback Handler Declarations
*/
void updateItemCallbackHandler(touchgfx::DrawableListItemsInterface* items, int16_t containerIndex, int16_t itemIndex);
};
#endif // VEHICLECONFIGVIEWBASE_HPP

View File

@ -17,6 +17,8 @@
#include <gui/driverview_screen/DriverViewPresenter.hpp>
#include <gui/debugview_screen/DebugViewView.hpp>
#include <gui/debugview_screen/DebugViewPresenter.hpp>
#include <gui/vehicleconfig_screen/VehicleConfigView.hpp>
#include <gui/vehicleconfig_screen/VehicleConfigPresenter.hpp>
using namespace touchgfx;
@ -86,3 +88,16 @@ void FrontendApplicationBase::gotoDebugViewScreenNoTransitionImpl()
{
touchgfx::makeTransition<DebugViewView, DebugViewPresenter, touchgfx::NoTransition, Model >(&currentScreen, &currentPresenter, frontendHeap, &currentTransition, &model);
}
// VehicleConfig
void FrontendApplicationBase::gotoVehicleConfigScreenNoTransition()
{
transitionCallback = touchgfx::Callback<FrontendApplicationBase>(this, &FrontendApplication::gotoVehicleConfigScreenNoTransitionImpl);
pendingScreenTransitionCallback = &transitionCallback;
}
void FrontendApplicationBase::gotoVehicleConfigScreenNoTransitionImpl()
{
touchgfx::makeTransition<VehicleConfigView, VehicleConfigPresenter, touchgfx::NoTransition, Model >(&currentScreen, &currentPresenter, frontendHeap, &currentTransition, &model);
}

View File

@ -0,0 +1,55 @@
/*********************************************************************************/
/********** THIS FILE IS GENERATED BY TOUCHGFX DESIGNER, DO NOT MODIFY ***********/
/*********************************************************************************/
#include <gui_generated/containers/ConfigItemBase.hpp>
#include <touchgfx/Color.hpp>
#include <texts/TextKeysAndLanguages.hpp>
ConfigItemBase::ConfigItemBase()
{
setWidth(450);
setHeight(50);
bg.setPosition(0, 0, 450, 50);
bg.setColor(touchgfx::Color::getColorFromRGB(0, 0, 0));
add(bg);
title.setPosition(0, 6, 200, 37);
title.setColor(touchgfx::Color::getColorFromRGB(255, 255, 255));
title.setLinespacing(0);
title.setTypedText(touchgfx::TypedText(T___SINGLEUSE_YTAB));
add(title);
line1.setPosition(200, 0, 2, 50);
line1Painter.setColor(touchgfx::Color::getColorFromRGB(255, 255, 255));
line1.setPainter(line1Painter);
line1.setStart(0, 0);
line1.setEnd(0, 50);
line1.setLineWidth(10);
line1.setLineEndingStyle(touchgfx::Line::ROUND_CAP_ENDING);
add(line1);
value.setPosition(207, -7, 243, 55);
value.setColor(touchgfx::Color::getColorFromRGB(255, 255, 255));
value.setLinespacing(0);
value.setTypedText(touchgfx::TypedText(T___SINGLEUSE_4E84));
add(value);
line2.setPosition(0, 48, 450, 2);
line2Painter.setColor(touchgfx::Color::getColorFromRGB(255, 255, 255));
line2.setPainter(line2Painter);
line2.setStart(0, 0);
line2.setEnd(450, 0);
line2.setLineWidth(10);
line2.setLineEndingStyle(touchgfx::Line::ROUND_CAP_ENDING);
add(line2);
}
ConfigItemBase::~ConfigItemBase()
{
}
void ConfigItemBase::initialize()
{
}

View File

@ -126,4 +126,13 @@ void MissionSelectViewBase::handleKeyEvent(uint8_t key)
application().gotoDebugViewScreenNoTransition();
}
if(251 == key)
{
//DummyChangeConfigView
//When hardware button 251 clicked change screen to VehicleConfig
//Go to VehicleConfig with no screen transition
application().gotoVehicleConfigScreenNoTransition();
}
}

View File

@ -0,0 +1,117 @@
/*********************************************************************************/
/********** THIS FILE IS GENERATED BY TOUCHGFX DESIGNER, DO NOT MODIFY ***********/
/*********************************************************************************/
#include <gui_generated/vehicleconfig_screen/VehicleConfigViewBase.hpp>
#include <touchgfx/canvas_widget_renderer/CanvasWidgetRenderer.hpp>
#include <touchgfx/Color.hpp>
#include <texts/TextKeysAndLanguages.hpp>
VehicleConfigViewBase::VehicleConfigViewBase() :
updateItemCallback(this, &VehicleConfigViewBase::updateItemCallbackHandler)
{
touchgfx::CanvasWidgetRenderer::setupBuffer(canvasBuffer, CANVAS_BUFFER_SIZE);
__background.setPosition(0, 0, 480, 320);
__background.setColor(touchgfx::Color::getColorFromRGB(0, 0, 0));
add(__background);
title.setPosition(15, 15, 450, 37);
title.setColor(touchgfx::Color::getColorFromRGB(255, 255, 255));
title.setLinespacing(0);
title.setTypedText(touchgfx::TypedText(T___SINGLEUSE_RWCE));
add(title);
params.setPosition(15, 60, 450, 245);
params.setHorizontal(false);
params.setCircular(false);
params.setEasingEquation(touchgfx::EasingEquations::cubicEaseOut);
params.setSwipeAcceleration(10);
params.setDragAcceleration(10);
params.setNumberOfItems(1);
params.setSelectedItemOffset(0);
params.setDrawableSize(50, 0);
params.setDrawables(paramsListItems, updateItemCallback);
params.animateToItem(0, 0);
add(params);
line1.setPosition(15, 58, 450, 2);
line1Painter.setColor(touchgfx::Color::getColorFromRGB(255, 255, 255));
line1.setPainter(line1Painter);
line1.setStart(0, 0);
line1.setEnd(450, 0);
line1.setLineWidth(10);
line1.setLineEndingStyle(touchgfx::Line::ROUND_CAP_ENDING);
add(line1);
}
VehicleConfigViewBase::~VehicleConfigViewBase()
{
touchgfx::CanvasWidgetRenderer::resetBuffer();
}
void VehicleConfigViewBase::setupScreen()
{
params.initialize();
for (int i = 0; i < paramsListItems.getNumberOfDrawables(); i++)
{
paramsListItems[i].initialize();
}
}
void VehicleConfigViewBase::handleKeyEvent(uint8_t key)
{
if(22 == key)
{
//SelectPreviousParam
//When hardware button 22 clicked call virtual function
//Call selectPrevParam
selectPrevParam();
}
if(21 == key)
{
//SelectNextParam
//When hardware button 21 clicked call virtual function
//Call selectNextParam
selectNextParam();
}
if(24 == key)
{
//DecreaseParam
//When hardware button 24 clicked call virtual function
//Call decParam
decParam();
}
if(23 == key)
{
//IncreaseParam
//When hardware button 23 clicked call virtual function
//Call incParam
incParam();
}
if(6 == key)
{
//ConfirmParam
//When hardware button 6 clicked call virtual function
//Call confirmParam
confirmParam();
}
}
void VehicleConfigViewBase::updateItemCallbackHandler(touchgfx::DrawableListItemsInterface* items, int16_t containerIndex, int16_t itemIndex)
{
if (items == &paramsListItems)
{
touchgfx::Drawable* d = items->getDrawable(containerIndex);
ConfigItem* cc = (ConfigItem*)d;
paramsUpdateItem(*cc, itemIndex);
}
}