diff --git a/src/dev/device.h b/src/dev/device.h index 3e49d271..4f6ae713 100644 --- a/src/dev/device.h +++ b/src/dev/device.h @@ -37,7 +37,7 @@ class BaseDevice { { return ""; } - virtual const char* get_display_driver() + virtual const char* get_chip_model() { return ""; } diff --git a/src/dev/esp32/esp32.cpp b/src/dev/esp32/esp32.cpp index ede2dbdb..837a6bad 100644 --- a/src/dev/esp32/esp32.cpp +++ b/src/dev/esp32/esp32.cpp @@ -43,11 +43,34 @@ void Esp32Device::set_hostname(const char* hostname) } const char* Esp32Device::get_core_version() { - return ESP.getSdkVersion(); + return esp_get_idf_version(); // == ESP.getSdkVersion(); } -const char* Esp32Device::get_display_driver() +const char* Esp32Device::get_chip_model() { - return Utilities::tft_driver_name().c_str(); + esp_chip_info_t chip_info; + esp_chip_info(&chip_info); + + // model = chip_info.cores; + // model += F("core "); + switch(chip_info.model) { + case CHIP_ESP32: + return "ESP32"; + +#ifdef CHIP_ESP32S2 + case CHIP_ESP32S2: + return "ESP32-S2"; +#endif + +#ifdef CHIP_ESP32S3 + case CHIP_ESP32S3: + return "ESP32-S3"; +#endif + + default: + return "Unknown ESP32"; + } + // model += F(" rev"); + // model += chip_info.revision; } void Esp32Device::set_backlight_pin(uint8_t pin) diff --git a/src/dev/esp32/esp32.h b/src/dev/esp32/esp32.h index 90f7485a..7c2b6797 100644 --- a/src/dev/esp32/esp32.h +++ b/src/dev/esp32/esp32.h @@ -30,7 +30,7 @@ class Esp32Device : public BaseDevice { const char* get_hostname(); void set_hostname(const char*); const char* get_core_version(); - const char* get_display_driver(); + const char* get_chip_model(); void set_backlight_pin(uint8_t pin) override; void set_backlight_level(uint8_t val) override; diff --git a/src/dev/esp8266/esp8266.cpp b/src/dev/esp8266/esp8266.cpp index bcd9a850..7435133e 100644 --- a/src/dev/esp8266/esp8266.cpp +++ b/src/dev/esp8266/esp8266.cpp @@ -42,9 +42,9 @@ const char* Esp8266Device::get_core_version() return ESP.getCoreVersion().c_str(); } -const char* Esp8266Device::get_display_driver() +const char* Esp8266Device::get_chip_model() { - return Utilities::tft_driver_name().c_str(); + return "ESP8266"; } void Esp8266Device::set_backlight_pin(uint8_t pin) diff --git a/src/dev/esp8266/esp8266.h b/src/dev/esp8266/esp8266.h index 458add99..460cb264 100644 --- a/src/dev/esp8266/esp8266.h +++ b/src/dev/esp8266/esp8266.h @@ -32,7 +32,7 @@ class Esp8266Device : public BaseDevice { const char* get_hostname(); void set_hostname(const char*); const char* get_core_version(); - const char* get_display_driver(); + const char* get_chip_model(); void set_backlight_pin(uint8_t pin) override; void set_backlight_level(uint8_t val) override; diff --git a/src/dev/posix/hasp_posix.cpp b/src/dev/posix/hasp_posix.cpp index 1515b315..8884861a 100644 --- a/src/dev/posix/hasp_posix.cpp +++ b/src/dev/posix/hasp_posix.cpp @@ -15,51 +15,53 @@ namespace dev { -PosixDevice::PosixDevice() { - struct utsname uts; +PosixDevice::PosixDevice() +{ + struct utsname uts; - if (uname(&uts) < 0) { - LOG_ERROR(0,"uname() error"); - _hostname = "localhost"; - _core_version = "unknown"; - } else { + if(uname(&uts) < 0) { + LOG_ERROR(0, "uname() error"); + _hostname = "localhost"; + _core_version = "unknown"; + _chip_model = "unknown"; + } else { // LOG_VERBOSE(0,"Sysname: %s", uts.sysname); // LOG_VERBOSE(0,"Nodename: %s", uts.nodename); // LOG_VERBOSE(0,"Release: %s", uts.release); // LOG_VERBOSE(0,"Version: %s", uts.version); // LOG_VERBOSE(0,"Machine: %s", uts.machine); - char version[128]; - snprintf(version, sizeof(version), "%s %s", uts.sysname, uts.release); - _core_version = version; - _hostname = uts.nodename; - } - - _backlight_power = 1; - _backlight_level = 100; + char version[128]; + snprintf(version, sizeof(version), "%s %s", uts.sysname, uts.release); + _core_version = version; + _chip_model = uts.machine; + _hostname = uts.nodename; } + _backlight_power = 1; + _backlight_level = 100; +} + void PosixDevice::reboot() {} void PosixDevice::show_info() { - struct utsname uts; + struct utsname uts; - if (uname(&uts) < 0) { - LOG_ERROR(0,"uname() error"); - } else { - LOG_VERBOSE(0,"Sysname: %s", uts.sysname); - LOG_VERBOSE(0,"Nodename: %s", uts.nodename); - LOG_VERBOSE(0,"Release: %s", uts.release); - LOG_VERBOSE(0,"Version: %s", uts.version); - LOG_VERBOSE(0,"Machine: %s", uts.machine); - } + if(uname(&uts) < 0) { + LOG_ERROR(0, "uname() error"); + } else { + LOG_VERBOSE(0, "Sysname: %s", uts.sysname); + LOG_VERBOSE(0, "Nodename: %s", uts.nodename); + LOG_VERBOSE(0, "Release: %s", uts.release); + LOG_VERBOSE(0, "Version: %s", uts.version); + LOG_VERBOSE(0, "Machine: %s", uts.machine); + } LOG_VERBOSE(0, "Processor : %s", "unknown"); LOG_VERBOSE(0, "CPU freq. : %i MHz", 0); } - const char* PosixDevice::get_hostname() { return _hostname.c_str(); @@ -74,9 +76,9 @@ const char* PosixDevice::get_core_version() { return _core_version.c_str(); } -const char* PosixDevice::get_display_driver() +const char* PosixDevice::get_chip_model() { - return "SDL2"; + return _chip_model.c_str(); } void PosixDevice::set_backlight_pin(uint8_t pin) @@ -89,8 +91,7 @@ void PosixDevice::set_backlight_level(uint8_t level) uint8_t new_level = level >= 0 ? level : 0; new_level = new_level <= 100 ? new_level : 100; - if(_backlight_level != new_level) - { + if(_backlight_level != new_level) { _backlight_level = new_level; update_backlight(); } @@ -121,7 +122,7 @@ void PosixDevice::update_backlight() // monitor.sdl_refr_qry = true; // monitor_sdl_refr(NULL); // const lv_area_t area = {1,1,0,0}; - //monitor_flush(NULL,&area,NULL); + // monitor_flush(NULL,&area,NULL); } size_t PosixDevice::get_free_max_block() diff --git a/src/dev/posix/hasp_posix.h b/src/dev/posix/hasp_posix.h index 687aa8ea..962bd45d 100644 --- a/src/dev/posix/hasp_posix.h +++ b/src/dev/posix/hasp_posix.h @@ -7,8 +7,7 @@ #include #include -extern "C" -{ +extern "C" { #include #include #include @@ -19,9 +18,9 @@ extern "C" #include "../device.h" #if defined(POSIX) -static inline void itoa(int i, char *out, int unused_) +static inline void itoa(int i, char* out, int unused_) { - (void) unused_; + (void)unused_; sprintf(out, "%d", i); } @@ -38,7 +37,7 @@ class PosixDevice : public BaseDevice { const char* get_hostname(); void set_hostname(const char*); const char* get_core_version(); - const char* get_display_driver(); + const char* get_chip_model(); void set_backlight_pin(uint8_t pin); void set_backlight_level(uint8_t val); @@ -56,6 +55,7 @@ class PosixDevice : public BaseDevice { private: std::string _hostname; std::string _core_version; + std::string _chip_model; uint8_t _backlight_pin; uint8_t _backlight_level; diff --git a/src/dev/stm32f4/stm32f4.cpp b/src/dev/stm32f4/stm32f4.cpp index 78e84484..41df3ad3 100644 --- a/src/dev/stm32f4/stm32f4.cpp +++ b/src/dev/stm32f4/stm32f4.cpp @@ -41,11 +41,6 @@ const char* Stm32f4Device::get_core_version() // return ESP.getCoreVersion().c_str(); } -const char* Stm32f4Device::get_display_driver() -{ - return Utilities::tft_driver_name().c_str(); -} - void Stm32f4Device::set_backlight_pin(uint8_t pin) { _backlight_pin = pin; @@ -57,6 +52,23 @@ void Stm32f4Device::set_backlight_pin(uint8_t pin) } } +const char* Stm32f4Device::get_chip_model() +{ +#if defined(STM32F407ZG) + return "STM32F407ZG"; +#elif defined(STM32F407ZE) + return "STM32F407ZE"; +#elif defined(STM32F407VE) + return "STM32F407VE"; +#elif defined(STM32F407VG) + return "STM32F407VG"; +#elif defined(STM32F4xx) || defined(ARDUINO_ARCH_STM32F4) + return "STM32F4"; +#else + return "Unknown STM32"; +#endif +} + void Stm32f4Device::set_backlight_level(uint8_t level) { _backlight_level = level >= 0 ? level : 0; diff --git a/src/dev/stm32f4/stm32f4.h b/src/dev/stm32f4/stm32f4.h index fcd76eba..30513dc0 100644 --- a/src/dev/stm32f4/stm32f4.h +++ b/src/dev/stm32f4/stm32f4.h @@ -32,7 +32,7 @@ class Stm32f4Device : public BaseDevice { const char* get_hostname(); void set_hostname(const char*); const char* get_core_version(); - const char* get_display_driver(); + const char* get_chip_model(); void set_backlight_pin(uint8_t pin) override; void set_backlight_level(uint8_t val) override; diff --git a/src/dev/win32/hasp_win32.cpp b/src/dev/win32/hasp_win32.cpp index 7aa1c93a..56e25f1a 100644 --- a/src/dev/win32/hasp_win32.cpp +++ b/src/dev/win32/hasp_win32.cpp @@ -56,7 +56,7 @@ const char* Win32Device::get_core_version() { return _core_version.c_str(); } -const char* Win32Device::get_display_driver() +const char* Win32Device::get_chip_model() { return "SDL2"; } diff --git a/src/dev/win32/hasp_win32.h b/src/dev/win32/hasp_win32.h index f833b60f..7aaa9ae3 100644 --- a/src/dev/win32/hasp_win32.h +++ b/src/dev/win32/hasp_win32.h @@ -57,7 +57,7 @@ class Win32Device : public BaseDevice { const char* get_hostname(); void set_hostname(const char*); const char* get_core_version(); - const char* get_display_driver(); + const char* get_chip_model(); void set_backlight_pin(uint8_t pin); void set_backlight_level(uint8_t val); diff --git a/src/sys/svc/hasp_http.cpp b/src/sys/svc/hasp_http.cpp index 071eee2f..fff180e3 100644 --- a/src/sys/svc/hasp_http.cpp +++ b/src/sys/svc/hasp_http.cpp @@ -646,7 +646,7 @@ void webHandleInfo() /* ESP Stats */ httpMessage += F("

MCU Model: "); - httpMessage += halGetChipModel(); + httpMessage += haspDevice.get_chip_model(); httpMessage += F("
CPU Frequency: "); httpMessage += String(haspDevice.get_cpu_frequency()); httpMessage += F("MHz"); @@ -670,7 +670,7 @@ void webHandleInfo() // httpMessage += String(ESP.getSdkVersion()); //#else httpMessage += F("
Core version: "); - httpMessage += halGetCoreVersion(); + httpMessage += haspDevice.get_core_version(); //#endif httpMessage += F("
Last Reset: "); httpMessage += halGetResetInfo();