114 Commits

Author SHA1 Message Date
c307b64b0a Schon wieder irgendwas 2023-08-14 15:34:31 +02:00
101a2b03a8 More fixes again 2023-08-13 22:33:45 +02:00
7b4fd61a39 Again so many tft fixes 2023-08-13 20:37:50 +02:00
f32013f782 Even more more fixes 2023-08-13 20:26:51 +02:00
cca17b7ded More fixes 2023-08-13 20:15:53 +02:00
a9794b13bd Updated to newest idf 2023-08-13 20:13:05 +02:00
1a7e83de83 Merge pull request #400 from bobbycar-graz/update-mick-config
Update mick configs
2023-04-04 09:18:51 +02:00
69b030268f Update mick configs 2023-04-04 08:35:14 +02:00
b3b45653b5 Merge pull request #399 from bobbycar-graz/fix-open-quickaction
Skip empty configs on door open quickaction
2023-04-04 08:32:50 +02:00
199a8f1e4e Skip empty configs on door open quickaction 2023-04-04 07:52:09 +02:00
d6c76f3c3f Merge pull request #398 from bobbycar-graz/fix-build
Also build components with C++23
2023-04-04 07:51:00 +02:00
0909c055de Also build components with C++23 2023-04-04 06:27:23 +02:00
52b55b38cd Merge pull request #391 from bobbycar-graz/add-idf-ver
Added idf version to git menu
2022-12-24 16:08:40 +01:00
65d7a7e9ec Added idf version to git menu 2022-12-24 16:05:13 +01:00
13a6ce3cc2 Merge pull request #390 from bobbycar-graz/update-for-nimble-tests
Fixed ble
2022-12-24 16:02:52 +01:00
6bc85875ee Fixed ble 2022-12-24 15:55:35 +01:00
4688326323 Revert init change 2022-12-24 15:30:05 +01:00
1b7a523acd Made some modifications 2022-12-24 15:29:45 +01:00
c85e84e9a1 Updated submodules 2022-12-23 00:02:52 +01:00
9e6ee2c957 Merge pull request #389 from bobbycar-graz/accel-brake-lights 2022-12-18 20:32:29 +01:00
d29a74dbd4 Decreased limit 2022-12-18 19:33:37 +01:00
b984360956 Added acceleration and power cause for brake lights 2022-12-18 19:32:41 +01:00
fa819822f0 Removed unused file 2022-12-18 19:31:45 +01:00
52ff7acd02 Added brake light optimizations 2022-12-18 02:31:41 +01:00
b61dfcf53d Added acceleration detection for brake lights 2022-12-18 00:18:50 +01:00
f6b4966071 Merge pull request #388 from bobbycar-graz/optimizations 2022-12-17 23:25:26 +01:00
a6fb1b7396 Added more stats 2022-10-30 02:47:13 +01:00
fd40d8dbd8 Increase timings 2022-10-30 02:19:41 +02:00
8cf766356c Do not display so many can messages 2022-10-30 02:19:27 +02:00
da8b91403d Merge pull request #372 from bobbycar-graz/setup-screen-361 2022-10-26 19:19:17 +02:00
4b4044626b Poti screen 2022-10-26 19:03:55 +02:00
71906ba511 Changed potis 2022-10-26 18:11:12 +02:00
ef7e605eb7 Enable feedcode cloud 2022-10-26 18:11:05 +02:00
32389f2bf9 Fixed font 2022-10-26 17:49:51 +02:00
e647c4b372 Merge pull request #384 from bobbycar-graz/fix-tft-espi 2022-10-26 17:31:00 +02:00
3c0b0cdbb1 Fixed everything 2022-10-26 17:30:02 +02:00
43c2338dbd Added raw poti graphs 2022-10-21 21:18:31 +02:00
846a5d753a Updated librarys 2022-10-21 16:15:38 +02:00
f4110bb854 Minor modifications 2022-10-21 15:42:26 +02:00
226636a82a Remove old files 2022-10-13 22:01:25 +02:00
a93f34e0ba Refactor into multiple files 2022-10-13 22:00:16 +02:00
f2350c8746 Made some opimizations 2022-10-13 16:48:32 +02:00
1840030461 Fixed layout 2022-10-13 16:23:09 +02:00
62a4b88acb Added more setup scripts 2022-10-13 15:43:09 +02:00
bc9a0c396c Unfinished button calibration 2022-10-13 15:43:09 +02:00
2bc1625fab Old formatting 2022-10-13 15:43:08 +02:00
9db3da4b27 Dev commit 2022-10-13 15:43:08 +02:00
4e0fdd65c3 Remove commented out code 2022-10-13 15:43:08 +02:00
129cc64d24 Partitially done 2022-10-13 15:43:08 +02:00
f8b1454f9a Added git status 2022-10-13 15:43:08 +02:00
4f703c4d10 Fixed compiling commits that contains "quotes" 2022-10-13 15:43:08 +02:00
95e04ef543 Changed nvs reset and some other things 2022-10-13 15:43:08 +02:00
87751682b2 Made some modifications to qr functions 2022-10-13 15:43:08 +02:00
7a3a081af4 Modified reset, added option to debug menu 2022-10-13 15:43:08 +02:00
327932ac14 Merge pull request #381 from bobbycar-graz/clang-format 2022-10-08 16:32:46 +02:00
17eff6127f Added basic clang format file 2022-10-08 16:10:11 +02:00
2ec6ddc150 Merge pull request #380 from bobbycar-graz/fix-boardcomputerhardwaresettingsmenu 2022-10-06 15:56:15 +02:00
ba5d907e38 Switched to popScreen 2022-10-06 15:42:45 +02:00
3de6827bc5 Merge pull request #379 from bobbycar-graz/fix-display-rotation 2022-10-06 13:51:03 +02:00
846d90836d Fixed screen rotation 2022-10-06 13:41:12 +02:00
6e3324fe65 Merge pull request #378 from bobbycar-graz/enhancements 2022-10-06 11:37:02 +02:00
79e51f7511 Added more debug text 2022-10-06 11:23:55 +02:00
33f35f14b7 Merge pull request #359 from bobbycar-graz/new-ota-url 2022-10-06 11:23:33 +02:00
b43e4e76ac Changed to new ota url 2022-10-06 10:50:49 +02:00
e6ddc39177 Merge pull request #377 from bobbycar-graz/fix-319-udpcloud
Performance improvements
2022-10-06 10:43:49 +02:00
780fe01015 Performance improvements 2022-10-06 10:43:03 +02:00
5085b1daa6 Merge pull request #375 from bobbycar-graz/fix-319-udpcloud 2022-10-06 10:34:18 +02:00
4f174fe76f Fixed dumb typo 2022-10-06 08:50:11 +02:00
219b995695 Renamed ota_name into username and rewrite udp cloud 2022-10-05 23:12:19 +02:00
44100bcc0a Added emulate feedback option 2022-10-05 21:41:14 +02:00
e3f783977b Cleanup 2022-10-05 13:00:35 +02:00
9ea453f94b Merge pull request #371 from bobbycar-graz/fix-issue-360 2022-10-03 20:24:54 +02:00
4ff623195f Added locked for swap and copy 2022-10-03 20:08:50 +02:00
d8eb55277b Fixed compiling 2022-10-03 13:40:32 +02:00
47e49da69c Merge pull request #370 from bobbycar-graz/cmake-checks 2022-10-03 12:58:22 +02:00
91ebc22dc9 Check if variable is set 2022-10-03 12:47:09 +02:00
6202f5c913 Merge pull request #369 from bobbycar-graz/configure-cloud 2022-10-02 23:54:29 +02:00
16b7924c93 Added two settings accessors, fixed cloud 2022-10-02 23:41:27 +02:00
d71fd669e8 Minor fixes 2022-10-02 23:14:15 +02:00
5b0df729b3 Merge pull request #368 from bobbycar-graz/improvements 2022-10-02 23:07:10 +02:00
40e200a147 Implement nvs erase 2022-10-02 22:54:19 +02:00
4347377d61 Fixed hostname 2022-10-02 22:54:00 +02:00
c532907f20 Merge pull request #367 from bobbycar-graz/crash-handler 2022-10-01 17:50:44 +02:00
b27135ab90 Implemented recovery mode 2022-10-01 17:34:13 +02:00
a829b69217 Merge pull request #363 from bobbycar-graz/testdevice2
2nd Testdevice config
2022-10-01 15:32:54 +02:00
dd91c5826c Add display flip option 2022-10-01 15:21:55 +02:00
8c5e19f880 Fixed config, added more scripts 2022-10-01 15:05:16 +02:00
27e690b058 Testdevice 2 config 2022-10-01 14:38:09 +02:00
0eba8b3cce Merge pull request #365 from bobbycar-graz/feedc0de_private_branch 2022-10-01 13:33:23 +02:00
cac60a248d Stop logging can errors after 500 2022-10-01 02:48:24 +02:00
a062b9369b Alt eingessene C Trottel 2022-10-01 02:48:01 +02:00
8b6cdabfbc Updated config 2022-10-01 02:21:29 +02:00
eb353f56b9 Fixed more configs 2022-10-01 01:55:25 +02:00
ebc1bf88b6 Fixed config 2022-10-01 01:45:14 +02:00
e9d0915b69 Fixed feedc0de_new config 2022-10-01 01:40:57 +02:00
cd9a6ba32c Fixed configs 2022-10-01 01:32:30 +02:00
1b63870c4e fixed bgr color order 2022-10-01 00:19:49 +02:00
b13e45065f Fixed feedc0de_new button config 2022-09-30 22:46:46 +02:00
a97f84de33 Updated esp-idf again 2022-09-30 22:46:46 +02:00
cbad8dfa7b Fixed allfeatures 2022-09-30 22:46:46 +02:00
dd3608a09d Add setting to enable/disable remote control in default mode 2022-09-30 22:46:46 +02:00
6a2720c437 Apply ble remote control command also in default driving mode 2022-09-30 22:46:46 +02:00
e930a515ca Fix for tempomat, apply cruise speed before enabling 2022-09-30 22:46:46 +02:00
61fddd0724 Fixed button hold handling 2022-09-30 22:46:46 +02:00
a7242a4a7d feedc0de enable CAN erratas 2022-09-30 22:46:46 +02:00
e518388631 Fixed retarded log statements in can 2022-09-30 22:46:46 +02:00
785c887efe Fixed allfeatures 2022-09-30 22:46:46 +02:00
de17619208 Updated submodules 2022-09-30 22:46:46 +02:00
c71e02b004 Fixed feedc0de config 2022-09-30 22:46:46 +02:00
3246d5ec07 commit as is 2022-09-30 22:46:46 +02:00
c412ff6a01 Add asio_web 2022-09-30 22:46:46 +02:00
12975932e3 Add esp_boost 2022-09-30 22:46:45 +02:00
79be6d2fe6 Add feedc0de_new and dont build shitty configs anymore 2022-09-30 22:45:42 +02:00
8e8e694b57 New tft lib 2022-09-30 22:43:34 +02:00
312 changed files with 15329 additions and 3814 deletions

66
.clang-format Normal file
View 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

View File

@ -154,7 +154,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node: [feedc0de, comred_new, peter, mick, nofeatures, seatbot]
node: [feedc0de, feedc0de_new, comred_new, peter, mick, nofeatures, seatbot]
name: ${{ matrix.node }}
needs:
- checkout

16
.gitmodules vendored
View File

@ -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
@ -67,3 +64,12 @@
[submodule "components/TFT_eSPI"]
path = components/TFT_eSPI
url = ../../0xFEEDC0DE64/TFT_eSPI.git
[submodule "esp_boost"]
path = esp_boost
url = ../../0xFEEDC0DE64/esp_boost.git
[submodule "components/esptftlib"]
path = components/esptftlib
url = ../../0xFEEDC0DE64/esptftlib.git
[submodule "components/espfontlib"]
path = components/espfontlib
url = ../../0xFEEDC0DE64/espfontlib.git

View File

@ -25,9 +25,10 @@ include($ENV{IDF_PATH}/tools/cmake/project.cmake)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_definitions(-DASIO_DISABLE_CONCEPTS=1)
idf_build_set_property(CXX_COMPILE_OPTIONS -std=gnu++23 APPEND)
set(EXTRA_COMPONENT_DIRS
esp_boost
esp-protocols/components
)

1
components/espfontlib Submodule

Submodule components/espfontlib added at 89048ff162

1
components/esptftlib Submodule

Submodule components/esptftlib added at b779a4c09d

View File

@ -1,4 +1,5 @@
set(BOBBY_APP_NAME bobbyquad_allfeatures)
set(BOBBY_DEFAULT_USERNAME allfeatures)
add_definitions(
-DUSER_SETUP_LOADED=1
@ -17,8 +18,6 @@ add_definitions(
set(BOBBYCAR_BUILDFLAGS
# Pins
-DPINS_GAS=34
-DPINS_BREMS=35
# -DFEATURE_JOYSTICK
# -DPINS_RX1=4
# -DPINS_TX1=5

View File

@ -1,5 +1,5 @@
set(BOBBY_APP_NAME bobbyquad_aveexy)
set(BOBBY_DEFAULT_OTA_NAME aveexy)
set(BOBBY_DEFAULT_USERNAME aveexy)
add_definitions(
-DUSER_SETUP_LOADED=1

View File

@ -1,5 +1,5 @@
set(BOBBY_APP_NAME bobbyquad_comred)
set(BOBBY_DEFAULT_OTA_NAME comred)
set(BOBBY_DEFAULT_USERNAMENAME comred)
add_definitions(
-DUSER_SETUP_LOADED=1

View File

@ -1,20 +1,20 @@
set(BOBBY_APP_NAME bobbyquad_comred_new)
set(BOBBY_DEFAULT_OTA_NAME 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

View File

@ -1,25 +1,8 @@
set(BOBBY_APP_NAME bobbyquad_feedc0de)
set(BOBBY_DEFAULT_OTA_NAME feedc0de)
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(BOBBY_DEFAULT_USERNAME feedc0de)
set(BOBBYCAR_BUILDFLAGS
# Pins
-DPINS_GAS=34
-DPINS_BREMS=35
# -DFEATURE_JOYSTICK
# -DPINS_RX1=4
# -DPINS_TX1=5

View File

@ -0,0 +1,56 @@
set(BOBBY_APP_NAME bobbyquad_feedc0de)
set(BOBBY_DEFAULT_USERNAME feedc0de)
set(BOBBYCAR_BUILDFLAGS
# Pins
# -DFEATURE_JOYSTICK
# -DPINS_RX1=4
# -DPINS_TX1=5
# -DPINS_RX2=22
# -DPINS_TX2=23
-DPINS_MOSFET0=4
-DPINS_MOSFET1=5
-DPINS_MOSFET2=25
# -DPINS_GAMETRAKX=34
# -DPINS_GAMETRAKY=39
# -DPINS_GAMETRAKDIST=36
-DPINS_LEDBACKLIGHT=23
-DPINS_LEDSTRIP=26
# Config flags
-DFEATURE_ADC_IN
-DFEATURE_CAN
# -DFEATURE_SERIAL
-DFEATURE_MOSFETS
# -DFEATURE_BLUETOOTH
# -DFEATURE_BMS
# -DFEATURE_GAMETRAK
-DFEATURE_POWERSUPPLY
-DFEATURE_LEDBACKLIGHT
# -DLEDBACKLIGHT_INVERTED
# -DLEDSTRIP_WRONG_DIRECTION
# -DHEAP_LRGST_CRASH_TEXT_FIX
# Default values
-DDEFAULT_SWAPSCREENBYTES=false
-DDEFAULT_INVERTFRONTLEFT=false
-DDEFAULT_INVERTFRONTRIGHT=true
-DDEFAULT_INVERTBACKLEFT=false
-DDEFAULT_INVERTBACKRIGHT=true
-DDEFAULT_WHEELDIAMETER=255
-DDEFAULT_IMOTMAX=40
-DDEFAULT_IDCMAX=42
-DDEFAULT_NMOTMAX=2000
-DDEFAULT_FIELDWEAKMAX=17
-DDEFAULT_FIELDADVMAX=40
# DPAD
-DDPAD_BOARDCOMPUTER_V2
-DPINS_DPAD_BOARDCOMPUTER_V2_OUT1=19
-DPINS_DPAD_BOARDCOMPUTER_V2_OUT2=5
-DPINS_DPAD_BOARDCOMPUTER_V2_IN1=4
-DPINS_DPAD_BOARDCOMPUTER_V2_IN2=18
-DPINS_DPAD_BOARDCOMPUTER_V2_IN3=27
-DPINS_DPAD_BOARDCOMPUTER_V2_IN4=16
)

View File

@ -1,5 +1,5 @@
set(BOBBY_APP_NAME bobbyquad_gernot)
set(BOBBY_DEFAULT_OTA_NAME gernot)
set(BOBBY_DEFAULT_USERNAME gernot)
add_definitions(
-DUSER_SETUP_LOADED=1

View File

@ -1,5 +1,5 @@
set(BOBBY_APP_NAME bobbyquad_greyhash)
set(BOBBY_DEFAULT_OTA_NAME greyhash)
set(BOBBY_DEFAULT_USERNAME greyhash)
add_definitions(
-DUSER_SETUP_LOADED=1

View File

@ -1,20 +1,5 @@
set(BOBBY_APP_NAME bobbyquad_mick)
set(BOBBY_DEFAULT_OTA_NAME 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(BOBBY_DEFAULT_USERNAME mick)
set(BOBBYCAR_BUILDFLAGS
# Pins

View File

@ -1,5 +1,5 @@
set(BOBBY_APP_NAME bobbyquad_nofeatures)
set(BOBBY_DEFAULT_OTA_NAME nofeatures)
set(BOBBY_DEFAULT_USERNAME nofeatures)
add_definitions(
-DUSER_SETUP_LOADED=1

View File

@ -1,5 +1,5 @@
set(BOBBY_APP_NAME bobbyquad_peter)
set(BOBBY_DEFAULT_OTA_NAME peter)
set(BOBBY_DEFAULT_USERNAME peter)
add_definitions(
-DUSER_SETUP_LOADED=1

View File

@ -1,5 +1,5 @@
set(BOBBY_APP_NAME bobbyquad_seatbot)
set(BOBBY_DEFAULT_OTA_NAME seatbot)
set(BOBBY_DEFAULT_USERNAME seatbot)
add_definitions(
-DUSER_SETUP_LOADED=1

View File

@ -1,4 +1,5 @@
set(BOBBY_APP_NAME testdevice)
set(BOBBY_DEFAULT_USERNAME testdevice)
add_definitions(
-DUSER_SETUP_LOADED=1

View File

@ -0,0 +1,90 @@
set(BOBBY_APP_NAME testdevice2)
set(BOBBY_DEFAULT_USERNAME testdevice2)
add_definitions(
-DUSER_SETUP_LOADED=1
-DLOAD_GLCD=1
-DLOAD_FONT2=1
-DLOAD_FONT4=1
-DLOAD_FONT7=1
-DST7789_DRIVER=1
-DTFT_MOSI=13
-DTFT_SCLK=15
-DTFT_CS=14
-DTFT_DC=12
-DTFT_RST=2
-DSPI_FREQUENCY=40000000
)
set(BOBBYCAR_BUILDFLAGS
# Pins
-DPINS_GAS=34
-DPINS_BREMS=35
# -DFEATURE_JOYSTICK
# -DPINS_RX1=4
# -DPINS_TX1=5
# -DPINS_RX2=22
# -DPINS_TX2=23
# -DPINS_MOSFET0=18
# -DPINS_MOSFET1=19
# -DPINS_MOSFET2=21
# -DPINS_GAMETRAKX=34
# -DPINS_GAMETRAKY=39
# -DPINS_GAMETRAKDIST=36
-DPINS_LEDBACKLIGHT=23
-DPINS_LEDSTRIP=33
# Config flags
-DFEATURE_ADC_IN
-DFEATURE_CAN
# -DFEATURE_SERIAL
# -DFEATURE_MOSFETS
# -DFEATURE_BLUETOOTH
# -DFEATURE_BMS
# -DFEATURE_GAMETRAK
# -DFEATURE_POWERSUPPLY
-DFEATURE_LEDBACKLIGHT
-DLEDBACKLIGHT_INVERTED
# -DLEDSTRIP_WRONG_DIRECTION
-DHEAP_LRGST_CRASH_TEXT_FIX
# Default values
-DDEFAULT_SWAPSCREENBYTES=false
-DDEFAULT_INVERTFRONTLEFT=false
-DDEFAULT_INVERTFRONTRIGHT=true
-DDEFAULT_INVERTBACKLEFT=false
-DDEFAULT_INVERTBACKRIGHT=true
-DDEFAULT_WHEELDIAMETER=200
-DDEFAULT_IMOTMAX=28
-DDEFAULT_IDCMAX=30
-DDEFAULT_NMOTMAX=2000
-DDEFAULT_FIELDWEAKMAX=17
-DDEFAULT_FIELDADVMAX=40
# DPAD
# -DFEATURE_DPAD_5WIRESW
# -DPINS_DPAD_5WIRESW_OUT=4
# -DPINS_DPAD_5WIRESW_IN1=5
# -DPINS_DPAD_5WIRESW_IN2=27
# -DPINS_DPAD_5WIRESW_IN3=18
# -DPINS_DPAD_5WIRESW_IN4=19
# -DPINS_DPAD_EXTRASW_IN5=25
# -DFEATURE_DPAD_6WIRESW
# -DPINS_DPAD_6WIRESW_OUT=4
# -DPINS_DPAD_6WIRESW_IN1=5
# -DPINS_DPAD_6WIRESW_IN2=27
# -DPINS_DPAD_6WIRESW_IN3=18
# -DPINS_DPAD_6WIRESW_IN4=19
# -DPINS_DPAD_6WIRESW_IN5=26
# -DFEATURE_GSCHISSENE_DIODE
-DDPAD_BOARDCOMPUTER_V2
-DPINS_DPAD_BOARDCOMPUTER_V2_OUT1=19
-DPINS_DPAD_BOARDCOMPUTER_V2_OUT2=5
-DPINS_DPAD_BOARDCOMPUTER_V2_IN1=4
-DPINS_DPAD_BOARDCOMPUTER_V2_IN2=18
-DPINS_DPAD_BOARDCOMPUTER_V2_IN3=27
-DPINS_DPAD_BOARDCOMPUTER_V2_IN4=16
# -DDPAD_BOARDCOMPUTER_V2_DEBUG
)

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

View File

@ -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.0.0
manifest_hash: 7c3516d5e235caf076ae74598eb0fa0e7367ac4e40a46f5f1c262bd592a127e4
version: 5.2.0
manifest_hash: 04b1e89bb78c4187b4d7bc0cf9461b7a3475762e58fec6f3bb49a885c56532c2
target: esp32
version: 1.0.0

Submodule esp-idf updated: 468b1f17c9...14b365579b

1
esp_boost Submodule

Submodule esp_boost added at 76e5b5075c

View File

@ -1,4 +1,4 @@
set(headers
set(BOBBY_HEADERS
accessorhelpers.h
accessors/globalaccessors.h
accessors/settingsaccessors.h
@ -23,8 +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
@ -71,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
@ -128,6 +128,7 @@ set(headers
displays/menus/networksettingsmenu.h
displays/menus/otamenu.h
displays/menus/profilesmenu.h
displays/menus/recoverymenu.h
displays/menus/remotecontrolmodesettingsmenu.h
displays/menus/selectbuildserverbranch.h
displays/menus/selectbuildservermenu.h
@ -157,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
@ -173,6 +182,7 @@ set(headers
drivingstatistics.h
espnowfunctions.h
esptexthelpers.h
feedbackemulator.h
feedbackparser.h
globals.h
handbremse.h
@ -230,6 +240,7 @@ set(headers
serial_bobby.h
settingspersister.h
settingsutils.h
setup.h
softpwmlimiter.h
statistics.h
statustexthelper.h
@ -256,7 +267,7 @@ set(headers
wifiguiutils.h
)
set(sources
set(BOBBY_SOURCES
accessors/wifistaconfigaccessors.cpp
actions/assertaction.cpp
actions/bluetoothbeginaction.cpp
@ -276,8 +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
@ -321,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
@ -376,6 +387,7 @@ set(sources
displays/menus/networksettingsmenu.cpp
displays/menus/otamenu.cpp
displays/menus/profilesmenu.cpp
displays/menus/recoverymenu.cpp
displays/menus/remotecontrolmodesettingsmenu.cpp
displays/menus/selectbuildserverbranch.cpp
displays/menus/selectbuildservermenu.cpp
@ -405,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
@ -421,6 +441,7 @@ set(sources
drivingstatistics.cpp
espnowfunctions.cpp
esptexthelpers.cpp
feedbackemulator.cpp
feedbackparser.cpp
globals.cpp
handbremse.cpp
@ -479,6 +500,7 @@ set(sources
serial_bobby.cpp
settingspersister.cpp
settingsutils.cpp
setup.cpp
softpwmlimiter.cpp
statistics.cpp
statustexthelper.cpp
@ -505,16 +527,16 @@ set(sources
)
set(dependencies
freertos nvs_flash esp_http_server esp_https_ota mdns app_update esp_system esp_websocket_client driver
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
@ -532,14 +554,35 @@ 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()
target_compile_options(${COMPONENT_TARGET}
PRIVATE
-fstack-reuse=all
@ -553,6 +596,6 @@ target_compile_options(${COMPONENT_TARGET}
-DGIT_SHORT_REV="${GIT_SHORT_REV}"
-DGIT_MESSAGE="${GIT_MESSAGE}"
-DGIT_BRANCH="${GIT_BRANCH}"
-DBOBBY_DEFAULT_OTA_NAME="${BOBBY_DEFAULT_OTA_NAME}"
-DBOBBY_DEFAULT_USERNAME="${BOBBY_DEFAULT_USERNAME}"
${BOBBYCAR_BUILDFLAGS}
)

View File

@ -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 {};
};

View File

@ -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 {};
}
};
@ -45,6 +48,8 @@ struct BleFenceEnabledAccessor : public NewSettingsAccessor<bool> { ConfigWrappe
struct CloudEnabledAccessor : public NewSettingsAccessor<bool> { ConfigWrapper<bool> &getConfig() const override { return configs.cloudSettings.cloudEnabled; } };
struct CloudTransmitTimeoutAccessor : public NewSettingsAccessor<int16_t> { ConfigWrapper<int16_t> &getConfig() const override { return configs.cloudSettings.cloudTransmitTimeout; } };
struct CloudSendStatisticsAccessor : public NewSettingsAccessor<bool> { ConfigWrapper<bool> &getConfig() const override { return configs.cloudSettings.sendStatistic; } };
struct CloudURLAccessor : public NewSettingsAccessor<std::string> { ConfigWrapper<std::string> &getConfig() const override { return configs.cloudUrl; } };
struct CloudKeyAccessor : public NewSettingsAccessor<std::string> { ConfigWrapper<std::string> &getConfig() const override { return configs.cloudSettings.cloudKey; } };
// Time
//struct TimezoneOffsetAccessor : public NewSettingsAccessor<int32_t> { ConfigWrapper<int32_t> &getConfig() const override { return configs.timezoneOffset; } };
@ -75,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));
}
@ -127,11 +132,13 @@ struct CloudSendRateAccessor : public NewSettingsAccessor<int16_t> { ConfigWrapp
struct UdpCloudSendIntervalAccessor : public NewSettingsAccessor<int16_t> { ConfigWrapper<int16_t> &getConfig() const override { return configs.boardcomputerHardware.timersSettings.udpSendRateMs; } };
struct UdpCloudEnabledAccessor : public NewSettingsAccessor<bool> { ConfigWrapper<bool> &getConfig() const override { return configs.udpCloudSettings.udpCloudEnabled; } };
struct CloudDebugEnableAccessor : public NewSettingsAccessor<bool> { ConfigWrapper<bool> &getConfig() const override { return configs.udpCloudSettings.enableCloudDebug; } };
struct UdpUseStdStringAccessor : public NewSettingsAccessor<bool> { ConfigWrapper<bool> &getConfig() const override { return configs.udpCloudSettings.udpUseStdString; } };
struct UdpCloudDebugEnableAccessor : public NewSettingsAccessor<bool> { ConfigWrapper<bool> &getConfig() const override { return configs.udpCloudSettings.enableCloudDebug; } };
struct UdpCloudHostAccessor : public NewSettingsAccessor<std::string> { ConfigWrapper<std::string> &getConfig() const override { return configs.udpCloudSettings.udpCloudHost; } };
struct UdpCloudPortAccessor : public NewSettingsAccessor<uint16_t> { ConfigWrapper<uint16_t> &getConfig() const override { return configs.udpCloudSettings.udpCloudPort; } };
// DefaultMode
struct DefaultModeModelModeAccessor : public RefAccessorSaveSettings<UnifiedModelMode> { UnifiedModelMode &getRef() const override { return profileSettings.defaultMode.modelMode; } };
struct DefaultModeAllowRemoteControlAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return profileSettings.defaultMode.allowRemoteControl; } };
struct DefaultModeSquareGasAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return profileSettings.defaultMode.squareGas; } };
struct DefaultModeSquareBremsAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return profileSettings.defaultMode.squareBrems; } };
@ -201,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; } };
@ -261,5 +271,9 @@ struct QuickActionExtra2Accessor : public NewSettingsAccessor<BobbyQuickActions>
struct QuickActionExtra3Accessor : public NewSettingsAccessor<BobbyQuickActions> { ConfigWrapper<BobbyQuickActions> &getConfig() const override { return configs.quickActionExtra3; } };
struct QuickActionExtra4Accessor : public NewSettingsAccessor<BobbyQuickActions> { ConfigWrapper<BobbyQuickActions> &getConfig() const override { return configs.quickActionExtra4; } };
// boardcomputer-hardware
struct FlipScreenAccessor : public NewSettingsAccessor<bool> { ConfigWrapper<bool> &getConfig() const override { return configs.boardcomputerHardware.flipScreen; } };
// Other
struct AnhaengerIdAccessor : public NewSettingsAccessor<uint16_t> { ConfigWrapper<uint16_t> &getConfig() const override { return configs.anhaenger_id; } };
struct UsernameAccessor : public NewSettingsAccessor<std::string> { ConfigWrapper<std::string> &getConfig() const override { return configs.otaUsername; } };

View File

@ -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;

View File

@ -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();
}

View File

@ -1,10 +0,0 @@
#pragma once
// 3rdparty lib includes
#include <actioninterface.h>
class RebootAction : public virtual espgui::ActionInterface
{
public:
void triggered() override;
};

View File

View File

@ -0,0 +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
{
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();
}
}
};

View 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
}

View 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;
};

View File

@ -10,6 +10,7 @@
// local includes
#include "ledstrip.h"
#include "globals.h"
#include "modes/defaultmode.h"
#include "modes/remotecontrolmode.h"
#include "utils.h"
#include "newsettings.h"
@ -20,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
@ -54,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);
@ -71,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 = {};
@ -225,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))
@ -246,18 +257,20 @@ void RemoteControlCallbacks::onWrite(NimBLECharacteristic* pCharacteristic)
if (!simplified)
{
modes::remoteControlMode.setCommand(RemoteCommand{
RemoteCommand cmd {
.frontLeft = doc[isInverted ? "fr":"fl"].as<int16_t>(),
.frontRight = doc[isInverted ? "fl":"fr"].as<int16_t>(),
.backLeft = doc["bl"].as<int16_t>(),
.backRight = doc["br"].as<int16_t>()
});
};
modes::defaultMode.setRemoteCommand(cmd);
modes::remoteControlMode.setRemoteCommand(cmd);
}
}
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))
@ -270,7 +283,7 @@ void WirelessSettingsCallbacks::onWrite(NimBLECharacteristic* pCharacteristic)
if (write_type == "wifi") {
const int index = doc["wifi_index"].as<int>();
ESP_LOGI(TAG, "[ble_config]: Set wifi%i: WiFi-SSID: %s, WiFi-Password: ***", doc["wifi_index"].as<int>(), doc["wifi_ssid"].as<const char*>());
ESP_LOGI(TAG, "Set wifi%i: WiFi-SSID: %s, WiFi-Password: ***", doc["wifi_index"].as<int>(), doc["wifi_ssid"].as<const char*>());
configs.write_config(configs.wifi_configs[index].ssid, doc["wifi_ssid"].as<std::string>());
configs.write_config(configs.wifi_configs[index].key, doc["wifi_pass"].as<std::string>());
} else {
@ -279,11 +292,11 @@ 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");
ESP_LOGI(TAG, "[ble_wifilist] Got request for listing wifi ssids.");
ESP_LOGI(TAG, "Got request for listing wifi ssids.");
for (const auto &wifi : configs.wifi_configs)
{
wifiArray.add(wifi.ssid.value());

View File

@ -13,3 +13,10 @@ extern BLECharacteristic *getwifilist;
void initBle();
void handleBle();
struct RemoteCommand {
int16_t frontLeft{};
int16_t frontRight{};
int16_t backLeft{};
int16_t backRight{};
};

View File

@ -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;
}
}
}
}

View File

@ -110,6 +110,7 @@ void buttonReleasedCommon(espgui::Button button)
void BobbyButtons::rawButtonPressed(uint8_t button)
{
ESP_LOGI(TAG, "%hhu", button);
//Base::rawButtonPressed(button);
if (const auto translated = translateRawButton(button))
buttonPressed(*translated);
@ -117,6 +118,7 @@ void BobbyButtons::rawButtonPressed(uint8_t button)
void BobbyButtons::rawButtonReleased(uint8_t button)
{
ESP_LOGI(TAG, "%hhu", button);
//Base::rawButtonReleased(button);
if (const auto translated = translateRawButton(button))
buttonReleased(*translated);

View File

@ -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);
};
}

View File

@ -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));

View File

@ -3,11 +3,42 @@
// 3rdparty lib includes
#include <schedulertask.h>
#include <esp_log.h>
class BobbySchedulerTask : public espcpputils::SchedulerTask {
public:
using SchedulerTask::SchedulerTask;
void setup() const { SchedulerTask::setup(); m_wasInitialized = true; }
// using SchedulerTask::SchedulerTask; -> we need to add one more parameter
BobbySchedulerTask(const char *name, void (&setupCallback)(), void (&loopCallback)(),
espchrono::millis_clock::duration loopInterval, bool use_in_recovery = false,
bool intervalImportant = false,
std::string (*perfInfo)() = nullptr) :
espcpputils::SchedulerTask(name, setupCallback, loopCallback, loopInterval, intervalImportant, perfInfo),
m_use_in_recovery{use_in_recovery}
{
}
void setup(bool in_recovery = false)
{
m_in_recovery = in_recovery;
if (in_recovery && !m_use_in_recovery)
{
ESP_LOGI("BobbySchedulerTask", "Skipping setup of %s (%s)", name(), m_use_in_recovery ? "use in recovery" : "no use in recovery");
return;
}
SchedulerTask::setup();
m_wasInitialized = true;
ESP_LOGI("BobbySchedulerTask", "Task %s initialized", name());
}
void loop()
{
if (!m_in_recovery || m_use_in_recovery)
{
// ESP_LOGI("BobbySchedulerTask", "Loop %s", name());
SchedulerTask::loop();
}
}
bool isInitialized() const { return m_wasInitialized; }
private:
mutable bool m_wasInitialized{false};
const bool m_use_in_recovery;
bool m_in_recovery{false};
};

View File

@ -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;
}

View File

@ -82,6 +82,11 @@ void initCan()
void updateCan()
{
if (configs.emulateFeedback.value())
{
return;
}
for (int i = 0; i < 4; i++)
if (!tryParseCanInput())
break;
@ -265,7 +270,7 @@ bool tryParseCanInput()
if (parseBoardcomputerCanMessage(message))
return true;
ESP_LOGW(TAG, "Unknown CAN info received .identifier = %u", message.identifier);
ESP_LOGW(TAG, "Unknown CAN info received .identifier = %lu", message.identifier);
return true;
}
@ -296,22 +301,24 @@ void sendCanCommands()
const auto status = twai_get_status_info(&status_info);
const auto timestamp_after = espchrono::millis_clock::now();
if ((result == ESP_ERR_TIMEOUT || status_info.state == TWAI_STATE_BUS_OFF) || (status == ESP_OK && status_info.bus_error_count > can_sequential_bus_errors))
if ((result == ESP_ERR_TIMEOUT || status_info.state == TWAI_STATE_BUS_OFF) ||
(status == ESP_OK && status_info.bus_error_count > can_sequential_bus_errors))
{
++can_sequential_error_cnt;
++can_total_error_cnt;
can_sequential_bus_errors = status_info.bus_error_count;
ESP_LOGW(TAG, "twai_transmit() failed after %lldms with %s, seq err: %d, total err: %d",
(timestamp_after - timestamp_before).count(),
esp_err_to_name(result),
can_sequential_error_cnt,
can_total_error_cnt);
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),
can_sequential_error_cnt,
can_total_error_cnt);
}
else if (result != ESP_OK)
{
ESP_LOGD(TAG, "ERROR: twai_transmit() failed after %lldms with %s",
(timestamp_after - timestamp_before).count(),
ESP_LOGE(TAG, "twai_transmit() failed after %lldms with %s",
std::chrono::floor<std::chrono::milliseconds>(timestamp_after - timestamp_before).count(),
esp_err_to_name(result));
}
else
@ -325,28 +332,28 @@ void sendCanCommands()
can_sequential_error_cnt = 0;
if (configs.canResetOnError.value())
{
ESP_LOGW(TAG, "WARNING: Something isn't right, trying to restart can ic...");
ESP_LOGW(TAG, "Something isn't right, trying to restart can ic...");
if (const auto err = twai_stop(); err != ESP_OK)
{
ESP_LOGE(TAG, "ERROR: twai_stop() failed with %s", esp_err_to_name(err));
ESP_LOGE(TAG, "twai_stop() failed with %s", esp_err_to_name(err));
}
if (configs.canUninstallOnReset.value())
{
if (const auto err = twai_driver_uninstall(); err != ESP_OK) {
ESP_LOGE(TAG, "ERROR: twai_driver_uninstall() failed with %s", esp_err_to_name(err));
ESP_LOGE(TAG, "twai_driver_uninstall() failed with %s", esp_err_to_name(err));
}
twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(GPIO_NUM_21, GPIO_NUM_22,
TWAI_MODE_NORMAL);
twai_timing_config_t t_config = TWAI_TIMING_CONFIG_250KBITS();
twai_filter_config_t f_config = TWAI_FILTER_CONFIG_ACCEPT_ALL();
if (const auto err = twai_driver_install(&g_config, &t_config, &f_config); err != ESP_OK) {
ESP_LOGE(TAG, "ERROR: twai_driver_install() failed with %s", esp_err_to_name(err));
ESP_LOGE(TAG, "twai_driver_install() failed with %s", esp_err_to_name(err));
}
}
if (const auto err = twai_start(); err != ESP_OK)
{
ESP_LOGE(TAG, "ERROR: twai_start() failed with %s", esp_err_to_name(err));
ESP_LOGE(TAG, "twai_start() failed with %s", esp_err_to_name(err));
}
}
}
@ -386,18 +393,33 @@ void sendCanCommands()
static struct {
struct {
uint8_t freq = 0;
uint8_t pattern = 0;
struct {
int16_t nCruiseMotTgt{};
bool cruiseCtrlEna{};
} left, right;
uint8_t freq{};
uint8_t pattern{};
} front, back;
std::underlying_type_t<Boardcomputer::Button> buttonLeds{};
} lastValues;
static int i{};
if ((front && front->command.buzzer.freq != lastValues.front.freq ) ||
(front && front->command.buzzer.pattern != lastValues.front.pattern ) ||
(back && back->command.buzzer.freq != lastValues.back.freq) ||
(back && back->command.buzzer.pattern != lastValues.back.pattern))
// anti aufklatsch when tempomat
if ((front && front->command.left.nCruiseMotTgt != lastValues.front.left.nCruiseMotTgt) ||
(front && front->command.right.nCruiseMotTgt != lastValues.front.right.nCruiseMotTgt) ||
(back && back->command.left.nCruiseMotTgt != lastValues.back.left.nCruiseMotTgt) ||
(back && back->command.right.nCruiseMotTgt != lastValues.back.right.nCruiseMotTgt))
i = 8;
else if ((front && front->command.left.cruiseCtrlEna != lastValues.front.left.cruiseCtrlEna) ||
(front && front->command.right.cruiseCtrlEna != lastValues.front.right.cruiseCtrlEna) ||
(back && back->command.left.cruiseCtrlEna != lastValues.back.left.cruiseCtrlEna) ||
(back && back->command.right.cruiseCtrlEna != lastValues.back.right.cruiseCtrlEna))
i = 9;
else if ((front && front->command.buzzer.freq != lastValues.front.freq ) ||
(front && front->command.buzzer.pattern != lastValues.front.pattern ) ||
(back && back->command.buzzer.freq != lastValues.back.freq) ||
(back && back->command.buzzer.pattern != lastValues.back.pattern))
i = 10;
else if (buttonLeds != lastValues.buttonLeds)
i = 12;
@ -472,17 +494,17 @@ void sendCanCommands()
if (back) send(MotorController<true, true>::Command::PhaseAdvMax, back->command.right.phaseAdvMax);
break;
case 8:
if (front) send(MotorController<false, false>::Command::CruiseCtrlEna, front->command.left.cruiseCtrlEna);
if (front) send(MotorController<false, true>::Command::CruiseCtrlEna, front->command.right.cruiseCtrlEna);
if (back) send(MotorController<true, false>::Command::CruiseCtrlEna, back->command.left.cruiseCtrlEna);
if (back) send(MotorController<true, true>::Command::CruiseCtrlEna, back->command.right.cruiseCtrlEna);
break;
case 9:
if (front) send(MotorController<false, false>::Command::CruiseMotTgt, front->command.left.nCruiseMotTgt);
if (front) send(MotorController<false, true>::Command::CruiseMotTgt, front->command.right.nCruiseMotTgt);
if (back) send(MotorController<true, false>::Command::CruiseMotTgt, back->command.left.nCruiseMotTgt);
if (back) send(MotorController<true, true>::Command::CruiseMotTgt, back->command.right.nCruiseMotTgt);
break;
case 9:
if (front) send(MotorController<false, false>::Command::CruiseCtrlEna, front->command.left.cruiseCtrlEna);
if (front) send(MotorController<false, true>::Command::CruiseCtrlEna, front->command.right.cruiseCtrlEna);
if (back) send(MotorController<true, false>::Command::CruiseCtrlEna, back->command.left.cruiseCtrlEna);
if (back) send(MotorController<true, true>::Command::CruiseCtrlEna, back->command.right.cruiseCtrlEna);
break;
case 10:
if (front && send(MotorController<false, false>::Command::BuzzerFreq, front->command.buzzer.freq) == ESP_OK)
lastValues.front.freq = front->command.buzzer.freq;

View File

@ -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;
@ -721,9 +721,6 @@ void cloudSend()
if (configs.cloudUrl.value().empty())
return;
if (!configs.cloudSettings.sendStatistic.value())
return;
if (!cloudStarted)
{
if (espchrono::ago(lastStartTry) < 10s)
@ -746,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());
@ -996,7 +993,7 @@ void cloudEventHandler(void *event_handler_arg, esp_event_base_t event_base, int
cloudStarted = false;
break;
default:
ESP_LOGI(TAG, "%s unknown event_id %i", event_base, event_id);
ESP_LOGI(TAG, "%s unknown event_id %li", event_base, event_id);
}
}

View File

@ -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':

View File

@ -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);
}
}
}

View File

@ -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};

View File

@ -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);
}
}
}

View File

@ -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:

View File

@ -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);

View File

@ -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;

View File

@ -48,5 +48,6 @@ void BobbyChangeValueDisplay<Tvalue>::buttonPressed(espgui::Button button)
template<typename Tvalue>
void BobbyChangeValueDisplay<Tvalue>::buttonReleased(espgui::Button button)
{
//Base::buttonReleased(button);
Base::buttonReleased(button);
buttonReleasedCommon(button);
}

View File

@ -26,4 +26,5 @@ void BobbyDisplayWithTitle::buttonPressed(espgui::Button button)
void BobbyDisplayWithTitle::buttonReleased(espgui::Button button)
{
//Base::buttonReleased(button);
buttonReleasedCommon(button);
}

View File

@ -46,4 +46,5 @@ template<size_t COUNT>
void BobbyGraphDisplay<COUNT>::buttonReleased(espgui::Button button)
{
//Base::buttonReleased(button);
buttonReleasedCommon(button);
}

View File

@ -26,6 +26,6 @@ void BobbyMenuDisplay::buttonPressed(espgui::Button button)
void BobbyMenuDisplay::buttonReleased(espgui::Button button)
{
//Base::buttonReleased(button);
Base::buttonReleased(button);
buttonReleasedCommon(button);
}

View File

@ -26,4 +26,5 @@ void BobbyPopupDisplay::buttonPressed(espgui::Button button)
void BobbyPopupDisplay::buttonReleased(espgui::Button button)
{
//Base::buttonReleased(button);
buttonReleasedCommon(button);
}

View File

@ -46,5 +46,6 @@ template<std::size_t COUNT0, std::size_t COUNT1>
void BobbySplitGraphDisplay<COUNT0, COUNT1>::buttonReleased(espgui::Button button)
{
//Base::buttonReleased(button);
buttonReleasedCommon(button);
}

View File

@ -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);
}

View File

@ -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;
};

View File

@ -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;
}

View File

@ -8,7 +8,7 @@ class CalibrateVoltageDisplay : public BobbyMenuDisplay
public:
CalibrateVoltageDisplay();
std::string text() const override;
std::string title() const override;
void back() override;
};

View File

@ -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";
}

View File

@ -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};

View File

@ -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);
}
}
}

View File

@ -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();

View File

@ -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));

View File

@ -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)
{

View File

@ -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;

View File

@ -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);
}

View File

@ -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:

View File

@ -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);
}

Some files were not shown because too many files have changed in this diff Show More