Fixed menu, Wifi settings
This commit is contained in:
@@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
#include <analogWrite.h>
|
#include <analogWrite.h>
|
||||||
#include <TFT_eSPI.h>
|
#include <TFT_eSPI.h>
|
||||||
|
#include <WiFi.h>
|
||||||
|
#include <WiFiClient.h>
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "BoardInterface.h"
|
#include "BoardInterface.h"
|
||||||
#include "Board320_240.h"
|
#include "Board320_240.h"
|
||||||
@@ -38,11 +40,18 @@ void Board320_240::initBoard() {
|
|||||||
After setup device
|
After setup device
|
||||||
*/
|
*/
|
||||||
void Board320_240::afterSetup() {
|
void Board320_240::afterSetup() {
|
||||||
|
|
||||||
// Show test data on right button during boot device
|
// Show test data on right button during boot device
|
||||||
displayScreen = liveData->settings.defaultScreen;
|
displayScreen = liveData->settings.defaultScreen;
|
||||||
if (digitalRead(pinButtonRight) == LOW) {
|
if (digitalRead(pinButtonRight) == LOW) {
|
||||||
loadTestData();
|
loadTestData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Wifi
|
||||||
|
if (liveData->settings.wifiEnabled == 1) {
|
||||||
|
/*WiFi.mode(WIFI_STA);
|
||||||
|
WiFi.begin(liveData->settings.wifiSsid, liveData->settings.wifiPassword);*/
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -839,8 +848,23 @@ String Board320_240::menuItemCaption(int16_t menuItemId, String title) {
|
|||||||
case MENU_DEBUG_SCREEN: suffix = (liveData->settings.debugScreen == 1) ? "[on]" : "[off]"; 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_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_WIFI: switch (WiFi.status()) {
|
||||||
|
WL_CONNECTED: suffix = "CONNECTED"; break;
|
||||||
|
WL_NO_SHIELD: suffix = "NO_SHIELD"; break;
|
||||||
|
WL_IDLE_STATUS: suffix = "IDLE_STATUS"; break;
|
||||||
|
WL_NO_SSID_AVAIL: suffix = "NO_SSID_AVAIL"; break;
|
||||||
|
WL_SCAN_COMPLETED: suffix = "SCAN_COMPLETED"; break;
|
||||||
|
WL_CONNECT_FAILED: suffix = "CONNECT_FAILED"; break;
|
||||||
|
WL_CONNECTION_LOST: suffix = "CONNECTION_LOST"; break;
|
||||||
|
WL_DISCONNECTED: suffix = "DISCONNECTED"; break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case MENU_HEADLIGHTS_REMINDER: suffix = (liveData->settings.headlightsReminder == 1) ? "[on]" : "[off]"; break;
|
case MENU_HEADLIGHTS_REMINDER: suffix = (liveData->settings.headlightsReminder == 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_GPRS: sprintf(tmpStr1, "[%s] %s", (liveData->settings.gprsEnabled == 1) ? "on" : "off", liveData->settings.gprsApn); suffix = tmpStr1; break;
|
||||||
|
//
|
||||||
|
case MENU_WIFI_ENABLED: suffix = (liveData->settings.wifiEnabled == 1) ? "[on]" : "[off]"; break;
|
||||||
|
case MENU_WIFI_SSID: sprintf(tmpStr1, "%s", liveData->settings.wifiSsid); suffix = tmpStr1; break;
|
||||||
|
case MENU_WIFI_PASSWORD: sprintf(tmpStr1, "%s", liveData->settings.wifiPassword); suffix = tmpStr1; break;
|
||||||
//
|
//
|
||||||
case MENU_DISTANCE_UNIT: suffix = (liveData->settings.distanceUnit == 'k') ? "[km]" : "[mi]"; 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;
|
case MENU_TEMPERATURE_UNIT: suffix = (liveData->settings.temperatureUnit == 'c') ? "[C]" : "[F]"; break;
|
||||||
@@ -906,9 +930,8 @@ void Board320_240::menuMove(bool forward) {
|
|||||||
if (forward) {
|
if (forward) {
|
||||||
uint16_t tmpCount = 0;
|
uint16_t tmpCount = 0;
|
||||||
for (uint16_t i = 0; i < liveData->menuItemsCount; ++i) {
|
for (uint16_t i = 0; i < liveData->menuItemsCount; ++i) {
|
||||||
if (liveData->menuCurrent == liveData->menuItems[i].parentId) {
|
if (liveData->menuCurrent == liveData->menuItems[i].parentId && strlen(liveData->menuItems[i].title) != 0)
|
||||||
tmpCount++;
|
tmpCount++;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
liveData->menuItemSelected = (liveData->menuItemSelected >= tmpCount - 1 ) ? tmpCount - 1 : liveData->menuItemSelected + 1;
|
liveData->menuItemSelected = (liveData->menuItemSelected >= tmpCount - 1 ) ? tmpCount - 1 : liveData->menuItemSelected + 1;
|
||||||
} else {
|
} else {
|
||||||
@@ -926,7 +949,7 @@ void Board320_240::menuItemClick() {
|
|||||||
MENU_ITEM* tmpMenuItem;
|
MENU_ITEM* tmpMenuItem;
|
||||||
uint16_t tmpCurrMenuItem = 0;
|
uint16_t tmpCurrMenuItem = 0;
|
||||||
int16_t parentMenu = -1;
|
int16_t parentMenu = -1;
|
||||||
|
|
||||||
for (uint16_t i = 0; i < liveData->menuItemsCount; ++i) {
|
for (uint16_t i = 0; i < liveData->menuItemsCount; ++i) {
|
||||||
if (liveData->menuCurrent == liveData->menuItems[i].parentId) {
|
if (liveData->menuCurrent == liveData->menuItems[i].parentId) {
|
||||||
if (parentMenu == -1)
|
if (parentMenu == -1)
|
||||||
@@ -990,7 +1013,11 @@ void Board320_240::menuItemClick() {
|
|||||||
case 3044: liveData->settings.lcdBrightness = 100; showParentMenu = true; break;
|
case 3044: liveData->settings.lcdBrightness = 100; showParentMenu = true; break;
|
||||||
// Pre-drawn charg.graphs off/on
|
// Pre-drawn charg.graphs off/on
|
||||||
case MENU_PREDRAWN_GRAPHS: liveData->settings.predrawnChargingGraphs = (liveData->settings.predrawnChargingGraphs == 1) ? 0 : 1; 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_HEADLIGHTS_REMINDER: liveData->settings.headlightsReminder = (liveData->settings.headlightsReminder == 1) ? 0 : 1; 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;
|
||||||
// Distance
|
// Distance
|
||||||
case 4011: liveData->settings.distanceUnit = 'k'; showParentMenu = true; break;
|
case 4011: liveData->settings.distanceUnit = 'k'; showParentMenu = true; break;
|
||||||
case 4012: liveData->settings.distanceUnit = 'm'; showParentMenu = true; break;
|
case 4012: liveData->settings.distanceUnit = 'm'; showParentMenu = true; break;
|
||||||
@@ -1114,7 +1141,7 @@ void Board320_240::redrawScreen() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Parse test data
|
Parse test data
|
||||||
*/
|
*/
|
||||||
void Board320_240::loadTestData() {
|
void Board320_240::loadTestData() {
|
||||||
|
|
||||||
@@ -1124,7 +1151,7 @@ void Board320_240::loadTestData() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Board looop
|
Board looop
|
||||||
*/
|
*/
|
||||||
void Board320_240::mainLoop() {
|
void Board320_240::mainLoop() {
|
||||||
|
|
||||||
|
|||||||
4
config.h
4
config.h
@@ -73,6 +73,10 @@ typedef struct {
|
|||||||
#define MENU_DEBUG_SCREEN 303
|
#define MENU_DEBUG_SCREEN 303
|
||||||
#define MENU_SCREEN_BRIGHTNESS 304
|
#define MENU_SCREEN_BRIGHTNESS 304
|
||||||
#define MENU_PREDRAWN_GRAPHS 305
|
#define MENU_PREDRAWN_GRAPHS 305
|
||||||
|
#define MENU_WIFI 306
|
||||||
|
#define MENU_WIFI_ENABLED 3061
|
||||||
|
#define MENU_WIFI_SSID 3062
|
||||||
|
#define MENU_WIFI_PASSWORD 3063
|
||||||
#define MENU_GPRS 308
|
#define MENU_GPRS 308
|
||||||
#define MENU_HEADLIGHTS_REMINDER 310
|
#define MENU_HEADLIGHTS_REMINDER 310
|
||||||
#define MENU_DISTANCE_UNIT 401
|
#define MENU_DISTANCE_UNIT 401
|
||||||
|
|||||||
14
menu.h
14
menu.h
@@ -6,7 +6,7 @@ MENU_ITEM menuItemsSource[100] = {
|
|||||||
|
|
||||||
{0, 0, 0, "<- exit menu"},
|
{0, 0, 0, "<- exit menu"},
|
||||||
{MENU_VEHICLE_TYPE, 0, -1, "Vehicle type"},
|
{MENU_VEHICLE_TYPE, 0, -1, "Vehicle type"},
|
||||||
{2, 0, -1, "Select OBD2BLE adapter"},
|
{2, 0, -1, "Select OBD2 BLE4 adapter"},
|
||||||
{3, 0, -1, "Others"},
|
{3, 0, -1, "Others"},
|
||||||
{4, 0, -1, "Units"},
|
{4, 0, -1, "Units"},
|
||||||
{8, 0, -1, "Factory reset"},
|
{8, 0, -1, "Factory reset"},
|
||||||
@@ -29,17 +29,13 @@ MENU_ITEM menuItemsSource[100] = {
|
|||||||
{MENU_DEBUG_SCREEN, 3, -1, "Debug screen"},
|
{MENU_DEBUG_SCREEN, 3, -1, "Debug screen"},
|
||||||
{MENU_SCREEN_BRIGHTNESS, 3, -1, "LCD brightness"},
|
{MENU_SCREEN_BRIGHTNESS, 3, -1, "LCD brightness"},
|
||||||
{MENU_PREDRAWN_GRAPHS, 3, -1, "Pre-drawn ch.graphs"},
|
{MENU_PREDRAWN_GRAPHS, 3, -1, "Pre-drawn ch.graphs"},
|
||||||
{306, 3, -1, "[DEV] WiFi network"},
|
{MENU_WIFI, 3, -1, "WiFi network"},
|
||||||
{307, 3, -1, "[DEV] SD card"},
|
{307, 3, -1, "[DEV] SD card"},
|
||||||
{MENU_GPRS, 3, -1, "GPRS"},
|
{MENU_GPRS, 3, -1, "GPRS"},
|
||||||
{309, 3, -1, "[DEV] Remote upload"},
|
{309, 3, -1, "[DEV] Remote upload"},
|
||||||
{MENU_HEADLIGHTS_REMINDER, 3, -1, "Headlight reminder"},
|
{MENU_HEADLIGHTS_REMINDER, 3, -1, "Headlight reminder"},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// Wifi
|
|
||||||
byte wifiEnabled; // 0/1
|
|
||||||
char wifiSsid[32];
|
|
||||||
char wifiPassword[32];
|
|
||||||
// NTP
|
// NTP
|
||||||
byte ntpEnabled; // 0/1
|
byte ntpEnabled; // 0/1
|
||||||
byte ntpTimezone;
|
byte ntpTimezone;
|
||||||
@@ -78,9 +74,9 @@ MENU_ITEM menuItemsSource[100] = {
|
|||||||
{3044, 304, -1, "100%"},
|
{3044, 304, -1, "100%"},
|
||||||
|
|
||||||
{3060, 306, 3, "<- parent menu"},
|
{3060, 306, 3, "<- parent menu"},
|
||||||
{3061, 306, -1, "WiFi off/on"},
|
{MENU_WIFI_ENABLED, 306, -1, "WiFi enabled"},
|
||||||
{3062, 306, -1, "SSID"},
|
{MENU_WIFI_SSID, 306, -1, "SSID"},
|
||||||
{3063, 306, -1, "Password"},
|
{MENU_WIFI_PASSWORD, 306, -1, "Password"},
|
||||||
|
|
||||||
{3070, 307, 3, "<- parent menu"},
|
{3070, 307, 3, "<- parent menu"},
|
||||||
{3071, 307, -1, "Info:"},
|
{3071, 307, -1, "Info:"},
|
||||||
|
|||||||
Reference in New Issue
Block a user