Compare commits
64 Commits
measuremen
...
new-idf
Author | SHA1 | Date | |
---|---|---|---|
c307b64b0a | |||
101a2b03a8 | |||
7b4fd61a39 | |||
f32013f782 | |||
cca17b7ded | |||
a9794b13bd | |||
1a7e83de83 | |||
69b030268f | |||
b3b45653b5 | |||
199a8f1e4e | |||
d6c76f3c3f | |||
0909c055de | |||
52b55b38cd | |||
65d7a7e9ec | |||
13a6ce3cc2 | |||
6bc85875ee | |||
4688326323 | |||
1b7a523acd | |||
c85e84e9a1 | |||
9e6ee2c957 | |||
d29a74dbd4 | |||
b984360956 | |||
fa819822f0 | |||
52ff7acd02 | |||
b61dfcf53d | |||
f6b4966071 | |||
a6fb1b7396 | |||
fd40d8dbd8 | |||
8cf766356c | |||
da8b91403d | |||
4b4044626b | |||
71906ba511 | |||
ef7e605eb7 | |||
32389f2bf9 | |||
e647c4b372 | |||
3c0b0cdbb1 | |||
43c2338dbd | |||
846a5d753a | |||
f4110bb854 | |||
226636a82a | |||
a93f34e0ba | |||
f2350c8746 | |||
1840030461 | |||
62a4b88acb | |||
bc9a0c396c | |||
2bc1625fab | |||
9db3da4b27 | |||
4e0fdd65c3 | |||
129cc64d24 | |||
f8b1454f9a | |||
4f703c4d10 | |||
95e04ef543 | |||
87751682b2 | |||
7a3a081af4 | |||
327932ac14 | |||
17eff6127f | |||
2ec6ddc150 | |||
ba5d907e38 | |||
3de6827bc5 | |||
846d90836d | |||
6e3324fe65 | |||
79e51f7511 | |||
33f35f14b7 | |||
b43e4e76ac |
66
.clang-format
Normal file
66
.clang-format
Normal file
@ -0,0 +1,66 @@
|
||||
# Generated from CLion C/C++ Code Style settings
|
||||
BasedOnStyle: LLVM
|
||||
AccessModifierOffset: -4
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveAssignments: None
|
||||
AlignOperands: Align
|
||||
AllowAllArgumentsOnNextLine: false
|
||||
AllowAllConstructorInitializersOnNextLine: false
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
AllowShortBlocksOnASingleLine: Always
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: All
|
||||
AllowShortIfStatementsOnASingleLine: Always
|
||||
AllowShortLambdasOnASingleLine: All
|
||||
AllowShortLoopsOnASingleLine: true
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakTemplateDeclarations: Yes
|
||||
BreakBeforeBraces: Custom
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: false
|
||||
AfterClass: true
|
||||
AfterControlStatement: Always
|
||||
AfterEnum: true
|
||||
AfterFunction: true
|
||||
AfterNamespace: false
|
||||
AfterUnion: true
|
||||
BeforeCatch: false
|
||||
BeforeElse: true
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: false
|
||||
SplitEmptyRecord: true
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeTernaryOperators: false
|
||||
BreakConstructorInitializers: BeforeColon
|
||||
BreakInheritanceList: BeforeColon
|
||||
ColumnLimit: 0
|
||||
CompactNamespaces: false
|
||||
ContinuationIndentWidth: 8
|
||||
IndentCaseLabels: false
|
||||
IndentPPDirectives: None
|
||||
IndentWidth: 4
|
||||
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||
MaxEmptyLinesToKeep: 2
|
||||
NamespaceIndentation: None
|
||||
ObjCSpaceAfterProperty: false
|
||||
ObjCSpaceBeforeProtocolList: true
|
||||
PointerAlignment: Right
|
||||
ReflowComments: false
|
||||
SpaceAfterCStyleCast: true
|
||||
SpaceAfterLogicalNot: false
|
||||
SpaceAfterTemplateKeyword: false
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeCpp11BracedList: false
|
||||
SpaceBeforeCtorInitializerColon: true
|
||||
SpaceBeforeInheritanceColon: true
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceBeforeRangeBasedForLoopColon: false
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 0
|
||||
SpacesInAngles: false
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInContainerLiterals: false
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
TabWidth: 4
|
||||
UseTab: Never
|
16
.gitmodules
vendored
16
.gitmodules
vendored
@ -3,7 +3,7 @@
|
||||
url = ../../0xFEEDC0DE64/espcpputils.git
|
||||
[submodule "esp-idf"]
|
||||
path = esp-idf
|
||||
url = ../../0xFEEDC0DE64/esp-idf.git
|
||||
url = ../../bobbycar-graz/esp-idf.git
|
||||
[submodule "components/cpputils"]
|
||||
path = components/cpputils
|
||||
url = ../../0xFEEDC0DE64/cpputils.git
|
||||
@ -22,9 +22,6 @@
|
||||
[submodule "components/arduino-esp32"]
|
||||
path = components/arduino-esp32
|
||||
url = ../../0xFEEDC0DE64/arduino-esp32.git
|
||||
[submodule "components/expected"]
|
||||
path = components/expected
|
||||
url = ../../0xFEEDC0DE64/expected.git
|
||||
[submodule "components/bobbycar-protocol"]
|
||||
path = components/bobbycar-protocol
|
||||
url = ../../bobbycar-graz/bobbycar-protocol.git
|
||||
@ -36,7 +33,7 @@
|
||||
url = ../../0xFEEDC0DE64/espwifistack.git
|
||||
[submodule "components/esp-nimble-cpp"]
|
||||
path = components/esp-nimble-cpp
|
||||
url = ../../0xFEEDC0DE64/esp-nimble-cpp.git
|
||||
url = ../../bobbycar-graz/esp-nimble-cpp.git
|
||||
[submodule "components/espasyncota"]
|
||||
path = components/espasyncota
|
||||
url = ../../0xFEEDC0DE64/espasyncota.git
|
||||
@ -70,6 +67,9 @@
|
||||
[submodule "esp_boost"]
|
||||
path = esp_boost
|
||||
url = ../../0xFEEDC0DE64/esp_boost.git
|
||||
[submodule "components/asio_web"]
|
||||
path = components/asio_web
|
||||
url = ../../0xFEEDC0DE64/asio_web.git
|
||||
[submodule "components/esptftlib"]
|
||||
path = components/esptftlib
|
||||
url = ../../0xFEEDC0DE64/esptftlib.git
|
||||
[submodule "components/espfontlib"]
|
||||
path = components/espfontlib
|
||||
url = ../../0xFEEDC0DE64/espfontlib.git
|
||||
|
@ -25,6 +25,8 @@ include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
set(CMAKE_CXX_STANDARD 23)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
idf_build_set_property(CXX_COMPILE_OPTIONS -std=gnu++23 APPEND)
|
||||
|
||||
set(EXTRA_COMPONENT_DIRS
|
||||
esp_boost
|
||||
esp-protocols/components
|
||||
|
Submodule components/FastLED-idf updated: 3f4d71050e...6a64e87bc3
Submodule components/TFT_eSPI updated: 4dacb617be...69f86aa4f2
Submodule components/arduino-esp32 updated: 07f43ec91c...745ccdeae8
Submodule components/asio_web deleted from 1e901fafbf
Submodule components/bobbycar-protocol updated: 701243ad89...0734d65146
Submodule components/cpputils updated: 3ab7a6c5ef...96e318fd6d
Submodule components/esp-gui-lib updated: ab946208e5...53c5f9a0f3
Submodule components/esp-nimble-cpp updated: c218a27dd8...29f9273c65
Submodule components/espasynchttpreq updated: 4719a27c5d...06ca1a6881
Submodule components/espasyncota updated: ac540310a4...ee623d78ea
Submodule components/espchrono updated: b83cc027cd...eff94f175c
Submodule components/espconfiglib updated: 6129681a6d...379533571f
Submodule components/espcpputils updated: 00fa5ec601...4cf49eac1d
1
components/espfontlib
Submodule
1
components/espfontlib
Submodule
Submodule components/espfontlib added at 89048ff162
Submodule components/esphttpdutils updated: eb152b8406...6ed0915d85
1
components/esptftlib
Submodule
1
components/esptftlib
Submodule
Submodule components/esptftlib added at b779a4c09d
Submodule components/espwifistack updated: 2bf332f3eb...e70b509e20
Submodule components/expected deleted from ce14a0fc6e
@ -1,20 +1,20 @@
|
||||
set(BOBBY_APP_NAME bobbyquad_comred_new)
|
||||
set(BOBBY_DEFAULT_USERNAME comred_new)
|
||||
|
||||
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
|
||||
)
|
||||
# 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
|
||||
# )
|
||||
|
||||
set(BOBBYCAR_BUILDFLAGS
|
||||
# Pins
|
||||
|
@ -1,21 +1,6 @@
|
||||
set(BOBBY_APP_NAME bobbyquad_mick)
|
||||
set(BOBBY_DEFAULT_USERNAME mick)
|
||||
|
||||
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=27000000
|
||||
)
|
||||
|
||||
set(BOBBYCAR_BUILDFLAGS
|
||||
# Pins
|
||||
-DPINS_GAS=34
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,9 +1,15 @@
|
||||
dependencies:
|
||||
espressif/esp-idf-cxx:
|
||||
component_hash: df7921090d6601b268b99b5d54d2f53bb5ea25dbd58cc53961ef7784326621de
|
||||
source:
|
||||
service_url: https://api.components.espressif.com/
|
||||
type: service
|
||||
version: 1.0.1-beta
|
||||
idf:
|
||||
component_hash: null
|
||||
source:
|
||||
type: idf
|
||||
version: 5.1.0
|
||||
manifest_hash: 61ebe3a040bdb7a8bb7b582261db12d83b6028789124b5f6ddacb4104628daa6
|
||||
version: 5.2.0
|
||||
manifest_hash: 04b1e89bb78c4187b4d7bc0cf9461b7a3475762e58fec6f3bb49a885c56532c2
|
||||
target: esp32
|
||||
version: 1.0.0
|
||||
|
2
esp-idf
2
esp-idf
Submodule esp-idf updated: 756de87ccf...14b365579b
Submodule esp-protocols updated: 49e1369ae9...d38f04b88f
@ -1,4 +1,4 @@
|
||||
set(headers
|
||||
set(BOBBY_HEADERS
|
||||
accessorhelpers.h
|
||||
accessors/globalaccessors.h
|
||||
accessors/settingsaccessors.h
|
||||
@ -23,9 +23,9 @@ set(headers
|
||||
actions/loadsettingsaction.h
|
||||
actions/modesettingsaction.h
|
||||
actions/qraction.h
|
||||
actions/rebootaction.h
|
||||
actions/resetnvsaction.h
|
||||
actions/savesettingsaction.h
|
||||
actions/setupactions.h
|
||||
actions/switchprofileaction.h
|
||||
actions/tempomatmodeapplycurrentpeedaction.h
|
||||
actions/updateswapfrontbackaction.h
|
||||
@ -72,7 +72,6 @@ set(headers
|
||||
displays/bobbymenudisplay.h
|
||||
displays/bobbypopupdisplay.h
|
||||
displays/bobbysplitgraphdisplay.h
|
||||
displays/buttoncalibratedisplay.h
|
||||
displays/calibratevoltagedisplay.h
|
||||
displays/confiscationdisplay.h
|
||||
displays/gameoflifedisplay.h
|
||||
@ -159,6 +158,14 @@ set(headers
|
||||
displays/qrcodedebug.h
|
||||
displays/qrdisplay.h
|
||||
displays/qrimportdisplay.h
|
||||
displays/rebootscreen.h
|
||||
displays/setup/ask_calibrate_other_buttons.h
|
||||
displays/setup/ask_setup_clouds.h
|
||||
displays/setup/basic_buttons.h
|
||||
displays/setup/calibrate_potis.h
|
||||
displays/setup/final_information.h
|
||||
displays/setup/information.h
|
||||
displays/setup/setup_cloud.h
|
||||
displays/speedinfodisplay.h
|
||||
displays/spirodisplay.h
|
||||
displays/starfielddisplay.h
|
||||
@ -233,6 +240,7 @@ set(headers
|
||||
serial_bobby.h
|
||||
settingspersister.h
|
||||
settingsutils.h
|
||||
setup.h
|
||||
softpwmlimiter.h
|
||||
statistics.h
|
||||
statustexthelper.h
|
||||
@ -259,7 +267,7 @@ set(headers
|
||||
wifiguiutils.h
|
||||
)
|
||||
|
||||
set(sources
|
||||
set(BOBBY_SOURCES
|
||||
accessors/wifistaconfigaccessors.cpp
|
||||
actions/assertaction.cpp
|
||||
actions/bluetoothbeginaction.cpp
|
||||
@ -279,9 +287,9 @@ set(sources
|
||||
actions/loadsettingsaction.cpp
|
||||
actions/modesettingsaction.cpp
|
||||
actions/qraction.cpp
|
||||
actions/rebootaction.cpp
|
||||
actions/resetnvsaction.cpp
|
||||
actions/savesettingsaction.cpp
|
||||
actions/setupactions.cpp
|
||||
actions/switchprofileaction.cpp
|
||||
actions/tempomatmodeapplycurrentpeedaction.cpp
|
||||
actions/updateswapfrontbackaction.cpp
|
||||
@ -325,7 +333,6 @@ set(sources
|
||||
displays/bobbymenudisplay.cpp
|
||||
displays/bobbypopupdisplay.cpp
|
||||
displays/bobbysplitgraphdisplay.cpp
|
||||
displays/buttoncalibratedisplay.cpp
|
||||
displays/calibratevoltagedisplay.cpp
|
||||
displays/confiscationdisplay.cpp
|
||||
displays/gameoflifedisplay.cpp
|
||||
@ -410,6 +417,14 @@ set(sources
|
||||
displays/qrcodedebug.cpp
|
||||
displays/qrdisplay.cpp
|
||||
displays/qrimportdisplay.cpp
|
||||
displays/rebootscreen.cpp
|
||||
displays/setup/ask_calibrate_other_buttons.cpp
|
||||
displays/setup/ask_setup_clouds.cpp
|
||||
displays/setup/basic_buttons.cpp
|
||||
displays/setup/calibrate_potis.cpp
|
||||
displays/setup/final_information.cpp
|
||||
displays/setup/information.cpp
|
||||
displays/setup/setup_cloud.cpp
|
||||
displays/speedinfodisplay.cpp
|
||||
displays/spirodisplay.cpp
|
||||
displays/starfielddisplay.cpp
|
||||
@ -485,6 +500,7 @@ set(sources
|
||||
serial_bobby.cpp
|
||||
settingspersister.cpp
|
||||
settingsutils.cpp
|
||||
setup.cpp
|
||||
softpwmlimiter.cpp
|
||||
statistics.cpp
|
||||
statustexthelper.cpp
|
||||
@ -514,13 +530,13 @@ set(dependencies
|
||||
freertos nvs_flash esp_http_server esp_https_ota mdns app_update esp_system esp_websocket_client driver esp_adc
|
||||
arduino-esp32 ArduinoJson esp-nimble-cpp FastLED-idf TFT_eSPI QRCode-esp32
|
||||
bobbycar-protocol cpputils cxx-ring-buffer date sunset
|
||||
espasynchttpreq espasyncota espchrono espcpputils espconfiglib esp-gui-lib esphttpdutils espwifistack expected fmt
|
||||
espasynchttpreq espasyncota espchrono espcpputils espconfiglib esp-gui-lib esphttpdutils espwifistack fmt
|
||||
)
|
||||
|
||||
idf_component_register(
|
||||
SRCS
|
||||
${headers}
|
||||
${sources}
|
||||
${BOBBY_HEADERS}
|
||||
${BOBBY_SOURCES}
|
||||
INCLUDE_DIRS
|
||||
.
|
||||
REQUIRES
|
||||
@ -538,14 +554,31 @@ execute_process(
|
||||
COMMAND git rev-parse --abbrev-ref HEAD
|
||||
OUTPUT_VARIABLE GIT_BRANCH
|
||||
)
|
||||
execute_process(
|
||||
COMMAND git status --short
|
||||
OUTPUT_VARIABLE GIT_STATUS
|
||||
)
|
||||
|
||||
if (NOT GIT_STATUS STREQUAL "")
|
||||
set(GIT_STATUS "dirty")
|
||||
else()
|
||||
set(GIT_STATUS "clean")
|
||||
endif()
|
||||
|
||||
string(STRIP "${GIT_REV}" GIT_REV)
|
||||
string(SUBSTRING "${GIT_REV}" 1 7 GIT_SHORT_REV)
|
||||
string(STRIP "${GIT_MESSAGE}" GIT_MESSAGE)
|
||||
string(REPLACE "\n" " " GIT_MESSAGE "${GIT_MESSAGE}")
|
||||
string(REPLACE "\"" "\\\"" GIT_MESSAGE "${GIT_MESSAGE}")
|
||||
string(SUBSTRING "${GIT_MESSAGE}" 0 100 GIT_MESSAGE)
|
||||
string(STRIP "${GIT_BRANCH}" GIT_BRANCH)
|
||||
|
||||
message(WARNING "Git revision: ${GIT_REV}")
|
||||
message(WARNING "Git short revision: ${GIT_SHORT_REV}")
|
||||
message(WARNING "Git message: ${GIT_MESSAGE}")
|
||||
message(WARNING "Git branch: ${GIT_BRANCH}")
|
||||
message(WARNING "Git status: ${GIT_STATUS}")
|
||||
|
||||
if(NOT DEFINED BOBBY_DEFAULT_USERNAME)
|
||||
message(FATAL_ERROR "Please define BOBBY_DEFAULT_USERNAME")
|
||||
endif()
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
// system includes
|
||||
#include <cstdint>
|
||||
#include <expected>
|
||||
|
||||
// 3rdparty lib includes
|
||||
#include <accessorinterface.h>
|
||||
@ -19,7 +20,7 @@ struct RefAccessorSaveSettings : public virtual espgui::RefAccessor<T>
|
||||
espgui::RefAccessor<T>::setValue(value);
|
||||
|
||||
if (!saveProfileSettings())
|
||||
return tl::make_unexpected("saveProfileSettings() failed!");
|
||||
return std::unexpected("saveProfileSettings() failed!");
|
||||
|
||||
return {};
|
||||
};
|
||||
|
@ -1,5 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
// system includes
|
||||
#include <expected>
|
||||
|
||||
// 3rdparty lib includes
|
||||
#include <accessorinterface.h>
|
||||
|
||||
@ -29,7 +32,7 @@ struct NMotMaxKmhAccessor : public virtual espgui::AccessorInterface<int16_t>
|
||||
{
|
||||
profileSettings.limits.nMotMax = convertFromKmh(value);
|
||||
if (!saveProfileSettings())
|
||||
return tl::make_unexpected("saveProfileSettings() failed!");
|
||||
return std::unexpected("saveProfileSettings() failed!");
|
||||
return {};
|
||||
}
|
||||
};
|
||||
@ -77,7 +80,7 @@ struct WheelDiameterInchAccessor : public virtual espgui::AccessorInterface<floa
|
||||
{
|
||||
// profileSettings.controllerHardware.wheelDiameter = convertFromInch(value);
|
||||
// if (!saveProfileSettings())
|
||||
// return tl::make_unexpected("saveProfileSettings() failed!");
|
||||
// return std::unexpected("saveProfileSettings() failed!");
|
||||
// return {};
|
||||
return configs.write_config(configs.controllerHardware.wheelDiameter, convertFromInch(value));
|
||||
}
|
||||
@ -205,6 +208,9 @@ struct LedstripEnableBlinkAnimationAccessor : public NewSettingsAccessor<bool> {
|
||||
struct LedstripOtaAnimationAccessor : public NewSettingsAccessor<OtaAnimationModes> { ConfigWrapper<OtaAnimationModes> &getConfig() const override { return configs.ledstrip.otaMode; } };
|
||||
struct LedstripEnableVisualizeBlinkAnimationAccessor : public NewSettingsAccessor<bool> { ConfigWrapper<bool> &getConfig() const override { return configs.ledstrip.enableVisualizeBlink; } };
|
||||
struct LedstripAutomaticLightAccessor : public NewSettingsAccessor<bool> { ConfigWrapper<bool> &getConfig() const override { return configs.ledstrip.automaticLight; } };
|
||||
struct LedstripBrakeLightUseAccelAccessor : public NewSettingsAccessor<bool> { ConfigWrapper<bool> &getConfig() const override { return configs.ledstrip.brakeLights_useAccel; } };
|
||||
struct LedstripBrakeLightUsePowerAccessor : public NewSettingsAccessor<bool> { ConfigWrapper<bool> &getConfig() const override { return configs.ledstrip.brakeLights_usePower; } };
|
||||
|
||||
|
||||
// Battery
|
||||
struct BatterySeriesCellsAccessor : public NewSettingsAccessor<uint8_t> { ConfigWrapper<uint8_t> &getConfig() const override { return configs.battery.cellsSeries; } };
|
||||
|
@ -32,7 +32,6 @@ private:
|
||||
std::string m_msg;
|
||||
};
|
||||
|
||||
template<typename TMenu>
|
||||
class PushQrImportDisplayAction : public virtual espgui::ActionInterface
|
||||
{
|
||||
public:
|
||||
@ -41,7 +40,7 @@ public:
|
||||
|
||||
void triggered() override
|
||||
{
|
||||
espgui::pushScreen<QrImportDisplay<TMenu>>(std::move(m_nvskey));
|
||||
espgui::pushScreen<QrImportDisplay>(std::move(m_nvskey));
|
||||
}
|
||||
private:
|
||||
std::string m_nvskey;
|
||||
|
@ -1,22 +0,0 @@
|
||||
#include "rebootaction.h"
|
||||
|
||||
// esp-idf includes
|
||||
#include <esp_system.h>
|
||||
|
||||
// 3rdparty lib includes
|
||||
#include <tftinstance.h>
|
||||
|
||||
void RebootAction::triggered()
|
||||
{
|
||||
espgui::tft.fillScreen(TFT_BLACK);
|
||||
espgui::tft.setTextColor(TFT_YELLOW);
|
||||
|
||||
espgui::tft.drawString("Reboot", 5, 5, 4);
|
||||
|
||||
espgui::tft.fillRect(0, 34, espgui::tft.width(), 3, TFT_WHITE);
|
||||
|
||||
espgui::tft.setTextColor(TFT_WHITE);
|
||||
espgui::tft.drawString("Rebooting now...", 0, 50, 4);
|
||||
|
||||
esp_restart();
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
// 3rdparty lib includes
|
||||
#include <actioninterface.h>
|
||||
|
||||
class RebootAction : public virtual espgui::ActionInterface
|
||||
{
|
||||
public:
|
||||
void triggered() override;
|
||||
};
|
@ -1,11 +0,0 @@
|
||||
#include "resetnvsaction.h"
|
||||
|
||||
// system includes
|
||||
#include <esp_system.h>
|
||||
#include <nvs_flash.h>
|
||||
|
||||
void ResetNVSAction::triggered()
|
||||
{
|
||||
nvs_flash_erase();
|
||||
esp_restart();
|
||||
}
|
||||
|
@ -1,10 +1,40 @@
|
||||
#pragma once
|
||||
|
||||
// system includes
|
||||
#include <esp_system.h>
|
||||
|
||||
// 3rdparty lib includes
|
||||
#include <actioninterface.h>
|
||||
#include <tftcolors.h>
|
||||
|
||||
// local includes
|
||||
#include "newsettings.h"
|
||||
|
||||
template<bool reboot>
|
||||
class ResetNVSAction : public virtual espgui::ActionInterface
|
||||
{
|
||||
public:
|
||||
void triggered() override;
|
||||
void triggered() override
|
||||
{
|
||||
if (reboot)
|
||||
{
|
||||
tft.fillScreen(espgui::TFT_BLACK);
|
||||
tft.setTextColor(espgui::TFT_YELLOW);
|
||||
|
||||
tft.drawString("Reboot", 5, 5, 4);
|
||||
|
||||
tft.fillRect(0, 34, tft.width(), 3, espgui::TFT_WHITE);
|
||||
|
||||
tft.setTextColor(espgui::TFT_WHITE);
|
||||
tft.drawString("Rebooting now...", 0, 50, 4);
|
||||
|
||||
configs.reset();
|
||||
|
||||
esp_restart();
|
||||
}
|
||||
else
|
||||
{
|
||||
configs.reset();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
26
main/actions/setupactions.cpp
Normal file
26
main/actions/setupactions.cpp
Normal file
@ -0,0 +1,26 @@
|
||||
#include "setupactions.h"
|
||||
|
||||
// 3rdparty lib includes
|
||||
#include <screenmanager.h>
|
||||
|
||||
// local includes
|
||||
#include "displays/setup/basic_buttons.h"
|
||||
#include "displays/setup/calibrate_potis.h"
|
||||
|
||||
PushButtonCalibrateDisplayAction::PushButtonCalibrateDisplayAction(const bool early_return) :
|
||||
m_early_return{early_return}
|
||||
{}
|
||||
|
||||
void PushButtonCalibrateDisplayAction::triggered()
|
||||
{
|
||||
espgui::pushScreen<SetupBasicButtonsDisplay>(m_early_return);
|
||||
}
|
||||
|
||||
PushPotiCalibrateDisplayAction::PushPotiCalibrateDisplayAction(const bool early_return) :
|
||||
m_early_return{early_return}
|
||||
{}
|
||||
|
||||
void PushPotiCalibrateDisplayAction::triggered()
|
||||
{
|
||||
// espgui::pushScreen<SetupCalibratePotisDisplay>(m_early_return); // commented out until implemented
|
||||
}
|
24
main/actions/setupactions.h
Normal file
24
main/actions/setupactions.h
Normal file
@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
// 3rdparty lib includes
|
||||
#include <actioninterface.h>
|
||||
|
||||
class PushButtonCalibrateDisplayAction : public virtual espgui::ActionInterface
|
||||
{
|
||||
public:
|
||||
explicit PushButtonCalibrateDisplayAction(bool early_return);
|
||||
|
||||
void triggered() override;
|
||||
private:
|
||||
const bool m_early_return;
|
||||
};
|
||||
|
||||
class PushPotiCalibrateDisplayAction : public virtual espgui::ActionInterface
|
||||
{
|
||||
public:
|
||||
explicit PushPotiCalibrateDisplayAction(bool early_return);
|
||||
|
||||
void triggered() override;
|
||||
private:
|
||||
const bool m_early_return;
|
||||
};
|
@ -21,19 +21,19 @@ constexpr const char * const TAG = "BOBBYBLE";
|
||||
class RemoteControlCallbacks : public NimBLECharacteristicCallbacks
|
||||
{
|
||||
public:
|
||||
void onWrite(NimBLECharacteristic* pCharacteristic) override;
|
||||
void onWrite(NimBLECharacteristic* pCharacteristic, NimBLEConnInfo& connInfo) override;
|
||||
};
|
||||
|
||||
class WirelessSettingsCallbacks : public NimBLECharacteristicCallbacks
|
||||
{
|
||||
public:
|
||||
void onWrite(NimBLECharacteristic* pCharacteristic) override;
|
||||
void onWrite(NimBLECharacteristic* pCharacteristic, NimBLEConnInfo& connInfo) override;
|
||||
};
|
||||
|
||||
class WiFiListCallbacks : public NimBLECharacteristicCallbacks
|
||||
{
|
||||
public:
|
||||
void onRead(NimBLECharacteristic* pCharacteristic) override;
|
||||
void onRead(NimBLECharacteristic* pCharacteristic, NimBLEConnInfo& connInfo) override;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
@ -55,14 +55,20 @@ void createBle()
|
||||
{
|
||||
ESP_LOGI("BOBBY", "called");
|
||||
|
||||
BLEDevice::init(configs.bluetoothName.value());
|
||||
NimBLEDevice::init(configs.bluetoothName.value());
|
||||
|
||||
const auto serviceUuid{"0335e46c-f355-4ce6-8076-017de08cee98"};
|
||||
|
||||
pServer = BLEDevice::createServer();
|
||||
ESP_LOGI(TAG, "Creating BLE server");
|
||||
|
||||
pServer = NimBLEDevice::createServer();
|
||||
|
||||
ESP_LOGI(TAG, "Creating BLE service");
|
||||
|
||||
pService = pServer->createService(serviceUuid);
|
||||
|
||||
ESP_LOGI(TAG, "Creating BLE characteristics");
|
||||
|
||||
livestatsCharacteristic = pService->createCharacteristic("a48321ea-329f-4eab-a401-30e247211524", NIMBLE_PROPERTY::READ | NIMBLE_PROPERTY::NOTIFY);
|
||||
remotecontrolCharacteristic = pService->createCharacteristic("4201def0-a264-43e6-946b-6b2d9612dfed", NIMBLE_PROPERTY::WRITE);
|
||||
remotecontrolCharacteristic->setCallbacks(&bleRemoteCallbacks);
|
||||
@ -72,19 +78,23 @@ void createBle()
|
||||
getwifilist = pService->createCharacteristic("4201def2-a264-43e6-946b-6b2d9612dfed", NIMBLE_PROPERTY::READ);
|
||||
getwifilist->setCallbacks(&bleWiFiListCallbacks);
|
||||
|
||||
ESP_LOGI(TAG, "Starting BLE service");
|
||||
|
||||
pService->start();
|
||||
|
||||
BLEAdvertising *pAdvertising = BLEDevice::getAdvertising();
|
||||
ESP_LOGI(TAG, "Starting BLE advertising");
|
||||
|
||||
NimBLEAdvertising *pAdvertising = NimBLEDevice::getAdvertising();
|
||||
pAdvertising->addServiceUUID(serviceUuid);
|
||||
pAdvertising->setScanResponse(true);
|
||||
BLEDevice::startAdvertising();
|
||||
NimBLEDevice::startAdvertising();
|
||||
}
|
||||
|
||||
void destroyBle()
|
||||
{
|
||||
ESP_LOGI("BOBBY", "called");
|
||||
|
||||
BLEDevice::deinit(true);
|
||||
NimBLEDevice::deinit(true);
|
||||
|
||||
pServer = {};
|
||||
pService = {};
|
||||
@ -226,9 +236,9 @@ void handleBle()
|
||||
|
||||
namespace {
|
||||
|
||||
void RemoteControlCallbacks::onWrite(NimBLECharacteristic* pCharacteristic)
|
||||
void RemoteControlCallbacks::onWrite(NimBLECharacteristic* pCharacteristic, NimBLEConnInfo& connInfo)
|
||||
{
|
||||
const auto &val = pCharacteristic->getValue();
|
||||
const std::string& val = pCharacteristic->getValue();
|
||||
|
||||
StaticJsonDocument<256> doc;
|
||||
if (const auto error = deserializeJson(doc, val))
|
||||
@ -258,9 +268,9 @@ void RemoteControlCallbacks::onWrite(NimBLECharacteristic* pCharacteristic)
|
||||
}
|
||||
}
|
||||
|
||||
void WirelessSettingsCallbacks::onWrite(NimBLECharacteristic* pCharacteristic)
|
||||
void WirelessSettingsCallbacks::onWrite(NimBLECharacteristic* pCharacteristic, NimBLEConnInfo& connInfo)
|
||||
{
|
||||
const auto &val = pCharacteristic->getValue();
|
||||
const std::string& val = pCharacteristic->getValue();
|
||||
|
||||
StaticJsonDocument<256> doc;
|
||||
if (const auto error = deserializeJson(doc, val))
|
||||
@ -282,7 +292,7 @@ void WirelessSettingsCallbacks::onWrite(NimBLECharacteristic* pCharacteristic)
|
||||
}
|
||||
}
|
||||
|
||||
void WiFiListCallbacks::onRead(NimBLECharacteristic *pCharacteristic)
|
||||
void WiFiListCallbacks::onRead(NimBLECharacteristic* pCharacteristic, NimBLEConnInfo& connInfo)
|
||||
{
|
||||
StaticJsonDocument<768> responseDoc;
|
||||
auto wifiArray = responseDoc.createNestedArray("wifis");
|
||||
|
@ -60,23 +60,18 @@ namespace bobbyblinker {
|
||||
}
|
||||
if (configs.ledstrip.enableBrakeLights.value() && espchrono::ago(*brake_last_time_sent) > 500ms)
|
||||
{
|
||||
float avgPwm{};
|
||||
for (const Controller &controller: controllers) {
|
||||
avgPwm +=
|
||||
controller.command.left.pwm * (controller.invertLeft ? -1 : 1) +
|
||||
controller.command.right.pwm * (controller.invertRight ? -1 : 1);
|
||||
}
|
||||
avgPwm /= 4;
|
||||
|
||||
if (avgPwm < -1.f)
|
||||
if (brakeLightsStatus == brakeLightsOffSent)
|
||||
{
|
||||
sendState("BRAKELIGHTSON");
|
||||
brakeLightsOffSent = false;
|
||||
}
|
||||
else if (!brakeLightsOffSent && avgPwm > -1.f)
|
||||
{
|
||||
sendState("BRAKELIGHTSOFF");
|
||||
brakeLightsOffSent = true;
|
||||
if (brakeLightsStatus)
|
||||
{
|
||||
sendState("BRAKELIGHTSON");
|
||||
brakeLightsOffSent = false;
|
||||
}
|
||||
else if (!brakeLightsOffSent)
|
||||
{
|
||||
sendState("BRAKELIGHTSOFF");
|
||||
brakeLightsOffSent = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,9 @@
|
||||
|
||||
void BobbyErrorHandler::errorOccurred(std::string &&error)
|
||||
{
|
||||
auto newDisplay = std::make_unique<BobbyPopupDisplay>(std::move(error), std::move(espgui::currentDisplay));
|
||||
newDisplay->initOverlay();
|
||||
espgui::currentDisplay = std::move(newDisplay);
|
||||
espgui::changeScreenCallback = [error_ = std::move(error)](espgui::TftInterface &tft) mutable {
|
||||
auto newDisplay = std::make_unique<BobbyPopupDisplay>(std::move(error_), std::move(espgui::currentDisplay));
|
||||
newDisplay->initOverlay(tft);
|
||||
espgui::currentDisplay = std::move(newDisplay);
|
||||
};
|
||||
}
|
||||
|
@ -95,6 +95,9 @@ void open_garage()
|
||||
return;
|
||||
for (const auto &config : configs.wireless_door_configs)
|
||||
{
|
||||
if (config.doorId.value().empty() || config.doorToken.value().empty())
|
||||
continue;
|
||||
|
||||
if (const auto error = espnow::send_espnow_message(fmt::format("BOBBYOPEN:{}:{}", config.doorId.value(), config.doorToken.value())); error != ESP_OK)
|
||||
{
|
||||
ESP_LOGE("BOBBY", "send_espnow_message() failed with: %s", esp_err_to_name(error));
|
||||
|
@ -155,7 +155,7 @@ namespace buildserver {
|
||||
|
||||
std::string get_hash_url(std::string hash)
|
||||
{
|
||||
return fmt::format(fmt::runtime(url_for_hashes), hash);
|
||||
return fmt::format("{}{}.bin", url_for_hashes, hash);
|
||||
}
|
||||
|
||||
std::string get_latest_url()
|
||||
@ -197,7 +197,7 @@ namespace buildserver {
|
||||
index = 0;
|
||||
|
||||
url_for_latest = fmt::format("{}{}", configs.otaServerUrl.value(), doc["latest"].as<std::string>());
|
||||
url_for_hashes = fmt::format("{}{}", configs.otaServerUrl.value(), doc["url"].as<std::string>());
|
||||
url_for_hashes = fmt::format("{}{}", configs.otaServerUrl.value(), doc["new_url"].as<std::string>());
|
||||
parsing_finished = true;
|
||||
}
|
||||
|
||||
|
@ -308,7 +308,7 @@ void sendCanCommands()
|
||||
++can_total_error_cnt;
|
||||
can_sequential_bus_errors = status_info.bus_error_count;
|
||||
|
||||
if (can_total_error_cnt < 500)
|
||||
if (can_total_error_cnt < 500 && (configs.canUninstallOnReset.value() && can_total_error_cnt < 100))
|
||||
ESP_LOGW(TAG, "twai_transmit() failed after %lldms with %s, seq err: %lu, total err: %lu",
|
||||
std::chrono::floor<std::chrono::milliseconds>(timestamp_after - timestamp_before).count(),
|
||||
esp_err_to_name(result),
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
// system includes
|
||||
#include <optional>
|
||||
#include <expected>
|
||||
|
||||
// esp-idf includes
|
||||
#include <esp_log.h>
|
||||
@ -13,7 +14,6 @@
|
||||
#include <menudisplay.h>
|
||||
#include <numberparsing.h>
|
||||
#include <screenmanager.h>
|
||||
#include <tftinstance.h>
|
||||
#include <tickchrono.h>
|
||||
#include <wrappers/websocket_client.h>
|
||||
|
||||
@ -196,41 +196,41 @@ typename std::enable_if<
|
||||
!std::is_same_v<T, HandbremseMode> &&
|
||||
!std::is_same_v<T, BobbyQuickActions> &&
|
||||
!std::is_same_v<T, BatteryCellType>
|
||||
, tl::expected<void, std::string>>::type
|
||||
, std::expected<void, std::string>>::type
|
||||
set_config(ConfigWrapper<T> &config, std::string_view newValue)
|
||||
{
|
||||
return tl::make_unexpected("Unsupported config type");
|
||||
return std::unexpected("Unsupported config type");
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
typename std::enable_if<
|
||||
std::is_same_v<T, bool>
|
||||
, tl::expected<void, std::string>>::type
|
||||
, std::expected<void, std::string>>::type
|
||||
set_config(ConfigWrapper<T> &config, std::string_view newValue)
|
||||
{
|
||||
if (cpputils::is_in(newValue, "true", "false"))
|
||||
return configs.write_config(config, newValue == "true");
|
||||
else
|
||||
return tl::make_unexpected(fmt::format("only true and false allowed, not {}", newValue));
|
||||
return std::unexpected(fmt::format("only true and false allowed, not {}", newValue));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
typename std::enable_if<
|
||||
!std::is_same_v<T, bool> &&
|
||||
std::is_integral_v<T>
|
||||
, tl::expected<void, std::string>>::type
|
||||
, std::expected<void, std::string>>::type
|
||||
set_config(ConfigWrapper<T> &config, std::string_view newValue)
|
||||
{
|
||||
if (auto parsed = cpputils::fromString<T>(newValue))
|
||||
return configs.write_config(config, *parsed);
|
||||
else
|
||||
return tl::make_unexpected(fmt::format("could not parse {}", newValue));
|
||||
return std::unexpected(fmt::format("could not parse {}", newValue));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
typename std::enable_if<
|
||||
std::is_same_v<T, std::string>
|
||||
, tl::expected<void, std::string>>::type
|
||||
, std::expected<void, std::string>>::type
|
||||
set_config(ConfigWrapper<T> &config, std::string_view newValue)
|
||||
{
|
||||
return configs.write_config(config, std::string{newValue});
|
||||
@ -239,31 +239,31 @@ set_config(ConfigWrapper<T> &config, std::string_view newValue)
|
||||
template<typename T>
|
||||
typename std::enable_if<
|
||||
std::is_same_v<T, wifi_stack::ip_address_t>
|
||||
, tl::expected<void, std::string>>::type
|
||||
, std::expected<void, std::string>>::type
|
||||
set_config(ConfigWrapper<T> &config, std::string_view newValue)
|
||||
{
|
||||
if (const auto parsed = wifi_stack::fromString<wifi_stack::ip_address_t>(newValue); parsed)
|
||||
return configs.write_config(config, *parsed);
|
||||
else
|
||||
return tl::make_unexpected(parsed.error());
|
||||
return std::unexpected(parsed.error());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
typename std::enable_if<
|
||||
std::is_same_v<T, wifi_stack::mac_t>
|
||||
, tl::expected<void, std::string>>::type
|
||||
, std::expected<void, std::string>>::type
|
||||
set_config(ConfigWrapper<T> &config, std::string_view newValue)
|
||||
{
|
||||
if (const auto parsed = wifi_stack::fromString<wifi_stack::mac_t>(newValue); parsed)
|
||||
return configs.write_config(config, *parsed);
|
||||
else
|
||||
return tl::make_unexpected(parsed.error());
|
||||
return std::unexpected(parsed.error());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
typename std::enable_if<
|
||||
std::is_same_v<T, std::optional<wifi_stack::mac_t>>
|
||||
, tl::expected<void, std::string>>::type
|
||||
, std::expected<void, std::string>>::type
|
||||
set_config(ConfigWrapper<T> &config, std::string_view newValue)
|
||||
{
|
||||
if (newValue.empty())
|
||||
@ -271,7 +271,7 @@ set_config(ConfigWrapper<T> &config, std::string_view newValue)
|
||||
else if (const auto parsed = wifi_stack::fromString<wifi_stack::mac_t>(newValue); parsed)
|
||||
return configs.write_config(config, *parsed);
|
||||
else
|
||||
return tl::make_unexpected(parsed.error());
|
||||
return std::unexpected(parsed.error());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
@ -284,13 +284,13 @@ typename std::enable_if<
|
||||
std::is_same_v<T, HandbremseMode> ||
|
||||
std::is_same_v<T, BobbyQuickActions> ||
|
||||
std::is_same_v<T, BatteryCellType>
|
||||
, tl::expected<void, std::string>>::type
|
||||
, std::expected<void, std::string>>::type
|
||||
set_config(ConfigWrapper<T> &config, std::string_view newValue)
|
||||
{
|
||||
if (auto parsed = cpputils::fromString<std::underlying_type_t<T>>(newValue))
|
||||
return configs.write_config(config, T(*parsed));
|
||||
else
|
||||
return tl::make_unexpected(fmt::format("could not parse {}", newValue));
|
||||
return std::unexpected(fmt::format("could not parse {}", newValue));
|
||||
}
|
||||
|
||||
void send_config(uint32_t skipCount)
|
||||
@ -448,7 +448,7 @@ void send_information()
|
||||
|
||||
if (const auto *display = currentDisplay->asMenuDisplay())
|
||||
{
|
||||
displayObject["name"] = display->text();
|
||||
displayObject["name"] = display->title();
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -590,7 +590,7 @@ void updateCloud()
|
||||
lastCloudSend = now;
|
||||
}
|
||||
|
||||
if (!lastHeartbeat || now - *lastHeartbeat >= 1500ms)
|
||||
if (!lastHeartbeat || now - *lastHeartbeat >= 1500ms && !configs.cloudSettings.cloudKey.value().empty())
|
||||
{
|
||||
cloudHeartbeat();
|
||||
lastHeartbeat = now;
|
||||
@ -743,7 +743,7 @@ void cloudSend()
|
||||
|
||||
const auto timeout = std::chrono::ceil<espcpputils::ticks>(espchrono::milliseconds32{configs.cloudSettings.cloudTransmitTimeout.value()}).count();
|
||||
|
||||
if (!hasAnnouncedItself && configs.cloudSettings.cloudEnabled.value())
|
||||
if (!hasAnnouncedItself && configs.cloudSettings.cloudEnabled.value() && !configs.cloudSettings.cloudKey.value().empty())
|
||||
{
|
||||
std::string helloWorld = getLoginMessage();
|
||||
ESP_LOGW(TAG, "=====> %s", helloWorld.c_str());
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include <esp_log.h>
|
||||
|
||||
// 3rdparty lib includes
|
||||
#include <tftinstance.h>
|
||||
#include <esp32-hal-gpio.h>
|
||||
#include <screenmanager.h>
|
||||
#include <changevaluedisplay.h>
|
||||
@ -117,7 +116,7 @@ void handleNormalChar(char c)
|
||||
{
|
||||
case 'i':
|
||||
case 'I':
|
||||
espgui::tft.init();
|
||||
tft.init();
|
||||
break;
|
||||
case 'p':
|
||||
case 'P':
|
||||
|
@ -3,7 +3,7 @@ constexpr const char * const TAG = "BatteryGraphDisplay";
|
||||
|
||||
// 3rdparty lib includes
|
||||
#include <screenmanager.h>
|
||||
#include <tftinstance.h>
|
||||
#include <tftcolors.h>
|
||||
|
||||
// local includes
|
||||
#include "battery.h"
|
||||
@ -18,13 +18,13 @@ namespace {
|
||||
constexpr const uint8_t TOP_OFFSET = 40;
|
||||
} // namespace
|
||||
|
||||
void BatteryGraphDisplay::initScreen()
|
||||
void BatteryGraphDisplay::initScreen(espgui::TftInterface &tft)
|
||||
{
|
||||
Base::initScreen();
|
||||
drawBatteryCurve();
|
||||
Base::initScreen(tft);
|
||||
drawBatteryCurve(tft);
|
||||
}
|
||||
|
||||
std::string BatteryGraphDisplay::text() const
|
||||
std::string BatteryGraphDisplay::title() const
|
||||
{
|
||||
if (const auto avgVoltage = controllers.getAvgVoltage(); avgVoltage)
|
||||
{
|
||||
@ -33,10 +33,10 @@ std::string BatteryGraphDisplay::text() const
|
||||
return TEXT_BATTERY_GRAPH;
|
||||
}
|
||||
|
||||
void BatteryGraphDisplay::redraw()
|
||||
void BatteryGraphDisplay::redraw(espgui::TftInterface &tft)
|
||||
{
|
||||
using namespace espgui;
|
||||
Base::redraw();
|
||||
Base::redraw(tft);
|
||||
|
||||
if (const auto avgVoltage = controllers.getAvgVoltage(); avgVoltage)
|
||||
{
|
||||
@ -50,10 +50,10 @@ void BatteryGraphDisplay::redraw()
|
||||
const uint16_t lastXOffset = onePercent * (100 - getBatteryPercentage(m_lastBatVoltage, cellType));
|
||||
|
||||
// clear the old one and draw the new one
|
||||
tft.fillRect(lastXOffset + 2, TOP_OFFSET, onePercent, tft.height() - TOP_OFFSET, TFT_BLACK);
|
||||
tft.fillRect(xOffset + 2, TOP_OFFSET, onePercent, tft.height() - TOP_OFFSET, TFT_WHITE);
|
||||
tft.fillRect(lastXOffset + 2, TOP_OFFSET, onePercent, tft.height() - TOP_OFFSET, espgui::TFT_BLACK);
|
||||
tft.fillRect(xOffset + 2, TOP_OFFSET, onePercent, tft.height() - TOP_OFFSET, espgui::TFT_WHITE);
|
||||
m_lastBatVoltage = *avgVoltage;
|
||||
drawBatteryCurve();
|
||||
drawBatteryCurve(tft);
|
||||
}
|
||||
// tft.drawLine() code
|
||||
}
|
||||
@ -73,11 +73,11 @@ void BatteryGraphDisplay::buttonPressed(espgui::Button button)
|
||||
}
|
||||
}
|
||||
|
||||
void BatteryGraphDisplay::drawBatteryCurve()
|
||||
void BatteryGraphDisplay::drawBatteryCurve(espgui::TftInterface &tft)
|
||||
{
|
||||
const auto points = count_curve_points(configs.battery.cellType.value());
|
||||
const auto max_height = espgui::tft.height() - 1;
|
||||
const auto max_width = espgui::tft.width() - 4;
|
||||
const auto max_height = tft.height() - 1;
|
||||
const auto max_width = tft.width() - 4;
|
||||
const uint16_t part = max_width / points;
|
||||
const auto min_voltage = getMinBatCellVoltage(configs.battery.cellType.value());
|
||||
const auto max_voltage = getMaxBatCellVoltage(configs.battery.cellType.value());
|
||||
@ -89,7 +89,7 @@ void BatteryGraphDisplay::drawBatteryCurve()
|
||||
const int y1 = float_map(point->minVoltage / 100.f, min_voltage, max_voltage, max_height, TOP_OFFSET);
|
||||
const int x2 = 2 + part * (points - i);
|
||||
const int y2 = float_map(point->maxVoltage / 100.f, min_voltage, max_voltage, max_height, TOP_OFFSET);
|
||||
espgui::tft.drawLine(x1, y1, x2, y2, TFT_WHITE);
|
||||
tft.drawLine(x1, y1, x2, y2, espgui::TFT_WHITE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,13 +7,13 @@ class BatteryGraphDisplay : public BobbyDisplayWithTitle {
|
||||
using Base = BobbyDisplayWithTitle;
|
||||
|
||||
public:
|
||||
std::string text() const override;
|
||||
void initScreen() override;
|
||||
void redraw() override;
|
||||
std::string title() const override;
|
||||
void initScreen(espgui::TftInterface &tft) override;
|
||||
void redraw(espgui::TftInterface &tft) override;
|
||||
|
||||
void buttonPressed(espgui::Button button) override;
|
||||
|
||||
static void drawBatteryCurve();
|
||||
static void drawBatteryCurve(espgui::TftInterface &tft);
|
||||
|
||||
private:
|
||||
float m_lastBatVoltage{0};
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
// 3rdparty lib includes
|
||||
#include <screenmanager.h>
|
||||
#include <tftinstance.h>
|
||||
#include <tftcolors.h>
|
||||
|
||||
// local includes
|
||||
#include "battery.h"
|
||||
@ -14,20 +14,20 @@
|
||||
|
||||
// display with big battery and ten bars (0-100%)
|
||||
|
||||
void BatteryInfoDisplay::initScreen()
|
||||
void BatteryInfoDisplay::initScreen(espgui::TftInterface &tft)
|
||||
{
|
||||
using namespace espgui;
|
||||
Base::initScreen();
|
||||
Base::initScreen(tft);
|
||||
|
||||
tft.drawRoundRect(m_offset, m_offset, tft.width() - (m_offset * 2), tft.height() - (m_offset * 2), 10, TFT_WHITE);
|
||||
tft.drawRoundRect((tft.width() / 2) - (m_offset / 2), m_offset / 2, m_offset, m_offset / 2, 3, TFT_WHITE);
|
||||
tft.drawRoundRect(m_offset, m_offset, tft.width() - (m_offset * 2), tft.height() - (m_offset * 2), 10, espgui::TFT_WHITE);
|
||||
tft.drawRoundRect((tft.width() / 2) - (m_offset / 2), m_offset / 2, m_offset, m_offset / 2, 3, espgui::TFT_WHITE);
|
||||
m_lastBarCount = 0;
|
||||
}
|
||||
|
||||
void BatteryInfoDisplay::redraw()
|
||||
void BatteryInfoDisplay::redraw(espgui::TftInterface &tft)
|
||||
{
|
||||
using namespace espgui;
|
||||
Base::redraw();
|
||||
Base::redraw(tft);
|
||||
|
||||
// calculate height of space available for all bars
|
||||
const auto min_x = m_offset + 3; // leave 2 pixels + 1 pixel for border
|
||||
@ -51,7 +51,7 @@ void BatteryInfoDisplay::redraw()
|
||||
for (auto i = 0; i < 10; ++i)
|
||||
{
|
||||
const auto y = bottomY - (i * segment_height) - segment_height;
|
||||
tft.fillRoundRect(min_x, y, width, segment_height - 2, 10, segment_count > i ? TFT_GREEN : TFT_DARKGREY);
|
||||
tft.fillRoundRect(min_x, y, width, segment_height - 2, 10, segment_count > i ? espgui::TFT_GREEN : espgui::TFT_DARKGREY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,8 +8,8 @@ class BatteryInfoDisplay : public BobbyDisplay
|
||||
using Base = BobbyDisplay;
|
||||
|
||||
public:
|
||||
void initScreen() override;
|
||||
void redraw() override;
|
||||
void initScreen(espgui::TftInterface &tft) override;
|
||||
void redraw(espgui::TftInterface &tft) override;
|
||||
|
||||
void buttonPressed(espgui::Button button) override;
|
||||
private:
|
||||
|
@ -5,13 +5,12 @@
|
||||
#include "displays/speedinfodisplay.h"
|
||||
#include "displays/statusdisplay.h"
|
||||
#include "screenmanager.h"
|
||||
#include "tftinstance.h"
|
||||
|
||||
using namespace espgui;
|
||||
|
||||
void BmsDisplay::initScreen()
|
||||
void BmsDisplay::initScreen(espgui::TftInterface &tft)
|
||||
{
|
||||
Base::initScreen();
|
||||
Base::initScreen(tft);
|
||||
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||
@ -43,9 +42,9 @@ void BmsDisplay::initScreen()
|
||||
m_cycleLabel.start();
|
||||
}
|
||||
|
||||
void BmsDisplay::redraw()
|
||||
void BmsDisplay::redraw(espgui::TftInterface &tft)
|
||||
{
|
||||
Base::redraw();
|
||||
Base::redraw(tft);
|
||||
|
||||
if (bluetoothSerial.hasClient())
|
||||
tft.setTextColor(TFT_GREEN, TFT_BLACK);
|
||||
|
@ -18,8 +18,8 @@ class BmsDisplay :
|
||||
using Base = BobbyDisplay;
|
||||
|
||||
public:
|
||||
void initScreen() override;
|
||||
void redraw() override;
|
||||
void initScreen(espgui::TftInterface &tft) override;
|
||||
void redraw(espgui::TftInterface &tft) override;
|
||||
|
||||
void buttonPressed(espgui::Button button) override;
|
||||
|
||||
|
@ -38,7 +38,7 @@ void BobbyGraphDisplay<COUNT>::rawButtonReleased(uint8_t button)
|
||||
template<size_t COUNT>
|
||||
void BobbyGraphDisplay<COUNT>::buttonPressed(espgui::Button button)
|
||||
{
|
||||
//Base::buttonPressed(button);
|
||||
Base::buttonPressed(button);
|
||||
buttonPressedCommon(button);
|
||||
}
|
||||
|
||||
|
@ -1,221 +0,0 @@
|
||||
#include "buttoncalibratedisplay.h"
|
||||
|
||||
// esp-idf includes
|
||||
#include <esp_log.h>
|
||||
|
||||
// 3rdparty lib includes
|
||||
#include <tftinstance.h>
|
||||
#include <fmt/core.h>
|
||||
#include <screenmanager.h>
|
||||
|
||||
// local includes
|
||||
#include "bobbyerrorhandler.h"
|
||||
#include "displays/statusdisplay.h"
|
||||
#include "newsettings.h"
|
||||
|
||||
namespace {
|
||||
constexpr const char TAG[] = "BUTTON";
|
||||
} // namespace
|
||||
|
||||
std::string ButtonCalibrateDisplay::text() const
|
||||
{
|
||||
return "Button calibrate";
|
||||
}
|
||||
|
||||
void ButtonCalibrateDisplay::start()
|
||||
{
|
||||
Base::start();
|
||||
|
||||
m_oldMode = currentMode;
|
||||
currentMode = &m_mode;
|
||||
m_lastButton = std::nullopt;
|
||||
m_status = WaitingLeft;
|
||||
|
||||
m_finished = false;
|
||||
}
|
||||
|
||||
void ButtonCalibrateDisplay::initScreen()
|
||||
{
|
||||
Base::initScreen();
|
||||
|
||||
m_labelInstruction.start();
|
||||
m_labelLeft.start();
|
||||
m_labelRight.start();
|
||||
m_labelUp.start();
|
||||
m_labelDown.start();
|
||||
m_labelEnd.start();
|
||||
}
|
||||
|
||||
void ButtonCalibrateDisplay::update()
|
||||
{
|
||||
Base::update();
|
||||
|
||||
if (m_finished)
|
||||
{
|
||||
m_finished = false;
|
||||
|
||||
if (auto result = configs.write_config(configs.dpadMappingLeft, m_leftButton); !result)
|
||||
{
|
||||
BobbyErrorHandler{}.errorOccurred(std::move(result).error());
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
ESP_LOGI(TAG, "Left button set to %d", m_leftButton);
|
||||
}
|
||||
|
||||
if (auto result = configs.write_config(configs.dpadMappingRight, m_rightButton); !result)
|
||||
{
|
||||
BobbyErrorHandler{}.errorOccurred(std::move(result).error());
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
ESP_LOGI(TAG, "Right button set to %d", m_rightButton);
|
||||
}
|
||||
if (auto result = configs.write_config(configs.dpadMappingUp, m_upButton); !result)
|
||||
{
|
||||
BobbyErrorHandler{}.errorOccurred(std::move(result).error());
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
ESP_LOGI(TAG, "Up button set to %d", m_upButton);
|
||||
}
|
||||
if (auto result = configs.write_config(configs.dpadMappingDown, m_downButton); !result)
|
||||
{
|
||||
BobbyErrorHandler{}.errorOccurred(std::move(result).error());
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
ESP_LOGI(TAG, "Down button set to %d", m_downButton);
|
||||
}
|
||||
|
||||
if (espgui::displayStack.empty())
|
||||
{
|
||||
espgui::switchScreen<StatusDisplay>();
|
||||
}
|
||||
else
|
||||
espgui::popScreen();
|
||||
}
|
||||
}
|
||||
|
||||
void ButtonCalibrateDisplay::redraw()
|
||||
{
|
||||
Base::redraw();
|
||||
|
||||
espgui::tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||
|
||||
switch (m_status)
|
||||
{
|
||||
case WaitingLeft:
|
||||
if (m_lastButton)
|
||||
m_labelInstruction.redraw("Press LEFT again");
|
||||
else
|
||||
m_labelInstruction.redraw("Press LEFT");
|
||||
break;
|
||||
case WaitingRight:
|
||||
if (m_lastButton)
|
||||
m_labelInstruction.redraw("Press RIGHT again");
|
||||
else
|
||||
m_labelInstruction.redraw("Press RIGHT");
|
||||
break;
|
||||
case WaitingUp:
|
||||
if (m_lastButton)
|
||||
m_labelInstruction.redraw("Press UP again");
|
||||
else
|
||||
m_labelInstruction.redraw("Press UP");
|
||||
break;
|
||||
case WaitingDown:
|
||||
if (m_lastButton)
|
||||
m_labelInstruction.redraw("Press DOWN again");
|
||||
else
|
||||
m_labelInstruction.redraw("Press DOWN");
|
||||
break;
|
||||
case Finished:
|
||||
m_labelInstruction.redraw("Finished");
|
||||
break;
|
||||
}
|
||||
|
||||
m_labelLeft.redraw(m_status > WaitingLeft ? fmt::format("Left: {}", m_leftButton) : std::string{});
|
||||
m_labelRight.redraw(m_status > WaitingRight ? fmt::format("Right: {}", m_rightButton) : std::string{});
|
||||
m_labelUp.redraw(m_status > WaitingUp ? fmt::format("Up: {}", m_upButton) : std::string{});
|
||||
m_labelDown.redraw(m_status > WaitingDown ? fmt::format("Down: {}", m_downButton) : std::string{});
|
||||
|
||||
m_labelEnd.redraw(m_status == Finished ? "Press RIGHT to save" : "");
|
||||
}
|
||||
|
||||
void ButtonCalibrateDisplay::stop()
|
||||
{
|
||||
Base::stop();
|
||||
|
||||
if (currentMode == &m_mode)
|
||||
{
|
||||
// to avoid crash after deconstruction
|
||||
m_mode.stop();
|
||||
lastMode = nullptr;
|
||||
|
||||
currentMode = m_oldMode;
|
||||
}
|
||||
}
|
||||
|
||||
void ButtonCalibrateDisplay::rawButtonPressed(uint8_t button)
|
||||
{
|
||||
//Base::rawButtonPressed(button);
|
||||
|
||||
if (m_status == Finished)
|
||||
{
|
||||
if (button == m_rightButton)
|
||||
{
|
||||
ESP_LOGI(TAG, "correct button");
|
||||
m_finished = true;
|
||||
}
|
||||
else
|
||||
ESP_LOGI(TAG, "wrong button");
|
||||
}
|
||||
else if (!m_lastButton || *m_lastButton != button)
|
||||
m_lastButton = button;
|
||||
else
|
||||
{
|
||||
switch (m_status)
|
||||
{
|
||||
case WaitingLeft:
|
||||
m_leftButton = button;
|
||||
m_lastButton = std::nullopt;
|
||||
m_status = WaitingRight;
|
||||
break;
|
||||
case WaitingRight:
|
||||
m_rightButton = button;
|
||||
m_lastButton = std::nullopt;
|
||||
m_status = WaitingUp;
|
||||
break;
|
||||
case WaitingUp:
|
||||
m_upButton = button;
|
||||
m_lastButton = std::nullopt;
|
||||
m_status = WaitingDown;
|
||||
break;
|
||||
case WaitingDown:
|
||||
m_downButton = button;
|
||||
m_lastButton = std::nullopt;
|
||||
m_status = Finished;
|
||||
break;
|
||||
case Finished:;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ButtonCalibrateDisplay::rawButtonReleased(uint8_t button)
|
||||
{
|
||||
//Base::rawButtonReleased(button);
|
||||
}
|
||||
|
||||
void ButtonCalibrateDisplay::buttonPressed(espgui::Button button)
|
||||
{
|
||||
//Base::buttonPressed(button);
|
||||
}
|
||||
|
||||
void ButtonCalibrateDisplay::buttonReleased(espgui::Button button)
|
||||
{
|
||||
//Base::buttonReleased(button);
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
// 3rdparty lib includes
|
||||
#include <displaywithtitle.h>
|
||||
#include <widgets/label.h>
|
||||
|
||||
// local includes
|
||||
#include "globals.h"
|
||||
#include "modeinterface.h"
|
||||
#include "modes/ignoreinputmode.h"
|
||||
|
||||
class ButtonCalibrateDisplay : public espgui::DisplayWithTitle
|
||||
{
|
||||
using Base = espgui::DisplayWithTitle;
|
||||
|
||||
public:
|
||||
ButtonCalibrateDisplay() = default;
|
||||
explicit ButtonCalibrateDisplay(bool bootup) : m_bootup{bootup} {}
|
||||
|
||||
std::string text() const override;
|
||||
void start() override;
|
||||
void initScreen() override;
|
||||
void update() override;
|
||||
void redraw() override;
|
||||
void stop() override;
|
||||
|
||||
void rawButtonPressed(uint8_t button) override;
|
||||
void rawButtonReleased(uint8_t button) override;
|
||||
void buttonPressed(espgui::Button button) override;
|
||||
void buttonReleased(espgui::Button button) override;
|
||||
|
||||
private:
|
||||
const bool m_bootup{false};
|
||||
ModeInterface *m_oldMode;
|
||||
IgnoreInputMode m_mode{0, bobbycar::protocol::ControlType::FieldOrientedControl, bobbycar::protocol::ControlMode::Torque};
|
||||
|
||||
std::optional<uint8_t> m_lastButton;
|
||||
|
||||
enum { WaitingLeft, WaitingRight, WaitingUp, WaitingDown, Finished } m_status;
|
||||
|
||||
espgui::Label m_labelInstruction{25, 72};
|
||||
|
||||
espgui::Label m_labelLeft{25, 100};
|
||||
espgui::Label m_labelRight{25, 125};
|
||||
espgui::Label m_labelUp{25, 150};
|
||||
espgui::Label m_labelDown{25, 175};
|
||||
|
||||
espgui::Label m_labelEnd{25, 225};
|
||||
|
||||
uint8_t m_leftButton, m_rightButton, m_upButton, m_downButton;
|
||||
|
||||
bool m_finished;
|
||||
};
|
@ -134,7 +134,7 @@ CalibrateVoltageDisplay::CalibrateVoltageDisplay()
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_VOLTAGECALIBRATION_RESET>, ResetCalibrationAction>>();
|
||||
}
|
||||
|
||||
std::string CalibrateVoltageDisplay::text() const
|
||||
std::string CalibrateVoltageDisplay::title() const
|
||||
{
|
||||
return TEXT_BATTERY_CALIBRATE;
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ class CalibrateVoltageDisplay : public BobbyMenuDisplay
|
||||
public:
|
||||
CalibrateVoltageDisplay();
|
||||
|
||||
std::string text() const override;
|
||||
std::string title() const override;
|
||||
|
||||
void back() override;
|
||||
};
|
||||
|
@ -1,10 +1,10 @@
|
||||
#include "confiscationdisplay.h"
|
||||
|
||||
// 3rdparty lib includes
|
||||
#include <tftinstance.h>
|
||||
#include <screenmanager.h>
|
||||
#include <esprandom.h>
|
||||
#include <randomutils.h>
|
||||
#include <fontrenderer.h>
|
||||
|
||||
// local includes
|
||||
#include "globals.h"
|
||||
@ -29,39 +29,39 @@ void ConfiscationDisplay::start()
|
||||
m_nextRestart = espchrono::millis_clock::now() + std::chrono::seconds{cpputils::randomNumber(3, 7, espcpputils::esp_random_device{})};
|
||||
}
|
||||
|
||||
void ConfiscationDisplay::initScreen()
|
||||
void ConfiscationDisplay::initScreen(espgui::TftInterface &tft)
|
||||
{
|
||||
Base::initScreen();
|
||||
Base::initScreen(tft);
|
||||
|
||||
espgui::tft.setSwapBytes(true);
|
||||
espgui::tft.pushImage(10, 70, bobbyicons::shortcircuit.WIDTH, bobbyicons::shortcircuit.HEIGHT, bobbyicons::shortcircuit.buffer);
|
||||
espgui::tft.setSwapBytes(false);
|
||||
espgui::FontRenderer fontRenderer{tft};
|
||||
|
||||
m_progressBar.start();
|
||||
tft.pushImage(10, 70, bobbyicons::shortcircuit.WIDTH, bobbyicons::shortcircuit.HEIGHT, bobbyicons::shortcircuit.buffer);
|
||||
|
||||
m_label.start();
|
||||
m_progressBar.start(tft);
|
||||
|
||||
espgui::tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||
espgui::tft.setTextFont(2);
|
||||
m_label.start(tft);
|
||||
|
||||
fontRenderer.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||
fontRenderer.setTextFont(2);
|
||||
|
||||
auto y = 235;
|
||||
constexpr auto lineheight = 15;
|
||||
espgui::tft.drawString("Bei erneuter, widerrechtlicher", 10, y+=lineheight);
|
||||
espgui::tft.drawString("Beschlagnahmung wird die Selbst-", 10, y+=lineheight);
|
||||
espgui::tft.drawString("Vernichtung durch Kurzschluss", 10, y+=lineheight);
|
||||
espgui::tft.drawString(fmt::format("der Batterie eingeleitet (ca {:.2f}MJ)", calculateMegaJoules()), 10, y+=lineheight);
|
||||
tft.drawString(tft, fontRenderer, "Bei erneuter, widerrechtlicher", 10, y+=lineheight);
|
||||
tft.drawString(tft, fontRenderer, "Beschlagnahmung wird die Selbst-", 10, y+=lineheight);
|
||||
tft.drawString(tft, fontRenderer, "Vernichtung durch Kurzschluss", 10, y+=lineheight);
|
||||
tft.drawString(tft, fontRenderer, fmt::format("der Batterie eingeleitet (ca {:.2f}MJ)", calculateMegaJoules()), 10, y+=lineheight);
|
||||
}
|
||||
|
||||
void ConfiscationDisplay::redraw()
|
||||
void ConfiscationDisplay::redraw(espgui::TftInterface &tft)
|
||||
{
|
||||
Base::redraw();
|
||||
Base::redraw(tft);
|
||||
|
||||
m_progressBar.redraw(m_progress);
|
||||
m_progressBar.redraw(tft, m_progress);
|
||||
|
||||
espgui::tft.setTextColor(TFT_YELLOW, TFT_BLACK);
|
||||
tft.setTextColor(TFT_YELLOW, TFT_BLACK);
|
||||
|
||||
espgui::tft.setTextFont(2);
|
||||
m_label.redraw([](){
|
||||
tft.setTextFont(2);
|
||||
m_label.redraw(tft, fontRenderer, [](){
|
||||
if (const auto period = espchrono::millis_clock::now().time_since_epoch() % 6000ms; period < 2000ms)
|
||||
return "Halten Sie 10m Abstand.";
|
||||
else if (period < 4000ms)
|
||||
@ -110,7 +110,7 @@ void ConfiscationDisplay::buttonPressed(espgui::Button button)
|
||||
}
|
||||
}
|
||||
|
||||
std::string ConfiscationDisplay::text() const
|
||||
std::string ConfiscationDisplay::title() const
|
||||
{
|
||||
return "Explosions-Modus";
|
||||
}
|
||||
|
@ -16,14 +16,14 @@ class ConfiscationDisplay : public BobbyDisplayWithTitle
|
||||
public:
|
||||
void start() override;
|
||||
|
||||
void initScreen() override;
|
||||
void redraw() override;
|
||||
void initScreen(espgui::TftInterface &tft) override;
|
||||
void redraw(espgui::TftInterface &tft) override;
|
||||
void update() override;
|
||||
void stop() override;
|
||||
|
||||
void buttonPressed(espgui::Button button) override;
|
||||
|
||||
std::string text() const override;
|
||||
std::string title() const override;
|
||||
|
||||
private:
|
||||
espgui::ProgressBar m_progressBar{10, 210, 200, 10, 0, 500};
|
||||
|
@ -3,8 +3,12 @@
|
||||
// 3rdparty lib includes
|
||||
#include <randomutils.h>
|
||||
#include <esprandom.h>
|
||||
#include <tftinstance.h>
|
||||
#include <screenmanager.h>
|
||||
#include <tftinterface.h>
|
||||
#include <tftcolors.h>
|
||||
|
||||
// local includes
|
||||
#include "screens.h"
|
||||
|
||||
void GameOfLifeDisplay::start()
|
||||
{
|
||||
@ -14,26 +18,28 @@ void GameOfLifeDisplay::start()
|
||||
m_newgrid = std::make_unique<std::bitset<GRIDX*GRIDY>>();
|
||||
}
|
||||
|
||||
void GameOfLifeDisplay::initScreen()
|
||||
void GameOfLifeDisplay::initScreen(espgui::TftInterface &tft)
|
||||
{
|
||||
Base::initScreen();
|
||||
Base::initScreen(tft);
|
||||
|
||||
espgui::tft.setRotation(3);
|
||||
espgui::tft.fillScreen(TFT_BLACK);
|
||||
disableScreenFlip(true);
|
||||
|
||||
tft.setRotation(3);
|
||||
tft.fillScreen(espgui::TFT_BLACK);
|
||||
}
|
||||
|
||||
void GameOfLifeDisplay::redraw()
|
||||
void GameOfLifeDisplay::redraw(espgui::TftInterface &tft)
|
||||
{
|
||||
Base::redraw();
|
||||
Base::redraw(tft);
|
||||
|
||||
if (gen == 0)
|
||||
{
|
||||
espgui::tft.fillScreen(TFT_BLACK);
|
||||
tft.fillScreen(espgui::TFT_BLACK);
|
||||
initGrid();
|
||||
}
|
||||
|
||||
computeCA();
|
||||
drawGrid();
|
||||
drawGrid(tft);
|
||||
|
||||
*m_grid = *m_newgrid;
|
||||
|
||||
@ -45,7 +51,8 @@ void GameOfLifeDisplay::stop()
|
||||
{
|
||||
Base::stop();
|
||||
|
||||
espgui::tft.setRotation(0);
|
||||
disableScreenFlip(false);
|
||||
|
||||
m_grid = nullptr;
|
||||
m_newgrid = nullptr;
|
||||
}
|
||||
@ -64,9 +71,9 @@ void GameOfLifeDisplay::buttonPressed(espgui::Button button)
|
||||
}
|
||||
}
|
||||
|
||||
void GameOfLifeDisplay::drawGrid()
|
||||
void GameOfLifeDisplay::drawGrid(espgui::TftInterface &tft)
|
||||
{
|
||||
uint16_t color = TFT_WHITE;
|
||||
uint16_t color = espgui::TFT_WHITE;
|
||||
for (int16_t x = 1; x < GRIDX - 1; x++) {
|
||||
for (int16_t y = 1; y < GRIDY - 1; y++) {
|
||||
if (((*m_grid)[index(x,y)]) != ((*m_newgrid)[index(x,y)])) {
|
||||
@ -74,7 +81,7 @@ void GameOfLifeDisplay::drawGrid()
|
||||
color = 0xFFFF; //random(0xFFFF);
|
||||
else
|
||||
color = 0;
|
||||
espgui::tft.fillRect(CELLXY * x, CELLXY * y, CELLXY, CELLXY, color);
|
||||
tft.fillRect(CELLXY * x, CELLXY * y, CELLXY, CELLXY, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,8 +13,8 @@ class GameOfLifeDisplay : public BobbyDisplay
|
||||
|
||||
public:
|
||||
void start() override;
|
||||
void initScreen() override;
|
||||
void redraw() override;
|
||||
void initScreen(espgui::TftInterface &tft) override;
|
||||
void redraw(espgui::TftInterface &tft) override;
|
||||
void stop() override;
|
||||
|
||||
void buttonPressed(espgui::Button button) override;
|
||||
@ -22,7 +22,7 @@ public:
|
||||
private:
|
||||
|
||||
//Draws the grid on the display
|
||||
void drawGrid();
|
||||
void drawGrid(espgui::TftInterface &tft);
|
||||
|
||||
//Initialise Grid
|
||||
void initGrid();
|
||||
|
@ -21,8 +21,8 @@ class GametrakCalibrateDisplay : public BobbyDisplay, public ConfirmActionInterf
|
||||
using Base = BobbyDisplay;
|
||||
|
||||
public:
|
||||
void initScreen() override;
|
||||
void redraw() override;
|
||||
void initScreen(espgui::TftInterface &tft) override;
|
||||
void redraw(espgui::TftInterface &tft) override;
|
||||
|
||||
private:
|
||||
std::array<Label, 6> m_labels {{
|
||||
@ -41,9 +41,9 @@ private:
|
||||
}};
|
||||
};
|
||||
|
||||
void GametrakCalibrateDisplay::initScreen()
|
||||
void GametrakCalibrateDisplay::initScreen(espgui::TftInterface &tft)
|
||||
{
|
||||
Base::initScreen();
|
||||
Base::initScreen(tft);
|
||||
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
tft.setTextFont(4);
|
||||
@ -62,9 +62,9 @@ void GametrakCalibrateDisplay::initScreen()
|
||||
progressBar.start();
|
||||
}
|
||||
|
||||
void GametrakCalibrateDisplay::redraw()
|
||||
void GametrakCalibrateDisplay::redraw(espgui::TftInterface &tft)
|
||||
{
|
||||
Base::redraw();
|
||||
Base::redraw(tft);
|
||||
|
||||
m_labels[0].redraw(fmt::format("{:.02f}", gametrakX));
|
||||
m_labels[1].redraw(std::to_string(raw_gametrakX));
|
||||
|
@ -2,7 +2,6 @@
|
||||
#include "joystickdebugdisplay.h"
|
||||
|
||||
// 3rdparty lib includes
|
||||
#include <tftinstance.h>
|
||||
#include <screenmanager.h>
|
||||
|
||||
// local includes
|
||||
@ -27,7 +26,7 @@ void JoystickDebugDisplay::start()
|
||||
copyFromSettings();
|
||||
}
|
||||
|
||||
std::string JoystickDebugDisplay::text() const
|
||||
std::string JoystickDebugDisplay::title() const
|
||||
{
|
||||
return TEXT_JOYSTICK;
|
||||
}
|
||||
@ -49,9 +48,9 @@ void JoystickDebugDisplay::update()
|
||||
m_y = map_analog_stick(m_bremsMitte, m_bremsMin, m_bremsMax, configs.deadband.value(), *raw_brems);
|
||||
}
|
||||
|
||||
void JoystickDebugDisplay::redraw()
|
||||
void JoystickDebugDisplay::redraw(espgui::TftInterface &tft)
|
||||
{
|
||||
Base::redraw();
|
||||
Base::redraw(tft);
|
||||
|
||||
if (m_x && m_y)
|
||||
{
|
||||
|
@ -16,7 +16,7 @@ class JoystickDebugDisplay : public BobbyDisplayWithTitle
|
||||
public:
|
||||
JoystickDebugDisplay();
|
||||
|
||||
std::string text() const override;
|
||||
std::string title() const override;
|
||||
void start() override;
|
||||
void update() override;
|
||||
void redraw() override;
|
||||
|
@ -8,9 +8,9 @@
|
||||
#include <cpputils.h>
|
||||
#include <menuitem.h>
|
||||
#include <actioninterface.h>
|
||||
#include <tftinstance.h>
|
||||
#include <screenmanager.h>
|
||||
#include <actions/dummyaction.h>
|
||||
#include <fontrenderer.h>
|
||||
|
||||
// local includes
|
||||
#include "utils.h"
|
||||
@ -49,41 +49,39 @@ const std::array<uint16_t, 8> tft_colors = {
|
||||
};
|
||||
} // namespace
|
||||
|
||||
std::string LedstripColorsDisplay::text() const
|
||||
std::string LedstripColorsDisplay::title() const
|
||||
{
|
||||
return TEXT_LEDSTRIPCOLORMENU;
|
||||
}
|
||||
|
||||
void LedstripColorsDisplay::initScreen()
|
||||
void LedstripColorsDisplay::initScreen(espgui::TftInterface &tft)
|
||||
{
|
||||
Base::initScreen();
|
||||
Base::initScreen(tft);
|
||||
|
||||
espgui::tft.setSwapBytes(true);
|
||||
espgui::tft.pushImage(70, 60, bobbyicons::bobbycar.WIDTH, bobbyicons::bobbycar.HEIGHT, bobbyicons::bobbycar.buffer);
|
||||
espgui::tft.setSwapBytes(false);
|
||||
tft.pushImage(70, 60, bobbyicons::bobbycar.WIDTH, bobbyicons::bobbycar.HEIGHT, bobbyicons::bobbycar.buffer);
|
||||
}
|
||||
|
||||
void LedstripColorsDisplay::redraw()
|
||||
void LedstripColorsDisplay::redraw(espgui::TftInterface &tft)
|
||||
{
|
||||
Base::redraw();
|
||||
Base::redraw(tft);
|
||||
|
||||
auto y_pos = ((espgui::tft.width() - 40) / 8 + 4) + 240;
|
||||
auto y_pos = ((tft.width() - 40) / 8 + 4) + 240;
|
||||
if (last_state != state_select_color)
|
||||
{
|
||||
espgui::tft.fillRect(0,y_pos - 1, espgui::tft.width(), 20, TFT_BLACK);
|
||||
tft.fillRect(0,y_pos - 1, tft.width(), 20, TFT_BLACK);
|
||||
last_state = state_select_color;
|
||||
}
|
||||
|
||||
espgui::tft.setTextFont(2);
|
||||
espgui::tft.setTextColor(TFT_WHITE);
|
||||
|
||||
espgui::tft.drawString(state_select_color ?
|
||||
"Please select a color!" :
|
||||
"Please select a side!", 50, y_pos);
|
||||
espgui::FontRenderer fontRenderer{tft};
|
||||
fontRenderer.drawString(state_select_color ?
|
||||
"Please select a color!" :
|
||||
"Please select a side!", 50, y_pos,
|
||||
espgui::TFT_WHITE, espgui::TFT_BLACK,
|
||||
2);
|
||||
|
||||
if (!already_drew_circle)
|
||||
{
|
||||
drawSide(static_cast<Bobbycar_Side>(selected_side), TFT_GOLD);
|
||||
drawSide(tft, static_cast<Bobbycar_Side>(selected_side), TFT_GOLD);
|
||||
already_drew_circle = true;
|
||||
}
|
||||
}
|
||||
@ -103,7 +101,7 @@ void LedstripColorsDisplay::buttonPressed(espgui::Button button)
|
||||
else
|
||||
{
|
||||
state_select_color = false;
|
||||
espgui::tft.fillRect(0, 228, espgui::tft.width(), ((espgui::tft.width() - 40) / 8) + 4, TFT_BLACK);
|
||||
tft.fillRect(0, 228, tft.width(), ((tft.width() - 40) / 8) + 4, TFT_BLACK);
|
||||
}
|
||||
|
||||
break;
|
||||
@ -111,7 +109,7 @@ void LedstripColorsDisplay::buttonPressed(espgui::Button button)
|
||||
if(!state_select_color)
|
||||
{
|
||||
state_select_color = true;
|
||||
drawColors();
|
||||
drawColors(tft);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -119,7 +117,7 @@ void LedstripColorsDisplay::buttonPressed(espgui::Button button)
|
||||
// Uncomment to close select color menu on color select
|
||||
/*
|
||||
state_select_color = false;
|
||||
espgui::tft.fillRect(0, 228, espgui::tft.width(), ((espgui::tft.width() - 40) / 8) + 4, TFT_BLACK);
|
||||
tft.fillRect(0, 228, tft.width(), ((tft.width() - 40) / 8) + 4, TFT_BLACK);
|
||||
*/
|
||||
}
|
||||
break;
|
||||
@ -144,13 +142,13 @@ void LedstripColorsDisplay::buttonPressed(espgui::Button button)
|
||||
/* TODO commander: move into redraw method */
|
||||
if (state_select_color)
|
||||
{
|
||||
drawColors();
|
||||
drawColors(tft);
|
||||
}
|
||||
else
|
||||
{
|
||||
espgui::tft.fillRect(0, 228, espgui::tft.width(), ((espgui::tft.width() - 40) / 8) + 4, TFT_BLACK);
|
||||
tft.fillRect(0, 228, tft.width(), ((tft.width() - 40) / 8) + 4, TFT_BLACK);
|
||||
clearSides();
|
||||
drawSide(static_cast<Bobbycar_Side>(selected_side), TFT_GOLD);
|
||||
drawSide(tft, static_cast<Bobbycar_Side>(selected_side), TFT_GOLD);
|
||||
}
|
||||
|
||||
break;
|
||||
@ -175,11 +173,11 @@ void LedstripColorsDisplay::buttonPressed(espgui::Button button)
|
||||
/* TODO commander: move into redraw method */
|
||||
if (state_select_color)
|
||||
{
|
||||
drawColors();
|
||||
drawColors(tft);
|
||||
}
|
||||
else
|
||||
{
|
||||
espgui::tft.fillRect(0, 228, espgui::tft.width(), ((espgui::tft.width() - 40) / 8) + 4, TFT_BLACK);
|
||||
tft.fillRect(0, 228, tft.width(), ((tft.width() - 40) / 8) + 4, TFT_BLACK);
|
||||
clearSides();
|
||||
drawSide(static_cast<Bobbycar_Side>(selected_side), TFT_GOLD);
|
||||
}
|
||||
@ -188,19 +186,19 @@ void LedstripColorsDisplay::buttonPressed(espgui::Button button)
|
||||
}
|
||||
}
|
||||
|
||||
void LedstripColorsDisplay::drawColors()
|
||||
void LedstripColorsDisplay::drawColors(espgui::TftInterface &tft)
|
||||
{
|
||||
uint16_t width = (espgui::tft.width() - 40);
|
||||
uint16_t width = (tft.width() - 40);
|
||||
auto cube_width = width / 8;
|
||||
|
||||
espgui::tft.fillRect(0, 228, espgui::tft.width(), cube_width + 4, TFT_BLACK);
|
||||
espgui::tft.fillRect(21, 231, width - 1, cube_width - 1, TFT_WHITE);
|
||||
tft.fillRect(0, 228, tft.width(), cube_width + 4, TFT_BLACK);
|
||||
tft.fillRect(21, 231, width - 1, cube_width - 1, TFT_WHITE);
|
||||
|
||||
espgui::tft.fillRect(20 + (selected_color * cube_width - 1), 228, cube_width + 4, cube_width + 4, TFT_YELLOW);
|
||||
tft.fillRect(20 + (selected_color * cube_width - 1), 228, cube_width + 4, cube_width + 4, TFT_YELLOW);
|
||||
for (int index = 0; index < 8; index++)
|
||||
{
|
||||
auto offset = index * (cube_width);
|
||||
espgui::tft.fillRect(22 + offset, 232, cube_width - 4, cube_width - 4, tft_colors[index]);
|
||||
tft.fillRect(22 + offset, 232, cube_width - 4, cube_width - 4, tft_colors[index]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -212,9 +210,9 @@ void LedstripColorsDisplay::clearSides()
|
||||
}
|
||||
}
|
||||
|
||||
void LedstripColorsDisplay::drawSide(Bobbycar_Side side, unsigned int color)
|
||||
void LedstripColorsDisplay::drawSide(espgui::TftInterface &tft, Bobbycar_Side side, unsigned int color)
|
||||
{
|
||||
const auto middle = espgui::tft.width() / 2;
|
||||
const auto middle = tft.width() / 2;
|
||||
const auto width = bobbyicons::bobbycar.WIDTH;
|
||||
const auto height = bobbyicons::bobbycar.HEIGHT;
|
||||
const auto left = middle - (width / 2);
|
||||
@ -224,33 +222,33 @@ void LedstripColorsDisplay::drawSide(Bobbycar_Side side, unsigned int color)
|
||||
|
||||
switch (side) {
|
||||
case Bobbycar_Side::FRONT:
|
||||
espgui::tft.fillRect(left, above, width, 5, color);
|
||||
tft.fillRect(left, above, width, 5, color);
|
||||
break;
|
||||
case Bobbycar_Side::FRONT_LEFT:
|
||||
espgui::tft.fillRect(left - 10, above + 10, 5, height / 2, color);
|
||||
espgui::tft.fillRect(left, above, width / 2, 5, color);
|
||||
tft.fillRect(left - 10, above + 10, 5, height / 2, color);
|
||||
tft.fillRect(left, above, width / 2, 5, color);
|
||||
break;
|
||||
case Bobbycar_Side::LEFT:
|
||||
espgui::tft.fillRect(left - 10, above + 10, 5, height, color);
|
||||
tft.fillRect(left - 10, above + 10, 5, height, color);
|
||||
break;
|
||||
case Bobbycar_Side::BACK_LEFT:
|
||||
espgui::tft.fillRect(left - 10, above + 10 + (height / 2), 5, height / 2, color);
|
||||
espgui::tft.fillRect(left, bellow + 5, width / 2, 5, color);
|
||||
tft.fillRect(left - 10, above + 10 + (height / 2), 5, height / 2, color);
|
||||
tft.fillRect(left, bellow + 5, width / 2, 5, color);
|
||||
break;
|
||||
case Bobbycar_Side::BACK:
|
||||
espgui::tft.fillRect(left, bellow + 5, width, 5, color);
|
||||
tft.fillRect(left, bellow + 5, width, 5, color);
|
||||
break;
|
||||
case Bobbycar_Side::BACK_RIGHT:
|
||||
espgui::tft.fillRect(right + 5, above + 10 + (height / 2), 5, height / 2, color);
|
||||
espgui::tft.fillRect(middle, bellow + 5, width / 2, 5, color);
|
||||
tft.fillRect(right + 5, above + 10 + (height / 2), 5, height / 2, color);
|
||||
tft.fillRect(middle, bellow + 5, width / 2, 5, color);
|
||||
break;
|
||||
case Bobbycar_Side::RIGHT:
|
||||
espgui::tft.fillRect(right + 5, above + 10, 5, height, color);
|
||||
tft.fillRect(right + 5, above + 10, 5, height, color);
|
||||
break;
|
||||
case Bobbycar_Side::FRONT_RIGHT:
|
||||
espgui::tft.fillRect(right + 5, above + 10, 5, height / 2, color);
|
||||
espgui::tft.fillRect(middle, above, width / 2, 5, color);
|
||||
tft.fillRect(right + 5, above + 10, 5, height / 2, color);
|
||||
tft.fillRect(middle, above, width / 2, 5, color);
|
||||
break;
|
||||
}
|
||||
// espgui::tft.fillCircle(espgui::tft.width() / 2, 140, 100, TFT_BLACK);
|
||||
// tft.fillCircle(tft.width() / 2, 140, 100, TFT_BLACK);
|
||||
}
|
||||
|
@ -15,14 +15,14 @@ class LedstripColorsDisplay : public BobbyDisplayWithTitle
|
||||
using Base = BobbyDisplayWithTitle;
|
||||
|
||||
public:
|
||||
std::string text() const override;
|
||||
void initScreen() override;
|
||||
void redraw() override;
|
||||
std::string title() const override;
|
||||
void initScreen(espgui::TftInterface &tft) override;
|
||||
void redraw(espgui::TftInterface &tft) override;
|
||||
|
||||
void buttonPressed(espgui::Button button) override;
|
||||
|
||||
void drawColors();
|
||||
void drawSide(Bobbycar_Side side, unsigned int color);
|
||||
void drawColors(espgui::TftInterface &tft);
|
||||
void drawSide(espgui::TftInterface &tft, Bobbycar_Side side, unsigned int color);
|
||||
void clearSides();
|
||||
|
||||
private:
|
||||
|
@ -4,8 +4,8 @@
|
||||
#include <algorithm>
|
||||
|
||||
// 3rdparty lib includes
|
||||
#include <tftinstance.h>
|
||||
#include <screenmanager.h>
|
||||
#include <fontrenderer.h>
|
||||
|
||||
// local includes
|
||||
#include "globals.h"
|
||||
@ -53,39 +53,34 @@ void Lockscreen::start()
|
||||
}
|
||||
}
|
||||
|
||||
void Lockscreen::initScreen()
|
||||
void Lockscreen::initScreen(espgui::TftInterface &tft)
|
||||
{
|
||||
Base::initScreen();
|
||||
Base::initScreen(tft);
|
||||
|
||||
espgui::tft.fillScreen(TFT_BLACK);
|
||||
espgui::tft.setTextFont(4);
|
||||
espgui::tft.setTextColor(TFT_YELLOW);
|
||||
espgui::FontRenderer fontRenderer{tft};
|
||||
|
||||
espgui::tft.drawString("Lock vehicle", 5, 5);
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
|
||||
espgui::tft.fillRect(0, 34, espgui::tft.width(), 3, TFT_WHITE);
|
||||
fontRenderer.drawString("Lock vehicle", 5, 5, 4, espgui::TFT_YELLOW, espgui::TFT_BLACK);
|
||||
|
||||
espgui::tft.setTextColor(TFT_WHITE);
|
||||
espgui::tft.drawString("Enter code to unlock:", 0, 50);
|
||||
tft.fillRect(0, 34, tft.width(), 3, espgui::TFT_WHITE);
|
||||
|
||||
espgui::tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||
fontRenderer.drawString("Enter code to unlock:", 0, 50, 4, espgui::TFT_WHITE, espgui::TFT_BLACK);
|
||||
|
||||
for(int i = 0; i <= 3; i++)
|
||||
{
|
||||
drawRect(i, 3, TFT_WHITE);
|
||||
drawRect(i, 4, TFT_WHITE);
|
||||
drawRect(tft, i, 3, espgui::TFT_WHITE);
|
||||
drawRect(tft, i, 4, espgui::TFT_WHITE);
|
||||
}
|
||||
|
||||
for (auto &label : m_labels)
|
||||
label.start();
|
||||
label.start(tft);
|
||||
|
||||
espgui::tft.setTextFont(7);
|
||||
|
||||
drawRect(m_currentIndex, 1, TFT_YELLOW);
|
||||
drawRect(m_currentIndex, 2, TFT_YELLOW);
|
||||
drawRect(tft, m_currentIndex, 1, espgui::TFT_YELLOW);
|
||||
drawRect(tft, m_currentIndex, 2, espgui::TFT_YELLOW);
|
||||
|
||||
for(int i = 0; i <= m_currentIndex; i++)
|
||||
m_labels[i].redraw(std::to_string(m_numbers[i]));
|
||||
m_labels[i].redraw(tft, fontRenderer, std::to_string(m_numbers[i]), espgui::TFT_WHITE, espgui::TFT_BLACK, 7);
|
||||
}
|
||||
|
||||
void Lockscreen::update()
|
||||
@ -93,23 +88,20 @@ void Lockscreen::update()
|
||||
Base::update();
|
||||
}
|
||||
|
||||
void Lockscreen::redraw()
|
||||
void Lockscreen::redraw(espgui::TftInterface &tft)
|
||||
{
|
||||
Base::redraw();
|
||||
Base::redraw(tft);
|
||||
|
||||
if (m_pressed || m_back_pressed)
|
||||
{
|
||||
drawRect(m_currentIndex, 1, TFT_BLACK);
|
||||
drawRect(m_currentIndex, 2, TFT_BLACK);
|
||||
drawRect(tft, m_currentIndex, 1, TFT_BLACK);
|
||||
drawRect(tft, m_currentIndex, 2, TFT_BLACK);
|
||||
|
||||
if (!m_back_pressed && ++m_currentIndex>=4)
|
||||
{
|
||||
if (isValid1stPin(m_numbers))
|
||||
{
|
||||
if (!gas || !brems || *gas > 200.f || *brems > 200.f)
|
||||
espgui::switchScreen<PotisCalibrateDisplay>(true);
|
||||
else
|
||||
espgui::popScreen();
|
||||
espgui::popScreen();
|
||||
#ifdef LOCKSCREEN_PLUGIN
|
||||
#include LOCKSCREEN_PLUGIN
|
||||
LOCKSCREEN_PLUGIN_FIXES_1
|
||||
@ -118,10 +110,7 @@ LOCKSCREEN_PLUGIN_FIXES_1
|
||||
}
|
||||
else if(isValid2ndPin(m_numbers))
|
||||
{
|
||||
if (!gas || !brems || *gas > 200.f || *brems > 200.f)
|
||||
espgui::switchScreen<PotisCalibrateDisplay>(true);
|
||||
else
|
||||
espgui::popScreen();
|
||||
espgui::popScreen();
|
||||
#ifdef LOCKSCREEN_PLUGIN_FIXES_2
|
||||
LOCKSCREEN_PLUGIN_FIXES_2
|
||||
#endif
|
||||
@ -130,18 +119,19 @@ LOCKSCREEN_PLUGIN_FIXES_2
|
||||
|
||||
m_numbers = {0,0,0,0};
|
||||
m_currentIndex = 0;
|
||||
std::for_each(std::begin(m_labels) + 1, std::end(m_labels), [](auto &label){ label.redraw("0"); });
|
||||
std::for_each(std::begin(m_labels) + 1, std::end(m_labels),
|
||||
[&tft](auto &label){ label.redraw(tft, "0"); });
|
||||
}
|
||||
else if (m_back_pressed && m_currentIndex < 3)
|
||||
{
|
||||
drawRect(m_currentIndex+1, 1, TFT_BLACK);
|
||||
drawRect(m_currentIndex+1, 2, TFT_BLACK);
|
||||
drawRect(tft, m_currentIndex+1, 1, TFT_BLACK);
|
||||
drawRect(tft, m_currentIndex+1, 2, TFT_BLACK);
|
||||
}
|
||||
|
||||
m_labels[m_currentIndex].redraw(std::to_string(m_numbers[m_currentIndex]));
|
||||
m_labels[m_currentIndex].redraw(tft, std::to_string(m_numbers[m_currentIndex]));
|
||||
|
||||
drawRect(m_currentIndex, 1, TFT_YELLOW);
|
||||
drawRect(m_currentIndex, 2, TFT_YELLOW);
|
||||
drawRect(tft, m_currentIndex, 1, TFT_YELLOW);
|
||||
drawRect(tft, m_currentIndex, 2, TFT_YELLOW);
|
||||
|
||||
m_pressed = false;
|
||||
m_back_pressed = false;
|
||||
@ -211,7 +201,7 @@ void Lockscreen::buttonPressed(espgui::Button button)
|
||||
}
|
||||
}
|
||||
|
||||
void Lockscreen::drawRect(int index, int offset, uint32_t color) const
|
||||
void Lockscreen::drawRect(espgui::TftInterface &tft, int index, int offset, uint32_t color) const
|
||||
{
|
||||
espgui::tft.drawRect(m_labels[index].x()-offset, m_labels[index].y()-offset, boxWidth+(offset*2), boxHeight+(offset*2), color);
|
||||
tft.drawRect(m_labels[index].x()-offset, m_labels[index].y()-offset, boxWidth+(offset*2), boxHeight+(offset*2), color);
|
||||
}
|
||||
|
@ -24,15 +24,15 @@ class Lockscreen : public BobbyDisplay
|
||||
|
||||
public:
|
||||
void start() override;
|
||||
void initScreen() override;
|
||||
void initScreen(espgui::TftInterface &tft) override;
|
||||
void update() override;
|
||||
void redraw() override;
|
||||
void redraw(espgui::TftInterface &tft) override;
|
||||
void stop() override;
|
||||
|
||||
void buttonPressed(espgui::Button button) override;
|
||||
|
||||
private:
|
||||
void drawRect(int index, int offset, uint32_t color) const;
|
||||
void drawRect(espgui::TftInterface &tft, int index, int offset, uint32_t color) const;
|
||||
|
||||
std::array<espgui::Label, 4> m_labels {{
|
||||
espgui::Label{spacing, 100}, // boxWidth, boxHeight
|
||||
|
@ -1,8 +1,8 @@
|
||||
#include "menudisplaywithtime.h"
|
||||
|
||||
// 3rdparty lib includes
|
||||
#include <tftinstance.h>
|
||||
#include <fmt/core.h>
|
||||
#include <fontrenderer.h>
|
||||
|
||||
// local includes
|
||||
#include "utils.h"
|
||||
@ -10,17 +10,16 @@
|
||||
using namespace espgui;
|
||||
|
||||
namespace bobbygui {
|
||||
void MenuDisplayWithTime::start()
|
||||
void MenuDisplayWithTime::initScreen(espgui::TftInterface &tft)
|
||||
{
|
||||
Base::start();
|
||||
m_label_currentTime.start();
|
||||
Base::initScreen(tft);
|
||||
m_label_currentTime.start(tft);
|
||||
}
|
||||
|
||||
void MenuDisplayWithTime::redraw()
|
||||
void MenuDisplayWithTime::redraw(espgui::TftInterface &tft)
|
||||
{
|
||||
Base::redraw();
|
||||
tft.setTextFont(use_big_font() ? 4 : 2);
|
||||
m_label_currentTime.redraw(fmt::format("&7Time: {}", local_clock_string()));
|
||||
Base::redraw(tft);
|
||||
m_label_currentTime.redraw(tft, fmt::format("&7Time: {}", local_clock_string()), espgui::TFT_WHITE, espgui::TFT_BLACK, use_big_font() ? 4 : 2);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -10,8 +10,8 @@ class MenuDisplayWithTime :
|
||||
using Base = BobbyMenuDisplay;
|
||||
|
||||
public:
|
||||
void start() override;
|
||||
void redraw() override;
|
||||
void initScreen(espgui::TftInterface &tft) override;
|
||||
void redraw(espgui::TftInterface &tft) override;
|
||||
espgui::Label m_label_currentTime{145, 6};
|
||||
|
||||
private:
|
||||
|
@ -45,6 +45,7 @@ AboutMenu::AboutMenu()
|
||||
constructMenuItem<makeComponent<MenuItem, HeapLargest32Text, StaticFont<2>, DisabledColor, DummyAction>>();
|
||||
#endif
|
||||
constructMenuItem<makeComponent<MenuItem, EspChipRevisionText, StaticFont<2>, DisabledColor, DummyAction>>();
|
||||
constructMenuItem<makeComponent<MenuItem, EspChipModelText, StaticFont<2>, DisabledColor, DummyAction>>();
|
||||
constructMenuItem<makeComponent<MenuItem, EspCpuMinFreqMHzText, StaticFont<2>, DisabledColor, DummyAction>>();
|
||||
constructMenuItem<makeComponent<MenuItem, EspCpuMaxFreqMHzText, StaticFont<2>, DisabledColor, DummyAction>>();
|
||||
constructMenuItem<makeComponent<MenuItem, EspSdkVersionText, StaticFont<2>, DisabledColor, DummyAction>>();
|
||||
@ -57,7 +58,7 @@ AboutMenu::AboutMenu()
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, PopScreenAction, StaticMenuItemIcon<&espgui::icons::back>>>();
|
||||
}
|
||||
|
||||
std::string AboutMenu::text() const
|
||||
std::string AboutMenu::title() const
|
||||
{
|
||||
return TEXT_ABOUT;
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ class AboutMenu : public BobbyMenuDisplay
|
||||
public:
|
||||
AboutMenu();
|
||||
|
||||
std::string text() const override;
|
||||
std::string title() const override;
|
||||
|
||||
void back() override;
|
||||
};
|
||||
|
@ -84,7 +84,7 @@ BatteryDebugMenu::BatteryDebugMenu()
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, PopScreenAction, StaticMenuItemIcon<&espgui::icons::back>>>();
|
||||
}
|
||||
|
||||
std::string BatteryDebugMenu::text() const
|
||||
std::string BatteryDebugMenu::title() const
|
||||
{
|
||||
return TEXT_BATTERYDEBUG;
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ class BatteryDebugMenu : public BobbyMenuDisplay
|
||||
public:
|
||||
BatteryDebugMenu();
|
||||
|
||||
std::string text() const override;
|
||||
std::string title() const override;
|
||||
|
||||
void back() override;
|
||||
};
|
||||
|
@ -9,8 +9,7 @@
|
||||
#include <changevaluedisplay.h>
|
||||
#include <textwithvaluehelper.h>
|
||||
#include <fmt/core.h>
|
||||
|
||||
#include <tftinstance.h>
|
||||
#include <tftcolors.h>
|
||||
|
||||
// Local includes
|
||||
#include "utils.h"
|
||||
@ -54,7 +53,7 @@ class WhStatisticsText : public virtual espgui::TextInterface { public: std::str
|
||||
|
||||
using BatteryCellSeriesChangeScreen = espgui::makeComponent<
|
||||
BobbyChangeValueDisplay<uint8_t>,
|
||||
espgui::StaticText<TEXT_CELL_SERIES>,
|
||||
espgui::StaticTitle<TEXT_CELL_SERIES>,
|
||||
BatterySeriesCellsAccessor,
|
||||
espgui::ConfirmActionInterface<espgui::PopScreenAction>,
|
||||
espgui::BackActionInterface<espgui::PopScreenAction>
|
||||
@ -62,7 +61,7 @@ using BatteryCellSeriesChangeScreen = espgui::makeComponent<
|
||||
|
||||
using BatteryCellParallelChangeScreen = espgui::makeComponent<
|
||||
BobbyChangeValueDisplay<uint8_t>,
|
||||
espgui::StaticText<TEXT_CELL_PARALLEL>,
|
||||
espgui::StaticTitle<TEXT_CELL_PARALLEL>,
|
||||
BatteryParallelCellsAccessor,
|
||||
espgui::ConfirmActionInterface<espgui::PopScreenAction>,
|
||||
espgui::BackActionInterface<espgui::PopScreenAction>
|
||||
@ -70,7 +69,7 @@ using BatteryCellParallelChangeScreen = espgui::makeComponent<
|
||||
|
||||
using BatteryWHperKMChangeScreen = espgui::makeComponent<
|
||||
BobbyChangeValueDisplay<uint16_t>,
|
||||
espgui::StaticText<TEXT_BATTERY_WHKM>,
|
||||
espgui::StaticTitle<TEXT_BATTERY_WHKM>,
|
||||
BatteryWHperKMAccessor,
|
||||
espgui::ConfirmActionInterface<espgui::PopScreenAction>,
|
||||
espgui::BackActionInterface<espgui::PopScreenAction>
|
||||
@ -88,22 +87,21 @@ BatteryMenu::BatteryMenu()
|
||||
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_BATTERY_WHKM, BatteryWHperKMAccessor>, PushScreenAction<BatteryWHperKMChangeScreen>>>();
|
||||
constructMenuItem<PushScreenTypeSafeChangeMenuItem<BatteryCellType, TEXT_SELECT_CELL_TYPE>>(&configs.battery.cellType);
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SHOW_BATTERY_GRAPH>, PushScreenAction<BatteryGraphDisplay>, StaticMenuItemIcon<&bobbyicons::graph>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, EmptyText, DummyAction>>();
|
||||
constructMenuItem<makeComponent<MenuItem, WhStatisticsText, DummyAction>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BATTERY_CALIBRATE>, PushScreenAction<CalibrateVoltageDisplay>, StaticMenuItemIcon<&bobbyicons::settings>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, PopScreenAction, StaticMenuItemIcon<&espgui::icons::back>>>();
|
||||
}
|
||||
|
||||
std::string BatteryMenu::text() const
|
||||
std::string BatteryMenu::title() const
|
||||
{
|
||||
return TEXT_BATTERY;
|
||||
}
|
||||
|
||||
void BatteryMenu::initScreen()
|
||||
void BatteryMenu::initScreen(espgui::TftInterface &tft)
|
||||
{
|
||||
Base::initScreen();
|
||||
m_batPercentBootLabel.start();
|
||||
m_batPercentNowLabel.start();
|
||||
Base::initScreen(tft);
|
||||
m_batPercentBootLabel.start(tft);
|
||||
m_batPercentNowLabel.start(tft);
|
||||
}
|
||||
|
||||
void BatteryMenu::start()
|
||||
@ -112,9 +110,9 @@ void BatteryMenu::start()
|
||||
m_doubleProgressBarBatPercentage.start();
|
||||
}
|
||||
|
||||
void BatteryMenu::redraw()
|
||||
void BatteryMenu::redraw(espgui::TftInterface &tft)
|
||||
{
|
||||
Base::redraw();
|
||||
Base::redraw(tft);
|
||||
|
||||
if (const auto avgVoltage = controllers.getAvgVoltage(); avgVoltage)
|
||||
{
|
||||
@ -124,11 +122,11 @@ void BatteryMenu::redraw()
|
||||
m_doubleProgressBarBatPercentage.redraw(batPercent, *battery::bootBatPercentage);
|
||||
|
||||
tft.setTextFont(2);
|
||||
tft.setTextColor(TFT_DARKGREY, TFT_BLACK);
|
||||
tft.setTextColor(espgui::TFT_DARKGREY, espgui::TFT_BLACK);
|
||||
m_batPercentNowLabel.redraw(fmt::format("{:.2f} %", batPercent));
|
||||
m_batPercentBootLabel.redraw(fmt::format("{:.2f} %", *battery::bootBatPercentage));
|
||||
tft.setTextFont(4);
|
||||
tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||
tft.setTextColor(espgui::TFT_WHITE, espgui::TFT_BLACK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,11 +12,11 @@ class BatteryMenu : public BobbyMenuDisplay
|
||||
public:
|
||||
BatteryMenu();
|
||||
|
||||
std::string text() const override;
|
||||
std::string title() const override;
|
||||
|
||||
void initScreen() override;
|
||||
void initScreen(espgui::TftInterface &tft) override;
|
||||
void start() override;
|
||||
void redraw() override;
|
||||
void redraw(espgui::TftInterface &tft) override;
|
||||
void back() override;
|
||||
|
||||
private:
|
||||
|
@ -26,7 +26,7 @@ constexpr char TEXT_BACK[] = "Back";
|
||||
|
||||
using ApSsidChangeScreen = espgui::makeComponent<
|
||||
BobbyChangeValueDisplay<std::string>,
|
||||
espgui::StaticText<TEXT_NAME>,
|
||||
espgui::StaticTitle<TEXT_NAME>,
|
||||
BluetoothNameAccessor,
|
||||
espgui::ConfirmActionInterface<espgui::PopScreenAction>,
|
||||
espgui::BackActionInterface<espgui::PopScreenAction>
|
||||
@ -44,7 +44,7 @@ BleSettingsMenu::BleSettingsMenu()
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, PopScreenAction, StaticMenuItemIcon<&espgui::icons::back>>>();
|
||||
}
|
||||
|
||||
std::string BleSettingsMenu::text() const
|
||||
std::string BleSettingsMenu::title() const
|
||||
{
|
||||
return TEXT_BLESETTINGS;
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ class BleSettingsMenu : public BobbyMenuDisplay
|
||||
public:
|
||||
BleSettingsMenu();
|
||||
|
||||
std::string text() const override;
|
||||
std::string title() const override;
|
||||
|
||||
void back() override;
|
||||
};
|
||||
|
@ -11,17 +11,15 @@
|
||||
|
||||
// local includes
|
||||
#include "accessors/settingsaccessors.h"
|
||||
#include "actions/setupactions.h"
|
||||
#include "bobbycheckbox.h"
|
||||
#include "displays/bobbychangevaluedisplay.h"
|
||||
#include "displays/buttoncalibratedisplay.h"
|
||||
#include "displays/menus/extrabuttoncalibratemenu.h"
|
||||
#include "displays/menus/lockscreensettingsmenu.h"
|
||||
#include "displays/menus/settingsmenu.h"
|
||||
#include "displays/menus/setupquickactionsmenu.h"
|
||||
#include "displays/menus/timersmenu.h"
|
||||
#include "displays/potiscalibratedisplay.h"
|
||||
#include "icons/lock.h"
|
||||
#include "utils.h"
|
||||
|
||||
#ifdef FEATURE_JOYSTICK
|
||||
#include "displays/joystickdebugdisplay.h"
|
||||
@ -78,35 +76,35 @@ public:
|
||||
|
||||
using SampleCountChangeScreen = espgui::makeComponent<
|
||||
BobbyChangeValueDisplay<int16_t>,
|
||||
espgui::StaticText<TEXT_SAMPLECOUNT>,
|
||||
espgui::StaticTitle<TEXT_SAMPLECOUNT>,
|
||||
SampleCountAccessor,
|
||||
espgui::ConfirmActionInterface<espgui::PopScreenAction>,
|
||||
espgui::BackActionInterface<espgui::PopScreenAction>
|
||||
>;
|
||||
using GasMinChangeScreen = espgui::makeComponent<
|
||||
BobbyChangeValueDisplay<int16_t>,
|
||||
espgui::StaticText<TEXT_GASMIN>,
|
||||
espgui::StaticTitle<TEXT_GASMIN>,
|
||||
GasMinAccessor,
|
||||
espgui::ConfirmActionInterface<espgui::PopScreenAction>,
|
||||
espgui::BackActionInterface<espgui::PopScreenAction>
|
||||
>;
|
||||
using GasMaxChangeScreen = espgui::makeComponent<
|
||||
BobbyChangeValueDisplay<int16_t>,
|
||||
espgui::StaticText<TEXT_GASMAX>,
|
||||
espgui::StaticTitle<TEXT_GASMAX>,
|
||||
GasMaxAccessor,
|
||||
espgui::ConfirmActionInterface<espgui::PopScreenAction>,
|
||||
espgui::BackActionInterface<espgui::PopScreenAction>
|
||||
>;
|
||||
using BremsMinChangeScreen = espgui::makeComponent<
|
||||
BobbyChangeValueDisplay<int16_t>,
|
||||
espgui::StaticText<TEXT_BREMSMIN>,
|
||||
espgui::StaticTitle<TEXT_BREMSMIN>,
|
||||
BremsMinAccessor,
|
||||
espgui::ConfirmActionInterface<espgui::PopScreenAction>,
|
||||
espgui::BackActionInterface<espgui::PopScreenAction>
|
||||
>;
|
||||
using BremsMaxChangeScreen = espgui::makeComponent<
|
||||
BobbyChangeValueDisplay<int16_t>,
|
||||
espgui::StaticText<TEXT_BREMSMAX>,
|
||||
espgui::StaticTitle<TEXT_BREMSMAX>,
|
||||
BremsMaxAccessor,
|
||||
espgui::ConfirmActionInterface<espgui::PopScreenAction>,
|
||||
espgui::BackActionInterface<espgui::PopScreenAction>
|
||||
@ -116,14 +114,14 @@ using BremsMaxChangeScreen = espgui::makeComponent<
|
||||
#if defined(FEATURE_DPAD) || defined(FEATURE_DPAD_3WIRESW) || defined(FEATURE_DPAD_5WIRESW) || defined(FEATURE_DPAD_5WIRESW_2OUT) || defined (FEATURE_DPAD_6WIRESW) || defined (DPAD_BOARDCOMPUTER_V2)
|
||||
using DPadDebounceChangeScreen = espgui::makeComponent<
|
||||
BobbyChangeValueDisplay<uint8_t>,
|
||||
espgui::StaticText<TEXT_DPADDEBOUNCE>,
|
||||
espgui::StaticTitle<TEXT_DPADDEBOUNCE>,
|
||||
DPadDebounceAccessor,
|
||||
espgui::ConfirmActionInterface<espgui::PopScreenAction>,
|
||||
espgui::BackActionInterface<espgui::PopScreenAction>
|
||||
>;
|
||||
using ButtonDelayChangeScreen = espgui::makeComponent<
|
||||
BobbyChangeValueDisplay<uint16_t>,
|
||||
espgui::StaticText<TEXT_BUTTONDELAY>,
|
||||
espgui::StaticTitle<TEXT_BUTTONDELAY>,
|
||||
ButtonDelayAccessor,
|
||||
espgui::ConfirmActionInterface<espgui::PopScreenAction>,
|
||||
espgui::BackActionInterface<espgui::PopScreenAction>
|
||||
@ -146,42 +144,42 @@ public:
|
||||
|
||||
using GametrakXMinChangeScreen = espgui::makeComponent<
|
||||
BobbyChangeValueDisplay<int16_t>,
|
||||
espgui::StaticText<TEXT_SETGAMETRAKXMIN>,
|
||||
espgui::StaticTitle<TEXT_SETGAMETRAKXMIN>,
|
||||
GametrakXMinAccessor,
|
||||
espgui::ConfirmActionInterface<espgui::PopScreenAction>,
|
||||
espgui::BackActionInterface<espgui::PopScreenAction>
|
||||
>;
|
||||
using GametrakXMaxChangeScreen = espgui::makeComponent<
|
||||
BobbyChangeValueDisplay<int16_t>,
|
||||
espgui::StaticText<TEXT_SETGAMETRAKXMAX>,
|
||||
espgui::StaticTitle<TEXT_SETGAMETRAKXMAX>,
|
||||
GametrakXMaxAccessor,
|
||||
espgui::ConfirmActionInterface<espgui::PopScreenAction>,
|
||||
espgui::BackActionInterface<espgui::PopScreenAction>
|
||||
>;
|
||||
using GametrakYMinChangeScreen = espgui::makeComponent<
|
||||
BobbyChangeValueDisplay<int16_t>,
|
||||
espgui::StaticText<TEXT_SETGAMETRAKYMIN>,
|
||||
espgui::StaticTitle<TEXT_SETGAMETRAKYMIN>,
|
||||
GametrakYMinAccessor,
|
||||
espgui::ConfirmActionInterface<espgui::PopScreenAction>,
|
||||
espgui::BackActionInterface<espgui::PopScreenAction>
|
||||
>;
|
||||
using GametrakYMaxChangeScreen = espgui::makeComponent<
|
||||
BobbyChangeValueDisplay<int16_t>,
|
||||
espgui::StaticText<TEXT_SETGAMETRAKYMAX>,
|
||||
espgui::StaticTitle<TEXT_SETGAMETRAKYMAX>,
|
||||
GametrakYMaxAccessor,
|
||||
espgui::ConfirmActionInterface<espgui::PopScreenAction>,
|
||||
espgui::BackActionInterface<espgui::PopScreenAction>
|
||||
>;
|
||||
using GametrakDistMinChangeScreen = espgui::makeComponent<
|
||||
BobbyChangeValueDisplay<int16_t>,
|
||||
espgui::StaticText<TEXT_SETGAMETRAKDISTMIN>,
|
||||
espgui::StaticTitle<TEXT_SETGAMETRAKDISTMIN>,
|
||||
GametrakDistMinAccessor,
|
||||
espgui::ConfirmActionInterface<espgui::PopScreenAction>,
|
||||
espgui::BackActionInterface<espgui::PopScreenAction>
|
||||
>;
|
||||
using GametrakDistMaxChangeScreen = espgui::makeComponent<
|
||||
BobbyChangeValueDisplay<int16_t>,
|
||||
espgui::StaticText<TEXT_SETGAMETRAKDISTMAX>,
|
||||
espgui::StaticTitle<TEXT_SETGAMETRAKDISTMAX>,
|
||||
GametrakDistMaxAccessor,
|
||||
espgui::ConfirmActionInterface<espgui::PopScreenAction>,
|
||||
espgui::BackActionInterface<espgui::PopScreenAction>
|
||||
@ -194,12 +192,12 @@ using namespace espgui;
|
||||
BoardcomputerHardwareSettingsMenu::BoardcomputerHardwareSettingsMenu()
|
||||
{
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LOCKSCREENSETTINGS>, PushScreenAction<LockscreenSettingsMenu>, StaticMenuItemIcon<&bobbyicons::lock>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BUTTONCALIBRATE>, PushScreenAction<ButtonCalibrateDisplay>>>();
|
||||
constructMenuItem<makeComponentArgs<MenuItem, PushButtonCalibrateDisplayAction, StaticText<TEXT_BUTTONCALIBRATE>>>(true);
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_EXTRABUTTONCALIBRATE>, PushScreenAction<ExtraButtonCalibrateMenu>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_QUICKACTIONS>, PushScreenAction<SetupQuickActionsMenu>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, GasText, DisabledColor, StaticFont<2>, DummyAction>>();
|
||||
constructMenuItem<makeComponent<MenuItem, BremsText, DisabledColor, StaticFont<2>, DummyAction>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_POTISCALIBRATE>, PushScreenAction<PotisCalibrateDisplay>>>();
|
||||
constructMenuItem<makeComponentArgs<MenuItem, PushPotiCalibrateDisplayAction, StaticText<TEXT_POTISCALIBRATE>>>(true);
|
||||
#ifdef FEATURE_JOYSTICK
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_JOYSTICK>, PushScreenAction<JoystickDebugDisplay>>>();
|
||||
#endif
|
||||
@ -231,12 +229,12 @@ BoardcomputerHardwareSettingsMenu::BoardcomputerHardwareSettingsMenu()
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, PopScreenAction, StaticMenuItemIcon<&icons::back>>>();
|
||||
}
|
||||
|
||||
std::string BoardcomputerHardwareSettingsMenu::text() const
|
||||
std::string BoardcomputerHardwareSettingsMenu::title() const
|
||||
{
|
||||
return TEXT_BOARDCOMPUTERHARDWARESETTINGS;
|
||||
}
|
||||
|
||||
void BoardcomputerHardwareSettingsMenu::back()
|
||||
{
|
||||
switchScreen<SettingsMenu>();
|
||||
popScreen();
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ class BoardcomputerHardwareSettingsMenu : public BobbyMenuDisplay
|
||||
public:
|
||||
BoardcomputerHardwareSettingsMenu();
|
||||
|
||||
std::string text() const override;
|
||||
std::string title() const override;
|
||||
|
||||
void back() override;
|
||||
};
|
||||
|
@ -31,7 +31,7 @@ constexpr char TEXT_BACK[] = "Back";
|
||||
struct FrontFreqAccessor : public espgui::RefAccessor<uint8_t> { uint8_t &getRef() const override { return controllers.front.command.buzzer.freq; } };
|
||||
using FrontFreqChangeScreen = espgui::makeComponent<
|
||||
BobbyChangeValueDisplay<uint8_t>,
|
||||
espgui::StaticText<TEXT_FRONTFREQ>,
|
||||
espgui::StaticTitle<TEXT_FRONTFREQ>,
|
||||
FrontFreqAccessor,
|
||||
espgui::ConfirmActionInterface<espgui::PopScreenAction>,
|
||||
espgui::BackActionInterface<espgui::PopScreenAction>
|
||||
@ -40,7 +40,7 @@ using FrontFreqChangeScreen = espgui::makeComponent<
|
||||
struct FrontPatternAccessor : public espgui::RefAccessor<uint8_t> { uint8_t &getRef() const override { return controllers.front.command.buzzer.pattern; } };
|
||||
using FrontPatternChangeScreen = espgui::makeComponent<
|
||||
BobbyChangeValueDisplay<uint8_t>,
|
||||
espgui::StaticText<TEXT_FRONTPATTERN>,
|
||||
espgui::StaticTitle<TEXT_FRONTPATTERN>,
|
||||
FrontPatternAccessor,
|
||||
espgui::ConfirmActionInterface<espgui::PopScreenAction>,
|
||||
espgui::BackActionInterface<espgui::PopScreenAction>
|
||||
@ -49,7 +49,7 @@ using FrontPatternChangeScreen = espgui::makeComponent<
|
||||
struct BackFreqAccessor : public espgui::RefAccessor<uint8_t> { uint8_t &getRef() const override { return controllers.back.command.buzzer.freq; } };
|
||||
using BackFreqChangeScreen = espgui::makeComponent<
|
||||
BobbyChangeValueDisplay<uint8_t>,
|
||||
espgui::StaticText<TEXT_BACKFREQ>,
|
||||
espgui::StaticTitle<TEXT_BACKFREQ>,
|
||||
BackFreqAccessor,
|
||||
espgui::ConfirmActionInterface<espgui::PopScreenAction>,
|
||||
espgui::BackActionInterface<espgui::PopScreenAction>
|
||||
@ -58,7 +58,7 @@ using BackFreqChangeScreen = espgui::makeComponent<
|
||||
struct BackPatternAccessor : public espgui::RefAccessor<uint8_t> { uint8_t &getRef() const override { return controllers.back.command.buzzer.pattern; } };
|
||||
using BackPatternChangeScreen = espgui::makeComponent<
|
||||
BobbyChangeValueDisplay<uint8_t>,
|
||||
espgui::StaticText<TEXT_BACKPATTERN>,
|
||||
espgui::StaticTitle<TEXT_BACKPATTERN>,
|
||||
BackPatternAccessor,
|
||||
espgui::ConfirmActionInterface<espgui::PopScreenAction>,
|
||||
espgui::BackActionInterface<espgui::PopScreenAction>
|
||||
@ -66,28 +66,28 @@ using BackPatternChangeScreen = espgui::makeComponent<
|
||||
|
||||
using ReverseBeepFreq0ChangeScreen = espgui::makeComponent<
|
||||
BobbyChangeValueDisplay<uint8_t>,
|
||||
espgui::StaticText<TEXT_REVERSEBEEPFREQ0>,
|
||||
espgui::StaticTitle<TEXT_REVERSEBEEPFREQ0>,
|
||||
ReverseBeepFreq0Accessor,
|
||||
espgui::ConfirmActionInterface<espgui::PopScreenAction>,
|
||||
espgui::BackActionInterface<espgui::PopScreenAction>
|
||||
>;
|
||||
using ReverseBeepFreq1ChangeScreen = espgui::makeComponent<
|
||||
BobbyChangeValueDisplay<uint8_t>,
|
||||
espgui::StaticText<TEXT_REVERSEBEEPFREQ1>,
|
||||
espgui::StaticTitle<TEXT_REVERSEBEEPFREQ1>,
|
||||
ReverseBeepFreq1Accessor,
|
||||
espgui::ConfirmActionInterface<espgui::PopScreenAction>,
|
||||
espgui::BackActionInterface<espgui::PopScreenAction>
|
||||
>;
|
||||
using ReverseBeepDuration0ChangeScreen = espgui::makeComponent<
|
||||
BobbyChangeValueDisplay<int16_t>,
|
||||
espgui::StaticText<TEXT_REVERSEBEEPDURATION0>,
|
||||
espgui::StaticTitle<TEXT_REVERSEBEEPDURATION0>,
|
||||
ReverseBeepDuration0Accessor,
|
||||
espgui::ConfirmActionInterface<espgui::PopScreenAction>,
|
||||
espgui::BackActionInterface<espgui::PopScreenAction>
|
||||
>;
|
||||
using ReverseBeepDuration1ChangeScreen = espgui::makeComponent<
|
||||
BobbyChangeValueDisplay<int16_t>,
|
||||
espgui::StaticText<TEXT_REVERSEBEEPDURATION1>,
|
||||
espgui::StaticTitle<TEXT_REVERSEBEEPDURATION1>,
|
||||
ReverseBeepDuration1Accessor,
|
||||
espgui::ConfirmActionInterface<espgui::PopScreenAction>,
|
||||
espgui::BackActionInterface<espgui::PopScreenAction>
|
||||
@ -110,7 +110,7 @@ BuzzerMenu::BuzzerMenu()
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, PopScreenAction, StaticMenuItemIcon<&espgui::icons::back>>>();
|
||||
}
|
||||
|
||||
std::string BuzzerMenu::text() const
|
||||
std::string BuzzerMenu::title() const
|
||||
{
|
||||
return TEXT_BUZZER;
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ class BuzzerMenu : public BobbyMenuDisplay
|
||||
public:
|
||||
BuzzerMenu();
|
||||
|
||||
std::string text() const override;
|
||||
std::string title() const override;
|
||||
|
||||
void back() override;
|
||||
};
|
||||
|
@ -49,7 +49,7 @@ std::string toString(twai_state_t val)
|
||||
class CanStatusText : public virtual espgui::TextInterface
|
||||
{
|
||||
public:
|
||||
explicit CanStatusText(const tl::expected<twai_status_info_t, esp_err_t> &last_can_status_info) :
|
||||
explicit CanStatusText(const std::expected<twai_status_info_t, esp_err_t> &last_can_status_info) :
|
||||
m_last_can_status_info{last_can_status_info}
|
||||
{
|
||||
}
|
||||
@ -67,7 +67,7 @@ protected:
|
||||
virtual std::string canStatusText(const twai_status_info_t &can_status_info) const = 0;
|
||||
|
||||
private:
|
||||
const tl::expected<twai_status_info_t, esp_err_t> &m_last_can_status_info;
|
||||
const std::expected<twai_status_info_t, esp_err_t> &m_last_can_status_info;
|
||||
};
|
||||
|
||||
class CanStatusStateText : public CanStatusText
|
||||
@ -260,7 +260,7 @@ CanDebugMenu::CanDebugMenu()
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, PopScreenAction, StaticMenuItemIcon<&espgui::icons::back>>>();
|
||||
}
|
||||
|
||||
std::string CanDebugMenu::text() const
|
||||
std::string CanDebugMenu::title() const
|
||||
{
|
||||
return TEXT_CANDEBUG;
|
||||
}
|
||||
@ -273,7 +273,7 @@ void CanDebugMenu::update()
|
||||
if (const auto result = twai_get_status_info(&status_info); result != ESP_OK)
|
||||
{
|
||||
ESP_LOGE(TAG, "twai_get_status_info() failed with %s", esp_err_to_name(result));
|
||||
m_last_can_status_info = tl::make_unexpected(result);
|
||||
m_last_can_status_info = std::unexpected(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1,16 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include "sdkconfig.h"
|
||||
|
||||
// local includes
|
||||
#include "displays/bobbymenudisplay.h"
|
||||
|
||||
#ifdef FEATURE_CAN
|
||||
|
||||
// system includes
|
||||
#include <expected>
|
||||
|
||||
// esp-idf includes
|
||||
#include <driver/twai.h>
|
||||
|
||||
// 3rdparty lib includes
|
||||
#include <tl/expected.hpp>
|
||||
|
||||
class CanDebugMenu : public BobbyMenuDisplay
|
||||
{
|
||||
using Base = BobbyMenuDisplay;
|
||||
@ -18,14 +20,14 @@ class CanDebugMenu : public BobbyMenuDisplay
|
||||
public:
|
||||
CanDebugMenu();
|
||||
|
||||
std::string text() const override;
|
||||
std::string title() const override;
|
||||
|
||||
void update() override;
|
||||
|
||||
void back() override;
|
||||
|
||||
private:
|
||||
tl::expected<twai_status_info_t, esp_err_t> m_last_can_status_info;
|
||||
std::expected<twai_status_info_t, esp_err_t> m_last_can_status_info;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -32,7 +32,7 @@ constexpr char TEXT_BACK[] = "Back";
|
||||
|
||||
using CloudURLChangeScreen = espgui::makeComponent<
|
||||
BobbyChangeValueDisplay<std::string>,
|
||||
espgui::StaticText<TEXT_CLOUDURL>,
|
||||
espgui::StaticTitle<TEXT_CLOUDURL>,
|
||||
CloudURLAccessor,
|
||||
espgui::ConfirmActionInterface<espgui::PopScreenAction>,
|
||||
espgui::BackActionInterface<espgui::PopScreenAction>
|
||||
@ -40,7 +40,7 @@ using CloudURLChangeScreen = espgui::makeComponent<
|
||||
|
||||
using CloudKeyChangeScreen = espgui::makeComponent<
|
||||
BobbyChangeValueDisplay<std::string>,
|
||||
espgui::StaticText<TEXT_CLOUDKEY>,
|
||||
espgui::StaticTitle<TEXT_CLOUDKEY>,
|
||||
CloudKeyAccessor,
|
||||
espgui::ConfirmActionInterface<espgui::PopScreenAction>,
|
||||
espgui::BackActionInterface<espgui::PopScreenAction>
|
||||
@ -48,7 +48,7 @@ using CloudKeyChangeScreen = espgui::makeComponent<
|
||||
|
||||
using CloudTransmitTimeoutChangeScreen = espgui::makeComponent<
|
||||
BobbyChangeValueDisplay<int16_t>,
|
||||
espgui::StaticText<TEXT_CLOUDTRANSMITTIMEOUT>,
|
||||
espgui::StaticTitle<TEXT_CLOUDTRANSMITTIMEOUT>,
|
||||
CloudTransmitTimeoutAccessor,
|
||||
espgui::ConfirmActionInterface<espgui::PopScreenAction>,
|
||||
espgui::BackActionInterface<espgui::PopScreenAction>
|
||||
@ -65,7 +65,7 @@ public:
|
||||
|
||||
using CloudCollectRateChangeDisplay = espgui::makeComponent<
|
||||
BobbyChangeValueDisplay<int16_t>,
|
||||
espgui::StaticText<TEXT_CLOUDCOLLECTRATE>,
|
||||
espgui::StaticTitle<TEXT_CLOUDCOLLECTRATE>,
|
||||
CloudCollectRateAccessor,
|
||||
espgui::ConfirmActionInterface<espgui::PopScreenAction>,
|
||||
espgui::BackActionInterface<espgui::PopScreenAction>
|
||||
@ -73,7 +73,7 @@ using CloudCollectRateChangeDisplay = espgui::makeComponent<
|
||||
|
||||
using CloudSendRateChangeDisplay = espgui::makeComponent<
|
||||
BobbyChangeValueDisplay<int16_t>,
|
||||
espgui::StaticText<TEXT_CLOUDSENDRATE>,
|
||||
espgui::StaticTitle<TEXT_CLOUDSENDRATE>,
|
||||
CloudSendRateAccessor,
|
||||
espgui::ConfirmActionInterface<espgui::PopScreenAction>,
|
||||
espgui::BackActionInterface<espgui::PopScreenAction>
|
||||
@ -98,7 +98,7 @@ CloudSettingsMenu::CloudSettingsMenu()
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, PushScreenAction<SettingsMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
|
||||
}
|
||||
|
||||
std::string CloudSettingsMenu::text() const
|
||||
std::string CloudSettingsMenu::title() const
|
||||
{
|
||||
return TEXT_CLOUDSETTINGS;
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ class CloudSettingsMenu : public BobbyMenuDisplay
|
||||
public:
|
||||
CloudSettingsMenu();
|
||||
|
||||
std::string text() const override;
|
||||
std::string title() const override;
|
||||
|
||||
void back() override;
|
||||
};
|
||||
|
@ -39,14 +39,14 @@ constexpr char TEXT_BACK[] = "Back";
|
||||
|
||||
using WheelDiameterMmChangeScreen = espgui::makeComponent<
|
||||
BobbyChangeValueDisplay<int16_t>,
|
||||
espgui::StaticText<TEXT_WHEELDIAMETERMM>,
|
||||
espgui::StaticTitle<TEXT_WHEELDIAMETERMM>,
|
||||
WheelDiameterMmAccessor,
|
||||
espgui::ConfirmActionInterface<espgui::PopScreenAction>,
|
||||
espgui::BackActionInterface<espgui::PopScreenAction>
|
||||
>;
|
||||
using WheelDiameterInchChangeScreen = espgui::makeComponent<
|
||||
BobbyChangeValueDisplay<float>,
|
||||
espgui::StaticText<TEXT_WHEELDIAMETERINCH>,
|
||||
espgui::StaticTitle<TEXT_WHEELDIAMETERINCH>,
|
||||
WheelDiameterInchAccessor,
|
||||
espgui::RatioNumberStep<float, std::ratio<1,10>>,
|
||||
espgui::ConfirmActionInterface<espgui::PopScreenAction>,
|
||||
@ -54,7 +54,7 @@ using WheelDiameterInchChangeScreen = espgui::makeComponent<
|
||||
>;
|
||||
using NumMagnetPolesChangeScreen = espgui::makeComponent<
|
||||
BobbyChangeValueDisplay<int16_t>,
|
||||
espgui::StaticText<TEXT_NUMMAGNETPOLES>,
|
||||
espgui::StaticTitle<TEXT_NUMMAGNETPOLES>,
|
||||
NumMagnetPolesAccessor,
|
||||
espgui::ConfirmActionInterface<espgui::PopScreenAction>,
|
||||
espgui::BackActionInterface<espgui::PopScreenAction>
|
||||
@ -62,14 +62,14 @@ using NumMagnetPolesChangeScreen = espgui::makeComponent<
|
||||
#ifdef FEATURE_CAN
|
||||
using CanTransmitTimeoutChangeScreen = espgui::makeComponent<
|
||||
BobbyChangeValueDisplay<int16_t>,
|
||||
espgui::StaticText<TEXT_CANTRANSMITTIMEOUT>,
|
||||
espgui::StaticTitle<TEXT_CANTRANSMITTIMEOUT>,
|
||||
CanTransmitTimeoutAccessor,
|
||||
espgui::ConfirmActionInterface<espgui::PopScreenAction>,
|
||||
espgui::BackActionInterface<espgui::PopScreenAction>
|
||||
>;
|
||||
using CanReceiveTimeoutChangeScreen = espgui::makeComponent<
|
||||
BobbyChangeValueDisplay<int16_t>,
|
||||
espgui::StaticText<TEXT_CANRECEIVETIMEOUT>,
|
||||
espgui::StaticTitle<TEXT_CANRECEIVETIMEOUT>,
|
||||
CanReceiveTimeoutAccessor,
|
||||
espgui::ConfirmActionInterface<espgui::PopScreenAction>,
|
||||
espgui::BackActionInterface<espgui::PopScreenAction>
|
||||
@ -97,7 +97,7 @@ ControllerHardwareSettingsMenu::ControllerHardwareSettingsMenu()
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, PopScreenAction, StaticMenuItemIcon<&espgui::icons::back>>>();
|
||||
}
|
||||
|
||||
std::string ControllerHardwareSettingsMenu::text() const
|
||||
std::string ControllerHardwareSettingsMenu::title() const
|
||||
{
|
||||
return TEXT_CONTROLLERHARDWARESETTINGS;
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ class ControllerHardwareSettingsMenu : public BobbyMenuDisplay
|
||||
public:
|
||||
ControllerHardwareSettingsMenu();
|
||||
|
||||
std::string text() const override;
|
||||
std::string title() const override;
|
||||
|
||||
void back() override;
|
||||
};
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user