mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-29 06:06:40 +00:00
Add chip_model
This commit is contained in:
parent
aff19396fe
commit
787b91910d
@ -37,7 +37,7 @@ class BaseDevice {
|
|||||||
{
|
{
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
virtual const char* get_display_driver()
|
virtual const char* get_chip_model()
|
||||||
{
|
{
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -43,11 +43,34 @@ void Esp32Device::set_hostname(const char* hostname)
|
|||||||
}
|
}
|
||||||
const char* Esp32Device::get_core_version()
|
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)
|
void Esp32Device::set_backlight_pin(uint8_t pin)
|
||||||
|
@ -30,7 +30,7 @@ class Esp32Device : public BaseDevice {
|
|||||||
const char* get_hostname();
|
const char* get_hostname();
|
||||||
void set_hostname(const char*);
|
void set_hostname(const char*);
|
||||||
const char* get_core_version();
|
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_pin(uint8_t pin) override;
|
||||||
void set_backlight_level(uint8_t val) override;
|
void set_backlight_level(uint8_t val) override;
|
||||||
|
@ -42,9 +42,9 @@ const char* Esp8266Device::get_core_version()
|
|||||||
return ESP.getCoreVersion().c_str();
|
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)
|
void Esp8266Device::set_backlight_pin(uint8_t pin)
|
||||||
|
@ -32,7 +32,7 @@ class Esp8266Device : public BaseDevice {
|
|||||||
const char* get_hostname();
|
const char* get_hostname();
|
||||||
void set_hostname(const char*);
|
void set_hostname(const char*);
|
||||||
const char* get_core_version();
|
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_pin(uint8_t pin) override;
|
||||||
void set_backlight_level(uint8_t val) override;
|
void set_backlight_level(uint8_t val) override;
|
||||||
|
@ -15,13 +15,15 @@
|
|||||||
|
|
||||||
namespace dev {
|
namespace dev {
|
||||||
|
|
||||||
PosixDevice::PosixDevice() {
|
PosixDevice::PosixDevice()
|
||||||
|
{
|
||||||
struct utsname uts;
|
struct utsname uts;
|
||||||
|
|
||||||
if(uname(&uts) < 0) {
|
if(uname(&uts) < 0) {
|
||||||
LOG_ERROR(0, "uname() error");
|
LOG_ERROR(0, "uname() error");
|
||||||
_hostname = "localhost";
|
_hostname = "localhost";
|
||||||
_core_version = "unknown";
|
_core_version = "unknown";
|
||||||
|
_chip_model = "unknown";
|
||||||
} else {
|
} else {
|
||||||
// LOG_VERBOSE(0,"Sysname: %s", uts.sysname);
|
// LOG_VERBOSE(0,"Sysname: %s", uts.sysname);
|
||||||
// LOG_VERBOSE(0,"Nodename: %s", uts.nodename);
|
// LOG_VERBOSE(0,"Nodename: %s", uts.nodename);
|
||||||
@ -32,6 +34,7 @@ PosixDevice::PosixDevice() {
|
|||||||
char version[128];
|
char version[128];
|
||||||
snprintf(version, sizeof(version), "%s %s", uts.sysname, uts.release);
|
snprintf(version, sizeof(version), "%s %s", uts.sysname, uts.release);
|
||||||
_core_version = version;
|
_core_version = version;
|
||||||
|
_chip_model = uts.machine;
|
||||||
_hostname = uts.nodename;
|
_hostname = uts.nodename;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,7 +62,6 @@ void PosixDevice::show_info()
|
|||||||
LOG_VERBOSE(0, "CPU freq. : %i MHz", 0);
|
LOG_VERBOSE(0, "CPU freq. : %i MHz", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char* PosixDevice::get_hostname()
|
const char* PosixDevice::get_hostname()
|
||||||
{
|
{
|
||||||
return _hostname.c_str();
|
return _hostname.c_str();
|
||||||
@ -74,9 +76,9 @@ const char* PosixDevice::get_core_version()
|
|||||||
{
|
{
|
||||||
return _core_version.c_str();
|
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)
|
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;
|
uint8_t new_level = level >= 0 ? level : 0;
|
||||||
new_level = new_level <= 100 ? new_level : 100;
|
new_level = new_level <= 100 ? new_level : 100;
|
||||||
|
|
||||||
if(_backlight_level != new_level)
|
if(_backlight_level != new_level) {
|
||||||
{
|
|
||||||
_backlight_level = new_level;
|
_backlight_level = new_level;
|
||||||
update_backlight();
|
update_backlight();
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,7 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
extern "C"
|
extern "C" {
|
||||||
{
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
@ -38,7 +37,7 @@ class PosixDevice : public BaseDevice {
|
|||||||
const char* get_hostname();
|
const char* get_hostname();
|
||||||
void set_hostname(const char*);
|
void set_hostname(const char*);
|
||||||
const char* get_core_version();
|
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_pin(uint8_t pin);
|
||||||
void set_backlight_level(uint8_t val);
|
void set_backlight_level(uint8_t val);
|
||||||
@ -56,6 +55,7 @@ class PosixDevice : public BaseDevice {
|
|||||||
private:
|
private:
|
||||||
std::string _hostname;
|
std::string _hostname;
|
||||||
std::string _core_version;
|
std::string _core_version;
|
||||||
|
std::string _chip_model;
|
||||||
|
|
||||||
uint8_t _backlight_pin;
|
uint8_t _backlight_pin;
|
||||||
uint8_t _backlight_level;
|
uint8_t _backlight_level;
|
||||||
|
@ -41,11 +41,6 @@ const char* Stm32f4Device::get_core_version()
|
|||||||
// return ESP.getCoreVersion().c_str();
|
// 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)
|
void Stm32f4Device::set_backlight_pin(uint8_t pin)
|
||||||
{
|
{
|
||||||
_backlight_pin = 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)
|
void Stm32f4Device::set_backlight_level(uint8_t level)
|
||||||
{
|
{
|
||||||
_backlight_level = level >= 0 ? level : 0;
|
_backlight_level = level >= 0 ? level : 0;
|
||||||
|
@ -32,7 +32,7 @@ class Stm32f4Device : public BaseDevice {
|
|||||||
const char* get_hostname();
|
const char* get_hostname();
|
||||||
void set_hostname(const char*);
|
void set_hostname(const char*);
|
||||||
const char* get_core_version();
|
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_pin(uint8_t pin) override;
|
||||||
void set_backlight_level(uint8_t val) override;
|
void set_backlight_level(uint8_t val) override;
|
||||||
|
@ -56,7 +56,7 @@ const char* Win32Device::get_core_version()
|
|||||||
{
|
{
|
||||||
return _core_version.c_str();
|
return _core_version.c_str();
|
||||||
}
|
}
|
||||||
const char* Win32Device::get_display_driver()
|
const char* Win32Device::get_chip_model()
|
||||||
{
|
{
|
||||||
return "SDL2";
|
return "SDL2";
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ class Win32Device : public BaseDevice {
|
|||||||
const char* get_hostname();
|
const char* get_hostname();
|
||||||
void set_hostname(const char*);
|
void set_hostname(const char*);
|
||||||
const char* get_core_version();
|
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_pin(uint8_t pin);
|
||||||
void set_backlight_level(uint8_t val);
|
void set_backlight_level(uint8_t val);
|
||||||
|
@ -646,7 +646,7 @@ void webHandleInfo()
|
|||||||
|
|
||||||
/* ESP Stats */
|
/* ESP Stats */
|
||||||
httpMessage += F("</p/><p><b>MCU Model: </b>");
|
httpMessage += F("</p/><p><b>MCU Model: </b>");
|
||||||
httpMessage += halGetChipModel();
|
httpMessage += haspDevice.get_chip_model();
|
||||||
httpMessage += F("<br/><b>CPU Frequency: </b>");
|
httpMessage += F("<br/><b>CPU Frequency: </b>");
|
||||||
httpMessage += String(haspDevice.get_cpu_frequency());
|
httpMessage += String(haspDevice.get_cpu_frequency());
|
||||||
httpMessage += F("MHz");
|
httpMessage += F("MHz");
|
||||||
@ -670,7 +670,7 @@ void webHandleInfo()
|
|||||||
// httpMessage += String(ESP.getSdkVersion());
|
// httpMessage += String(ESP.getSdkVersion());
|
||||||
//#else
|
//#else
|
||||||
httpMessage += F("<br/><b>Core version: </b>");
|
httpMessage += F("<br/><b>Core version: </b>");
|
||||||
httpMessage += halGetCoreVersion();
|
httpMessage += haspDevice.get_core_version();
|
||||||
//#endif
|
//#endif
|
||||||
httpMessage += F("<br/><b>Last Reset: </b>");
|
httpMessage += F("<br/><b>Last Reset: </b>");
|
||||||
httpMessage += halGetResetInfo();
|
httpMessage += halGetResetInfo();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user