1
0

fin SETR2

This commit is contained in:
Jose
2025-12-19 17:13:32 +01:00
parent b9c332427d
commit ec45536183
740 changed files with 465505 additions and 284 deletions

View File

@@ -0,0 +1,24 @@
#ifndef FRONTENDAPPLICATION_HPP
#define FRONTENDAPPLICATION_HPP
#include <gui_generated/common/FrontendApplicationBase.hpp>
class FrontendHeap;
using namespace touchgfx;
class FrontendApplication : public FrontendApplicationBase
{
public:
FrontendApplication(Model& m, FrontendHeap& heap);
virtual ~FrontendApplication() { }
virtual void handleTickEvent()
{
model.tick();
FrontendApplicationBase::handleTickEvent();
}
private:
};
#endif // FRONTENDAPPLICATION_HPP

View File

@@ -0,0 +1,74 @@
#ifndef FRONTENDHEAP_HPP
#define FRONTENDHEAP_HPP
#include <gui_generated/common/FrontendHeapBase.hpp>
class FrontendHeap : public FrontendHeapBase
{
public:
/* List any user-defined view types here*/
typedef touchgfx::meta::TypeList< touchgfx::meta::Nil, //Replace this with first user-defined type
touchgfx::meta::Nil //List must always end with meta::Nil !
> UserDefinedViewTypes;
/* List any user-defined presenter types here*/
typedef touchgfx::meta::TypeList< touchgfx::meta::Nil, //Replace this with first user-defined type
touchgfx::meta::Nil //List must always end with meta::Nil !
> UserDefinedPresenterTypes;
/* List any user-defined transition types here*/
typedef touchgfx::meta::TypeList< touchgfx::meta::Nil, //Replace this with first user-defined type
touchgfx::meta::Nil //List must always end with meta::Nil !
> UserDefinedTransitionTypes;
/* Calculate largest view, both from generated and user-defined typelists */
typedef touchgfx::meta::select_type_maxsize< UserDefinedViewTypes >::type MaxUserViewType;
typedef touchgfx::meta::TypeList< MaxGeneratedViewType,
touchgfx::meta::TypeList< MaxUserViewType,
touchgfx::meta::Nil
> > CombinedViewTypes;
typedef touchgfx::meta::select_type_maxsize< CombinedViewTypes >::type MaxViewType;
/* Calculate largest presenter, both from generated and user-defined typelists */
typedef touchgfx::meta::select_type_maxsize< UserDefinedPresenterTypes >::type MaxUserPresenterType;
typedef touchgfx::meta::TypeList< MaxGeneratedPresenterType,
touchgfx::meta::TypeList< MaxUserPresenterType,
touchgfx::meta::Nil
> > CombinedPresenterTypes;
typedef touchgfx::meta::select_type_maxsize< CombinedPresenterTypes >::type MaxPresenterType;
/* Calculate largest transition, both from generated and user-defined typelists */
typedef touchgfx::meta::select_type_maxsize< UserDefinedTransitionTypes >::type MaxUserTransitionType;
typedef touchgfx::meta::TypeList< MaxGeneratedTransitionType,
touchgfx::meta::TypeList< MaxUserTransitionType,
touchgfx::meta::Nil
> > CombinedTransitionTypes;
typedef touchgfx::meta::select_type_maxsize< CombinedTransitionTypes >::type MaxTransitionType;
static FrontendHeap& getInstance()
{
static FrontendHeap instance;
return instance;
}
touchgfx::Partition< CombinedPresenterTypes, 1 > presenters;
touchgfx::Partition< CombinedViewTypes, 1 > views;
touchgfx::Partition< CombinedTransitionTypes, 1 > transitions;
Model model;
FrontendApplication app;
private:
FrontendHeap() : FrontendHeapBase(presenters, views, transitions, app),
app(model, *this)
{
gotoStartScreen(app);
}
};
#endif // FRONTENDHEAP_HPP

View File

@@ -0,0 +1,39 @@
#ifndef MAINSCREENPRESENTER_HPP
#define MAINSCREENPRESENTER_HPP
#include <gui/model/ModelListener.hpp>
#include <mvp/Presenter.hpp>
using namespace touchgfx;
class MainScreenView;
class MainScreenPresenter : public touchgfx::Presenter, public ModelListener
{
public:
MainScreenPresenter(MainScreenView& 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();
/**
* 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 ~MainScreenPresenter() {}
virtual void set_button(bool state);
virtual void set_temperature(uint16_t temp);
private:
MainScreenPresenter();
MainScreenView& view;
};
#endif // MAINSCREENPRESENTER_HPP

View File

@@ -0,0 +1,20 @@
#ifndef MAINSCREENVIEW_HPP
#define MAINSCREENVIEW_HPP
#include <gui_generated/mainscreen_screen/MainScreenViewBase.hpp>
#include <gui/mainscreen_screen/MainScreenPresenter.hpp>
class MainScreenView : public MainScreenViewBase
{
public:
MainScreenView();
virtual ~MainScreenView() {}
virtual void setupScreen();
virtual void tearDownScreen();
virtual void set_button(bool state);
virtual void set_temperature(uint16_t temp);
protected:
};
#endif // MAINSCREENVIEW_HPP

View File

@@ -0,0 +1,25 @@
#ifndef MODEL_HPP
#define MODEL_HPP
#include <cstdint>
class ModelListener;
class Model
{
public:
Model();
void bind(ModelListener* listener)
{
modelListener = listener;
}
void tick();
protected:
ModelListener* modelListener;
bool button_state; // estado del boton en la gui
uint16_t temp; // estado del gauge en la gui
};
#endif // MODEL_HPP

View File

@@ -0,0 +1,24 @@
#ifndef MODELLISTENER_HPP
#define MODELLISTENER_HPP
#include <gui/model/Model.hpp>
class ModelListener
{
public:
ModelListener() : model(0) {}
virtual ~ModelListener() {}
void bind(Model* m)
{
model = m;
}
virtual void set_button(bool state);
virtual void set_temperature(uint16_t temp);
protected:
Model* model;
};
#endif // MODELLISTENER_HPP

View File

@@ -0,0 +1,7 @@
#include <gui/common/FrontendApplication.hpp>
FrontendApplication::FrontendApplication(Model& m, FrontendHeap& heap)
: FrontendApplicationBase(m, heap)
{
}

View File

@@ -0,0 +1,29 @@
#include <gui/mainscreen_screen/MainScreenView.hpp>
#include <gui/mainscreen_screen/MainScreenPresenter.hpp>
MainScreenPresenter::MainScreenPresenter(MainScreenView& v)
: view(v)
{
}
void MainScreenPresenter::activate()
{
}
void MainScreenPresenter::deactivate()
{
}
void MainScreenPresenter::set_button(bool state)
{
view.set_button(state); // actualiza la view (UI)
}
void MainScreenPresenter::set_temperature(uint16_t temp)
{
view.set_temperature(temp); // actualiza la view (UI)
}

View File

@@ -0,0 +1,28 @@
#include <gui/mainscreen_screen/MainScreenView.hpp>
MainScreenView::MainScreenView()
{
}
void MainScreenView::setupScreen()
{
MainScreenViewBase::setupScreen();
}
void MainScreenView::tearDownScreen()
{
MainScreenViewBase::tearDownScreen();
}
void MainScreenView::set_button(bool state)
{
led_on.setVisible(state);
led_on.invalidate();
}
void MainScreenView::set_temperature(uint16_t temp)
{
temperature.setValue(temp);
temperature.invalidate();
}

View File

@@ -0,0 +1,27 @@
#include <gui/model/Model.hpp>
#include <gui/model/ModelListener.hpp>
#include "FreeRTOS.h"
#include "queue.h"
extern "C" {
extern QueueHandle_t button_queue;
extern QueueHandle_t temperature_queue;
}
Model::Model() : modelListener(0)
{
}
void Model::tick()
{
if(xQueueReceive(button_queue, &button_state, 10) == pdPASS)
{
modelListener->set_button(button_state); // lo envia al presenter
}
if(xQueueReceive(temperature_queue, &temp, 10) == pdPASS)
{
modelListener->set_temperature(temp); // lo envia al presenter
}
}