graphdisplay now with confirm and back

This commit is contained in:
2021-12-28 12:32:45 +01:00
parent 4871df0898
commit 4cb29d1d3b

View File

@ -9,6 +9,8 @@
#include "widgets/label.h"
#include "widgets/graph.h"
#include "tftinstance.h"
#include "confirminterface.h"
#include "backinterface.h"
namespace espgui {
template<size_t COUNT>
@ -41,7 +43,9 @@ public:
template<size_t COUNT>
class GraphDisplay :
public DisplayWithTitle,
public virtual GraphAccessorInterface<COUNT>
public virtual GraphAccessorInterface<COUNT>,
public virtual ConfirmInterface,
public virtual BackInterface
{
using Base = DisplayWithTitle;
@ -49,6 +53,8 @@ public:
void initScreen() override;
void redraw() override;
void buttonPressed(Button button) override;
private:
static constexpr int screenHeight = 320, topMargin = 40, bottomMargin = 10, labelOffset = -5;
static constexpr int graphHeight = screenHeight-topMargin-bottomMargin;
@ -71,4 +77,17 @@ void GraphDisplay<COUNT>::redraw()
m_graph.redraw(static_cast<const GraphAccessorInterface<COUNT> &>(*this).getBuffers());
}
template<size_t COUNT>
void GraphDisplay<COUNT>::buttonPressed(Button button)
{
Base::buttonPressed(button);
switch (button)
{
case Button::Left: back(); break;
case Button::Right: confirm(); break;
default:;
}
}
}