From 3dcfab24ea2f8876f9b569fd4f7dbab4b6fffc5e Mon Sep 17 00:00:00 2001 From: Lubos Petrovic Date: Sat, 5 Dec 2020 11:24:20 +0100 Subject: [PATCH] update --- Board320_240.cpp | 4 +++- BoardInterface.cpp | 3 +++ BoardInterface.h | 1 + LiveData.cpp | 3 +-- LiveData.h | 2 +- config.h | 1 + evDash.ino | 5 ++++- menu.h | 23 ++++++++++++++++++++++- 8 files changed, 36 insertions(+), 6 deletions(-) diff --git a/Board320_240.cpp b/Board320_240.cpp index 3f0ccce..0b1c706 100644 --- a/Board320_240.cpp +++ b/Board320_240.cpp @@ -838,7 +838,8 @@ String Board320_240::menuItemCaption(int16_t menuItemId, String title) { case MENU_DEFAULT_SCREEN: sprintf(tmpStr1, "[%d]", liveData->settings.defaultScreen); suffix = tmpStr1; break; case MENU_DEBUG_SCREEN: suffix = (liveData->settings.debugScreen == 1) ? "[on]" : "[off]"; break; case MENU_SCREEN_BRIGHTNESS: sprintf(tmpStr1, "[%d%%]", liveData->settings.lcdBrightness); suffix = (liveData->settings.lcdBrightness == 0) ? "[auto]" : tmpStr1; break; - case MENU_PREDRAWN_GRAPHS: suffix = (liveData->settings.predrawnChargingGraphs == 1) ? "[on]" : "[off]"; break; + case MENU_PREDRAWN_GRAPHS: suffix = (liveData->settings.predrawnChargingGraphs == 1) ? "[on]" : "[off]"; break; + case MENU_GPRS: sprintf(tmpStr1, "[%s] %s", (liveData->settings.gprsEnabled == 1) ? "on": "off", liveData->settings.gprsApn); suffix = tmpStr1; break; // case MENU_DISTANCE_UNIT: suffix = (liveData->settings.distanceUnit == 'k') ? "[km]" : "[mi]"; break; case MENU_TEMPERATURE_UNIT: suffix = (liveData->settings.temperatureUnit == 'c') ? "[C]" : "[F]"; break; @@ -924,6 +925,7 @@ void Board320_240::menuItemClick() { MENU_ITEM* tmpMenuItem; uint16_t tmpCurrMenuItem = 0; int16_t parentMenu = -1; + for (uint16_t i = 0; i < liveData->menuItemsCount; ++i) { if (liveData->menuCurrent == liveData->menuItems[i].parentId) { if (parentMenu == -1) diff --git a/BoardInterface.cpp b/BoardInterface.cpp index c11a673..09e45c1 100644 --- a/BoardInterface.cpp +++ b/BoardInterface.cpp @@ -178,6 +178,9 @@ void BoardInterface::loadSettings() { // Apply settings from flash if needed liveData->settings = liveData->tmpSettings; } + + void customConsoleCommand(String cmd); + } #endif // BOARDINTERFACE_CPP diff --git a/BoardInterface.h b/BoardInterface.h index 5ae2d08..bbcc580 100644 --- a/BoardInterface.h +++ b/BoardInterface.h @@ -45,6 +45,7 @@ class BoardInterface { void saveSettings(); void resetSettings(); void loadSettings(); + void customConsoleCommand(String cmd); }; #endif // BOARDINTERFACE_H diff --git a/LiveData.cpp b/LiveData.cpp index c1a904c..badcefd 100644 --- a/LiveData.cpp +++ b/LiveData.cpp @@ -11,10 +11,8 @@ void LiveData::initParams() { params.automaticShutdownTimer = 0; -#ifdef SIM800L_ENABLED params.lastDataSent = 0; params.sim800l_enabled = false; -#endif //SIM800L_ENABLED params.ignitionOn = false; params.ignitionOnPrevious = false; params.chargingStartTime = params.currentTime = 0; @@ -98,6 +96,7 @@ void LiveData::initParams() { } // Menu + menuItemsCount = sizeof(menuItemsSource) / sizeof(menuItemsSource[0]); menuItems = menuItemsSource; } diff --git a/LiveData.h b/LiveData.h index 881b2b1..0731d16 100644 --- a/LiveData.h +++ b/LiveData.h @@ -183,7 +183,7 @@ class LiveData { String currentAtshRequest = ""; // Menu bool menuVisible = false; - uint8_t menuItemsCount = 79; + uint8_t menuItemsCount; uint16_t menuCurrent = 0; uint8_t menuItemSelected = 0; uint8_t menuItemOffset = 0; diff --git a/config.h b/config.h index cba2567..dc8d9cd 100644 --- a/config.h +++ b/config.h @@ -73,6 +73,7 @@ typedef struct { #define MENU_DEBUG_SCREEN 303 #define MENU_SCREEN_BRIGHTNESS 304 #define MENU_PREDRAWN_GRAPHS 305 +#define MENU_GPRS 308 #define MENU_DISTANCE_UNIT 401 #define MENU_TEMPERATURE_UNIT 402 #define MENU_PRESSURE_UNIT 403 diff --git a/evDash.ino b/evDash.ino index 35beb98..9cba4f4 100644 --- a/evDash.ino +++ b/evDash.ino @@ -635,11 +635,14 @@ void loop() { if (liveData->bleConnected) { if (Serial.available()) { ch = Serial.read(); - line = line + ch; if (ch == '\r' || ch == '\n') { + board->customConsoleCommand(line); + line = line + ch; Serial.println(line); liveData->pRemoteCharacteristicWrite->writeValue(line.c_str(), line.length()); line = ""; + } else { + line = line + ch; } } diff --git a/menu.h b/menu.h index 6f18707..45dd4e4 100644 --- a/menu.h +++ b/menu.h @@ -2,7 +2,7 @@ #include "config.h"; -MENU_ITEM menuItemsSource[79] = { +MENU_ITEM menuItemsSource[100] = { {0, 0, 0, "<- exit menu"}, {MENU_VEHICLE_TYPE, 0, -1, "Vehicle type"}, @@ -31,6 +31,27 @@ MENU_ITEM menuItemsSource[79] = { {MENU_PREDRAWN_GRAPHS, 3, -1, "Pre-drawn ch.graphs"}, {306, 3, -1, "[DEV] WiFi network"}, {307, 3, -1, "[DEV] SD card"}, + {MENU_GPRS, 3, -1, "GPRS"}, + {309, 3, -1, "[DEV] Remote upload"}, +/* + // Wifi + byte wifiEnabled; // 0/1 + char wifiSsid[32]; + char wifiPassword[32]; + // NTP + byte ntpEnabled; // 0/1 + byte ntpTimezone; + byte ntpDaySaveTime; // 0/1 + // SDcard logging + byte sdcardEnabled; // 0/1 + byte sdcardAutstartLog; // 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"},