autoshut down when car goes off, menu scroll
This commit is contained in:
@@ -63,6 +63,9 @@ Screen list
|
|||||||
|
|
||||||
## Release notes
|
## Release notes
|
||||||
|
|
||||||
|
- Fixed menu
|
||||||
|
- Automatic shutdown when car goes off
|
||||||
|
|
||||||
### v1.8.2 2020-11-25
|
### v1.8.2 2020-11-25
|
||||||
- Removed screen flickering. (via Sprites, esp32 with SRAM is now required!)
|
- Removed screen flickering. (via Sprites, esp32 with SRAM is now required!)
|
||||||
- Code cleaning. Removed force no/yes redraw mode. Not required with sprites
|
- Code cleaning. Removed force no/yes redraw mode. Not required with sprites
|
||||||
|
|||||||
@@ -90,6 +90,8 @@ bool activateCommandQueueForKiaENiro() {
|
|||||||
*/
|
*/
|
||||||
bool parseRowMergedKiaENiro() {
|
bool parseRowMergedKiaENiro() {
|
||||||
|
|
||||||
|
bool tempByte;
|
||||||
|
|
||||||
// ABS / ESP + AHB 7D1
|
// ABS / ESP + AHB 7D1
|
||||||
if (currentAtshRequest.equals("ATSH7D1")) {
|
if (currentAtshRequest.equals("ATSH7D1")) {
|
||||||
if (commandRequest.equals("22C101")) {
|
if (commandRequest.equals("22C101")) {
|
||||||
@@ -103,6 +105,12 @@ bool parseRowMergedKiaENiro() {
|
|||||||
// IGPM
|
// IGPM
|
||||||
if (currentAtshRequest.equals("ATSH770")) {
|
if (currentAtshRequest.equals("ATSH770")) {
|
||||||
if (commandRequest.equals("22BC03")) {
|
if (commandRequest.equals("22BC03")) {
|
||||||
|
tempByte = hexToDec(responseRowMerged.substring(16, 18).c_str(), 1, false);
|
||||||
|
params.ignitionOnPrevious = params.ignitionOn;
|
||||||
|
params.ignitionOn = (bitRead(tempByte, 5) == 1);
|
||||||
|
if (params.ignitionOnPrevious && !params.ignitionOn)
|
||||||
|
params.automatickShutdownTimer = params.currentTime;
|
||||||
|
|
||||||
params.lightInfo = hexToDec(responseRowMerged.substring(18, 20).c_str(), 1, false);
|
params.lightInfo = hexToDec(responseRowMerged.substring(18, 20).c_str(), 1, false);
|
||||||
params.headLights = (bitRead(params.lightInfo, 5) == 1);
|
params.headLights = (bitRead(params.lightInfo, 5) == 1);
|
||||||
params.dayLights = (bitRead(params.lightInfo, 3) == 1);
|
params.dayLights = (bitRead(params.lightInfo, 3) == 1);
|
||||||
|
|||||||
@@ -109,6 +109,32 @@ bool displayMessage(const char* row1, const char* row2) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Shutdown device
|
||||||
|
*/
|
||||||
|
bool shutdownDevice() {
|
||||||
|
|
||||||
|
Serial.println("Shutdown.");
|
||||||
|
|
||||||
|
displayMessage("Shutdown in 3 sec.", "");
|
||||||
|
delay(3000);
|
||||||
|
|
||||||
|
setCpuFrequencyMhz(80);
|
||||||
|
analogWrite(TFT_BL, 0);
|
||||||
|
//WiFi.disconnect(true);
|
||||||
|
//WiFi.mode(WIFI_OFF);
|
||||||
|
btStop();
|
||||||
|
//adc_power_off();
|
||||||
|
//esp_wifi_stop();
|
||||||
|
esp_bt_controller_disable();
|
||||||
|
|
||||||
|
delay(2000);
|
||||||
|
//esp_sleep_enable_timer_wakeup(/*minutes*/ 525600L * 60L * 1000000L);
|
||||||
|
esp_deep_sleep_start();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Load settings from flash memory, upgrade structure if version differs
|
Load settings from flash memory, upgrade structure if version differs
|
||||||
*/
|
*/
|
||||||
@@ -230,6 +256,9 @@ bool loadSettings() {
|
|||||||
*/
|
*/
|
||||||
bool initStructure() {
|
bool initStructure() {
|
||||||
|
|
||||||
|
params.automatickShutdownTimer = 0;
|
||||||
|
params.ignitionOn = false;
|
||||||
|
params.ignitionOnPrevious = false;
|
||||||
params.chargingStartTime = params.currentTime = 0;
|
params.chargingStartTime = params.currentTime = 0;
|
||||||
params.lightInfo = 0;
|
params.lightInfo = 0;
|
||||||
params.headLights = false;
|
params.headLights = false;
|
||||||
@@ -1175,12 +1204,22 @@ bool showMenu() {
|
|||||||
spr.setTextDatum(TL_DATUM);
|
spr.setTextDatum(TL_DATUM);
|
||||||
spr.setFreeFont(&Roboto_Thin_24);
|
spr.setFreeFont(&Roboto_Thin_24);
|
||||||
|
|
||||||
|
// Page scroll
|
||||||
|
uint8_t visibleCount = (int)(tft.height() / spr.fontHeight());
|
||||||
|
if (menuItemSelected >= menuItemOffset + visibleCount)
|
||||||
|
menuItemOffset = menuItemSelected - visibleCount + 1;
|
||||||
|
if (menuItemSelected < menuItemOffset)
|
||||||
|
menuItemOffset = menuItemSelected;
|
||||||
|
|
||||||
|
// Print items
|
||||||
for (uint16_t i = 0; i < menuItemsCount; ++i) {
|
for (uint16_t i = 0; i < menuItemsCount; ++i) {
|
||||||
if (menuCurrent == menuItems[i].parentId) {
|
if (menuCurrent == menuItems[i].parentId) {
|
||||||
|
if (tmpCurrMenuItem >= menuItemOffset) {
|
||||||
spr.fillRect(0, posY, 320, spr.fontHeight() + 2, (menuItemSelected == tmpCurrMenuItem) ? TFT_DARKGREEN2 : TFT_BLACK);
|
spr.fillRect(0, posY, 320, spr.fontHeight() + 2, (menuItemSelected == tmpCurrMenuItem) ? TFT_DARKGREEN2 : TFT_BLACK);
|
||||||
spr.setTextColor((menuItemSelected == tmpCurrMenuItem) ? TFT_WHITE : TFT_WHITE, (menuItemSelected == tmpCurrMenuItem) ? TFT_DARKGREEN2 : TFT_BLACK);
|
spr.setTextColor((menuItemSelected == tmpCurrMenuItem) ? TFT_WHITE : TFT_WHITE, (menuItemSelected == tmpCurrMenuItem) ? TFT_DARKGREEN2 : TFT_BLACK);
|
||||||
spr.drawString(menuItemCaption(menuItems[i].id, menuItems[i].title), 0, posY + 2, GFXFF);
|
spr.drawString(menuItemCaption(menuItems[i].id, menuItems[i].title), 0, posY + 2, GFXFF);
|
||||||
posY += spr.fontHeight();
|
posY += spr.fontHeight();
|
||||||
|
}
|
||||||
tmpCurrMenuItem++;
|
tmpCurrMenuItem++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1215,7 +1254,7 @@ bool menuMove(bool forward) {
|
|||||||
tmpCount++;
|
tmpCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
menuItemSelected = (menuItemSelected > tmpCount) ? tmpCount : menuItemSelected + 1;
|
menuItemSelected = (menuItemSelected >= tmpCount - 1 ) ? tmpCount - 1 : menuItemSelected + 1;
|
||||||
} else {
|
} else {
|
||||||
menuItemSelected = (menuItemSelected <= 0) ? 0 : menuItemSelected - 1;
|
menuItemSelected = (menuItemSelected <= 0) ? 0 : menuItemSelected - 1;
|
||||||
}
|
}
|
||||||
@@ -1311,6 +1350,8 @@ bool menuItemClick() {
|
|||||||
case 9: saveSettings(); break;
|
case 9: saveSettings(); break;
|
||||||
// Version
|
// Version
|
||||||
case 10: hideMenu(); return false;
|
case 10: hideMenu(); return false;
|
||||||
|
// Shutdown
|
||||||
|
case 11: shutdownDevice(); return false;
|
||||||
default:
|
default:
|
||||||
// Submenu
|
// Submenu
|
||||||
menuCurrent = tmpMenuItem.id;
|
menuCurrent = tmpMenuItem.id;
|
||||||
@@ -1970,4 +2011,7 @@ void loop() {
|
|||||||
struct tm now;
|
struct tm now;
|
||||||
getLocalTime(&now, 0);
|
getLocalTime(&now, 0);
|
||||||
params.currentTime = mktime(&now);
|
params.currentTime = mktime(&now);
|
||||||
|
// Shutdown when car is off
|
||||||
|
if (params.automatickShutdownTimer != 0 && params.currentTime - params.automatickShutdownTimer > 5)
|
||||||
|
shutdownDevice();
|
||||||
}
|
}
|
||||||
|
|||||||
4
menu.h
4
menu.h
@@ -8,10 +8,11 @@ typedef struct {
|
|||||||
char serviceUUID[40];
|
char serviceUUID[40];
|
||||||
} MENU_ITEM;
|
} MENU_ITEM;
|
||||||
|
|
||||||
#define menuItemsCount 66
|
#define menuItemsCount 67
|
||||||
bool menuVisible = false;
|
bool menuVisible = false;
|
||||||
uint16_t menuCurrent = 0;
|
uint16_t menuCurrent = 0;
|
||||||
uint8_t menuItemSelected = 0;
|
uint8_t menuItemSelected = 0;
|
||||||
|
uint8_t menuItemOffset = 0;
|
||||||
uint16_t scanningDeviceIndex = 0;
|
uint16_t scanningDeviceIndex = 0;
|
||||||
MENU_ITEM menuItems[menuItemsCount] = {
|
MENU_ITEM menuItems[menuItemsCount] = {
|
||||||
|
|
||||||
@@ -23,6 +24,7 @@ MENU_ITEM menuItems[menuItemsCount] = {
|
|||||||
{8, 0, -1, "Factory reset"},
|
{8, 0, -1, "Factory reset"},
|
||||||
{9, 0, -1, "Save settings"},
|
{9, 0, -1, "Save settings"},
|
||||||
{10, 0, -1, "Version"},
|
{10, 0, -1, "Version"},
|
||||||
|
{11, 0, -1, "Shutdown"},
|
||||||
|
|
||||||
{100, 1, 0, "<- parent menu"},
|
{100, 1, 0, "<- parent menu"},
|
||||||
{101, 1, -1, "Kia eNiro 2020 64kWh"},
|
{101, 1, -1, "Kia eNiro 2020 64kWh"},
|
||||||
|
|||||||
3
struct.h
3
struct.h
@@ -33,6 +33,9 @@ String currentAtshRequest = "";
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
time_t currentTime;
|
time_t currentTime;
|
||||||
time_t chargingStartTime;
|
time_t chargingStartTime;
|
||||||
|
time_t automatickShutdownTimer;
|
||||||
|
bool ignitionOn;
|
||||||
|
bool ignitionOnPrevious;
|
||||||
bool forwardDriveMode;
|
bool forwardDriveMode;
|
||||||
bool reverseDriveMode;
|
bool reverseDriveMode;
|
||||||
bool parkModeOrNeutral;
|
bool parkModeOrNeutral;
|
||||||
|
|||||||
Reference in New Issue
Block a user