Added confirm and back (#186)
This commit is contained in:
@ -1,104 +1,104 @@
|
||||
set(BOBBY_APP_NAME bobbyquad_peter)
|
||||
|
||||
add_definitions(
|
||||
-DUSER_SETUP_LOADED=1
|
||||
-DLOAD_GLCD=1
|
||||
-DLOAD_FONT2=1
|
||||
-DLOAD_FONT4=1
|
||||
-DLOAD_FONT7=1
|
||||
-DILI9341_DRIVER=1
|
||||
-DTFT_MOSI=13
|
||||
-DTFT_SCLK=15
|
||||
-DTFT_CS=14
|
||||
-DTFT_DC=12
|
||||
-DTFT_RST=2
|
||||
-DSPI_FREQUENCY=40000000
|
||||
-DUSER_SETUP_LOADED=1
|
||||
-DLOAD_GLCD=1
|
||||
-DLOAD_FONT2=1
|
||||
-DLOAD_FONT4=1
|
||||
-DLOAD_FONT7=1
|
||||
-DILI9341_DRIVER=1
|
||||
-DTFT_MOSI=13
|
||||
-DTFT_SCLK=15
|
||||
-DTFT_CS=14
|
||||
-DTFT_DC=12
|
||||
-DTFT_RST=2
|
||||
-DSPI_FREQUENCY=40000000
|
||||
)
|
||||
|
||||
set(BOBBYCAR_BUILDFLAGS
|
||||
-DFEATURE_ADC_IN
|
||||
-DPINS_GAS=34
|
||||
-DPINS_BREMS=35
|
||||
-DDEFAULT_SWAPSCREENBYTES=false
|
||||
-DFEATURE_CAN
|
||||
# -DFEATURE_SERIAL
|
||||
# -DPINS_RX1=4
|
||||
# -DPINS_TX1=5
|
||||
# -DPINS_RX2=22
|
||||
# -DPINS_TX2=23
|
||||
-DDEFAULT_INVERTFRONTLEFT=false
|
||||
-DDEFAULT_INVERTFRONTRIGHT=true
|
||||
-DDEFAULT_INVERTBACKLEFT=false
|
||||
-DDEFAULT_INVERTBACKRIGHT=true
|
||||
-DDEFAULT_WHEELDIAMETER=200
|
||||
# -DFEATURE_MOSFETS
|
||||
# -DPINS_MOSFET0=18
|
||||
# -DPINS_MOSFET1=19
|
||||
# -DPINS_MOSFET2=21
|
||||
-DDEFAULT_IMOTMAX=28
|
||||
-DDEFAULT_IDCMAX=30
|
||||
-DDEFAULT_NMOTMAX=2000
|
||||
-DDEFAULT_FIELDWEAKMAX=7
|
||||
-DDEFAULT_FIELDADVMAX=40
|
||||
-DDEVICE_PREFIX=peter_bobbyquad
|
||||
-DAP_PASSWORD=Passwort_123
|
||||
-DFEATURE_WEBSERVER
|
||||
-DFEATURE_OTA
|
||||
-DOTA_USERNAME="peter"
|
||||
-DFEATURE_DPAD_5WIRESW_2OUT
|
||||
-DPINS_DPAD_5WIRESW_OUT1=18
|
||||
-DPINS_DPAD_5WIRESW_OUT2=19
|
||||
-DPINS_DPAD_5WIRESW_IN1=4
|
||||
-DPINS_DPAD_5WIRESW_IN2=5
|
||||
-DPINS_DPAD_5WIRESW_IN3=27
|
||||
-DDPAD_5WIRESW_UP=4
|
||||
-DDPAD_5WIRESW_DOWN=7
|
||||
-DDPAD_5WIRESW_CONFIRM=1
|
||||
-DDPAD_5WIRESW_BACK=10
|
||||
-DDPAD_5WIRESW_PROFILE0=11
|
||||
-DDPAD_5WIRESW_PROFILE1=8
|
||||
-DDPAD_5WIRESW_PROFILE2=5
|
||||
-DDPAD_5WIRESW_PROFILE3=2
|
||||
-DDPAD_5WIRESW_BLINK_LEFT=9
|
||||
-DDPAD_5WIRESW_BLINK_RIGHT=0
|
||||
-DDPAD_5WIRESW_QUICKACTION_DOWN=3
|
||||
-DDPAD_5WIRESW_QUICKACTION_UP=6
|
||||
# -DDPAD_5WIRESW_DEBUG
|
||||
-DDEFAULT_GASMIN=842
|
||||
-DDEFAULT_GASMAX=2480
|
||||
-DDEFAULT_BREMSMIN=826
|
||||
-DDEFAULT_BREMSMAX=2502
|
||||
-DFEATURE_BLE
|
||||
# -DFEATURE_BLUETOOTH
|
||||
# -DFEATURE_BMS
|
||||
# -DFEATURE_GAMETRAK
|
||||
# -DPINS_GAMETRAKX=34
|
||||
# -DPINS_GAMETRAKY=39
|
||||
# -DPINS_GAMETRAKDIST=36
|
||||
# -DDEFAULT_GAMETRAKXMIN=0
|
||||
# -DDEFAULT_GAMETRAKXMAX=4095
|
||||
# -DDEFAULT_GAMETRAKYMIN=0
|
||||
# -DDEFAULT_GAMETRAKYMAX=4095
|
||||
# -DDEFAULT_GAMETRAKDISTMIN=0
|
||||
# -DDEFAULT_GAMETRAKDISTMAX=4095
|
||||
# -DFEATURE_POWERSUPPLY
|
||||
# -DFEATURE_CLOUD
|
||||
-DFEATURE_UDPCLOUD
|
||||
-DFEATURE_LEDBACKLIGHT
|
||||
-DPINS_LEDBACKLIGHT=23
|
||||
-DLEDBACKLIGHT_INVERTED
|
||||
-DFEATURE_GARAGE
|
||||
#-DFEATURE_NTP
|
||||
-DFEATURE_WIRELESS_CONFIG
|
||||
-DFEATURE_LEDSTRIP
|
||||
-DPINS_LEDSTRIP=33
|
||||
-DLEDSTRIP_LENGTH=288
|
||||
# -DLEDSTRIP_WRONG_DIRECTION
|
||||
-DLEDSTRIP_ANIMATION_DEFAULT=2
|
||||
-DLEDS_PER_METER=144
|
||||
-DOLD_NVS
|
||||
-DFEATURE_DNS_NS
|
||||
-DFEATURE_ESPNOW
|
||||
-DFEATURE_ADC_IN
|
||||
-DPINS_GAS=34
|
||||
-DPINS_BREMS=35
|
||||
-DDEFAULT_SWAPSCREENBYTES=false
|
||||
-DFEATURE_CAN
|
||||
# -DFEATURE_SERIAL
|
||||
# -DPINS_RX1=4
|
||||
# -DPINS_TX1=5
|
||||
# -DPINS_RX2=22
|
||||
# -DPINS_TX2=23
|
||||
-DDEFAULT_INVERTFRONTLEFT=false
|
||||
-DDEFAULT_INVERTFRONTRIGHT=true
|
||||
-DDEFAULT_INVERTBACKLEFT=false
|
||||
-DDEFAULT_INVERTBACKRIGHT=true
|
||||
-DDEFAULT_WHEELDIAMETER=200
|
||||
# -DFEATURE_MOSFETS
|
||||
# -DPINS_MOSFET0=18
|
||||
# -DPINS_MOSFET1=19
|
||||
# -DPINS_MOSFET2=21
|
||||
-DDEFAULT_IMOTMAX=28
|
||||
-DDEFAULT_IDCMAX=30
|
||||
-DDEFAULT_NMOTMAX=2000
|
||||
-DDEFAULT_FIELDWEAKMAX=7
|
||||
-DDEFAULT_FIELDADVMAX=40
|
||||
-DDEVICE_PREFIX=peter_bobbyquad
|
||||
-DAP_PASSWORD=Passwort_123
|
||||
-DFEATURE_WEBSERVER
|
||||
-DFEATURE_OTA
|
||||
-DOTA_USERNAME="peter"
|
||||
-DFEATURE_DPAD_5WIRESW_2OUT
|
||||
-DPINS_DPAD_5WIRESW_OUT1=18
|
||||
-DPINS_DPAD_5WIRESW_OUT2=19
|
||||
-DPINS_DPAD_5WIRESW_IN1=4
|
||||
-DPINS_DPAD_5WIRESW_IN2=5
|
||||
-DPINS_DPAD_5WIRESW_IN3=27
|
||||
-DDPAD_5WIRESW_UP=4
|
||||
-DDPAD_5WIRESW_DOWN=7
|
||||
-DDPAD_5WIRESW_CONFIRM=1
|
||||
-DDPAD_5WIRESW_BACK=10
|
||||
-DDPAD_5WIRESW_PROFILE0=11
|
||||
-DDPAD_5WIRESW_PROFILE1=8
|
||||
-DDPAD_5WIRESW_PROFILE2=5
|
||||
-DDPAD_5WIRESW_PROFILE3=2
|
||||
-DDPAD_5WIRESW_BLINK_LEFT=9
|
||||
-DDPAD_5WIRESW_BLINK_RIGHT=0
|
||||
-DDPAD_5WIRESW_QUICKACTION_DOWN=3
|
||||
-DDPAD_5WIRESW_QUICKACTION_UP=6
|
||||
# -DDPAD_5WIRESW_DEBUG
|
||||
-DDEFAULT_GASMIN=842
|
||||
-DDEFAULT_GASMAX=2480
|
||||
-DDEFAULT_BREMSMIN=826
|
||||
-DDEFAULT_BREMSMAX=2502
|
||||
-DFEATURE_BLE
|
||||
# -DFEATURE_BLUETOOTH
|
||||
# -DFEATURE_BMS
|
||||
# -DFEATURE_GAMETRAK
|
||||
# -DPINS_GAMETRAKX=34
|
||||
# -DPINS_GAMETRAKY=39
|
||||
# -DPINS_GAMETRAKDIST=36
|
||||
# -DDEFAULT_GAMETRAKXMIN=0
|
||||
# -DDEFAULT_GAMETRAKXMAX=4095
|
||||
# -DDEFAULT_GAMETRAKYMIN=0
|
||||
# -DDEFAULT_GAMETRAKYMAX=4095
|
||||
# -DDEFAULT_GAMETRAKDISTMIN=0
|
||||
# -DDEFAULT_GAMETRAKDISTMAX=4095
|
||||
# -DFEATURE_POWERSUPPLY
|
||||
# -DFEATURE_CLOUD
|
||||
-DFEATURE_UDPCLOUD
|
||||
-DFEATURE_LEDBACKLIGHT
|
||||
-DPINS_LEDBACKLIGHT=23
|
||||
-DLEDBACKLIGHT_INVERTED
|
||||
-DFEATURE_GARAGE
|
||||
#-DFEATURE_NTP
|
||||
-DFEATURE_WIRELESS_CONFIG
|
||||
-DFEATURE_LEDSTRIP
|
||||
-DPINS_LEDSTRIP=33
|
||||
-DLEDSTRIP_LENGTH=288
|
||||
# -DLEDSTRIP_WRONG_DIRECTION
|
||||
-DLEDSTRIP_ANIMATION_DEFAULT=2
|
||||
-DLEDS_PER_METER=144
|
||||
-DOLD_NVS
|
||||
-DFEATURE_DNS_NS
|
||||
-DFEATURE_ESPNOW
|
||||
)
|
||||
|
||||
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/ignore/lockscreen_plugin.cmake")
|
||||
|
@ -67,7 +67,6 @@ set(headers
|
||||
displays/dpad6wiredebugdisplay.h
|
||||
displays/gameoflifedisplay.h
|
||||
displays/gametrakcalibratedisplay.h
|
||||
displays/garagedisplay.h
|
||||
displays/ledstripcolorsdisplay.h
|
||||
displays/lockscreen.h
|
||||
displays/menudisplaywithtime.cpp
|
||||
@ -92,6 +91,7 @@ set(headers
|
||||
displays/menus/espnowmenu.h
|
||||
displays/menus/espnowsettingsmenu.h
|
||||
displays/menus/feedbackdebugmenu.h
|
||||
displays/menus/garagenmenu.h
|
||||
displays/menus/gametrakmodesettingsmenu.h
|
||||
displays/menus/genericwifisettingsmenu.h
|
||||
displays/menus/graphsmenu.h
|
||||
@ -293,7 +293,6 @@ set(sources
|
||||
displays/dpad6wiredebugdisplay.cpp
|
||||
displays/gameoflifedisplay.cpp
|
||||
displays/gametrakcalibratedisplay.cpp
|
||||
displays/garagedisplay.cpp
|
||||
displays/ledstripcolorsdisplay.cpp
|
||||
displays/lockscreen.cpp
|
||||
displays/menus/aboutmenu.cpp
|
||||
@ -317,6 +316,7 @@ set(sources
|
||||
displays/menus/espnowmenu.cpp
|
||||
displays/menus/espnowsettingsmenu.cpp
|
||||
displays/menus/feedbackdebugmenu.cpp
|
||||
displays/menus/garagenmenu.cpp
|
||||
displays/menus/gametrakmodesettingsmenu.cpp
|
||||
displays/menus/genericwifisettingsmenu.cpp
|
||||
displays/menus/graphsmenu.cpp
|
||||
|
@ -12,7 +12,9 @@ enum BobbyButton
|
||||
Left2,
|
||||
Right2,
|
||||
Up2,
|
||||
Down2
|
||||
Down2,
|
||||
Confirm = espgui::Button::Right,
|
||||
Back = espgui::Button::Left
|
||||
};
|
||||
|
||||
class BobbyButtons : public virtual espgui::ButtonsInterface
|
||||
|
@ -1,70 +0,0 @@
|
||||
#include "garagedisplay.h"
|
||||
|
||||
// system includes
|
||||
|
||||
// esp-idf includes
|
||||
#include <esp_log.h>
|
||||
|
||||
// 3rdparty lib includes
|
||||
#include <fmt/core.h>
|
||||
#include <tftinstance.h>
|
||||
#include <screenmanager.h>
|
||||
|
||||
// local includes
|
||||
#include "displays/menus/mainmenu.h"
|
||||
#include "globals.h"
|
||||
#include "texts.h"
|
||||
#include "espnowfunctions.h"
|
||||
|
||||
#ifdef FEATURE_GARAGE
|
||||
void GarageDisplay::start()
|
||||
{
|
||||
Base::start();
|
||||
}
|
||||
|
||||
void GarageDisplay::initScreen()
|
||||
{
|
||||
Base::initScreen();
|
||||
|
||||
espgui::tft.fillScreen(TFT_BLACK);
|
||||
espgui::tft.setTextFont(4);
|
||||
espgui::tft.setTextColor(TFT_YELLOW);
|
||||
|
||||
espgui::tft.drawString(TEXT_GARAGE, 5, 5, 4);
|
||||
|
||||
espgui::tft.fillRect(0, 34, espgui::tft.width(), 3, TFT_WHITE);
|
||||
|
||||
espgui::tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||
|
||||
espgui::tft.drawString("Garage", 20, 100);
|
||||
}
|
||||
|
||||
void GarageDisplay::redraw()
|
||||
{
|
||||
Base::redraw();
|
||||
}
|
||||
|
||||
void GarageDisplay::buttonPressed(espgui::Button button)
|
||||
{
|
||||
Base::buttonPressed(button);
|
||||
|
||||
switch (button)
|
||||
{
|
||||
using espgui::Button;
|
||||
case Button::Left:
|
||||
espgui::switchScreen<MainMenu>();
|
||||
break;
|
||||
case Button::Right:
|
||||
#ifdef FEATURE_ESPNOW
|
||||
if (const auto error = espnow::send_espnow_message(fmt::format("BOBBYOPEN:garage:{}", "TOKEN")); error != ESP_OK)
|
||||
{
|
||||
ESP_LOGE("BOBBY", "send_espnow_message() failed with: %s", esp_err_to_name(error));
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
espgui::switchScreen<MainMenu>();
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
}
|
||||
#endif
|
@ -1,20 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
// local includes
|
||||
#include "bobbydisplay.h"
|
||||
|
||||
#ifdef FEATURE_GARAGE
|
||||
class GarageDisplay : public BobbyDisplay
|
||||
{
|
||||
using Base = BobbyDisplay;
|
||||
|
||||
public:
|
||||
void start() override;
|
||||
void initScreen() override;
|
||||
void redraw() override;
|
||||
|
||||
void buttonPressed(espgui::Button button) override;
|
||||
|
||||
private:
|
||||
};
|
||||
#endif
|
32
main/displays/menus/garagenmenu.cpp
Normal file
32
main/displays/menus/garagenmenu.cpp
Normal file
@ -0,0 +1,32 @@
|
||||
#if defined(FEATURE_GARAGE) && defined (FEATURE_ESPNOW)
|
||||
#include "garagenmenu.h"
|
||||
|
||||
// 3rd party libs
|
||||
#include <icons/back.h>
|
||||
#include <menuitem.h>
|
||||
|
||||
// local includes
|
||||
#include "actions/switchscreenaction.h"
|
||||
#include "displays/menus/mainmenu.h"
|
||||
|
||||
using namespace espgui;
|
||||
|
||||
GarageMenu::GarageMenu()
|
||||
{
|
||||
for (uint8_t index = 0; index < stringSettings.wirelessDoors.size(); index++)
|
||||
{
|
||||
const auto &wirelessDoor = stringSettings.wirelessDoors[index];
|
||||
if (wirelessDoor.doorId.empty() || wirelessDoor.doorToken.empty())
|
||||
continue;
|
||||
auto &menuitem = constructMenuItem<makeComponentArgs<MenuItem, garagenmenu::SendEspNowMessageAction, ChangeableText>>(index);
|
||||
menuitem.setTitle(wirelessDoor.doorId);
|
||||
}
|
||||
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<MainMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
|
||||
}
|
||||
|
||||
void GarageMenu::back()
|
||||
{
|
||||
switchScreen<MainMenu>();
|
||||
}
|
||||
#endif
|
40
main/displays/menus/garagenmenu.h
Normal file
40
main/displays/menus/garagenmenu.h
Normal file
@ -0,0 +1,40 @@
|
||||
#pragma once
|
||||
#if defined(FEATURE_GARAGE) && defined (FEATURE_ESPNOW)
|
||||
// 3rd party lib
|
||||
#include <actioninterface.h>
|
||||
#include <esp_log.h>
|
||||
#include <menuitem.h>
|
||||
|
||||
// local includes
|
||||
#include "displays/bobbymenudisplay.h"
|
||||
#include "espnowfunctions.h"
|
||||
#include "texts.h"
|
||||
#include "globals.h"
|
||||
|
||||
namespace garagenmenu {
|
||||
class SendEspNowMessageAction : public virtual espgui::ActionInterface
|
||||
{
|
||||
public:
|
||||
SendEspNowMessageAction(uint8_t index) : m_index{index} {}
|
||||
void triggered() override
|
||||
{
|
||||
if (const auto error = espnow::send_espnow_message(fmt::format("BOBBYOPEN:{}:{}", stringSettings.wirelessDoors[m_index].doorId, stringSettings.wirelessDoors[m_index].doorToken)); error != ESP_OK)
|
||||
{
|
||||
ESP_LOGE("BOBBY", "send_espnow_message() failed with: %s", esp_err_to_name(error));
|
||||
return;
|
||||
}
|
||||
}
|
||||
private:
|
||||
uint8_t m_index;
|
||||
};
|
||||
} // namespace garagenmenu
|
||||
|
||||
class GarageMenu :
|
||||
public BobbyMenuDisplay,
|
||||
public espgui::StaticText<TEXT_GARAGE>
|
||||
{
|
||||
public:
|
||||
GarageMenu();
|
||||
void back() override;
|
||||
};
|
||||
#endif
|
@ -21,7 +21,9 @@
|
||||
#include "displays/menus/demosmenu.h"
|
||||
#include "displays/menus/greenpassmenu.h"
|
||||
#include "displays/lockscreen.h"
|
||||
#include "displays/garagedisplay.h"
|
||||
#if defined(FEATURE_GARAGE) && defined (FEATURE_ESPNOW)
|
||||
#include "displays/menus/garagenmenu.h"
|
||||
#endif
|
||||
#include "displays/menus/otamenu.h"
|
||||
#include "displays/poweroffdisplay.h"
|
||||
#include "displays/menus/statisticsmenu.h"
|
||||
@ -92,8 +94,8 @@ MainMenu::MainMenu()
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_DEMOS>, SwitchScreenAction<DemosMenu>, StaticMenuItemIcon<&bobbyicons::demos>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_GREENPASS>, SwitchScreenAction<GreenPassMenu>, StaticMenuItemIcon<&bobbyicons::greenpass>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LOCKVEHICLE>, SwitchScreenAction<Lockscreen>, StaticMenuItemIcon<&bobbyicons::lock>>>();
|
||||
#ifdef FEATURE_GARAGE
|
||||
if (SHOWITEM) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_GARAGE>, SwitchScreenAction<GarageDisplay>>>(); }
|
||||
#if defined(FEATURE_GARAGE) && defined (FEATURE_ESPNOW)
|
||||
if (SHOWITEM) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_GARAGE>, SwitchScreenAction<GarageMenu>>>(); }
|
||||
#endif
|
||||
#ifdef FEATURE_OTA
|
||||
if (SHOWITEM) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_UPDATE>, SwitchScreenAction<OtaMenu>, StaticMenuItemIcon<&bobbyicons::update>>>(); }
|
||||
|
@ -56,6 +56,15 @@ struct StringSettings
|
||||
std::string otaServerBranch;
|
||||
#endif
|
||||
std::string webserver_password;
|
||||
|
||||
#ifdef FEATURE_ESPNOW
|
||||
struct ConfiguredWirelessDoors {
|
||||
std::string doorId;
|
||||
std::string doorToken;
|
||||
};
|
||||
|
||||
std::array<ConfiguredWirelessDoors, 5> wirelessDoors;
|
||||
#endif
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
@ -130,6 +139,19 @@ void StringSettings::executeForEveryCommonSetting(T &&callable)
|
||||
#endif
|
||||
callable("ap_pw", ap_password);
|
||||
callable("webpw", webserver_password);
|
||||
|
||||
#ifdef FEATURE_ESPNOW
|
||||
callable("doorId0", wirelessDoors[0].doorId);
|
||||
callable("doorToken0", wirelessDoors[0].doorToken);
|
||||
callable("doorId1", wirelessDoors[1].doorId);
|
||||
callable("doorToken1", wirelessDoors[1].doorToken);
|
||||
callable("doorId2", wirelessDoors[2].doorId);
|
||||
callable("doorToken2", wirelessDoors[2].doorToken);
|
||||
callable("doorId3", wirelessDoors[3].doorId);
|
||||
callable("doorToken3", wirelessDoors[3].doorToken);
|
||||
callable("doorId4", wirelessDoors[4].doorId);
|
||||
callable("doorToken4", wirelessDoors[4].doorToken);
|
||||
#endif
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
Reference in New Issue
Block a user