update
This commit is contained in:
@@ -17,12 +17,6 @@ void Board320_240::initBoard() {
|
|||||||
pinMode(pinButtonLeft, INPUT);
|
pinMode(pinButtonLeft, INPUT);
|
||||||
pinMode(pinButtonRight, INPUT);
|
pinMode(pinButtonRight, INPUT);
|
||||||
|
|
||||||
// mute speaker
|
|
||||||
if (pinSpeaker != 0) {
|
|
||||||
Serial.println("Mute speaker for m5stack");
|
|
||||||
dacWrite(pinSpeaker, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Init display
|
// Init display
|
||||||
Serial.println("Init tft display");
|
Serial.println("Init tft display");
|
||||||
tft.begin();
|
tft.begin();
|
||||||
@@ -1174,7 +1168,7 @@ void Board320_240::mainLoop() {
|
|||||||
* skipAdapterScan
|
* skipAdapterScan
|
||||||
*/
|
*/
|
||||||
bool Board320_240::skipAdapterScan() {
|
bool Board320_240::skipAdapterScan() {
|
||||||
return digitalRead(pinButtonMiddle) == LOW || digitalRead(pinButtonRight) == LOW;
|
return digitalRead(pinButtonMiddle) == LOW || digitalRead(pinButtonLeft) == LOW || digitalRead(pinButtonRight) == LOW;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // BOARD320_240_CPP
|
#endif // BOARD320_240_CPP
|
||||||
|
|||||||
@@ -80,12 +80,10 @@ void BoardInterface::loadSettings() {
|
|||||||
|
|
||||||
String tmpStr;
|
String tmpStr;
|
||||||
|
|
||||||
// Init
|
// Default settings
|
||||||
liveData->settings.initFlag = 183;
|
liveData->settings.initFlag = 183;
|
||||||
liveData->settings.settingsVersion = 3;
|
liveData->settings.settingsVersion = 4;
|
||||||
liveData->settings.carType = CAR_KIA_ENIRO_2020_64;
|
liveData->settings.carType = CAR_KIA_ENIRO_2020_64;
|
||||||
|
|
||||||
// Default OBD adapter MAC and UUID's
|
|
||||||
tmpStr = "00:00:00:00:00:00"; // Pair via menu (middle button)
|
tmpStr = "00:00:00:00:00:00"; // Pair via menu (middle button)
|
||||||
tmpStr.toCharArray(liveData->settings.obdMacAddress, tmpStr.length() + 1);
|
tmpStr.toCharArray(liveData->settings.obdMacAddress, tmpStr.length() + 1);
|
||||||
tmpStr = "000018f0-0000-1000-8000-00805f9b34fb"; // Default UUID's for VGate iCar Pro BLE4 adapter
|
tmpStr = "000018f0-0000-1000-8000-00805f9b34fb"; // Default UUID's for VGate iCar Pro BLE4 adapter
|
||||||
@@ -94,7 +92,6 @@ void BoardInterface::loadSettings() {
|
|||||||
tmpStr.toCharArray(liveData->settings.charTxUUID, tmpStr.length() + 1);
|
tmpStr.toCharArray(liveData->settings.charTxUUID, tmpStr.length() + 1);
|
||||||
tmpStr = "00002af1-0000-1000-8000-00805f9b34fb";
|
tmpStr = "00002af1-0000-1000-8000-00805f9b34fb";
|
||||||
tmpStr.toCharArray(liveData->settings.charRxUUID, tmpStr.length() + 1);
|
tmpStr.toCharArray(liveData->settings.charRxUUID, tmpStr.length() + 1);
|
||||||
|
|
||||||
liveData->settings.displayRotation = 1; // 1,3
|
liveData->settings.displayRotation = 1; // 1,3
|
||||||
liveData->settings.distanceUnit = 'k';
|
liveData->settings.distanceUnit = 'k';
|
||||||
liveData->settings.temperatureUnit = 'c';
|
liveData->settings.temperatureUnit = 'c';
|
||||||
@@ -103,15 +100,26 @@ void BoardInterface::loadSettings() {
|
|||||||
liveData->settings.lcdBrightness = 0;
|
liveData->settings.lcdBrightness = 0;
|
||||||
liveData->settings.debugScreen = 0;
|
liveData->settings.debugScreen = 0;
|
||||||
liveData->settings.predrawnChargingGraphs = 1;
|
liveData->settings.predrawnChargingGraphs = 1;
|
||||||
|
liveData->settings.commType = 0; // BLE4
|
||||||
#ifdef SIM800L_ENABLED
|
liveData->settings.wifiEnabled = 0;
|
||||||
|
tmpStr = "empty";
|
||||||
|
tmpStr.toCharArray(liveData->settings.wifiSsid, tmpStr.length() + 1);
|
||||||
|
tmpStr = "not_set";
|
||||||
|
tmpStr.toCharArray(liveData->settings.wifiPassword, tmpStr.length() + 1);
|
||||||
|
liveData->settings.ntpEnabled = 0;
|
||||||
|
liveData->settings.ntpTimezone = 1;
|
||||||
|
liveData->settings.ntpDaySaveTime = 0;
|
||||||
|
liveData->settings.sdcardEnabled = 0;
|
||||||
|
liveData->settings.sdcardAutstartLog = 1;
|
||||||
|
liveData->settings.gprsEnabled = 0;
|
||||||
tmpStr = "internet.t-mobile.cz";
|
tmpStr = "internet.t-mobile.cz";
|
||||||
tmpStr.toCharArray(liveData->settings.gprsApn, tmpStr.length() + 1);
|
tmpStr.toCharArray(liveData->settings.gprsApn, tmpStr.length() + 1);
|
||||||
|
// Remote upload
|
||||||
|
liveData->settings.remoteUploadEnabled = 0;
|
||||||
tmpStr = "http://api.example.com";
|
tmpStr = "http://api.example.com";
|
||||||
tmpStr.toCharArray(liveData->settings.remoteApiSrvr, tmpStr.length() + 1);
|
tmpStr.toCharArray(liveData->settings.remoteApiUrl, tmpStr.length() + 1);
|
||||||
tmpStr = "example";
|
tmpStr = "example";
|
||||||
tmpStr.toCharArray(liveData->settings.remoteApiKey, tmpStr.length() + 1);
|
tmpStr.toCharArray(liveData->settings.remoteApiKey, tmpStr.length() + 1);
|
||||||
#endif //SIM800L_ENABLED
|
|
||||||
|
|
||||||
// Load settings and replace default values
|
// Load settings and replace default values
|
||||||
Serial.println("Reading settings from eeprom.");
|
Serial.println("Reading settings from eeprom.");
|
||||||
@@ -124,7 +132,7 @@ void BoardInterface::loadSettings() {
|
|||||||
saveSettings();
|
saveSettings();
|
||||||
} else {
|
} else {
|
||||||
Serial.print("Loaded settings ver.: ");
|
Serial.print("Loaded settings ver.: ");
|
||||||
Serial.println(liveData->settings.settingsVersion);
|
Serial.println(liveData->tmpSettings.settingsVersion);
|
||||||
|
|
||||||
// Upgrade structure
|
// Upgrade structure
|
||||||
if (liveData->settings.settingsVersion != liveData->tmpSettings.settingsVersion) {
|
if (liveData->settings.settingsVersion != liveData->tmpSettings.settingsVersion) {
|
||||||
@@ -138,13 +146,37 @@ void BoardInterface::loadSettings() {
|
|||||||
liveData->tmpSettings.settingsVersion = 3;
|
liveData->tmpSettings.settingsVersion = 3;
|
||||||
liveData->tmpSettings.predrawnChargingGraphs = liveData->settings.predrawnChargingGraphs;
|
liveData->tmpSettings.predrawnChargingGraphs = liveData->settings.predrawnChargingGraphs;
|
||||||
}
|
}
|
||||||
saveSettings();
|
if (liveData->tmpSettings.settingsVersion == 3) {
|
||||||
|
liveData->tmpSettings.settingsVersion = 4;
|
||||||
|
liveData->tmpSettings.commType = 0; // BLE4
|
||||||
|
liveData->tmpSettings.wifiEnabled = 0;
|
||||||
|
tmpStr = "empty";
|
||||||
|
tmpStr.toCharArray(liveData->tmpSettings.wifiSsid, tmpStr.length() + 1);
|
||||||
|
tmpStr = "not_set";
|
||||||
|
tmpStr.toCharArray(liveData->tmpSettings.wifiPassword, tmpStr.length() + 1);
|
||||||
|
liveData->tmpSettings.ntpEnabled = 0;
|
||||||
|
liveData->tmpSettings.ntpTimezone = 1;
|
||||||
|
liveData->tmpSettings.ntpDaySaveTime = 0;
|
||||||
|
liveData->tmpSettings.sdcardEnabled = 0;
|
||||||
|
liveData->tmpSettings.sdcardAutstartLog = 1;
|
||||||
|
liveData->tmpSettings.gprsEnabled = 0;
|
||||||
|
tmpStr = "internet.t-mobile.cz";
|
||||||
|
tmpStr.toCharArray(liveData->tmpSettings.gprsApn, tmpStr.length() + 1);
|
||||||
|
// Remote upload
|
||||||
|
liveData->tmpSettings.remoteUploadEnabled = 0;
|
||||||
|
tmpStr = "http://api.example.com";
|
||||||
|
tmpStr.toCharArray(liveData->tmpSettings.remoteApiUrl, tmpStr.length() + 1);
|
||||||
|
tmpStr = "example";
|
||||||
|
tmpStr.toCharArray(liveData->tmpSettings.remoteApiKey, tmpStr.length() + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save upgraded structure
|
||||||
|
liveData->settings = liveData->tmpSettings;
|
||||||
|
saveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save version? No need to upgrade structure
|
// Apply settings from flash if needed
|
||||||
if (liveData->settings.settingsVersion == liveData->tmpSettings.settingsVersion) {
|
liveData->settings = liveData->tmpSettings;
|
||||||
liveData->settings = liveData->tmpSettings;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,6 @@
|
|||||||
#include "BoardInterface.h"
|
#include "BoardInterface.h"
|
||||||
#include "Board320_240.h"
|
#include "Board320_240.h"
|
||||||
#include "BoardM5stackCore.h"
|
#include "BoardM5stackCore.h"
|
||||||
#include <SPI.h>
|
|
||||||
#include <SD.h>
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Init board
|
Init board
|
||||||
@@ -19,41 +17,17 @@ void BoardM5stackCore::initBoard() {
|
|||||||
pinSpeaker = SPEAKER_PIN;
|
pinSpeaker = SPEAKER_PIN;
|
||||||
pinBrightness = TFT_BL;
|
pinBrightness = TFT_BL;
|
||||||
|
|
||||||
|
// Mute speaker
|
||||||
|
//ledcWriteTone(TONE_PIN_CHANNEL, 0);
|
||||||
|
digitalWrite(SPEAKER_PIN, 0);
|
||||||
|
|
||||||
|
//
|
||||||
Board320_240::initBoard();
|
Board320_240::initBoard();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BoardM5stackCore::mainLoop() {
|
void BoardM5stackCore::mainLoop() {
|
||||||
|
|
||||||
Board320_240::mainLoop();
|
Board320_240::mainLoop();
|
||||||
|
|
||||||
/* if (!SD.begin(TFCARD_CS_PIN, SPI, 27000000)) {
|
|
||||||
Serial.println("Card Mount Failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
uint8_t cardType = SD.cardType();
|
|
||||||
if (cardType == CARD_NONE) {
|
|
||||||
Serial.println("No SD card attached");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Serial.print("SD Card Type: ");
|
|
||||||
if (cardType == CARD_MMC) {
|
|
||||||
Serial.println("MMC");
|
|
||||||
} else if (cardType == CARD_SD) {
|
|
||||||
Serial.println("SDSC");
|
|
||||||
} else if (cardType == CARD_SDHC) {
|
|
||||||
Serial.println("SDHC");
|
|
||||||
} else {
|
|
||||||
Serial.println("UNKNOWN");
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t cardSize = SD.cardSize() / (1024 * 1024);
|
|
||||||
Serial.printf("SD Card Size: %lluMB\n", cardSize);
|
|
||||||
|
|
||||||
Serial.printf("Total space: %lluMB\n", SD.totalBytes() / (1024 * 1024));
|
|
||||||
Serial.printf("Used space: %lluMB\n", SD.usedBytes() / (1024 * 1024));
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // BOARDM5STACKCORE_CPP
|
#endif // BOARDM5STACKCORE_CPP
|
||||||
|
|||||||
@@ -17,7 +17,10 @@
|
|||||||
#define TFT_BL 32 // LED back-light
|
#define TFT_BL 32 // LED back-light
|
||||||
#define SPI_FREQUENCY 27000000
|
#define SPI_FREQUENCY 27000000
|
||||||
#define SPI_READ_FREQUENCY 5000000
|
#define SPI_READ_FREQUENCY 5000000
|
||||||
|
// BEEP PIN
|
||||||
#define SPEAKER_PIN 25
|
#define SPEAKER_PIN 25
|
||||||
|
#define TONE_PIN_CHANNEL 0
|
||||||
|
// SDCARD
|
||||||
#define TFCARD_CS_PIN 4
|
#define TFCARD_CS_PIN 4
|
||||||
|
|
||||||
#define BUTTON_LEFT 37
|
#define BUTTON_LEFT 37
|
||||||
|
|||||||
32
LiveData.h
32
LiveData.h
@@ -126,7 +126,9 @@ typedef struct {
|
|||||||
// Setting stored to flash
|
// Setting stored to flash
|
||||||
typedef struct {
|
typedef struct {
|
||||||
byte initFlag; // 183 value
|
byte initFlag; // 183 value
|
||||||
byte settingsVersion; // current 3
|
byte settingsVersion; // current 4
|
||||||
|
// === settings version 1
|
||||||
|
// =================================
|
||||||
uint16_t carType; // 0 - Kia eNiro 2020, 1 - Hyundai Kona 2020, 2 - Hyudai Ioniq 2018
|
uint16_t carType; // 0 - Kia eNiro 2020, 1 - Hyundai Kona 2020, 2 - Hyudai Ioniq 2018
|
||||||
char obdMacAddress[20];
|
char obdMacAddress[20];
|
||||||
char serviceUUID[40];
|
char serviceUUID[40];
|
||||||
@@ -136,16 +138,34 @@ typedef struct {
|
|||||||
char distanceUnit; // k - kilometers
|
char distanceUnit; // k - kilometers
|
||||||
char temperatureUnit; // c - celsius
|
char temperatureUnit; // c - celsius
|
||||||
char pressureUnit; // b - bar
|
char pressureUnit; // b - bar
|
||||||
// version 2
|
// === settings version 3
|
||||||
|
// =================================
|
||||||
byte defaultScreen; // 1 .. 6
|
byte defaultScreen; // 1 .. 6
|
||||||
byte lcdBrightness; // 0 - auto, 1 .. 100%
|
byte lcdBrightness; // 0 - auto, 1 .. 100%
|
||||||
byte debugScreen; // 0 - off, 1 - on
|
byte debugScreen; // 0 - off, 1 - on
|
||||||
byte predrawnChargingGraphs; // 0 - off, 1 - on
|
byte predrawnChargingGraphs; // 0 - off, 1 - on
|
||||||
#ifdef SIM800L_ENABLED
|
// === settings version 4
|
||||||
|
// =================================
|
||||||
|
byte commType; // 0 - OBD2 BLE4 adapter, 1 - CAN
|
||||||
|
// 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];
|
char gprsApn[64];
|
||||||
char remoteApiSrvr[64];
|
// Remote upload
|
||||||
char remoteApiKey[13];
|
byte remoteUploadEnabled; // 0/1
|
||||||
#endif //SIM800L_ENABLED
|
char remoteApiUrl[64];
|
||||||
|
char remoteApiKey[32];
|
||||||
|
//
|
||||||
} SETTINGS_STRUC;
|
} SETTINGS_STRUC;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
# RELEASE NOTES
|
# RELEASE NOTES
|
||||||
|
|
||||||
|
### DEV
|
||||||
|
- m5stack mute speaker
|
||||||
|
- settings v4 (wifi/gprs/sdcard/ntp/..)
|
||||||
|
- ble4 skipped if mac is not set (00:00:00:00:00:00)
|
||||||
|
|
||||||
### v2.0.0 2020-12-02
|
### v2.0.0 2020-12-02
|
||||||
- Project renamed from eNiroDashboard to evDash
|
- Project renamed from eNiroDashboard to evDash
|
||||||
|
|
||||||
|
|||||||
@@ -366,7 +366,7 @@ void startBleScan() {
|
|||||||
|
|
||||||
liveData->foundMyBleDevice = NULL;
|
liveData->foundMyBleDevice = NULL;
|
||||||
liveData->scanningDeviceIndex = 0;
|
liveData->scanningDeviceIndex = 0;
|
||||||
board->displayMessage(" > Scanning BLE4 devices", "40 seconds");
|
board->displayMessage(" > Scanning BLE4 devices", "40sec.or hold middle&RST");
|
||||||
|
|
||||||
// Start scanning
|
// Start scanning
|
||||||
Serial.println("Scanning BLE devices...");
|
Serial.println("Scanning BLE devices...");
|
||||||
@@ -490,7 +490,7 @@ bool sendDataViaGPRS() {
|
|||||||
Serial.println(payload);
|
Serial.println(payload);
|
||||||
|
|
||||||
Serial.print("Remote API server: ");
|
Serial.print("Remote API server: ");
|
||||||
Serial.println(liveData->settings.remoteApiSrvr);
|
Serial.println(liveData->settings.remoteApiUrl);
|
||||||
|
|
||||||
uint16_t rc = sim800l->doPost(liveData->settings.remoteApiSrvr, "application/json", payload, 10000, 10000);
|
uint16_t rc = sim800l->doPost(liveData->settings.remoteApiSrvr, "application/json", payload, 10000, 10000);
|
||||||
if(rc == 200) {
|
if(rc == 200) {
|
||||||
@@ -592,7 +592,8 @@ void setup(void) {
|
|||||||
liveData->pBLEScan->setActiveScan(true);
|
liveData->pBLEScan->setActiveScan(true);
|
||||||
|
|
||||||
// Skip BLE scan if middle button pressed
|
// Skip BLE scan if middle button pressed
|
||||||
if (!board->skipAdapterScan()) {
|
Serial.println(liveData->settings.obdMacAddress);
|
||||||
|
if (strcmp(liveData->settings.obdMacAddress, "00:00:00:00:00:00") != 0 && !board->skipAdapterScan()) {
|
||||||
startBleScan();
|
startBleScan();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user