Add chip_model

This commit is contained in:
fvanroie 2021-03-10 01:08:39 +01:00
parent aff19396fe
commit 787b91910d
12 changed files with 90 additions and 54 deletions

View File

@ -37,7 +37,7 @@ class BaseDevice {
{
return "";
}
virtual const char* get_display_driver()
virtual const char* get_chip_model()
{
return "";
}

View File

@ -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)

View File

@ -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;

View File

@ -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)

View File

@ -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;

View File

@ -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()

View File

@ -7,8 +7,7 @@
#include <cstdint>
#include <cstddef>
extern "C"
{
extern "C" {
#include <inttypes.h>
#include <stdlib.h>
#include <stddef.h>
@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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";
}

View File

@ -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);

View File

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