This commit is contained in:
Ján Mátik
2020-12-29 09:50:30 +01:00
13 changed files with 109 additions and 75 deletions

View File

@@ -46,12 +46,14 @@ void Board320_240::afterSetup() {
loadTestData();
}
// Init from parent class
syslog->println("BoardInterface::afterSetup");
BoardInterface::afterSetup();
bool afterSetup = false;
// Check if bard was sleeping
if(bootCount > 1) {
if (bootCount > 1) {
// Init comm device
afterSetup = true;
BoardInterface::afterSetup();
// Wake or continue with sleeping
afterSleep();
}
@@ -115,26 +117,32 @@ void Board320_240::afterSetup() {
if (liveData->settings.gprsHwSerialPort <= 2) {
sim800lSetup();
}
// Init comm device
if (!afterSetup) {
BoardInterface::afterSetup();
}
}
/**
Go to Sleep for TIME_TO_SLEEP seconds
*/
void Board320_240::goToSleep() {
//Sleep MCP2515
commInterface->disconnectDevice();
//Sleep SIM800L
if(liveData->params.sim800l_enabled) {
if (liveData->params.sim800l_enabled) {
if (sim800l->isConnectedGPRS()) {
bool disconnected = sim800l->disconnectGPRS();
for(uint8_t i = 0; i < 5 && !disconnected; i++) {
for (uint8_t i = 0; i < 5 && !disconnected; i++) {
delay(1000);
disconnected = sim800l->disconnectGPRS();
}
}
if(sim800l->getPowerMode() == NORMAL) {
if (sim800l->getPowerMode() == NORMAL) {
sim800l->setPowerMode(SLEEP);
delay(1000);
}
@@ -156,16 +164,29 @@ void Board320_240::goToSleep() {
Iterate thru commands and determine if car is charging or ignition is on
*/
void Board320_240::afterSleep() {
syslog->println("Waking up from sleep mode!");
bool firstRun = true;
// Wakeup reason
esp_sleep_wakeup_cause_t wakeup_reason;
wakeup_reason = esp_sleep_get_wakeup_cause();
switch (wakeup_reason) {
case ESP_SLEEP_WAKEUP_EXT0 : syslog->println("Wakeup caused by external signal using RTC_IO"); break;
case ESP_SLEEP_WAKEUP_EXT1 : syslog->println("Wakeup caused by external signal using RTC_CNTL"); break;
case ESP_SLEEP_WAKEUP_TIMER : syslog->println("Wakeup caused by timer"); break;
case ESP_SLEEP_WAKEUP_TOUCHPAD : syslog->println("Wakeup caused by touchpad"); break;
case ESP_SLEEP_WAKEUP_ULP : syslog->println("Wakeup caused by ULP program"); break;
default: syslog->printf("Wakeup was not caused by deep sleep: %d\n", wakeup_reason); break;
}
while(liveData->commandQueueIndex -1 > liveData->commandQueueLoopFrom || firstRun) {
if(liveData->commandQueueIndex -1 == liveData->commandQueueLoopFrom) {
//
bool firstRun = true;
while (liveData->commandQueueIndex - 1 > liveData->commandQueueLoopFrom || firstRun) {
if (liveData->commandQueueIndex - 1 == liveData->commandQueueLoopFrom) {
firstRun = false;
}
if(millis() > 5000) {
if (millis() > 5000) {
syslog->println("Time's up (5s timeout)...");
goToSleep();
}
@@ -176,7 +197,7 @@ void Board320_240::afterSleep() {
if (liveData->params.auxVoltage > 5 && liveData->params.auxVoltage < 12) {
syslog->println("AuxBATT too low!");
goToSleep();
} else if(!liveData->params.ignitionOn && !liveData->params.chargingOn) {
} else if (!liveData->params.ignitionOn && !liveData->params.chargingOn) {
syslog->println("Not started & Not charging.");
goToSleep();
} else {
@@ -1127,25 +1148,25 @@ void Board320_240::menuItemClick() {
case 3064: liveData->settings.defaultScreen = 4; showParentMenu = true; break;
case 3065: liveData->settings.defaultScreen = 5; showParentMenu = true; break;
// SleepMode off/on
case MENU_SLEEP_MODE: liveData->settings.sleepModeEnabled = (liveData->settings.sleepModeEnabled == 1) ? 0 : 1; showMenu(); return; break;
case MENU_SCREEN_BRIGHTNESS: liveData->settings.lcdBrightness += 20; if (liveData->settings.lcdBrightness > 100) liveData->settings.lcdBrightness = 0;
case MENU_SLEEP_MODE: liveData->settings.sleepModeEnabled = (liveData->settings.sleepModeEnabled == 1) ? 0 : 1; showMenu(); return; break;
case MENU_SCREEN_BRIGHTNESS: liveData->settings.lcdBrightness += 20; if (liveData->settings.lcdBrightness > 100) liveData->settings.lcdBrightness = 0;
setBrightness((liveData->settings.lcdBrightness == 0) ? 100 : liveData->settings.lcdBrightness); showMenu(); return; break;
// Pre-drawn charg.graphs off/on
case MENU_PREDRAWN_GRAPHS: liveData->settings.predrawnChargingGraphs = (liveData->settings.predrawnChargingGraphs == 1) ? 0 : 1; showMenu(); return; break;
case MENU_HEADLIGHTS_REMINDER: liveData->settings.headlightsReminder = (liveData->settings.headlightsReminder == 1) ? 0 : 1; showMenu(); return; break;
case MENU_GPRS: liveData->settings.gprsHwSerialPort = (liveData->settings.gprsHwSerialPort == 2) ? 255 : liveData->settings.gprsHwSerialPort + 1; showMenu(); return; break;
case MENU_GPS: liveData->settings.gpsHwSerialPort = (liveData->settings.gpsHwSerialPort == 2) ? 255 : liveData->settings.gpsHwSerialPort + 1; showMenu(); return; break;
case MENU_SERIAL_CONSOLE: liveData->settings.serialConsolePort = (liveData->settings.serialConsolePort == 0) ? 255 : liveData->settings.serialConsolePort + 1; showMenu(); return; break;
case MENU_DEBUG_LEVEL: liveData->settings.debugLevel = (liveData->settings.debugLevel == 3) ? 0 : liveData->settings.debugLevel + 1; syslog->setDebugLevel(liveData->settings.debugLevel); showMenu(); return; break;
case MENU_PREDRAWN_GRAPHS: liveData->settings.predrawnChargingGraphs = (liveData->settings.predrawnChargingGraphs == 1) ? 0 : 1; showMenu(); return; break;
case MENU_HEADLIGHTS_REMINDER: liveData->settings.headlightsReminder = (liveData->settings.headlightsReminder == 1) ? 0 : 1; showMenu(); return; break;
case MENU_GPRS: liveData->settings.gprsHwSerialPort = (liveData->settings.gprsHwSerialPort == 2) ? 255 : liveData->settings.gprsHwSerialPort + 1; showMenu(); return; break;
case MENU_GPS: liveData->settings.gpsHwSerialPort = (liveData->settings.gpsHwSerialPort == 2) ? 255 : liveData->settings.gpsHwSerialPort + 1; showMenu(); return; break;
case MENU_SERIAL_CONSOLE: liveData->settings.serialConsolePort = (liveData->settings.serialConsolePort == 0) ? 255 : liveData->settings.serialConsolePort + 1; showMenu(); return; break;
case MENU_DEBUG_LEVEL: liveData->settings.debugLevel = (liveData->settings.debugLevel == 3) ? 0 : liveData->settings.debugLevel + 1; syslog->setDebugLevel(liveData->settings.debugLevel); showMenu(); return; break;
// Wifi menu
case MENU_WIFI_ENABLED: liveData->settings.wifiEnabled = (liveData->settings.wifiEnabled == 1) ? 0 : 1; showMenu(); return; break;
case MENU_WIFI_SSID: return; break;
case MENU_WIFI_PASSWORD: return; break;
case MENU_WIFI_ENABLED: liveData->settings.wifiEnabled = (liveData->settings.wifiEnabled == 1) ? 0 : 1; showMenu(); return; break;
case MENU_WIFI_SSID: return; break;
case MENU_WIFI_PASSWORD: return; break;
// Sdcard
case MENU_SDCARD_ENABLED: liveData->settings.sdcardEnabled = (liveData->settings.sdcardEnabled == 1) ? 0 : 1; showMenu(); return; break;
case MENU_SDCARD_ENABLED: liveData->settings.sdcardEnabled = (liveData->settings.sdcardEnabled == 1) ? 0 : 1; showMenu(); return; break;
case MENU_SDCARD_AUTOSTARTLOG: liveData->settings.sdcardAutstartLog = (liveData->settings.sdcardAutstartLog == 1) ? 0 : 1; showMenu(); return; break;
case MENU_SDCARD_MOUNT_STATUS: sdcardMount(); break;
case MENU_SDCARD_REC: sdcardToggleRecording(); showMenu(); return; break;
case MENU_SDCARD_REC: sdcardToggleRecording(); showMenu(); return; break;
// Distance
case 4011: liveData->settings.distanceUnit = 'k'; showParentMenu = true; break;
case 4012: liveData->settings.distanceUnit = 'm'; showParentMenu = true; break;
@@ -1156,7 +1177,17 @@ void Board320_240::menuItemClick() {
case 4031: liveData->settings.pressureUnit = 'b'; showParentMenu = true; break;
case 4032: liveData->settings.pressureUnit = 'p'; showParentMenu = true; break;
// Pair ble device
case 2: scanDevices = true; liveData->menuCurrent = 9999; commInterface->scanDevices(); return;
case 2:
if (liveData->settings.commType == COMM_TYPE_OBD2CAN) {
displayMessage("Not supported", "in CAN mode");
delay(3000);
hideMenu();
return;
}
scanDevices = true;
liveData->menuCurrent = 9999;
commInterface->scanDevices();
return;
// Reset settings
case 8: resetSettings(); hideMenu(); return;
// Save settings
@@ -1476,8 +1507,8 @@ void Board320_240::mainLoop() {
}
}
// Turn off display if Ignition is off for more than 10s
if(liveData->params.currentTime - liveData->params.lastIgnitionOnTime > 10
// Turn off display if Ignition is off for more than 10s, less than month (prevent sleep when gps time is synchronized)
if (liveData->params.currentTime - liveData->params.lastIgnitionOnTime > 10 && liveData->params.currentTime - liveData->params.lastIgnitionOnTime < MONTH_SEC
&& liveData->params.lastIgnitionOnTime != 0
&& liveData->settings.sleepModeEnabled) {
setBrightness(0);
@@ -1485,8 +1516,8 @@ void Board320_240::mainLoop() {
setBrightness((liveData->settings.lcdBrightness == 0) ? 100 : liveData->settings.lcdBrightness);
}
// Go to sleep when car is off for more than 10s and not charging
if (liveData->params.currentTime - liveData->params.lastIgnitionOnTime > 10
// Go to sleep when car is off for more than 30s and not charging (AC charger is disabled for few seconds when ignition is turned off)
if (liveData->params.currentTime - liveData->params.lastIgnitionOnTime > 30 && liveData->params.currentTime - liveData->params.lastIgnitionOnTime < MONTH_SEC
&& !liveData->params.chargingOn
&& liveData->params.lastIgnitionOnTime != 0
&& liveData->settings.sleepModeEnabled)
@@ -1519,12 +1550,10 @@ bool Board320_240::sdcardMount() {
while (1) {
syslog->print("Initializing SD card...");
#ifdef BOARD_TTGO_T4
syslog->print(" TTGO-T4 ");
SPIClass * hspi = new SPIClass(HSPI);
spiSD.begin(pinSdcardSclk, pinSdcardMiso, pinSdcardMosi, pinSdcardCs); //SCK,MISO,MOSI,ss
SdState = SD.begin(pinSdcardCs, *hspi, SPI_FREQUENCY);
#endif BOARD_TTGO_T4
/* syslog->print(" TTGO-T4 ");
SPIClass * hspi = new SPIClass(HSPI);
spiSD.begin(pinSdcardSclk, pinSdcardMiso, pinSdcardMosi, pinSdcardCs); //SCK,MISO,MOSI,ss
SdState = SD.begin(pinSdcardCs, *hspi, SPI_FREQUENCY);*/
syslog->print(" M5STACK ");
SdState = SD.begin(pinSdcardCs);
@@ -1648,9 +1677,9 @@ bool Board320_240::sim800lSetup() {
sim800l->exitSleepMode();
if(sim800l->getPowerMode() != NORMAL) {
if (sim800l->getPowerMode() != NORMAL) {
syslog->println("SIM800L module in sleep mode - Waking up");
if(sim800l->setPowerMode(NORMAL)) {
if (sim800l->setPowerMode(NORMAL)) {
syslog->println("SIM800L in normal power mode");
} else {
syslog->println("Failed to switch SIM800L to normal power mode");

View File

@@ -96,7 +96,7 @@ void BoardInterface::loadSettings() {
// Default settings
liveData->settings.initFlag = 183;
liveData->settings.settingsVersion = 5;
liveData->settings.settingsVersion = 6;
liveData->settings.carType = CAR_KIA_ENIRO_2020_64;
tmpStr = "00:00:00:00:00:00"; // Pair via menu (middle button)
tmpStr.toCharArray(liveData->settings.obdMacAddress, tmpStr.length() + 1);
@@ -198,7 +198,7 @@ void BoardInterface::loadSettings() {
if (liveData->tmpSettings.settingsVersion == 5) {
liveData->tmpSettings.settingsVersion = 6;
liveData->tmpSettings.serialConsolePort = 0; // hwuart0
liveData->tmpSettings.debugLevel = 1; // 1 - debug communication (BLE/CAN)
liveData->tmpSettings.debugLevel = 0; // show all
liveData->tmpSettings.sdcardLogIntervalSec = 2;
liveData->tmpSettings.gprsLogIntervalSec = 60;
}
@@ -220,6 +220,8 @@ void BoardInterface::loadSettings() {
*/
void BoardInterface::afterSetup() {
syslog->println("BoardInterface::afterSetup");
// Init Comm iterface
syslog->print("Init communication device: ");
syslog->println(liveData->settings.commType);

View File

@@ -185,6 +185,9 @@ void CarHyundaiIoniq::parseRowMerged() {
tempByte = liveData->hexToDecFromResponse(22, 24, 1, false);
liveData->params.chargingOn = (bitRead(tempByte, 5) == 1 || bitRead(tempByte, 6) == 1); // bit 5 = AC; bit 6 = DC
if(liveData->params.chargingOn) {
liveData->params.lastChargingOnTime = liveData->params.currentTime;
}
// This is more accurate than min/max from BMS. It's required to detect kona/eniro cold gates (min 15C is needed > 43kW charging, min 25C is needed > 58kW charging)
liveData->params.batInletC = liveData->hexToDecFromResponse(48, 50, 1, true);

View File

@@ -237,6 +237,9 @@ void CarKiaEniro::parseRowMerged() {
// liveData->params.chargingOn = (bitRead(tempByte, 2) == 1);
tempByte = liveData->hexToDecFromResponse(24, 26, 1, false);
liveData->params.chargingOn = (bitRead(tempByte, 5) == 1 || bitRead(tempByte, 6) == 1); // bit 5 = AC; bit 6 = DC
if(liveData->params.chargingOn) {
liveData->params.lastChargingOnTime = liveData->params.currentTime;
}
// This is more accurate than min/max from BMS. It's required to detect kona/eniro cold gates (min 15C is needed > 43kW charging, min 25C is needed > 58kW charging)
liveData->params.batMinC = liveData->params.batMaxC = liveData->params.batModuleTempC[0];

View File

@@ -6,17 +6,12 @@ Supported devices
Working only with electric vehicles
Kia e-NIRO (EV), Hyundai Kona EV, Hyundai Ioniq EV, Kia Niro Phev 8.9kWh
Vgate iCar Pro Bluetooth 4.0 (BLE4) OBD2 adapter is required. See Release notes, quick installation via flash tool bellow.
Vgate iCar Pro Bluetooth 4.0 (BLE4) OBD2 adapter is required or CAN (m5 COMMU module).
See Release notes, quick installation via flash tool bellow.
Use it at your own risk!
Author: nick.n17@gmail.com (Lubos Petrovic / Slovakia)
## Supporting me
- Buy Me a Beer via paypal https://www.paypal.me/nickn17
- EU companies can support me via IBAN/Invoice (my company is non-VAT payer in Slovakia).
Many thanks to Blas, Jens, Калин, Aleš Dokupil and others for help. Thank you for supporting me.
evDash Discord server: https://discord.gg/rfAvH7xzTr
## Required hardware
Board
@@ -55,15 +50,19 @@ See INSTALLATION.md
Screen list
- no0. blank screen, lcd off
- no1. auto mode (summary info / speed kmh / charging graph)
- no2. summary info (default)
- no3. speed kmh + kwh/100km (or kw for discharge)
- no1. automatic mode (summary info / speed kmh / charging graph)
- no2. summary info
- no3. speed kmh + kwh/100km
- no4. battery cells + battery module temperatures
- no5. charging graph
- no6. consumption table. Can be used to measure available battery capacity!
- no7. debug screen (default off in the menu)
- no6. consumption table. Can be used to measure available battery capacity.
![image](https://github.com/nickn17/evDash/blob/master/screenshots/v1.jpg)
![image](https://github.com/nickn17/evDash/blob/master/screenshots/v2.jpg)
![image](https://github.com/nickn17/evDash/blob/master/screenshots/v2_m5charging2.jpg)
[![Watch the video](https://github.com/nickn17/evDash/blob/master/screenshots/v0.9.jpg)](https://www.youtube.com/watch?v=Jg5VP2P58Yg&)
## Supporting me
- nick.n17@gmail.com (Lubos Petrovic / Slovakia)
- Buy Me a Beer via paypal https://www.paypal.me/nickn17
- Many thanks to all evDash contributors.

View File

@@ -1,9 +1,20 @@
# RELEASE NOTES
### Next version
- removed debug screen
- sdcard working only with m5stack
- M5 COMMU (CAN) module support.
### v2.2.0 2020-12-29
- Direct CAN support with m5 COMMU module (instead obd2 BLE4 adapter). RECOMMENDED
- EvDash deep sleep & wake up for Hyundai Ioniq/Kona & Kia e-Niro (kolaCZek).
- Send data via GPRS to own server (kolaCZek). Simple web api project https://github.com/kolaCZek/evDash_serverapi)
- Better support for Hyundai Ioniq (kolaCZek).
- Kia e-niro - added support for open doors/hood/trunk.
- Serial console off/on and improved logging & debug level setting
- Avoid GPS on UART0 collision with serial console.
- DEV initial support for Bmw i3 (Janulo)
- Command queue refactoring (Janulo)
- Sdcard is working only with m5stack
- Removed debug screen
- M5 mute speaker fix
### v2.1.1 2020-12-14
- tech refactoring: `hexToDecFromResponse`, `decFromResponse`

View File

@@ -2,8 +2,8 @@
#include <BLEDevice.h>
#define APP_VERSION "v2.2.0-dev"
#define APP_RELEASE_DATE "2020-12-14"
#define APP_VERSION "v2.2.0"
#define APP_RELEASE_DATE "2020-12-29"
// TFT COLORS FOR TTGO
#define TFT_BLACK 0x0000 /* 0, 0, 0 */

Binary file not shown.

Binary file not shown.

17
menu.h
View File

@@ -29,7 +29,7 @@ MENU_ITEM menuItemsSource[100] = {
{MENU_ADAPTER_BLE4-1, MENU_ADAPTER_TYPE, 0, "<- parent menu"},
{MENU_ADAPTER_BLE4, MENU_ADAPTER_TYPE, -1, "Bluetooth 4 (BLE4)"},
{MENU_ADAPTER_CAN, MENU_ADAPTER_TYPE, -1, "CAN bus (MCP2515-1/SO)"},
{MENU_ADAPTER_BT3, MENU_ADAPTER_TYPE, -1, "Bluetooth 3 (dev)"},
//{MENU_ADAPTER_BT3, MENU_ADAPTER_TYPE, -1, "Bluetooth 3 (dev)"},
{300, 3, 0, "<- parent menu"},
// {MENU_WIFI, 3, -1, "[dev] WiFi network"},
@@ -47,19 +47,6 @@ MENU_ITEM menuItemsSource[100] = {
{MENU_HEADLIGHTS_REMINDER, 3, -1, "Headlight reminder"},
{MENU_SLEEP_MODE, 3, -1, "SleepMode"},
/*
// NTP
byte ntpEnabled; // 0/1
byte ntpTimezone;
byte ntpDaySaveTime; // 0/1
// GPRS SIM800L
byte gprsEnabled; // 0/1
char gprsApn[64];
// Remote upload
byte remoteUploadEnabled; // 0/1
char remoteApiUrl[64];
char remoteApiKey[32];*/
{400, 4, 0, "<- parent menu"},
{MENU_DISTANCE_UNIT, 4, -1, "Distance"},
{MENU_TEMPERATURE_UNIT, 4, -1, "Temperature"},
@@ -75,7 +62,7 @@ MENU_ITEM menuItemsSource[100] = {
{MENU_SDCARD_AUTOSTARTLOG, MENU_SDCARD, -1, "Autostart log enabled"},
{MENU_SDCARD_MOUNT_STATUS, MENU_SDCARD, -1, "Status"},
{MENU_SDCARD_REC, MENU_SDCARD, -1, "Record"},
{MENU_SDCARD_INTERVAL, MENU_SDCARD, -1, "Log interval sec."},
//{MENU_SDCARD_INTERVAL, MENU_SDCARD, -1, "Log interval sec."},
{3060, 306, 3, "<- parent menu"},
{3061, 306, -1, "Auto mode"},

BIN
screenshots/v2.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

BIN
screenshots/v2_m5speed.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB