Switched build system to esp-idf
This commit is contained in:
9
.gitignore
vendored
9
.gitignore
vendored
@ -1,2 +1,7 @@
|
||||
.pio
|
||||
platformio.pro*
|
||||
desktop.ini
|
||||
/build
|
||||
/CMakeLists.txt.user*
|
||||
/cmake-build-debug
|
||||
/sdkconfig.old*
|
||||
/.idea
|
||||
/.ccache
|
||||
|
40
.gitmodules
vendored
40
.gitmodules
vendored
@ -1,9 +1,39 @@
|
||||
[submodule "src/bobbycar-protocol"]
|
||||
path = src/bobbycar-protocol
|
||||
url = git@github.com:bobbycar-graz/bobbycar-protocol.git
|
||||
[submodule "src/espcpputils"]
|
||||
path = src/espcpputils
|
||||
path = components/espcpputils
|
||||
url = git@github.com:0xFEEDC0DE64/espcpputils.git
|
||||
[submodule "esp-idf"]
|
||||
path = esp-idf
|
||||
url = https://github.com/0xFEEDC0DE64/esp-idf.git
|
||||
url = git@github.com:0xFEEDC0DE64/esp-idf.git
|
||||
[submodule "components/cpputils"]
|
||||
path = components/cpputils
|
||||
url = git@github.com:0xFEEDC0DE64/cpputils.git
|
||||
[submodule "components/espcpputils"]
|
||||
path = components/espcpputils
|
||||
url = git@github.com:0xFEEDC0DE64/espcpputils.git
|
||||
[submodule "components/cxx-ring-buffer"]
|
||||
path = components/cxx-ring-buffer
|
||||
url = git@github.com:0xFEEDC0DE64/cxx-ring-buffer.git
|
||||
[submodule "components/date"]
|
||||
path = components/date
|
||||
url = git@github.com:0xFEEDC0DE64/date.git
|
||||
[submodule "components/espchrono"]
|
||||
path = components/espchrono
|
||||
url = git@github.com:0xFEEDC0DE64/espchrono.git
|
||||
[submodule "components/ArduinoJson"]
|
||||
path = components/ArduinoJson
|
||||
url = git@github.com:0xFEEDC0DE64/ArduinoJson.git
|
||||
[submodule "components/TFT_eSPI"]
|
||||
path = components/TFT_eSPI
|
||||
url = git@github.com:0xFEEDC0DE64/TFT_eSPI.git
|
||||
[submodule "components/arduino-esp32"]
|
||||
path = components/arduino-esp32
|
||||
url = git@github.com:0xFEEDC0DE64/arduino-esp32.git
|
||||
[submodule "components/expected"]
|
||||
path = components/expected
|
||||
url = git@github.com:0xFEEDC0DE64/expected.git
|
||||
[submodule "components/bobbycar-protocol"]
|
||||
path = components/bobbycar-protocol
|
||||
url = git@github.com:bobbycar-graz/bobbycar-protocol.git
|
||||
[submodule "components/fmt"]
|
||||
path = components/fmt
|
||||
url = git@github.com:0xFEEDC0DE64/fmt.git
|
||||
|
85
CMakeLists.txt
Normal file
85
CMakeLists.txt
Normal file
@ -0,0 +1,85 @@
|
||||
cmake_minimum_required(VERSION 3.16.3)
|
||||
|
||||
add_definitions(
|
||||
-DUSER_SETUP_LOADED=1
|
||||
-DLOAD_GLCD=1
|
||||
-DLOAD_FONT2=1
|
||||
-DLOAD_FONT4=1
|
||||
-DLOAD_FONT7=1
|
||||
-DFEATURE_ADC_IN
|
||||
-DPINS_GAS=34
|
||||
-DPINS_BREMS=35
|
||||
# -DPINS_LED=23
|
||||
-DILI9341_DRIVER=1
|
||||
-DTFT_MOSI=13
|
||||
-DTFT_SCLK=15
|
||||
-DTFT_CS=14
|
||||
-DTFT_DC=12
|
||||
-DTFT_RST=2
|
||||
-DSPI_FREQUENCY=27000000
|
||||
-DDEFAULT_SWAPSCREENBYTES=false
|
||||
-DFEATURE_CAN
|
||||
# -DFEATURE_SERIAL
|
||||
# -DPINS_RX1=4
|
||||
# -DPINS_TX1=5
|
||||
# -DPINS_RX2=22
|
||||
# -DPINS_TX2=23
|
||||
-DDEFAULT_INVERTFRONTLEFT=false
|
||||
-DDEFAULT_INVERTFRONTRIGHT=true
|
||||
-DDEFAULT_INVERTBACKLEFT=false
|
||||
-DDEFAULT_INVERTBACKRIGHT=true
|
||||
-DDEFAULT_WHEELDIAMETER=255
|
||||
# -DFEATURE_MOSFETS
|
||||
# -DPINS_MOSFET0=18
|
||||
# -DPINS_MOSFET1=19
|
||||
# -DPINS_MOSFET2=21
|
||||
-DDEFAULT_IMOTMAX=35
|
||||
-DDEFAULT_IDCMAX=37
|
||||
-DDEFAULT_NMOTMAX=2000
|
||||
-DDEFAULT_FIELDWEAKMAX=7
|
||||
-DDEFAULT_FIELDADVMAX=40
|
||||
-DDEVICE_PREFIX=bobbyquad
|
||||
-DAP_PASSWORD=Passwort_123
|
||||
# -DFEATURE_WEBSERVER
|
||||
# -DFEATURE_ARDUINOOTA
|
||||
# -DFEATURE_WEBOTA
|
||||
-DFEATURE_DPAD_5WIRESW
|
||||
-DPINS_DPAD_5WIRESW_OUT=18
|
||||
-DPINS_DPAD_5WIRESW_IN1=19
|
||||
-DPINS_DPAD_5WIRESW_IN2=27
|
||||
-DPINS_DPAD_5WIRESW_IN3=32
|
||||
-DPINS_DPAD_5WIRESW_IN4=33
|
||||
-DDPAD_5WIRESW_UP=6
|
||||
-DDPAD_5WIRESW_DOWN=3
|
||||
-DDPAD_5WIRESW_CONFIRM=7
|
||||
-DDPAD_5WIRESW_BACK=2
|
||||
-DDPAD_5WIRESW_PROFILE0=1
|
||||
-DDPAD_5WIRESW_PROFILE1=5
|
||||
-DDPAD_5WIRESW_PROFILE2=0
|
||||
-DDPAD_5WIRESW_PROFILE3=4
|
||||
# -DDPAD_5WIRESW_DEBUG
|
||||
-DDEFAULT_GASMIN=150
|
||||
-DDEFAULT_GASMAX=1300
|
||||
-DDEFAULT_BREMSMIN=200
|
||||
-DDEFAULT_BREMSMAX=1500
|
||||
# -DFEATURE_BLUETOOTH
|
||||
# -DFEATURE_BMS
|
||||
# -DFEATURE_GAMETRAK
|
||||
# -DPINS_GAMETRAKX=34
|
||||
# -DPINS_GAMETRAKY=39
|
||||
# -DPINS_GAMETRAKDIST=36
|
||||
# -DDEFAULT_GAMETRAKXMIN=0
|
||||
# -DDEFAULT_GAMETRAKXMAX=4095
|
||||
# -DDEFAULT_GAMETRAKYMIN=0
|
||||
# -DDEFAULT_GAMETRAKYMAX=4095
|
||||
# -DDEFAULT_GAMETRAKDISTMIN=0
|
||||
# -DDEFAULT_GAMETRAKDISTMAX=4095
|
||||
# -DFEATURE_CLOUD
|
||||
)
|
||||
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
project(boardcomputer)
|
@ -8,7 +8,9 @@
|
||||
```
|
||||
git clone --recursive git@github.com:bobbycar-graz/bobbycar-boardcomputer-firmware.git
|
||||
cd bobbycar-boardcomputer-firmware/
|
||||
platformio run --environment bobbycar_usb --target upload
|
||||
./esp-idf/install.sh
|
||||
. esp-idf/export.sh
|
||||
idf.py -p /dev/ttyUSB0 -b 921600 flash monitor
|
||||
```
|
||||
|
||||
## How to wire all connections?
|
||||
|
32
backtrace.sh
32
backtrace.sh
@ -1,32 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
GDB_BINARY=~/.platformio/packages/toolchain-xtensa32/bin/xtensa-esp32-elf-gdb
|
||||
ELF_FILE=.pio/build/feedc0de_usb/firmware.elf
|
||||
|
||||
if [[ ! -x "$GDB_BINARY" ]]
|
||||
then
|
||||
echo Could not find gdb binary: "$GDB_BINARY"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -f "$ELF_FILE" ]]
|
||||
then
|
||||
echo Could not find elf file: "$ELF_FILE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ls -lah "$ELF_FILE"
|
||||
|
||||
PARAMS=()
|
||||
for i in $@
|
||||
do
|
||||
ADDR="$(echo "$i" | cut -d ":" -f 1)"
|
||||
OUTPUT="$($GDB_BINARY --batch $ELF_FILE -ex "set listsize 1" -ex "l *$ADDR" -ex "q")"
|
||||
|
||||
if [[ -z "$OUTPUT" ]]
|
||||
then
|
||||
echo "${ADDR} gdb empty output"
|
||||
else
|
||||
echo "${OUTPUT}"
|
||||
fi
|
||||
done
|
1
components/ArduinoJson
Submodule
1
components/ArduinoJson
Submodule
Submodule components/ArduinoJson added at d66159f51a
1
components/TFT_eSPI
Submodule
1
components/TFT_eSPI
Submodule
Submodule components/TFT_eSPI added at 95458b3875
1
components/arduino-esp32
Submodule
1
components/arduino-esp32
Submodule
Submodule components/arduino-esp32 added at ff9ec961c1
1
components/bobbycar-protocol
Submodule
1
components/bobbycar-protocol
Submodule
Submodule components/bobbycar-protocol added at 1acdbfe14e
1
components/cpputils
Submodule
1
components/cpputils
Submodule
Submodule components/cpputils added at 79a7f4ef85
1
components/cxx-ring-buffer
Submodule
1
components/cxx-ring-buffer
Submodule
Submodule components/cxx-ring-buffer added at c204c20888
1
components/date
Submodule
1
components/date
Submodule
Submodule components/date added at b1a75847d5
1
components/espchrono
Submodule
1
components/espchrono
Submodule
Submodule components/espchrono added at 7f8a185678
1
components/espcpputils
Submodule
1
components/espcpputils
Submodule
Submodule components/espcpputils added at a504262f39
1
components/expected
Submodule
1
components/expected
Submodule
Submodule components/expected added at aa9b2b2d1f
1
components/fmt
Submodule
1
components/fmt
Submodule
Submodule components/fmt added at 4b11c94036
@ -1,39 +0,0 @@
|
||||
|
||||
This directory is intended for project header files.
|
||||
|
||||
A header file is a file containing C declarations and macro definitions
|
||||
to be shared between several project source files. You request the use of a
|
||||
header file in your project source file (C, C++, etc) located in `src` folder
|
||||
by including it, with the C preprocessing directive `#include'.
|
||||
|
||||
```src/main.c
|
||||
|
||||
#include "header.h"
|
||||
|
||||
int main (void)
|
||||
{
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
Including a header file produces the same results as copying the header file
|
||||
into each source file that needs it. Such copying would be time-consuming
|
||||
and error-prone. With a header file, the related declarations appear
|
||||
in only one place. If they need to be changed, they can be changed in one
|
||||
place, and programs that include the header file will automatically use the
|
||||
new version when next recompiled. The header file eliminates the labor of
|
||||
finding and changing all the copies as well as the risk that a failure to
|
||||
find one copy will result in inconsistencies within a program.
|
||||
|
||||
In C, the usual convention is to give header files names that end with `.h'.
|
||||
It is most portable to use only letters, digits, dashes, and underscores in
|
||||
header file names, and at most one dot.
|
||||
|
||||
Read more about using header files in official GCC documentation:
|
||||
|
||||
* Include Syntax
|
||||
* Include Operation
|
||||
* Once-Only Headers
|
||||
* Computed Includes
|
||||
|
||||
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
|
18
init_ide.sh
18
init_ide.sh
@ -1,18 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
platformio init --ide qtcreator
|
||||
|
||||
echo "CONFIG+=c++17" >> platformio.pro
|
||||
|
||||
echo "OTHER_FILES += \\" >> platformio.pro
|
||||
|
||||
#for i in $(find data -type f)
|
||||
#do
|
||||
# echo " $i \\" >> platformio.pro
|
||||
#done
|
||||
|
||||
echo " partitions_16M_ota.csv \\" >> platformio.pro
|
||||
echo " partitions_4M_noota.csv \\" >> platformio.pro
|
||||
echo " partitions_4M_ota.csv \\" >> platformio.pro
|
||||
echo " LICENSE" >> platformio.pro
|
||||
echo " README.md" >> platformio.pro
|
203
main/CMakeLists.txt
Normal file
203
main/CMakeLists.txt
Normal file
@ -0,0 +1,203 @@
|
||||
set(headers
|
||||
accessorinterface.h
|
||||
actioninterface.h
|
||||
actions/backproxyaction.h
|
||||
actions/bluetoothbeginaction.h
|
||||
actions/bluetoothbeginmasteraction.h
|
||||
actions/bluetoothconnectbmsaction.h
|
||||
actions/bluetoothdisconnectaction.h
|
||||
actions/bluetoothendaction.h
|
||||
actions/bluetoothflushaction.h
|
||||
actions/bmsturnoffchargeaction.h
|
||||
actions/bmsturnoffdischargeaction.h
|
||||
actions/bmsturnonchargeaction.h
|
||||
actions/bmsturnondischargeaction.h
|
||||
actions/dummyaction.h
|
||||
actions/erasenvsaction.h
|
||||
actions/loadsettingsaction.h
|
||||
actions/modesettingsaction.h
|
||||
actions/multiaction.h
|
||||
actions/rebootaction.h
|
||||
actions/savesettingsaction.h
|
||||
actions/setvalueaction.h
|
||||
actions/switchscreenaction.h
|
||||
actions/toggleboolaction.h
|
||||
actions/wifidisconnectaction.h
|
||||
actions/wifienableipv6action.h
|
||||
actions/wifireconnectaction.h
|
||||
actions/wifisoftapaction.h
|
||||
actions/wifisoftapdisconnectaction.h
|
||||
actions/wifisoftapdisconnectwifioffaction.h
|
||||
actions/wifisoftapenableipv6action.h
|
||||
actions/switchprofileaction.h
|
||||
actions/updateswapfrontbackaction.h
|
||||
bluetoothmode.h
|
||||
bmsutils.h
|
||||
changevaluedisplay_bluetoothmode.h
|
||||
changevaluedisplay_bool.h
|
||||
changevaluedisplay_larsmmode_mode.h
|
||||
changevaluedisplay_unifiedmodelmode.h
|
||||
changevaluedisplay_wifi_mode_t.h
|
||||
changevaluedisplay_wifi_power_t.h
|
||||
checkboxicon.h
|
||||
cloud.h
|
||||
colorinterface.h
|
||||
debugcolorhelpers.h
|
||||
displays/gameoflifedisplay.h
|
||||
displays/graphdisplay.h
|
||||
displays/menus/aboutmenu.h
|
||||
displays/menus/accesspointwifisettingsmenu.h
|
||||
displays/menus/bluetoothsettingsmenu.h
|
||||
displays/menus/bmsmenu.h
|
||||
displays/menus/buzzermenu.h
|
||||
displays/menus/commanddebugmenu.h
|
||||
displays/menus/debugmenu.h
|
||||
displays/menus/defaultmodesettingsmenu.h
|
||||
displays/menus/demosmenu.h
|
||||
displays/menus/enablemenu.h
|
||||
displays/menus/feedbackdebugmenu.h
|
||||
displays/menus/gametrakmodesettingsmenu.h
|
||||
displays/menus/genericwifisettingsmenu.h
|
||||
displays/menus/graphsmenu.h
|
||||
displays/menus/invertmenu.h
|
||||
displays/menus/larsmmodesettingsmenu.h
|
||||
displays/menus/modessettingsmenu.h
|
||||
displays/menus/mosfetsmenu.h
|
||||
displays/menus/motorstatedebugmenu.h
|
||||
displays/menus/presetsmenu.h
|
||||
displays/menus/profilesmenu.h
|
||||
displays/menus/selectmodemenu.h
|
||||
displays/menus/settingsmenu.h
|
||||
displays/menus/stationwifisettingsmenu.h
|
||||
displays/menus/tempomatmodesettingsmenu.h
|
||||
displays/menus/timersmenu.h
|
||||
displays/menus/wifisettingsmenu.h
|
||||
displays/menus/controllerhardwaresettingsmenu.h
|
||||
displays/menus/boardcomputerhardwaresettingsmenu.h
|
||||
displays/menus/dynamicdebugmenu.h
|
||||
displays/menus/limitssettingsmenu.h
|
||||
displays/menus/mainmenu.h
|
||||
displays/menus/motorfeedbackdebugmenu.h
|
||||
displays/menus/wifiscanmenu.h
|
||||
displays/pingpongdisplay.h
|
||||
displays/poweroffdisplay.h
|
||||
displays/spirodisplay.h
|
||||
displays/splitgraphdisplay.h
|
||||
displays/starfielddisplay.h
|
||||
displays/bmsdisplay.h
|
||||
displays/calibratedisplay.h
|
||||
displays/dpad5wiredebugdisplay.h
|
||||
displays/gametrakcalibratedisplay.h
|
||||
displays/lockscreen.h
|
||||
displays/metersdisplay.h
|
||||
displays/powersupplydisplay.h
|
||||
displays/statusdisplay.h
|
||||
displays/updatedisplay.h
|
||||
esp_websocket_client.h
|
||||
fontinterface.h
|
||||
htmltag.h
|
||||
icon.h
|
||||
iconinterface.h
|
||||
icons/alert.h
|
||||
icons/back.h
|
||||
icons/bluetooth.h
|
||||
icons/bms.h
|
||||
icons/buzzer.h
|
||||
icons/checked.h
|
||||
icons/close.h
|
||||
icons/demos.h
|
||||
icons/graph.h
|
||||
icons/hardware.h
|
||||
icons/info.h
|
||||
icons/lock.h
|
||||
icons/logo.h
|
||||
icons/modes.h
|
||||
icons/poweroff.h
|
||||
icons/presets.h
|
||||
icons/reboot.h
|
||||
icons/scan.h
|
||||
icons/settings.h
|
||||
icons/unchecked.h
|
||||
icons/wifi.h
|
||||
menudisplay.h
|
||||
menuitem.h
|
||||
modes/defaultmode.h
|
||||
modes/gametrakmode.h
|
||||
modes/ignoreinputmode.h
|
||||
modes/larsmmode.h
|
||||
modes/tempomatmode.h
|
||||
rotary.h
|
||||
screens.h
|
||||
types.h
|
||||
widgets/progressbar.h
|
||||
widgets/reverseprogressbar.h
|
||||
widgets/verticalmeter.h
|
||||
widgets/vumeter.h
|
||||
widgets/graph.h
|
||||
widgets/label.h
|
||||
wifiaccessors.h
|
||||
esptexthelpers.h
|
||||
presets.h
|
||||
bluetoothtexthelpers.h
|
||||
bobby_webserver.h
|
||||
buttons.h
|
||||
can.h
|
||||
changevaluedisplay.h
|
||||
changevaluedisplay_controlmode.h
|
||||
changevaluedisplay_controltype.h
|
||||
controller.h
|
||||
debugtexthelpers.h
|
||||
display.h
|
||||
dpad.h
|
||||
dpad3wire.h
|
||||
dpad5wire.h
|
||||
feedbackparser.h
|
||||
globals.h
|
||||
htmlutils.h
|
||||
modeinterface.h
|
||||
ota.h
|
||||
serialhandler.h
|
||||
settings.h
|
||||
settingsaccessors.h
|
||||
settingspersister.h
|
||||
settingsutils.h
|
||||
statistics.h
|
||||
textinterface.h
|
||||
texts.h
|
||||
unifiedmodelmode.h
|
||||
utils.h
|
||||
wifitexthelpers.h
|
||||
)
|
||||
|
||||
set(sources
|
||||
main.cpp
|
||||
)
|
||||
|
||||
set(dependencies
|
||||
libsodium freertos nvs_flash esp_http_server esp_https_ota mdns app_update esp_system esp_websocket_client driver
|
||||
arduino-esp32 ArduinoJson
|
||||
# AsyncTCP
|
||||
bobbycar-protocol cpputils cxx-ring-buffer date
|
||||
# ESPAsyncWebServer
|
||||
espchrono espcpputils expected fmt TFT_eSPI
|
||||
)
|
||||
|
||||
idf_component_register(
|
||||
SRCS
|
||||
${headers}
|
||||
${sources}
|
||||
INCLUDE_DIRS
|
||||
.
|
||||
REQUIRES
|
||||
${dependencies}
|
||||
)
|
||||
|
||||
target_compile_options(${COMPONENT_TARGET}
|
||||
PRIVATE
|
||||
-fstack-reuse=all
|
||||
-fstack-protector-all
|
||||
-Wno-unused-function
|
||||
-Wno-deprecated-declarations
|
||||
-Wno-missing-field-initializers
|
||||
-Wno-parentheses
|
||||
)
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
namespace {
|
||||
class ActionInterface
|
||||
{
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <HardwareSerial.h>
|
||||
|
||||
#include "actioninterface.h"
|
||||
#include "globals.h"
|
||||
|
||||
@ -14,7 +12,7 @@ public:
|
||||
{
|
||||
if (!bluetoothSerial.begin(deviceName))
|
||||
{
|
||||
Serial.println("Could not begin bluetooth");
|
||||
//Serial.println("Could not begin bluetooth");
|
||||
// TODO: better error handling
|
||||
}
|
||||
}
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <HardwareSerial.h>
|
||||
|
||||
#include "actioninterface.h"
|
||||
#include "globals.h"
|
||||
|
||||
@ -14,7 +12,7 @@ public:
|
||||
{
|
||||
if (!bluetoothSerial.begin(deviceName, true))
|
||||
{
|
||||
Serial.println("Could not begin bluetooth master");
|
||||
//Serial.println("Could not begin bluetooth master");
|
||||
// TODO: better error handling
|
||||
}
|
||||
}
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <HardwareSerial.h>
|
||||
|
||||
#include "actioninterface.h"
|
||||
#include "globals.h"
|
||||
|
||||
@ -15,7 +13,7 @@ public:
|
||||
uint8_t remoteAddress[ESP_BD_ADDR_LEN] = {0xAA, 0xBB, 0xCC, 0xA1, 0x23, 0x45};
|
||||
if (!bluetoothSerial.connect(remoteAddress))
|
||||
{
|
||||
Serial.println("Could not connect bluetooth to bms");
|
||||
//Serial.println("Could not connect bluetooth to bms");
|
||||
// TODO: better error handling
|
||||
}
|
||||
}
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <HardwareSerial.h>
|
||||
|
||||
#include "actioninterface.h"
|
||||
#include "globals.h"
|
||||
|
||||
@ -14,7 +12,7 @@ public:
|
||||
{
|
||||
if (!bluetoothSerial.disconnect())
|
||||
{
|
||||
Serial.println("Could not disconnect bluetooth");
|
||||
//Serial.println("Could not disconnect bluetooth");
|
||||
// TODO: better error handling
|
||||
}
|
||||
}
|
@ -12,7 +12,7 @@ public:
|
||||
{
|
||||
if (!bms::send6Bit(42405, 250, 0))
|
||||
{
|
||||
Serial.println("Could not turn off charge mosfet");
|
||||
//Serial.println("Could not turn off charge mosfet");
|
||||
// TODO: better error handling
|
||||
}
|
||||
}
|
@ -12,7 +12,7 @@ public:
|
||||
{
|
||||
if (!bms::send6Bit(42405, 249, 0))
|
||||
{
|
||||
Serial.println("Could not turn off discharge mosfet");
|
||||
//Serial.println("Could not turn off discharge mosfet");
|
||||
// TODO: better error handling
|
||||
}
|
||||
}
|
@ -12,7 +12,7 @@ public:
|
||||
{
|
||||
if (!bms::send6Bit(42405, 250, 1))
|
||||
{
|
||||
Serial.println("Could not turn on charge mosfet");
|
||||
//Serial.println("Could not turn on charge mosfet");
|
||||
// TODO: better error handling
|
||||
}
|
||||
}
|
@ -12,7 +12,7 @@ public:
|
||||
{
|
||||
if (!bms::send6Bit(42405, 249, 1))
|
||||
{
|
||||
Serial.println("Could not turn on discharge mosfet");
|
||||
//Serial.println("Could not turn on discharge mosfet");
|
||||
// TODO: better error handling
|
||||
}
|
||||
}
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <HardwareSerial.h>
|
||||
|
||||
#include "actioninterface.h"
|
||||
#include "globals.h"
|
||||
#include "presets.h"
|
||||
@ -16,7 +14,7 @@ public:
|
||||
|
||||
if (!settingsPersister.erase())
|
||||
{
|
||||
Serial.println("EraseNvsAction::triggered() erase failed");
|
||||
//Serial.println("EraseNvsAction::triggered() erase failed");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -27,13 +25,13 @@ public:
|
||||
|
||||
if (!settingsPersister.openProfile(*profile))
|
||||
{
|
||||
Serial.println("EraseNvsAction::triggered() openProfile failed");
|
||||
//Serial.println("EraseNvsAction::triggered() openProfile failed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!settingsPersister.load(settings))
|
||||
{
|
||||
Serial.println("EraseNvsAction::triggered() load failed");
|
||||
//Serial.println("EraseNvsAction::triggered() load failed");
|
||||
return;
|
||||
}
|
||||
}
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <HardwareSerial.h>
|
||||
|
||||
#include "actioninterface.h"
|
||||
#include "globals.h"
|
||||
#include "modes/defaultmode.h"
|
||||
@ -33,6 +31,8 @@ void ModeSettingsAction::triggered()
|
||||
switchScreen<GametrakModeSettingsMenu>();
|
||||
#endif
|
||||
else
|
||||
Serial.println("Unknown mode, cannot open settings for it");
|
||||
{
|
||||
//Serial.println("Unknown mode, cannot open settings for it");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <Esp.h>
|
||||
#include <esp_system.h>
|
||||
|
||||
#include "actioninterface.h"
|
||||
#include "globals.h"
|
||||
@ -22,7 +22,7 @@ public:
|
||||
tft.setTextColor(TFT_WHITE);
|
||||
tft.drawString("Rebooting now...", 0, 50, 4);
|
||||
|
||||
ESP.restart();
|
||||
esp_restart();
|
||||
}
|
||||
};
|
||||
}
|
@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <HardwareSerial.h>
|
||||
|
||||
#include "actioninterface.h"
|
||||
#include "settingsutils.h"
|
||||
|
@ -1,8 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <HardwareSerial.h>
|
||||
#include <WiFi.h>
|
||||
|
||||
#include "actioninterface.h"
|
||||
|
||||
namespace {
|
||||
@ -11,11 +8,11 @@ class WifiDisconnectAction : public virtual ActionInterface
|
||||
public:
|
||||
void triggered() override
|
||||
{
|
||||
if (!WiFi.disconnect())
|
||||
{
|
||||
Serial.println("Could not disconnect WiFi");
|
||||
//if (!WiFi.disconnect())
|
||||
//{
|
||||
//Serial.println("Could not disconnect WiFi");
|
||||
// TODO: better error handling
|
||||
}
|
||||
//}
|
||||
}
|
||||
};
|
||||
}
|
@ -1,8 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <HardwareSerial.h>
|
||||
#include <WiFi.h>
|
||||
|
||||
#include "actioninterface.h"
|
||||
|
||||
namespace {
|
||||
@ -11,11 +8,11 @@ class WifiEnableIpV6Action : public virtual ActionInterface
|
||||
public:
|
||||
void triggered() override
|
||||
{
|
||||
if (!WiFi.enableIpV6())
|
||||
{
|
||||
Serial.println("Could not enableIpV6 WiFi");
|
||||
//if (!WiFi.enableIpV6())
|
||||
//{
|
||||
//Serial.println("Could not enableIpV6 WiFi");
|
||||
// TODO: better error handling
|
||||
}
|
||||
//}
|
||||
}
|
||||
};
|
||||
}
|
@ -1,8 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <HardwareSerial.h>
|
||||
#include <WiFi.h>
|
||||
|
||||
#include "actioninterface.h"
|
||||
|
||||
namespace {
|
||||
@ -11,11 +8,11 @@ class WifiReconnectAction : public virtual ActionInterface
|
||||
public:
|
||||
void triggered() override
|
||||
{
|
||||
if (!WiFi.reconnect())
|
||||
{
|
||||
Serial.println("Could not reconnect WiFi");
|
||||
//if (!WiFi.reconnect())
|
||||
//{
|
||||
//Serial.println("Could not reconnect WiFi");
|
||||
// TODO: better error handling
|
||||
}
|
||||
//}
|
||||
}
|
||||
};
|
||||
}
|
@ -1,8 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <HardwareSerial.h>
|
||||
#include <WiFi.h>
|
||||
|
||||
#include "actioninterface.h"
|
||||
#include "globals.h"
|
||||
#include "utils.h"
|
||||
@ -13,11 +10,11 @@ class WifiSoftApAction : public virtual ActionInterface
|
||||
public:
|
||||
void triggered() override
|
||||
{
|
||||
if (!WiFi.softAP(deviceName, STRING(AP_PASSWORD)))
|
||||
{
|
||||
Serial.println("Could not softAP WiFi");
|
||||
//if (!WiFi.softAP(deviceName, STRING(AP_PASSWORD)))
|
||||
//{
|
||||
//Serial.println("Could not softAP WiFi");
|
||||
// TODO: better error handling
|
||||
}
|
||||
//}
|
||||
}
|
||||
};
|
||||
}
|
@ -1,8 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <HardwareSerial.h>
|
||||
#include <WiFi.h>
|
||||
|
||||
#include "actioninterface.h"
|
||||
|
||||
namespace {
|
||||
@ -11,11 +8,11 @@ class WifiSoftApDisconnectAction : public virtual ActionInterface
|
||||
public:
|
||||
void triggered() override
|
||||
{
|
||||
if (!WiFi.softAPdisconnect())
|
||||
{
|
||||
Serial.println("Could not softAPdisconnect WiFi");
|
||||
//if (!WiFi.softAPdisconnect())
|
||||
//{
|
||||
//Serial.println("Could not softAPdisconnect WiFi");
|
||||
// TODO: better error handling
|
||||
}
|
||||
//}
|
||||
}
|
||||
};
|
||||
}
|
@ -1,8 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <HardwareSerial.h>
|
||||
#include <WiFi.h>
|
||||
|
||||
#include "actioninterface.h"
|
||||
|
||||
namespace {
|
||||
@ -11,11 +8,11 @@ class WifiSoftApDisconnectWifioffAction : public virtual ActionInterface
|
||||
public:
|
||||
void triggered() override
|
||||
{
|
||||
if (!WiFi.softAPdisconnect(true))
|
||||
{
|
||||
Serial.println("Could not softAPdisconnect wifioff WiFi");
|
||||
//if (!WiFi.softAPdisconnect(true))
|
||||
//{
|
||||
//Serial.println("Could not softAPdisconnect wifioff WiFi");
|
||||
// TODO: better error handling
|
||||
}
|
||||
//}
|
||||
}
|
||||
};
|
||||
}
|
@ -1,8 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <HardwareSerial.h>
|
||||
#include <WiFi.h>
|
||||
|
||||
#include "actioninterface.h"
|
||||
|
||||
namespace {
|
||||
@ -11,11 +8,11 @@ class WifiSoftApEnableIpV6Action : public virtual ActionInterface
|
||||
public:
|
||||
void triggered() override
|
||||
{
|
||||
if (!WiFi.softAPenableIpV6())
|
||||
{
|
||||
Serial.println("Could not softAPenableIpV6 WiFi");
|
||||
//if (!WiFi.softAPenableIpV6())
|
||||
//{
|
||||
//Serial.println("Could not softAPenableIpV6 WiFi");
|
||||
// TODO: better error handling
|
||||
}
|
||||
//}
|
||||
}
|
||||
};
|
||||
}
|
@ -1,7 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <espchrono.h>
|
||||
|
||||
#include "globals.h"
|
||||
#include "types.h"
|
||||
|
||||
namespace {
|
||||
#if defined(FEATURE_BLUETOOTH) && defined(FEATURE_BMS)
|
||||
@ -9,8 +10,8 @@ namespace bms {
|
||||
constexpr auto autoReconnect = false; // causes hangs when not available
|
||||
|
||||
bool lastConnected;
|
||||
millis_t lastSend;
|
||||
millis_t lastReceive;
|
||||
espchrono::millis_clock::time_point lastSend;
|
||||
espchrono::millis_clock::time_point lastReceive;
|
||||
|
||||
float voltage;
|
||||
float current;
|
||||
@ -32,13 +33,15 @@ bool send6Bit(int zhen_tou, int address, int data)
|
||||
|
||||
const auto sent = bluetoothSerial.write(buffer, 6);
|
||||
if (sent != 6)
|
||||
Serial.printf("send: %u\r\n", sent);
|
||||
{
|
||||
//Serial.printf("send: %u\r\n", sent);
|
||||
}
|
||||
return sent == 6;
|
||||
}
|
||||
|
||||
void update()
|
||||
{
|
||||
const auto now = millis();
|
||||
const auto now = espchrono::millis_clock::now();
|
||||
|
||||
if (bluetoothSerial.hasClient() != lastConnected)
|
||||
{
|
||||
@ -54,11 +57,13 @@ void update()
|
||||
const auto read = bluetoothSerial.readBytes(buffer, 140);
|
||||
if (read != 140)
|
||||
{
|
||||
Serial.printf("bms read buffer too short %u\r\n", read);
|
||||
//Serial.printf("bms read buffer too short %u\r\n", read);
|
||||
|
||||
for (int i = 0; i < read; i++)
|
||||
Serial.printf("%i ", buffer[i]);
|
||||
Serial.println();
|
||||
{
|
||||
//Serial.printf("%i ", buffer[i]);
|
||||
}
|
||||
//Serial.println();
|
||||
|
||||
goto after_read;
|
||||
}
|
||||
@ -68,11 +73,13 @@ void update()
|
||||
buffer[2] != 170 ||
|
||||
buffer[3] != 255)
|
||||
{
|
||||
Serial.println("bms read buffer wrong sequence");
|
||||
//Serial.println("bms read buffer wrong sequence");
|
||||
|
||||
for (const auto &x : buffer)
|
||||
Serial.printf("%i ", x);
|
||||
Serial.println();
|
||||
{
|
||||
//Serial.printf("%i ", x);
|
||||
}
|
||||
//Serial.println();
|
||||
|
||||
goto after_read;
|
||||
}
|
||||
@ -91,19 +98,23 @@ void update()
|
||||
}
|
||||
// else if (bluetoothSerial.available())
|
||||
// {
|
||||
// Serial.printf("available() = %i\r\n", bluetoothSerial.available());
|
||||
// //Serial.printf("available() = %i\r\n", bluetoothSerial.available());
|
||||
// while (bluetoothSerial.available())
|
||||
// Serial.printf("%i ", bluetoothSerial.read());
|
||||
// Serial.println();
|
||||
// {
|
||||
// //Serial.printf("%i ", bluetoothSerial.read());
|
||||
// }
|
||||
// //Serial.println();
|
||||
// }
|
||||
|
||||
after_read:
|
||||
|
||||
if (!lastSend || now-lastSend >= 1000)
|
||||
{
|
||||
Serial.println("requresting bms live values");
|
||||
//Serial.println("requresting bms live values");
|
||||
if (!send6Bit(56283, 0, 0))
|
||||
Serial.println("could not request bms live values");
|
||||
{
|
||||
//Serial.println("could not request bms live values");
|
||||
}
|
||||
lastSend = now;
|
||||
}
|
||||
}
|
||||
@ -112,9 +123,9 @@ void update()
|
||||
if (!lastSend || now-lastSend >= 500)
|
||||
{
|
||||
uint8_t remoteAddress[ESP_BD_ADDR_LEN] = {0xAA, 0xBB, 0xCC, 0xA1, 0x23, 0x45};
|
||||
Serial.println("connect()");
|
||||
//Serial.println("connect()");
|
||||
const auto result = bluetoothSerial.connect(remoteAddress);
|
||||
Serial.printf("connect() returned %s\r\n", result?"true":"false");
|
||||
//Serial.printf("connect() returned %s\r\n", result?"true":"false");
|
||||
|
||||
lastSend = now;
|
||||
}
|
@ -1,7 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
// 3rdparty lib includes
|
||||
#ifdef FEATURE_WEBSERVER
|
||||
#include <ESPAsyncWebServer.h>
|
||||
#endif
|
||||
|
||||
// local includes
|
||||
#include "screens.h"
|
||||
@ -268,11 +270,11 @@ void initWebserver()
|
||||
return [size, command](AsyncWebServerRequest *request, String filename, size_t index, uint8_t *data, size_t len, bool final){
|
||||
//ESP_UNUSED(request)
|
||||
|
||||
Serial.printf("callback %u %u\r\n", index, len);
|
||||
//Serial.printf("callback %u %u\r\n", index, len);
|
||||
|
||||
if (!index)
|
||||
{
|
||||
Serial.printf("Update Start: %s\r\n", filename.c_str());
|
||||
//Serial.printf("Update Start: %s\r\n", filename.c_str());
|
||||
//Update.runAsync(true);
|
||||
if (!Update.begin(size, command))
|
||||
Update.printError(Serial);
|
||||
@ -316,7 +318,7 @@ void initWebserver()
|
||||
{
|
||||
if (Update.end(true))
|
||||
{
|
||||
Serial.printf("Update Success: %uB\r\n", index + len);
|
||||
//Serial.printf("Update Success: %uB\r\n", index + len);
|
||||
|
||||
((UpdateDisplay*)currentDisplay.get())->m_finished = true;
|
||||
((UpdateDisplay*)currentDisplay.get())->redraw();
|
@ -3,8 +3,9 @@
|
||||
// Arduino includes
|
||||
#include <Arduino.h>
|
||||
|
||||
#include <espchrono.h>
|
||||
|
||||
// local includes
|
||||
#include "types.h"
|
||||
#include "settingsutils.h"
|
||||
|
||||
namespace {
|
||||
@ -27,9 +28,9 @@ public:
|
||||
|
||||
static void confirmButton(bool pressed)
|
||||
{
|
||||
static millis_t pressBegin = 0;
|
||||
static espchrono::millis_clock::time_point pressBegin{};
|
||||
|
||||
const auto now = millis();
|
||||
const auto now = espchrono::millis_clock::now();
|
||||
|
||||
if (pressed)
|
||||
pressBegin = now;
|
||||
@ -37,22 +38,22 @@ public:
|
||||
{
|
||||
const auto duration = now - pressBegin;
|
||||
|
||||
if (duration < 500)
|
||||
if (duration < 500ms)
|
||||
confirmButtonPressed = true;
|
||||
else if (duration < 2000)
|
||||
else if (duration < 2000ms)
|
||||
confirmButtonLongPressed = true;
|
||||
else
|
||||
requestFullRedraw = true;
|
||||
|
||||
pressBegin = 0;
|
||||
pressBegin = {};
|
||||
}
|
||||
}
|
||||
|
||||
static void backButton(bool pressed)
|
||||
{
|
||||
static millis_t pressBegin = 0;
|
||||
static espchrono::millis_clock::time_point pressBegin{};
|
||||
|
||||
const auto now = millis();
|
||||
const auto now = espchrono::millis_clock::now();
|
||||
|
||||
if (pressed)
|
||||
pressBegin = now;
|
||||
@ -60,12 +61,12 @@ public:
|
||||
{
|
||||
const auto duration = now - pressBegin;
|
||||
|
||||
if (duration < 500)
|
||||
if (duration < 500ms)
|
||||
backButtonPressed = true;
|
||||
else
|
||||
backButtonLongPressed = true;
|
||||
|
||||
pressBegin = 0;
|
||||
pressBegin = {};
|
||||
}
|
||||
}
|
||||
|
@ -4,20 +4,21 @@
|
||||
#include <optional>
|
||||
|
||||
#include <driver/gpio.h>
|
||||
#include <driver/can.h>
|
||||
#include <driver/twai.h>
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "bobbycar-protocol/bobbycar-can.h"
|
||||
#include <espchrono.h>
|
||||
|
||||
#include "bobbycar-can.h"
|
||||
|
||||
#include "types.h"
|
||||
#include "globals.h"
|
||||
#include "buttons.h"
|
||||
|
||||
namespace can {
|
||||
namespace {
|
||||
std::optional<int16_t> can_gas, can_brems;
|
||||
millis_t last_can_gas{}, last_can_brems{};
|
||||
espchrono::millis_clock::time_point last_can_gas{}, last_can_brems{};
|
||||
|
||||
struct CanButtonsState
|
||||
{
|
||||
@ -34,11 +35,11 @@ CanButtonsState lastButtonsState;
|
||||
|
||||
void initCan()
|
||||
{
|
||||
Serial.println("initCan()");
|
||||
//Serial.println("initCan()");
|
||||
|
||||
can_general_config_t g_config = CAN_GENERAL_CONFIG_DEFAULT(GPIO_NUM_21, GPIO_NUM_22, CAN_MODE_NORMAL);
|
||||
can_timing_config_t t_config CAN_TIMING_CONFIG_250KBITS();
|
||||
can_filter_config_t f_config CAN_FILTER_CONFIG_ACCEPT_ALL();
|
||||
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();
|
||||
// {
|
||||
// //
|
||||
// .acceptance_code = 0b00000000000,
|
||||
@ -46,31 +47,31 @@ void initCan()
|
||||
// .single_filter = true
|
||||
// };
|
||||
|
||||
if (const auto result = can_driver_install(&g_config, &t_config, &f_config); result == ESP_OK)
|
||||
if (const auto result = twai_driver_install(&g_config, &t_config, &f_config); result == ESP_OK)
|
||||
{
|
||||
Serial.printf("CAN info can_driver_install() succeeded\r\n");
|
||||
//Serial.printf("CAN info twai_driver_install() succeeded\r\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.printf("CAN err can_driver_install() failed with %s\r\n", esp_err_to_name(result));
|
||||
//Serial.printf("CAN err twai_driver_install() failed with %s\r\n", esp_err_to_name(result));
|
||||
return;
|
||||
}
|
||||
|
||||
if (const auto result = can_start(); result == ESP_OK)
|
||||
if (const auto result = twai_start(); result == ESP_OK)
|
||||
{
|
||||
Serial.printf("CAN info can_start() succeeded\r\n");
|
||||
//Serial.printf("CAN info twai_start() succeeded\r\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.printf("CAN err can_start() failed with %s\r\n", esp_err_to_name(result));
|
||||
//Serial.printf("CAN err twai_start() failed with %s\r\n", esp_err_to_name(result));
|
||||
|
||||
if (const auto result = can_driver_uninstall(); result == ESP_OK)
|
||||
if (const auto result = twai_driver_uninstall(); result == ESP_OK)
|
||||
{
|
||||
Serial.printf("CAN info can_driver_uninstall() succeeded\r\n");
|
||||
//Serial.printf("CAN info twai_driver_uninstall() succeeded\r\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.printf("CAN err can_driver_uninstall() failed with %s\r\n", esp_err_to_name(result));
|
||||
//Serial.printf("CAN err twai_driver_uninstall() failed with %s\r\n", esp_err_to_name(result));
|
||||
}
|
||||
|
||||
return;
|
||||
@ -78,7 +79,7 @@ void initCan()
|
||||
}
|
||||
|
||||
template<bool isBack>
|
||||
bool parseMotorControllerCanMessage(const can_message_t &message, Controller &controller)
|
||||
bool parseMotorControllerCanMessage(const twai_message_t &message, Controller &controller)
|
||||
{
|
||||
switch (message.identifier)
|
||||
{
|
||||
@ -154,7 +155,7 @@ bool parseMotorControllerCanMessage(const can_message_t &message, Controller &co
|
||||
return false;
|
||||
}
|
||||
|
||||
bool parseBoardcomputerCanMessage(const can_message_t &message)
|
||||
bool parseBoardcomputerCanMessage(const twai_message_t &message)
|
||||
{
|
||||
switch (message.identifier)
|
||||
{
|
||||
@ -204,11 +205,11 @@ bool parseBoardcomputerCanMessage(const can_message_t &message)
|
||||
}
|
||||
case Boardcomputer::Command::RawGas:
|
||||
can_gas = *((int16_t*)message.data);
|
||||
last_can_gas = millis();
|
||||
last_can_gas = espchrono::millis_clock::now();
|
||||
break;
|
||||
case Boardcomputer::Command::RawBrems:
|
||||
can_brems = *((int16_t*)message.data);
|
||||
last_can_brems = millis();
|
||||
last_can_brems = espchrono::millis_clock::now();
|
||||
break;
|
||||
}
|
||||
|
||||
@ -217,18 +218,20 @@ bool parseBoardcomputerCanMessage(const can_message_t &message)
|
||||
|
||||
bool tryParseCanInput()
|
||||
{
|
||||
can_message_t message;
|
||||
if (const auto result = can_receive(&message, pdMS_TO_TICKS(50)); result != ESP_OK)
|
||||
twai_message_t message;
|
||||
if (const auto result = twai_receive(&message, pdMS_TO_TICKS(50)); result != ESP_OK)
|
||||
{
|
||||
if (millis() - controllers.front.lastCanFeedback > 100)
|
||||
if (result != ESP_ERR_TIMEOUT)
|
||||
{
|
||||
//Serial.printf("CAN err twai_receive() failed with %s\r\n", esp_err_to_name(result));
|
||||
}
|
||||
|
||||
if (espchrono::millis_clock::now() - controllers.front.lastCanFeedback > 100ms)
|
||||
controllers.front.feedbackValid = false;
|
||||
|
||||
if (millis() - controllers.back.lastCanFeedback > 100)
|
||||
if (espchrono::millis_clock::now() - controllers.back.lastCanFeedback > 100ms)
|
||||
controllers.back.feedbackValid = false;
|
||||
|
||||
if (result != ESP_ERR_TIMEOUT)
|
||||
Serial.printf("CAN err can_receive() failed with %s\r\n", esp_err_to_name(result));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -237,28 +240,28 @@ bool tryParseCanInput()
|
||||
|
||||
if (parseMotorControllerCanMessage<false>(message, front))
|
||||
{
|
||||
if (millis() - back.lastCanFeedback > 100)
|
||||
if (espchrono::millis_clock::now() - back.lastCanFeedback > 100ms)
|
||||
back.feedbackValid = false;
|
||||
|
||||
front.lastCanFeedback = millis();
|
||||
front.lastCanFeedback = espchrono::millis_clock::now();
|
||||
front.feedbackValid = true;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (millis() - front.lastCanFeedback > 100)
|
||||
if (espchrono::millis_clock::now() - front.lastCanFeedback > 100ms)
|
||||
front.feedbackValid = false;
|
||||
}
|
||||
|
||||
if (parseMotorControllerCanMessage<true>(message, back))
|
||||
{
|
||||
back.lastCanFeedback = millis();
|
||||
back.lastCanFeedback = espchrono::millis_clock::now();
|
||||
back.feedbackValid = true;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (millis() - back.lastCanFeedback > 100)
|
||||
if (espchrono::millis_clock::now() - back.lastCanFeedback > 100ms)
|
||||
back.feedbackValid = false;
|
||||
}
|
||||
|
||||
@ -280,16 +283,18 @@ void parseCanInput()
|
||||
void sendCanCommands()
|
||||
{
|
||||
constexpr auto send = [](uint32_t addr, auto value){
|
||||
can_message_t message;
|
||||
twai_message_t message;
|
||||
message.identifier = addr;
|
||||
message.flags = CAN_MSG_FLAG_SS;
|
||||
message.flags = TWAI_MSG_FLAG_SS;
|
||||
message.data_length_code = sizeof(value);
|
||||
std::fill(std::begin(message.data), std::end(message.data), 0);
|
||||
std::memcpy(message.data, &value, sizeof(value));
|
||||
|
||||
const auto result = can_transmit(&message, pdMS_TO_TICKS(200));
|
||||
const auto result = twai_transmit(&message, pdMS_TO_TICKS(200));
|
||||
if (result != ESP_OK && result != ESP_ERR_TIMEOUT)
|
||||
Serial.printf("ERROR: can_transmit() failed with %s\r\n", esp_err_to_name(result));
|
||||
{
|
||||
//Serial.printf("ERROR: twai_transmit() failed with %s\r\n", esp_err_to_name(result));
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
@ -412,6 +417,7 @@ void sendCanCommands()
|
||||
case 10:
|
||||
if (send(Boardcomputer::Feedback::ButtonLeds, buttonLeds) == ESP_OK)
|
||||
lastValues.buttonLeds = buttonLeds;
|
||||
[[fallthrough]]
|
||||
default:
|
||||
i=0;
|
||||
break;
|
@ -45,7 +45,7 @@ void ChangeValueDisplay<BluetoothMode>::start()
|
||||
case BluetoothMode::Master: setSelectedIndex(1); break;
|
||||
case BluetoothMode::Slave: setSelectedIndex(2); break;
|
||||
default:
|
||||
Serial.printf("Unknown BluetoothMode: %i\r\n", int(value));
|
||||
//Serial.printf("Unknown BluetoothMode: %i\r\n", int(value));
|
||||
setSelectedIndex(4);
|
||||
}
|
||||
}
|
@ -45,7 +45,7 @@ void ChangeValueDisplay<bobbycar::protocol::ControlMode>::start()
|
||||
case ControlMode::Speed: setSelectedIndex(2); break;
|
||||
case ControlMode::Torque: setSelectedIndex(3); break;
|
||||
default:
|
||||
Serial.printf("Unknown ControlMode: %i\r\n", int(value));
|
||||
//Serial.printf("Unknown ControlMode: %i\r\n", int(value));
|
||||
setSelectedIndex(4);
|
||||
}
|
||||
}
|
@ -43,7 +43,7 @@ void ChangeValueDisplay<bobbycar::protocol::ControlType>::start()
|
||||
case ControlType::Sinusoidal: setSelectedIndex(1); break;
|
||||
case ControlType::FieldOrientedControl: setSelectedIndex(2); break;
|
||||
default:
|
||||
Serial.printf("Unknown ControlType: %i\r\n", int(value));
|
||||
//Serial.printf("Unknown ControlType: %i\r\n", int(value));
|
||||
setSelectedIndex(3);
|
||||
}
|
||||
}
|
@ -44,7 +44,7 @@ void ChangeValueDisplay<LarsmModeMode>::start()
|
||||
case LarsmModeMode::Mode3: setSelectedIndex(2); break;
|
||||
case LarsmModeMode::Mode4: setSelectedIndex(3); break;
|
||||
default:
|
||||
Serial.printf("Unknown LarsmModeMode: %i\r\n", int(value));
|
||||
//Serial.printf("Unknown LarsmModeMode: %i\r\n", int(value));
|
||||
setSelectedIndex(4);
|
||||
}
|
||||
}
|
@ -46,7 +46,7 @@ void ChangeValueDisplay<UnifiedModelMode>::start()
|
||||
case UnifiedModelMode::FocSpeed: setSelectedIndex(3); break;
|
||||
case UnifiedModelMode::FocTorque: setSelectedIndex(4); break;
|
||||
default:
|
||||
Serial.printf("Unknown UnifiedModelMode: %i\r\n", int(value));
|
||||
//Serial.printf("Unknown UnifiedModelMode: %i\r\n", int(value));
|
||||
setSelectedIndex(5);
|
||||
}
|
||||
}
|
@ -45,7 +45,7 @@ void ChangeValueDisplay<wifi_mode_t>::start()
|
||||
case WIFI_MODE_AP: setSelectedIndex(2); break;
|
||||
case WIFI_MODE_APSTA: setSelectedIndex(3); break;
|
||||
default:
|
||||
Serial.printf("Unknown wifi_mode_t: %i\r\n", int(value));
|
||||
//Serial.printf("Unknown wifi_mode_t: %i\r\n", int(value));
|
||||
setSelectedIndex(4);
|
||||
}
|
||||
}
|
66
main/changevaluedisplay_wifi_power_t.h
Normal file
66
main/changevaluedisplay_wifi_power_t.h
Normal file
@ -0,0 +1,66 @@
|
||||
#pragma once
|
||||
|
||||
#include "changevaluedisplay.h"
|
||||
#include "menudisplay.h"
|
||||
#include "utils.h"
|
||||
#include "actions/setvalueaction.h"
|
||||
#include "actions/backproxyaction.h"
|
||||
#include "icons/back.h"
|
||||
#include "texts.h"
|
||||
|
||||
namespace {
|
||||
//template<>
|
||||
//class ChangeValueDisplay<wifi_power_t> :
|
||||
// public MenuDisplay,
|
||||
// public virtual AccessorInterface<wifi_power_t>,
|
||||
// public virtual ActionInterface
|
||||
//{
|
||||
// using Base = MenuDisplay;
|
||||
|
||||
//public:
|
||||
// ChangeValueDisplay();
|
||||
|
||||
// void start() override;
|
||||
//};
|
||||
|
||||
//ChangeValueDisplay<wifi_power_t>::ChangeValueDisplay()
|
||||
//{
|
||||
// constructMenuItem<makeComponentArgs<MenuItem, SetValueAction<wifi_power_t>, StaticText<TEXT_WIFI_POWER_19_5dBm>>>(WIFI_POWER_19_5dBm, *this, *this);
|
||||
// constructMenuItem<makeComponentArgs<MenuItem, SetValueAction<wifi_power_t>, StaticText<TEXT_WIFI_POWER_19dBm>>>(WIFI_POWER_19dBm, *this, *this);
|
||||
// constructMenuItem<makeComponentArgs<MenuItem, SetValueAction<wifi_power_t>, StaticText<TEXT_WIFI_POWER_18_5dBm>>>(WIFI_POWER_18_5dBm, *this, *this);
|
||||
// constructMenuItem<makeComponentArgs<MenuItem, SetValueAction<wifi_power_t>, StaticText<TEXT_WIFI_POWER_17dBm>>>(WIFI_POWER_17dBm, *this, *this);
|
||||
// constructMenuItem<makeComponentArgs<MenuItem, SetValueAction<wifi_power_t>, StaticText<TEXT_WIFI_POWER_15dBm>>>(WIFI_POWER_15dBm, *this, *this);
|
||||
// constructMenuItem<makeComponentArgs<MenuItem, SetValueAction<wifi_power_t>, StaticText<TEXT_WIFI_POWER_13dBm>>>(WIFI_POWER_13dBm, *this, *this);
|
||||
// constructMenuItem<makeComponentArgs<MenuItem, SetValueAction<wifi_power_t>, StaticText<TEXT_WIFI_POWER_11dBm>>>(WIFI_POWER_11dBm, *this, *this);
|
||||
// constructMenuItem<makeComponentArgs<MenuItem, SetValueAction<wifi_power_t>, StaticText<TEXT_WIFI_POWER_8_5dBm>>>(WIFI_POWER_8_5dBm, *this, *this);
|
||||
// constructMenuItem<makeComponentArgs<MenuItem, SetValueAction<wifi_power_t>, StaticText<TEXT_WIFI_POWER_7dBm>>>(WIFI_POWER_7dBm, *this, *this);
|
||||
// constructMenuItem<makeComponentArgs<MenuItem, SetValueAction<wifi_power_t>, StaticText<TEXT_WIFI_POWER_5dBm>>>(WIFI_POWER_5dBm, *this, *this);
|
||||
// constructMenuItem<makeComponentArgs<MenuItem, SetValueAction<wifi_power_t>, StaticText<TEXT_WIFI_POWER_2dBm>>>(WIFI_POWER_2dBm, *this, *this);
|
||||
// constructMenuItem<makeComponentArgs<MenuItem, SetValueAction<wifi_power_t>, StaticText<TEXT_WIFI_POWER_MINUS_1dBm>>>(WIFI_POWER_MINUS_1dBm, *this, *this);
|
||||
// constructMenuItem<makeComponentArgs<MenuItem, BackProxyAction, StaticText<TEXT_BACK>, StaticMenuItemIcon<&icons::back>>>(*this);
|
||||
//}
|
||||
|
||||
//void ChangeValueDisplay<wifi_power_t>::start()
|
||||
//{
|
||||
// Base::start();
|
||||
|
||||
// switch (const auto value = getValue())
|
||||
// {
|
||||
// case WIFI_POWER_19_5dBm: setSelectedIndex(0); break;
|
||||
// case WIFI_POWER_19dBm: setSelectedIndex(1); break;
|
||||
// case WIFI_POWER_18_5dBm: setSelectedIndex(2); break;
|
||||
// case WIFI_POWER_17dBm: setSelectedIndex(3); break;
|
||||
// case WIFI_POWER_15dBm: setSelectedIndex(4); break;
|
||||
// case WIFI_POWER_13dBm: setSelectedIndex(5); break;
|
||||
// case WIFI_POWER_11dBm: setSelectedIndex(6); break;
|
||||
// case WIFI_POWER_8_5dBm: setSelectedIndex(7); break;
|
||||
// case WIFI_POWER_7dBm: setSelectedIndex(8); break;
|
||||
// case WIFI_POWER_5dBm: setSelectedIndex(9); break;
|
||||
// case WIFI_POWER_2dBm: setSelectedIndex(10); break;
|
||||
// case WIFI_POWER_MINUS_1dBm: setSelectedIndex(11); break;
|
||||
// default:
|
||||
// //Serial.printf("Unknown wifi_power_t: %i\r\n", int(value));
|
||||
// setSelectedIndex(12);
|
||||
// }
|
||||
//}
|
||||
}
|
106
main/cloud.h
Normal file
106
main/cloud.h
Normal file
@ -0,0 +1,106 @@
|
||||
#pragma once
|
||||
|
||||
// esp-idf includes
|
||||
#ifdef FEATURE_CLOUD
|
||||
#include <esp_websocket_client.h>
|
||||
#include <freertos/FreeRTOS.h>
|
||||
#include <freertos/task.h>
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
#ifdef FEATURE_CLOUD
|
||||
void cloudTask(void*)
|
||||
{
|
||||
const esp_websocket_client_config_t config = {
|
||||
.uri = "ws://iot.wattpilot.io:8080/charger/bobbycar1",
|
||||
};
|
||||
esp_websocket_client_handle_t handle = esp_websocket_client_init(&config);
|
||||
|
||||
if (handle)
|
||||
{
|
||||
//Serial.println("esp websocket init succeeded");
|
||||
|
||||
if (const auto result = esp_websocket_client_start(handle); result == ESP_OK)
|
||||
{
|
||||
//Serial.println("esp websocket start succeeded");
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (esp_websocket_client_is_connected(handle))
|
||||
{
|
||||
std::string msg = "{"
|
||||
"\"type\": \"fullStatus\","
|
||||
"\"partial\": false, "
|
||||
"\"status\": {"
|
||||
"\"millis\":" + std::to_string(std::chrono::milliseconds{espchrono::millis_clock::now().time_since_epoch()}.count()) + ","
|
||||
"\"front.valid\":" + std::to_string(controllers.front.feedbackValid) + ","
|
||||
"\"back.valid\":" + std::to_string(controllers.back.feedbackValid) + ","
|
||||
"\"front.left.pwm\":" + std::to_string(controllers.front.command.left.pwm) + ","
|
||||
"\"front.right.pwm\":" + std::to_string(controllers.front.command.right.pwm) + ","
|
||||
"\"back.left.pwm\":" + std::to_string(controllers.back.command.left.pwm) + ","
|
||||
"\"back.right.pwm\":" + std::to_string(controllers.back.command.right.pwm) + ","
|
||||
"\"front.volt\":" + std::to_string(controllers.front.feedback.batVoltage) + ","
|
||||
"\"back.volt\":" + std::to_string(controllers.back.feedback.batVoltage) + ","
|
||||
"\"front.temp\":" + std::to_string(controllers.front.feedback.boardTemp) + ","
|
||||
"\"back.temp\":" + std::to_string(controllers.back.feedback.boardTemp) + ","
|
||||
"\"front.bad\":" + std::to_string(controllers.front.feedback.timeoutCntSerial) + ","
|
||||
"\"back.bad\":" + std::to_string(controllers.back.feedback.timeoutCntSerial) + ","
|
||||
"\"front.left.speed\":" + std::to_string(controllers.front.feedback.left.speed) + ","
|
||||
"\"front.right.speed\":" + std::to_string(controllers.front.feedback.right.speed) + ","
|
||||
"\"back.left.speed\":" + std::to_string(controllers.back.feedback.left.speed) + ","
|
||||
"\"back.right.speed\":" + std::to_string(controllers.back.feedback.right.speed) + ","
|
||||
"\"front.left.current\":" + std::to_string(controllers.front.feedback.left.dcLink) + ","
|
||||
"\"front.right.current\":" + std::to_string(controllers.front.feedback.right.dcLink) + ","
|
||||
"\"back.left.current\":" + std::to_string(controllers.back.feedback.left.dcLink) + ","
|
||||
"\"back.right.current\":" + std::to_string(controllers.back.feedback.right.dcLink) + ","
|
||||
"\"front.left.error\":" + std::to_string(controllers.front.feedback.left.error) + ","
|
||||
"\"front.right.error\":" + std::to_string(controllers.front.feedback.right.error) + ","
|
||||
"\"back.left.error\":" + std::to_string(controllers.back.feedback.left.error) + ","
|
||||
"\"back.right.error\":" + std::to_string(controllers.back.feedback.right.error) +
|
||||
"}"
|
||||
"}";
|
||||
|
||||
const auto sent = esp_websocket_client_send_text(handle, msg.c_str(), msg.length(), 1000 / portTICK_PERIOD_MS);
|
||||
if (sent == msg.length())
|
||||
{
|
||||
//Serial.println("Sent cloud message");
|
||||
}
|
||||
else
|
||||
{
|
||||
//Serial.printf("sent=%i, msgsize=%i\r\n", sent, msg.length());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Serial.println("Not sending cloud because not connected");
|
||||
}
|
||||
|
||||
delay(100);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Serial.printf("esp websocket start failed with %s\r\n", esp_err_to_name(result));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Serial.println("esp websocket init failed");
|
||||
}
|
||||
|
||||
vTaskDelete(NULL);
|
||||
}
|
||||
|
||||
void startCloud()
|
||||
{
|
||||
if (const auto result = xTaskCreatePinnedToCore(cloudTask, "cloudTask", 4096, nullptr, 10, nullptr, 1); result == pdTRUE)
|
||||
{
|
||||
//Serial.println("cloud task create succeeded");
|
||||
}
|
||||
else
|
||||
{
|
||||
//Serial.printf("cloud task create failed\r\n");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
} // namespace
|
@ -1,16 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
// system includes
|
||||
#include <functional>
|
||||
|
||||
#include "bobbycar-protocol/bobbycar-common.h"
|
||||
#include "bobbycar-protocol/bobbycar-serial.h"
|
||||
// Arduino includes
|
||||
#ifdef FEATURE_SERIAL
|
||||
#include <HardwareSerial.h>
|
||||
#endif
|
||||
|
||||
#include "types.h"
|
||||
// 3rdparty lib includes
|
||||
#include <espchrono.h>
|
||||
|
||||
// local includes
|
||||
#include "bobbycar-common.h"
|
||||
#include "bobbycar-serial.h"
|
||||
#ifdef FEATURE_SERIAL
|
||||
#include "feedbackparser.h"
|
||||
#endif
|
||||
|
||||
// forward declares
|
||||
#ifdef FEATURE_SERIAL
|
||||
class HardwareSerial;
|
||||
#endif
|
||||
@ -39,7 +47,7 @@ struct Controller {
|
||||
bobbycar::protocol::serial::Command command{};
|
||||
|
||||
#ifdef FEATURE_CAN
|
||||
millis_t lastCanFeedback{};
|
||||
espchrono::millis_clock::time_point lastCanFeedback{};
|
||||
#endif
|
||||
bool feedbackValid{};
|
||||
bobbycar::protocol::serial::Feedback feedback{};
|
@ -1,5 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
// 3rdparty lib includes
|
||||
#include <fmt/core.h>
|
||||
|
||||
// local includes
|
||||
#include "textinterface.h"
|
||||
#include "globals.h"
|
||||
#include "utils.h"
|
||||
@ -42,9 +46,9 @@ public:
|
||||
using RightCommand = CommandTexts<LeftCommandGetter>;
|
||||
|
||||
struct BatVoltageText : public virtual TextInterface { public: std::string text() const override { std::string line{"batVoltage: "}; if (controller::get().feedbackValid) line += std::to_string(controller::get().feedback.batVoltage); return line; } };
|
||||
struct BatVoltageFixedText : public virtual TextInterface { public: std::string text() const override { std::string line{"batVoltage: "}; if (controller::get().feedbackValid) line += std::to_string(fixBatVoltage(controller::get().feedback.batVoltage)) + 'V'; return line; } };
|
||||
struct BatVoltageFixedText : public virtual TextInterface { public: std::string text() const override { std::string line{"batVoltage: "}; if (controller::get().feedbackValid) line += fmt::format("{:.2f}V", fixBatVoltage(controller::get().feedback.batVoltage)); return line; } };
|
||||
struct BoardTempText : public virtual TextInterface { public: std::string text() const override { std::string line{"boardTemp: "}; if (controller::get().feedbackValid) line += std::to_string(controller::get().feedback.boardTemp); return line; } };
|
||||
struct BoardTempFixedText : public virtual TextInterface { public: std::string text() const override { std::string line{"boardTemp: "}; if (controller::get().feedbackValid) line += std::to_string(fixBoardTemp(controller::get().feedback.boardTemp)) + 'C'; return line; } };
|
||||
struct BoardTempFixedText : public virtual TextInterface { public: std::string text() const override { std::string line{"boardTemp: "}; if (controller::get().feedbackValid) line += fmt::format("{:.2f}C", fixBoardTemp(controller::get().feedback.boardTemp)); return line; } };
|
||||
struct TimeoutCntSerialText : public virtual TextInterface { public: std::string text() const override { std::string line{"timeoutCntSerial: "}; if (controller::get().feedbackValid) line += std::to_string(controller::get().feedback.timeoutCntSerial); return line; } };
|
||||
|
||||
private:
|
||||
@ -59,16 +63,16 @@ private:
|
||||
|
||||
struct AngleText : public virtual TextInterface { public: std::string text() const override { std::string line{"angle: "}; if (controller::get().feedbackValid) line += std::to_string(MotorFeedbackGetter::get().angle); return line; } };
|
||||
struct SpeedText : public virtual TextInterface { public: std::string text() const override { std::string line{"speed: "}; if (controller::get().feedbackValid) line += std::to_string(MotorFeedbackGetter::get().speed); return line; } };
|
||||
struct SpeedKmhText : public virtual TextInterface { public: std::string text() const override { std::string line{"speed kmh: "}; if (controller::get().feedbackValid) line += std::to_string(convertToKmh(MotorFeedbackGetter::get().speed)); return line; } };
|
||||
struct SpeedKmhText : public virtual TextInterface { public: std::string text() const override { std::string line{"speed kmh: "}; if (controller::get().feedbackValid) line += fmt::format("{:.2f}", convertToKmh(MotorFeedbackGetter::get().speed)); return line; } };
|
||||
struct ErrorText : public virtual TextInterface { public: std::string text() const override { std::string line{"error: "}; if (controller::get().feedbackValid) line += std::to_string(MotorFeedbackGetter::get().error); return line; } };
|
||||
struct DcLinkText : public virtual TextInterface { public: std::string text() const override { std::string line{"dcLink: "}; if (controller::get().feedbackValid) line += std::to_string(MotorFeedbackGetter::get().dcLink); return line; } };
|
||||
struct DcLinkFixedText : public virtual TextInterface { public: std::string text() const override { std::string line{"dcLink: "}; if (controller::get().feedbackValid) line += std::to_string(fixCurrent(MotorFeedbackGetter::get().dcLink)) + 'A'; return line; } };
|
||||
struct DcLinkFixedText : public virtual TextInterface { public: std::string text() const override { std::string line{"dcLink: "}; if (controller::get().feedbackValid) line += fmt::format("{:.2f}A", fixCurrent(MotorFeedbackGetter::get().dcLink)); return line; } };
|
||||
struct DcPhaAText : public virtual TextInterface { public: std::string text() const override { std::string line{"dcPhaA: "}; if (controller::get().feedbackValid) line += std::to_string(MotorFeedbackGetter::get().dcPhaA); return line; } };
|
||||
struct DcPhaAFixedText : public virtual TextInterface { public: std::string text() const override { std::string line{"dcPhaA: "}; if (controller::get().feedbackValid) line += std::to_string(fixCurrent(MotorFeedbackGetter::get().dcPhaA)) + 'A'; return line; } };
|
||||
struct DcPhaAFixedText : public virtual TextInterface { public: std::string text() const override { std::string line{"dcPhaA: "}; if (controller::get().feedbackValid) line += fmt::format("{:.2f}A", fixCurrent(MotorFeedbackGetter::get().dcPhaA)); return line; } };
|
||||
struct DcPhaBText : public virtual TextInterface { public: std::string text() const override { std::string line{"dcPhaB: "}; if (controller::get().feedbackValid) line += std::to_string(MotorFeedbackGetter::get().dcPhaB); return line; } };
|
||||
struct DcPhaBFixedText : public virtual TextInterface { public: std::string text() const override { std::string line{"dcPhaB: "}; if (controller::get().feedbackValid) line += std::to_string(fixCurrent(MotorFeedbackGetter::get().dcPhaB)) + 'A'; return line; } };
|
||||
struct DcPhaBFixedText : public virtual TextInterface { public: std::string text() const override { std::string line{"dcPhaB: "}; if (controller::get().feedbackValid) line += fmt::format("{:.2f}A", fixCurrent(MotorFeedbackGetter::get().dcPhaB)); return line; } };
|
||||
struct DcPhaCText : public virtual TextInterface { public: std::string text() const override { std::string line{"dcPhaC: "}; if (controller::get().feedbackValid) line += std::to_string(MotorFeedbackGetter::get().dcPhaC); return line; } };
|
||||
struct DcPhaCFixedText : public virtual TextInterface { public: std::string text() const override { std::string line{"dcPhaC: "}; if (controller::get().feedbackValid) line += std::to_string(fixCurrent(MotorFeedbackGetter::get().dcPhaC)) + 'A'; return line; } };
|
||||
struct DcPhaCFixedText : public virtual TextInterface { public: std::string text() const override { std::string line{"dcPhaC: "}; if (controller::get().feedbackValid) line += fmt::format("{:.2f}A", fixCurrent(MotorFeedbackGetter::get().dcPhaC)); return line; } };
|
||||
struct ChopsText : public virtual TextInterface { public: std::string text() const override { std::string line{"chops: "}; if (controller::get().feedbackValid) line += std::to_string(MotorFeedbackGetter::get().chops); return line; } };
|
||||
struct HallText : public virtual TextInterface { public: std::string text() const override { std::string line{"hall: "}; if (controller::get().feedbackValid) line += hallString(MotorFeedbackGetter::get()); return line; } };
|
||||
};
|
@ -3,9 +3,6 @@
|
||||
#include <bitset>
|
||||
#include <memory>
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <HardwareSerial.h>
|
||||
|
||||
#include "display.h"
|
||||
#include "actions/switchscreenaction.h"
|
||||
|
||||
@ -50,18 +47,18 @@ private:
|
||||
{
|
||||
if (x >= GRIDX)
|
||||
{
|
||||
Serial.printf("x: %i\r\n", x);
|
||||
//Serial.printf("x: %i\r\n", x);
|
||||
return 0;
|
||||
}
|
||||
if (y >= GRIDY)
|
||||
{
|
||||
Serial.printf("y: %i\r\n", x);
|
||||
//Serial.printf("y: %i\r\n", x);
|
||||
return 0;
|
||||
}
|
||||
const auto result = (x * GRIDY) + y;
|
||||
if (result >= GRIDX*GRIDY)
|
||||
{
|
||||
Serial.printf("x:%i y:%i x*y:%i\r\n", x, y, result);
|
||||
//Serial.printf("x:%i y:%i x*y:%i\r\n", x, y, result);
|
||||
return 0;
|
||||
}
|
||||
return result;
|
@ -27,7 +27,7 @@ public:
|
||||
AboutMenu()
|
||||
{
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_VERSION>, DummyAction>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<nullptr>, DummyAction>>();
|
||||
constructMenuItem<makeComponent<MenuItem, EmptyText, DummyAction>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ESPINFO>, DummyAction>>();
|
||||
constructMenuItem<makeComponent<MenuItem, EspHeapSizeText, StaticFont<2>, DisabledColor, DummyAction>>();
|
||||
constructMenuItem<makeComponent<MenuItem, EspFreeHeapText, StaticFont<2>, DisabledColor, DummyAction>>();
|
@ -167,7 +167,7 @@ public:
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SETDPADDEBOUNCE>, SwitchScreenAction<DPadDebounceChangeScreen>>>();
|
||||
#endif
|
||||
#ifdef FEATURE_GAMETRAK
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<nullptr>, DummyAction>,
|
||||
constructMenuItem<makeComponent<MenuItem, EmptyText, DummyAction>,
|
||||
constructMenuItem<makeComponent<MenuItem, GametrakXText, DisabledColor, StaticFont<2>, DummyAction>>();
|
||||
constructMenuItem<makeComponent<MenuItem, GametrakYText, DisabledColor, StaticFont<2>, DummyAction>>();
|
||||
constructMenuItem<makeComponent<MenuItem, GametrakDistText, DisabledColor, StaticFont<2>, DummyAction>>();
|
||||
@ -179,7 +179,7 @@ public:
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SETGAMETRAKDISTMIN>, SwitchScreenAction<GametrakDistMinChangeScreen>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SETGAMETRAKDISTMAX>, SwitchScreenAction<GametrakDistMaxChangeScreen>>>();
|
||||
#endif
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<nullptr>, DummyAction>>();
|
||||
constructMenuItem<makeComponent<MenuItem, EmptyText, DummyAction>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SWAPSCREENBYTES>, ToggleBoolAction, CheckboxIcon, SwapScreenBytesAccessor>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_TIMERS>, SwitchScreenAction<TimersMenu>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<SettingsMenu>, StaticMenuItemIcon<&icons::back>>>();
|
@ -46,23 +46,23 @@ public:
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LOADSETTINGS>, LoadSettingsAction>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SAVESETTINGS>, SaveSettingsAction>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ERASENVS>, EraseNvsAction>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<nullptr>, DummyAction>>();
|
||||
constructMenuItem<makeComponent<MenuItem, EmptyText, DummyAction>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_FRONTCOMMAND>, SwitchScreenAction<FrontCommandDebugMenu>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACKCOMMAND>, SwitchScreenAction<BackCommandDebugMenu>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<nullptr>, DummyAction>>();
|
||||
constructMenuItem<makeComponent<MenuItem, EmptyText, DummyAction>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_FRONTLEFTCOMMAND>, SwitchScreenAction<FrontLeftMotorStateDebugMenu>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_FRONTRIGHTCOMMAND>, SwitchScreenAction<FrontRightMotorStateDebugMenu>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACKLEFTCOMMAND>, SwitchScreenAction<BackLeftMotorStateDebugMenu>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACKRIGHTCOMMAND>, SwitchScreenAction<BackRightMotorStateDebugMenu>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<nullptr>, DummyAction>>();
|
||||
constructMenuItem<makeComponent<MenuItem, EmptyText, DummyAction>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_FRONTFEEDBACK>, SwitchScreenAction<FrontFeedbackDebugMenu>, FrontFeedbackColor<TFT_WHITE>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACKFEEDBACK>, SwitchScreenAction<BackFeedbackDebugMenu>, BackFeedbackColor<TFT_WHITE>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<nullptr>, DummyAction>>();
|
||||
constructMenuItem<makeComponent<MenuItem, EmptyText, DummyAction>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_FRONTLEFTFEEDBACK>, SwitchScreenAction<FrontLeftMotorFeedbackDebugMenu>, FrontFeedbackColor<TFT_WHITE>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_FRONTRIGHTFEEDBACK>, SwitchScreenAction<FrontRightMotorFeedbackDebugMenu>, FrontFeedbackColor<TFT_WHITE>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACKLEFTFEEDBACK>, SwitchScreenAction<BackLeftMotorFeedbackDebugMenu>, BackFeedbackColor<TFT_WHITE>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACKRIGHTFEEDBACK>, SwitchScreenAction<BackRightMotorFeedbackDebugMenu>, BackFeedbackColor<TFT_WHITE>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<nullptr>, DummyAction>>();
|
||||
constructMenuItem<makeComponent<MenuItem, EmptyText, DummyAction>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_DYNAMICMENU>, SwitchScreenAction<DynamicDebugMenu>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<MainMenu>, StaticMenuItemIcon<&icons::back>>>();
|
||||
}
|
@ -1,8 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
// Arduino includes
|
||||
#include <Arduino.h>
|
||||
// system includes
|
||||
#include <string>
|
||||
#include <optional>
|
||||
|
||||
// 3rdparty lib includes
|
||||
#include <espchrono.h>
|
||||
|
||||
// local includes
|
||||
#include "menudisplay.h"
|
||||
@ -15,7 +18,6 @@
|
||||
#include "checkboxicon.h"
|
||||
#include "icons/back.h"
|
||||
#include "texts.h"
|
||||
#include "types.h"
|
||||
|
||||
// forward declares
|
||||
namespace {
|
||||
@ -28,18 +30,18 @@ class RandomText : public virtual TextInterface
|
||||
public:
|
||||
std::string text() const override
|
||||
{
|
||||
const auto now = millis();
|
||||
if (!m_nextUpdate || now >= m_nextUpdate)
|
||||
const auto now = espchrono::millis_clock::now();
|
||||
if (!m_nextUpdate || now >= *m_nextUpdate)
|
||||
{
|
||||
m_title = std::string{"Dynamic text: "} + std::to_string(random(0, 100));
|
||||
m_nextUpdate = now + random(0, 1000);
|
||||
m_title = "Dynamic text: " + std::to_string(random(0, 100));
|
||||
m_nextUpdate = now + std::chrono::milliseconds{random(0, 1000)};
|
||||
}
|
||||
|
||||
return m_title;
|
||||
}
|
||||
|
||||
private:
|
||||
mutable millis_t m_nextUpdate{};
|
||||
mutable std::optional<espchrono::millis_clock::time_point> m_nextUpdate;
|
||||
mutable std::string m_title;
|
||||
};
|
||||
|
||||
@ -48,19 +50,19 @@ class RandomColor : public virtual ColorInterface
|
||||
public:
|
||||
int color() const override
|
||||
{
|
||||
const auto now = millis();
|
||||
if (!m_nextUpdate || now >= m_nextUpdate)
|
||||
const auto now = espchrono::millis_clock::now();
|
||||
if (!m_nextUpdate || now >= *m_nextUpdate)
|
||||
{
|
||||
const auto count = std::distance(std::begin(default_4bit_palette), std::end(default_4bit_palette));
|
||||
const auto count = std::size(default_4bit_palette);
|
||||
m_color = default_4bit_palette[random(0, count)];
|
||||
m_nextUpdate = now + random(0, 1000);
|
||||
m_nextUpdate = now + std::chrono::milliseconds{random(0, 1000)};
|
||||
}
|
||||
|
||||
return m_color;
|
||||
}
|
||||
|
||||
private:
|
||||
mutable millis_t m_nextUpdate{};
|
||||
mutable std::optional<espchrono::millis_clock::time_point> m_nextUpdate;
|
||||
mutable int m_color;
|
||||
};
|
||||
|
||||
@ -69,18 +71,18 @@ class RandomFont : public virtual FontInterface
|
||||
public:
|
||||
int font() const override
|
||||
{
|
||||
const auto now = millis();
|
||||
if (!m_nextUpdate || now >= m_nextUpdate)
|
||||
const auto now = espchrono::millis_clock::now();
|
||||
if (!m_nextUpdate || now >= *m_nextUpdate)
|
||||
{
|
||||
m_font = random(1, 5);
|
||||
m_nextUpdate = now + random(0, 1000);
|
||||
m_nextUpdate = now + std::chrono::milliseconds{random(0, 1000)};
|
||||
}
|
||||
|
||||
return m_font;
|
||||
}
|
||||
|
||||
private:
|
||||
mutable millis_t m_nextUpdate{};
|
||||
mutable std::optional<espchrono::millis_clock::time_point> m_nextUpdate;
|
||||
mutable int m_font;
|
||||
};
|
||||
|
||||
@ -89,21 +91,21 @@ class RandomIcon : public virtual MenuItemIconInterface
|
||||
public:
|
||||
const MenuItemIcon *icon() const override
|
||||
{
|
||||
const auto now = millis();
|
||||
if (!m_nextUpdate || now >= m_nextUpdate)
|
||||
const auto now = espchrono::millis_clock::now();
|
||||
if (!m_nextUpdate || now >= *m_nextUpdate)
|
||||
{
|
||||
if (m_icon)
|
||||
m_icon = nullptr;
|
||||
else
|
||||
m_icon = &icons::lock;
|
||||
m_nextUpdate = now + random(0, 1000);
|
||||
m_nextUpdate = now + std::chrono::milliseconds{random(0, 1000)};
|
||||
}
|
||||
|
||||
return m_icon;
|
||||
}
|
||||
|
||||
private:
|
||||
mutable millis_t m_nextUpdate{};
|
||||
mutable std::optional<espchrono::millis_clock::time_point> m_nextUpdate;
|
||||
mutable const Icon<24, 24> *m_icon;
|
||||
};
|
||||
|
@ -1,8 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
// Arduino includes
|
||||
#include <HardwareSerial.h>
|
||||
|
||||
// local includes
|
||||
#include "menudisplay.h"
|
||||
#include "changevaluedisplay.h"
|
||||
@ -31,13 +28,13 @@ using WifiModeChangeScreen = makeComponent<
|
||||
SwitchScreenAction<GenericWifiSettingsMenu>
|
||||
>;
|
||||
|
||||
using WifiTxPowerChangeScreen = makeComponent<
|
||||
ChangeValueDisplay<wifi_power_t>,
|
||||
StaticText<TEXT_WIFICHANGETXPOWER>,
|
||||
WifiTxPowerAccessor,
|
||||
BackActionInterface<SwitchScreenAction<GenericWifiSettingsMenu>>,
|
||||
SwitchScreenAction<GenericWifiSettingsMenu>
|
||||
>;
|
||||
//using WifiTxPowerChangeScreen = makeComponent<
|
||||
// ChangeValueDisplay<wifi_power_t>,
|
||||
// StaticText<TEXT_WIFICHANGETXPOWER>,
|
||||
// WifiTxPowerAccessor,
|
||||
// BackActionInterface<SwitchScreenAction<GenericWifiSettingsMenu>>,
|
||||
// SwitchScreenAction<GenericWifiSettingsMenu>
|
||||
//>;
|
||||
|
||||
class GenericWifiSettingsMenu :
|
||||
public MenuDisplay,
|
||||
@ -51,7 +48,7 @@ public:
|
||||
constructMenuItem<makeComponent<MenuItem, WifiChannelText, DisabledColor, DummyAction>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_WIFICHANGEMODE>, SwitchScreenAction<WifiModeChangeScreen>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_WIFICHANGESLEEP>, ToggleBoolAction, CheckboxIcon, WifiSleepAccessor>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_WIFICHANGETXPOWER>, SwitchScreenAction<WifiTxPowerChangeScreen>>>();
|
||||
//constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_WIFICHANGETXPOWER>, SwitchScreenAction<WifiTxPowerChangeScreen>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<WifiSettingsMenu>, StaticMenuItemIcon<&icons::back>>>();
|
||||
}
|
||||
};
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user