improved menu (added scroll support), m5stack speaker fix

This commit is contained in:
Lubos Petrovic
2020-11-28 20:47:42 +01:00
parent 3b97f52a20
commit 38a7869beb
6 changed files with 76 additions and 30 deletions

View File

@@ -61,10 +61,10 @@ Screen list
[![Watch the video](https://github.com/nickn17/enirodashboard/blob/master/screenshots/v0.9.jpg)](https://www.youtube.com/watch?v=Jg5VP2P58Yg&) [![Watch the video](https://github.com/nickn17/enirodashboard/blob/master/screenshots/v0.9.jpg)](https://www.youtube.com/watch?v=Jg5VP2P58Yg&)
## Release notes ### v1.8.3 2020-11-28
- Fixed menu
- Automatic shutdown when car goes off - Automatic shutdown when car goes off
- Fixed M5stack speaker noise
- Fixed menu, added scroll support
### 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!)

View File

@@ -2,39 +2,52 @@
// SELECT HARDWARE !!!! // SELECT HARDWARE !!!!
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
//#define BOARD_TTGO_T4 #define BOARD_TTGO_T4
#define BOARD_M5STACK_CORE //#define BOARD_M5STACK_CORE
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#define USER_SETUP_LOADED 1 #define USER_SETUP_LOADED 1
#define SPI_FREQUENCY 27000000 #define SPI_FREQUENCY 27000000
//#define SPI_READ_FREQUENCY 20000000
#define SPI_TOUCH_FREQUENCY 2500000 #define SPI_TOUCH_FREQUENCY 2500000
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// BOARD LILYGO TTGO T4 v1.3 // BOARD LILYGO TTGO T4 v1.3
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
#ifdef BOARD_TTGO_T4 #ifdef BOARD_TTGO_T4
#define ILI9341_DRIVER #define ILI9341_DRIVER
#define TFT_MISO 12 #define TFT_MISO 12
#define TFT_MOSI 23 #define TFT_MOSI 23
#define TFT_SCLK 18 #define TFT_SCLK 18
#define TFT_CS 27 #define TFT_CS 27
#define TFT_DC 26 #define TFT_DC 32
#define TFT_RST 5 #define TFT_RST 5
//#define TFT_BACKLIGHT_ON HIGH
#define TFT_BL 4 #define TFT_BL 4
#define USE_HSPI_PORT #define USE_HSPI_PORT
//#define SPI_FREQUENCY 40000000 // Maximum for ILI9341
#define SPI_READ_FREQUENCY 6000000 // 6 MHz is the maximum SPI read speed for the ST7789V #define SPI_READ_FREQUENCY 6000000 // 6 MHz is the maximum SPI read speed for the ST7789V
#define SD_CS 13
#define SD_MOSI 15
#define SD_MISO 2
#define SD_SCLK 14
#define BUTTON_LEFT 38 #define BUTTON_LEFT 38
#define BUTTON_MIDDLE 37 #define BUTTON_MIDDLE 37
#define BUTTON_RIGHT 39 #define BUTTON_RIGHT 39
#endif // BOARD_TTGO_T4 #endif // BOARD_TTGO_T4
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
// BOARD M5STACK CORE IOT (M5-K001) // BOARD M5STACK CORE IOT (M5-K001)
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
#ifdef BOARD_M5STACK_CORE #ifdef BOARD_M5STACK_CORE
#define USER_SETUP_LOADED 1 #define USER_SETUP_LOADED 1
#define ILI9341_DRIVER #define ILI9341_DRIVER
#define M5STACK #define M5STACK
@@ -47,11 +60,18 @@
#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
#define SPEAKER_PIN 25
#define INVERT_DISPLAY
#define BUTTON_LEFT 37 #define BUTTON_LEFT 37
#define BUTTON_MIDDLE 38 #define BUTTON_MIDDLE 38
#define BUTTON_RIGHT 39 #define BUTTON_RIGHT 39
#define SPEAKER 25
#define INVERT_DISPLAY #define SD_CS 4
#define SD_MOSI 23
#define SD_MISO 19
#define SD_SCLK 18
#endif // BOARD_M5STACK_CORE #endif // BOARD_M5STACK_CORE
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////

Binary file not shown.

Binary file not shown.

View File

@@ -27,28 +27,31 @@
<= 0°C BMS allows max 40A <= 0°C BMS allows max 40A
*/ */
#define APP_VERSION "v1.8.2b" #define APP_VERSION "v1.8.3b"
#include "SPI.h" #include <SPI.h>
#include "TFT_eSPI.h" #include <TFT_eSPI.h>
#include "BLEDevice.h" #include <BLEDevice.h>
#include "./config.h"
#include <mySD.h>
//#include <SD.h>
#include <EEPROM.h> #include <EEPROM.h>
#include <sys/time.h> #include <sys/time.h>
#include <analogWrite.h> #include <analogWrite.h>
#include "config.h" #include "./struct.h"
#include "struct.h" #include "./menu.h"
#include "menu.h" #include "./car_kia_eniro.h"
#include "car_kia_eniro.h" #include "./car_hyundai_ioniq.h"
#include "car_hyundai_ioniq.h" #include "./car_renault_zoe.h"
#include "car_renault_zoe.h" #include "./car_debug_obd2_kia.h"
#include "car_debug_obd2_kia.h"
// PLEASE CHANGE THIS SETTING for your BLE4 // PLEASE CHANGE THIS SETTING for your BLE4
uint32_t PIN = 1234; uint32_t PIN = 1234;
// TFT // TFT, SD SPI
TFT_eSPI tft = TFT_eSPI(); TFT_eSPI tft = TFT_eSPI();
TFT_eSprite spr = TFT_eSprite(&tft); TFT_eSprite spr = TFT_eSprite(&tft);
//SPIClass spiSD(HSPI);
// BLUETOOTH4 // BLUETOOTH4
static boolean bleConnect = true; static boolean bleConnect = true;
@@ -176,7 +179,7 @@ bool loadSettings() {
// Init // Init
settings.initFlag = 183; settings.initFlag = 183;
settings.settingsVersion = 2; settings.settingsVersion = 3;
settings.carType = CAR_KIA_ENIRO_2020_64; settings.carType = CAR_KIA_ENIRO_2020_64;
// Default OBD adapter MAC and UUID's // Default OBD adapter MAC and UUID's
@@ -1830,6 +1833,7 @@ void setup(void) {
Serial.println(""); Serial.println("");
Serial.println("Booting device..."); Serial.println("Booting device...");
//
initStructure(); initStructure();
loadSettings(); loadSettings();
@@ -1840,9 +1844,9 @@ void setup(void) {
#ifdef BOARD_M5STACK_CORE #ifdef BOARD_M5STACK_CORE
// mute speaker // mute speaker
dacWrite(25, 0); Serial.println("Mute speaker for m5stack");
dacWrite(SPEAKER_PIN, 0);
#endif // BOARD_M5STACK_C #endif // BOARD_M5STACK_C
// Init display // Init display
Serial.println("Init TFT display"); Serial.println("Init TFT display");
tft.begin(); tft.begin();
@@ -1860,11 +1864,6 @@ void setup(void) {
if (psramFound()) if (psramFound())
psramUsed = true; psramUsed = true;
#endif #endif
// if (!psramUsed) {
// displayMessage("SRAM support required", "Compile with ESP32 Wrover CPU");
// delay(60000);
// ESP.restart();
// }
spr.setColorDepth((psramUsed) ? 16 : 8); spr.setColorDepth((psramUsed) ? 16 : 8);
spr.createSprite(320, 240); spr.createSprite(320, 240);
redrawScreen(); redrawScreen();
@@ -1884,6 +1883,19 @@ void setup(void) {
testData(); testData();
} }
// Init SDCARD
if (!SD.begin(SD_CS, SD_MOSI, SD_MISO, SD_SCLK)) {
Serial.println("SDCARD initialization failed!");
} else {
Serial.println("SDCARD initialization done.");
}
/*spiSD.begin(SD_SCLK,SD_MISO,SD_MOSI,SD_CS);
if(!SD.begin( SD_CS, spiSD, 27000000)){
Serial.println("SDCARD initialization failed!");
} else {
Serial.println("SDCARD initialization done.");
}*/
// Start BLE connection // Start BLE connection
line = ""; line = "";
Serial.println("Start BLE with PIN auth"); Serial.println("Start BLE with PIN auth");

16
menu.h
View File

@@ -8,7 +8,7 @@ typedef struct {
char serviceUUID[40]; char serviceUUID[40];
} MENU_ITEM; } MENU_ITEM;
#define menuItemsCount 67 #define menuItemsCount 79
bool menuVisible = false; bool menuVisible = false;
uint16_t menuCurrent = 0; uint16_t menuCurrent = 0;
uint8_t menuItemSelected = 0; uint8_t menuItemSelected = 0;
@@ -41,6 +41,8 @@ MENU_ITEM menuItems[menuItemsCount] = {
{303, 3, -1, "Debug screen off/on"}, {303, 3, -1, "Debug screen off/on"},
{304, 3, -1, "LCD brightness"}, {304, 3, -1, "LCD brightness"},
{305, 3, -1, "Pre-drawn ch.graphs 0/1"}, {305, 3, -1, "Pre-drawn ch.graphs 0/1"},
{306, 3, -1, "[DEV] WiFi network"},
{307, 3, -1, "[DEV] SD card"},
{400, 4, 0, "<- parent menu"}, {400, 4, 0, "<- parent menu"},
{401, 4, -1, "Distance"}, {401, 4, -1, "Distance"},
@@ -72,6 +74,18 @@ MENU_ITEM menuItems[menuItemsCount] = {
{3051, 305, -1, "Off"}, {3051, 305, -1, "Off"},
{3052, 305, -1, "On"}, {3052, 305, -1, "On"},
{3060, 306, 3, "<- parent menu"},
{3061, 306, -1, "WiFi off/on"},
{3062, 306, -1, "SSID"},
{3063, 306, -1, "Password"},
{3070, 307, 3, "<- parent menu"},
{3071, 307, -1, "Info:"},
{3072, 307, -1, "Mount manually"},
{3073, 307, -1, "Record now"},
{3074, 307, -1, "Stop recording"},
{3075, 307, -1, "Record on boot off/on"},
{4010, 401, 4, "<- parent menu"}, {4010, 401, 4, "<- parent menu"},
{4011, 401, -1, "Kilometers"}, {4011, 401, -1, "Kilometers"},
{4012, 401, -1, "Miles"}, {4012, 401, -1, "Miles"},