ttgo fix
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
|
|
||||||
|
rem slow GUI performance via arduino-cli yet
|
||||||
|
|
||||||
rem arduino-cli compile -v -b esp32:esp32:esp32:PSRAM=enabled,PartitionScheme=huge_app,CPUFreq=80 --build-properties build.extra_flags=-BOARD_TTGO_T4=1 -v enirodashboard.ino
|
rem arduino-cli compile -v -b esp32:esp32:esp32:PSRAM=enabled,PartitionScheme=huge_app,CPUFreq=80 --build-properties build.extra_flags=-BOARD_TTGO_T4=1 -v enirodashboard.ino
|
||||||
rem arduino-cli upload -b esp32:esp32:esp32 -v -p COM6
|
rem arduino-cli upload -b esp32:esp32:esp32 -v -p COM6
|
||||||
|
|
||||||
@@ -6,6 +8,6 @@ rem arduino-cli compile -v -b esp32:esp32:m5stack-core-esp32 --build-properties
|
|||||||
rem arduino-cli upload -v -b esp32:esp32:m5stack-core-esp32 -p COM9
|
rem arduino-cli upload -v -b esp32:esp32:m5stack-core-esp32 -p COM9
|
||||||
|
|
||||||
rem arduino-cli compile -v -b esp32:esp32:esp32:PSRAM=enabled,PartitionScheme=huge_app,CPUFreq=80 --build-properties build.extra_flags=-BOARD_M5STACK=1 -v enirodashboard.ino
|
rem arduino-cli compile -v -b esp32:esp32:esp32:PSRAM=enabled,PartitionScheme=huge_app,CPUFreq=80 --build-properties build.extra_flags=-BOARD_M5STACK=1 -v enirodashboard.ino
|
||||||
arduino-cli upload -b esp32:esp32:esp32 -v -p COM9
|
rem arduino-cli upload -b esp32:esp32:esp32 -v -p COM9
|
||||||
|
|
||||||
pause
|
pause
|
||||||
4
config.h
4
config.h
@@ -2,8 +2,8 @@
|
|||||||
// SELECT HARDWARE !!!!
|
// SELECT HARDWARE !!!!
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
//#define BOARD_TTGO_T4
|
#define BOARD_TTGO_T4
|
||||||
#define BOARD_M5STACK_CORE
|
//#define BOARD_M5STACK_CORE
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
|||||||
BIN
dist/ttgo_t4_v13/enirodashboard.ino.bin
vendored
BIN
dist/ttgo_t4_v13/enirodashboard.ino.bin
vendored
Binary file not shown.
@@ -27,7 +27,7 @@
|
|||||||
<= 0°C BMS allows max 40A
|
<= 0°C BMS allows max 40A
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define APP_VERSION "v1.8.0e"
|
#define APP_VERSION "v1.8.0f"
|
||||||
|
|
||||||
#include "SPI.h"
|
#include "SPI.h"
|
||||||
#include "TFT_eSPI.h"
|
#include "TFT_eSPI.h"
|
||||||
@@ -69,8 +69,9 @@ char tmpStr4[20];
|
|||||||
|
|
||||||
// Screens, buttons
|
// Screens, buttons
|
||||||
#define displayScreenCount 7
|
#define displayScreenCount 7
|
||||||
byte displayScreen = 1; // 0 - blank screen, 1 - automatic mode, 2 - dash board (default), 3 - big speed + kwh/100, 4 - battery cells, 5 - charging graph, 6 - soc10% CED table, 7 - debug screen
|
byte displayScreen = SCREEN_AUTO;
|
||||||
byte displayScreenAutoMode = 0;
|
byte displayScreenAutoMode = 0;
|
||||||
|
byte displayScreenSpeedHud = false;
|
||||||
bool btnLeftPressed = true;
|
bool btnLeftPressed = true;
|
||||||
bool btnMiddlePressed = true;
|
bool btnMiddlePressed = true;
|
||||||
bool btnRightPressed = true;
|
bool btnRightPressed = true;
|
||||||
@@ -590,11 +591,51 @@ bool drawSceneSpeed(bool force) {
|
|||||||
|
|
||||||
int32_t posx, posy;
|
int32_t posx, posy;
|
||||||
|
|
||||||
|
// HUD
|
||||||
|
if (displayScreenSpeedHud) {
|
||||||
|
|
||||||
|
// Change rotation to vertical & mirror
|
||||||
|
if (tft.getRotation() != 6)
|
||||||
|
tft.setRotation(6);
|
||||||
|
|
||||||
|
tft.fillRect(0, 0, 240, 320, TFT_BLACK);
|
||||||
|
tft.setTextDatum(TR_DATUM); // top-right alignment
|
||||||
|
tft.setTextColor(TFT_WHITE, TFT_BLACK); // foreground, background text color
|
||||||
|
|
||||||
|
// Draw speed
|
||||||
|
tft.setTextSize((params.speedKmh > 99) ? 1 : 2);
|
||||||
|
sprintf(tmpStr3, "0");
|
||||||
|
if (params.speedKmh > 10)
|
||||||
|
sprintf(tmpStr3, "%01.00f", km2distance(params.speedKmh));
|
||||||
|
tft.drawString(tmpStr3, 240, 0, 8);
|
||||||
|
|
||||||
|
// Draw power kWh/100km (>25kmh) else kW
|
||||||
|
tft.setTextSize(1);
|
||||||
|
if (params.speedKmh > 25 && params.batPowerKw < 0)
|
||||||
|
sprintf(tmpStr3, "%01.01f", km2distance(params.batPowerKwh100));
|
||||||
|
else
|
||||||
|
sprintf(tmpStr3, "%01.01f", params.batPowerKw);
|
||||||
|
tft.drawString(tmpStr3, 240, 150, 8);
|
||||||
|
|
||||||
|
// Draw soc%
|
||||||
|
sprintf(tmpStr3, "%01.00f", params.socPerc);
|
||||||
|
tft.drawString(tmpStr3, 240 , 230, 8);
|
||||||
|
|
||||||
|
// Cold gate cirlce
|
||||||
|
tft.fillCircle(30, 280, 25, (params.batTempC >= 15) ? ((params.batTempC >= 25) ? TFT_DARKGREEN2 : TFT_BLUE) : TFT_RED);
|
||||||
|
|
||||||
|
// Brake lights
|
||||||
|
tft.fillRect(0, 310, 240, 10, (params.brakeLights) ? TFT_RED : TFT_BLACK);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
tft.fillRect(0, 36, 200, 160, TFT_DARKRED);
|
tft.fillRect(0, 36, 200, 160, TFT_DARKRED);
|
||||||
|
|
||||||
posx = 320 / 2;
|
posx = 320 / 2;
|
||||||
posy = 40;
|
posy = 40;
|
||||||
tft.setTextDatum(TR_DATUM); // Top center
|
tft.setTextDatum(TR_DATUM);
|
||||||
tft.setTextColor(TFT_WHITE, TFT_DARKRED);
|
tft.setTextColor(TFT_WHITE, TFT_DARKRED);
|
||||||
tft.setTextSize(2); // Size for small 5cix7 font
|
tft.setTextSize(2); // Size for small 5cix7 font
|
||||||
sprintf(tmpStr3, "0");
|
sprintf(tmpStr3, "0");
|
||||||
@@ -1273,7 +1314,7 @@ bool redrawScreen(bool force) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 1. Auto mode = >5kpm Screen 3 - speed, other wise basic Screen2 - Main screen, if charging then Screen 5 Graph
|
// 1. Auto mode = >5kpm Screen 3 - speed, other wise basic Screen2 - Main screen, if charging then Screen 5 Graph
|
||||||
if (displayScreen == 1) {
|
if (displayScreen == SCREEN_AUTO) {
|
||||||
if (params.speedKmh > 5) {
|
if (params.speedKmh > 5) {
|
||||||
if (displayScreenAutoMode != 3) {
|
if (displayScreenAutoMode != 3) {
|
||||||
tft.fillScreen(TFT_BLACK);
|
tft.fillScreen(TFT_BLACK);
|
||||||
@@ -1295,27 +1336,27 @@ bool redrawScreen(bool force) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 2. Main screen
|
// 2. Main screen
|
||||||
if (displayScreen == 2) {
|
if (displayScreen == SCREEN_DASH) {
|
||||||
drawSceneMain(force);
|
drawSceneMain(force);
|
||||||
}
|
}
|
||||||
// 3. Big speed + kwh/100km
|
// 3. Big speed + kwh/100km
|
||||||
if (displayScreen == 3) {
|
if (displayScreen == SCREEN_SPEED) {
|
||||||
drawSceneSpeed(force);
|
drawSceneSpeed(force);
|
||||||
}
|
}
|
||||||
// 4. Battery cells
|
// 4. Battery cells
|
||||||
if (displayScreen == 4) {
|
if (displayScreen == SCREEN_CELLS) {
|
||||||
drawSceneBatteryCells(force);
|
drawSceneBatteryCells(force);
|
||||||
}
|
}
|
||||||
// 5. Charging graph
|
// 5. Charging graph
|
||||||
if (displayScreen == 5) {
|
if (displayScreen == SCREEN_CHARGING) {
|
||||||
drawSceneChargingGraph(force);
|
drawSceneChargingGraph(force);
|
||||||
}
|
}
|
||||||
// 6. SOC10% table (CEC-CED)
|
// 6. SOC10% table (CEC-CED)
|
||||||
if (displayScreen == 6) {
|
if (displayScreen == SCREEN_SOC10) {
|
||||||
drawSceneSoc10Table(force);
|
drawSceneSoc10Table(force);
|
||||||
}
|
}
|
||||||
// 7. DEBUG SCREEN
|
// 7. DEBUG SCREEN
|
||||||
if (displayScreen == 7) {
|
if (displayScreen == SCREEN_DEBUG) {
|
||||||
drawSceneDebug(force);
|
drawSceneDebug(force);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1328,7 +1369,6 @@ bool redrawScreen(bool force) {
|
|||||||
tft.drawString(" BLE4 OBDII not connected... ", 0, (240 / 2) - tft.fontHeight(), 2);
|
tft.drawString(" BLE4 OBDII not connected... ", 0, (240 / 2) - tft.fontHeight(), 2);
|
||||||
tft.drawString(" Press middle button to menu. ", 0, (240 / 2), 2);
|
tft.drawString(" Press middle button to menu. ", 0, (240 / 2), 2);
|
||||||
tft.drawString(APP_VERSION, 0, (240 / 2) + tft.fontHeight(), 2);
|
tft.drawString(APP_VERSION, 0, (240 / 2) + tft.fontHeight(), 2);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tft.endWrite();
|
tft.endWrite();
|
||||||
@@ -1392,7 +1432,7 @@ bool parseRowMerged() {
|
|||||||
Serial.println(responseRowMerged);
|
Serial.println(responseRowMerged);
|
||||||
|
|
||||||
// Catch output for debug screen
|
// Catch output for debug screen
|
||||||
if (displayScreen == 7) {
|
if (displayScreen == SCREEN_DEBUG) {
|
||||||
if (debugCommandIndex == commandQueueIndex) {
|
if (debugCommandIndex == commandQueueIndex) {
|
||||||
debugAtshRequest = currentAtshRequest;
|
debugAtshRequest = currentAtshRequest;
|
||||||
debugCommandRequest = commandRequest;
|
debugCommandRequest = commandRequest;
|
||||||
@@ -1826,6 +1866,7 @@ void loop() {
|
|||||||
} else {
|
} else {
|
||||||
if (!btnMiddlePressed) {
|
if (!btnMiddlePressed) {
|
||||||
btnMiddlePressed = true;
|
btnMiddlePressed = true;
|
||||||
|
tft.setRotation(settings.displayRotation);
|
||||||
if (menuVisible) {
|
if (menuVisible) {
|
||||||
menuItemClick();
|
menuItemClick();
|
||||||
} else {
|
} else {
|
||||||
@@ -1839,6 +1880,7 @@ void loop() {
|
|||||||
} else {
|
} else {
|
||||||
if (!btnLeftPressed) {
|
if (!btnLeftPressed) {
|
||||||
btnLeftPressed = true;
|
btnLeftPressed = true;
|
||||||
|
tft.setRotation(settings.displayRotation);
|
||||||
// Menu handling
|
// Menu handling
|
||||||
if (menuVisible) {
|
if (menuVisible) {
|
||||||
menuMove(false);
|
menuMove(false);
|
||||||
@@ -1847,7 +1889,7 @@ void loop() {
|
|||||||
if (displayScreen > displayScreenCount - (settings.debugScreen == 0) ? 1 : 0)
|
if (displayScreen > displayScreenCount - (settings.debugScreen == 0) ? 1 : 0)
|
||||||
displayScreen = 0; // rotate screens
|
displayScreen = 0; // rotate screens
|
||||||
// Turn off display on screen 0
|
// Turn off display on screen 0
|
||||||
analogWrite(TFT_BL, (displayScreen == 0) ? 0 : (settings.lcdBrightness == 0) ? 100 : settings.lcdBrightness);
|
analogWrite(TFT_BL, (displayScreen == SCREEN_BLANK) ? 0 : (settings.lcdBrightness == 0) ? 100 : settings.lcdBrightness);
|
||||||
redrawScreen(true);
|
redrawScreen(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1858,12 +1900,17 @@ void loop() {
|
|||||||
} else {
|
} else {
|
||||||
if (!btnRightPressed) {
|
if (!btnRightPressed) {
|
||||||
btnRightPressed = true;
|
btnRightPressed = true;
|
||||||
|
tft.setRotation(settings.displayRotation);
|
||||||
// Menu handling
|
// Menu handling
|
||||||
if (menuVisible) {
|
if (menuVisible) {
|
||||||
menuMove(true);
|
menuMove(true);
|
||||||
} else {
|
} else {
|
||||||
// doAction
|
// doAction
|
||||||
if (settings.debugScreen == 1 && displayScreen == 7) {
|
if (displayScreen == SCREEN_SPEED) {
|
||||||
|
displayScreenSpeedHud = !displayScreenSpeedHud;
|
||||||
|
redrawScreen(true);
|
||||||
|
}
|
||||||
|
if (settings.debugScreen == 1 && displayScreen == SCREEN_DEBUG) {
|
||||||
debugCommandIndex = (debugCommandIndex >= commandQueueCount) ? commandQueueLoopFrom : debugCommandIndex + 1;
|
debugCommandIndex = (debugCommandIndex >= commandQueueCount) ? commandQueueLoopFrom : debugCommandIndex + 1;
|
||||||
redrawScreen(true);
|
redrawScreen(true);
|
||||||
}
|
}
|
||||||
|
|||||||
10
struct.h
10
struct.h
@@ -8,6 +8,16 @@
|
|||||||
#define CAR_RENAULT_ZOE 5
|
#define CAR_RENAULT_ZOE 5
|
||||||
#define CAR_DEBUG_OBD2_KIA 999
|
#define CAR_DEBUG_OBD2_KIA 999
|
||||||
|
|
||||||
|
// SCREENS
|
||||||
|
#define SCREEN_BLANK 0
|
||||||
|
#define SCREEN_AUTO 1
|
||||||
|
#define SCREEN_DASH 2
|
||||||
|
#define SCREEN_SPEED 3
|
||||||
|
#define SCREEN_CELLS 4
|
||||||
|
#define SCREEN_CHARGING 5
|
||||||
|
#define SCREEN_SOC10 6
|
||||||
|
#define SCREEN_DEBUG 7
|
||||||
|
|
||||||
// Commands loop
|
// Commands loop
|
||||||
uint16_t commandQueueCount;
|
uint16_t commandQueueCount;
|
||||||
uint16_t commandQueueLoopFrom;
|
uint16_t commandQueueLoopFrom;
|
||||||
|
|||||||
Reference in New Issue
Block a user