restructure folder
Signed-off-by: Peter Siegmund <developer@mars3142.org>
This commit is contained in:
36
components/insa/src/ui/LightMenu.cpp
Normal file
36
components/insa/src/ui/LightMenu.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
#include "ui/LightMenu.h"
|
||||
|
||||
LightMenu::LightMenu(menu_options_t *options) : PSMenu(options), m_options(options)
|
||||
{
|
||||
std::vector<std::string> values;
|
||||
values.emplace_back("Tag");
|
||||
values.emplace_back("Nacht");
|
||||
addSelection(1, "Modus", values.front(), values, [this](const uint8_t id, const ButtonType button) {
|
||||
onButtonPressed(id, button);
|
||||
});
|
||||
|
||||
addText(2, "LED Einstellungen", [this](const uint8_t id, const ButtonType button) {
|
||||
onButtonPressed(id, button);
|
||||
});
|
||||
|
||||
addToggle(3, "Toggle", false, nullptr);
|
||||
}
|
||||
|
||||
void LightMenu::onButtonPressed(const uint8_t id, const ButtonType button) const
|
||||
{
|
||||
std::shared_ptr<Widget> widget;
|
||||
switch (id)
|
||||
{
|
||||
case 2:
|
||||
widget = std::make_shared<LightMenu>(m_options);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (m_options && m_options->pushScreen)
|
||||
{
|
||||
m_options->pushScreen(widget);
|
||||
}
|
||||
}
|
40
components/insa/src/ui/MainMenu.cpp
Normal file
40
components/insa/src/ui/MainMenu.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
#include "ui/MainMenu.h"
|
||||
|
||||
#include "common/Widget.h"
|
||||
#include "ui/LightMenu.h"
|
||||
#include "ui/SettingsMenu.h"
|
||||
|
||||
MainMenu::MainMenu(menu_options_t *options) : PSMenu(options), m_options(options)
|
||||
{
|
||||
addText(1, "Lichtsteuerung", [this](const uint8_t id, const ButtonType button) {
|
||||
onButtonPressed(id, button);
|
||||
});
|
||||
addText(2, "externe Geraete", [this](const uint8_t id, const ButtonType button) {
|
||||
onButtonPressed(id, button);
|
||||
});
|
||||
addText(3, "Einstellungen", [this](const uint8_t id, const ButtonType button) {
|
||||
onButtonPressed(id, button);
|
||||
});
|
||||
}
|
||||
|
||||
void MainMenu::onButtonPressed(const uint8_t id, const ButtonType button) const
|
||||
{
|
||||
std::shared_ptr<Widget> widget;
|
||||
switch (id)
|
||||
{
|
||||
case 1:
|
||||
widget = std::make_shared<LightMenu>(m_options);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
widget = std::make_shared<SettingsMenu>(m_options);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (m_options && m_options->pushScreen)
|
||||
{
|
||||
m_options->pushScreen(widget);
|
||||
}
|
||||
}
|
11
components/insa/src/ui/SettingsMenu.cpp
Normal file
11
components/insa/src/ui/SettingsMenu.cpp
Normal file
@@ -0,0 +1,11 @@
|
||||
#include "ui/SettingsMenu.h"
|
||||
|
||||
void demo(uint8_t id, ButtonType button)
|
||||
{
|
||||
///
|
||||
}
|
||||
|
||||
SettingsMenu::SettingsMenu(menu_options_t *options) : PSMenu(options)
|
||||
{
|
||||
addText(1, "OTA Einspielen", demo);
|
||||
}
|
40
components/insa/src/ui/SplashScreen.cpp
Normal file
40
components/insa/src/ui/SplashScreen.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
#include "ui/SplashScreen.h"
|
||||
|
||||
#include "ui/MainMenu.h"
|
||||
|
||||
#ifdef ESP32
|
||||
#else
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
#endif
|
||||
|
||||
uint64_t counter = 0;
|
||||
|
||||
SplashScreen::SplashScreen(menu_options_t *options) : Widget(options->u8g2), m_options(options)
|
||||
{
|
||||
}
|
||||
|
||||
void SplashScreen::update(const uint64_t dt)
|
||||
{
|
||||
counter += dt;
|
||||
if (counter > 200000)
|
||||
{
|
||||
counter = 0;
|
||||
if (m_options && m_options->setScreen)
|
||||
{
|
||||
m_options->setScreen(std::make_shared<MainMenu>(m_options));
|
||||
}
|
||||
}
|
||||
#ifndef ESP32
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||
#endif
|
||||
}
|
||||
|
||||
void SplashScreen::render()
|
||||
{
|
||||
u8g2_SetFont(u8g2, u8g2_font_DigitalDisco_tr);
|
||||
u8g2_DrawStr(u8g2, 28, u8g2->height / 2 - 10, "HO Anlage");
|
||||
u8g2_DrawStr(u8g2, 30, u8g2->height / 2 + 5, "Axel Janz");
|
||||
u8g2_SetFont(u8g2, u8g2_font_haxrcorp4089_tr);
|
||||
u8g2_DrawStr(u8g2, 35, 50, "Initialisierung...");
|
||||
}
|
Reference in New Issue
Block a user