mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-25 20:26:41 +00:00
Replace halGetResetInfo with haspDevice.gpio_name
This commit is contained in:
parent
fb060cc6c2
commit
e4ac45d9a2
@ -94,6 +94,12 @@ class BaseDevice {
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
virtual std::string gpio_name(uint8_t pin)
|
||||||
|
{
|
||||||
|
char buffer[8];
|
||||||
|
itoa(pin, buffer, DEC);
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace dev
|
} // namespace dev
|
||||||
|
@ -52,7 +52,7 @@ class TftEspi : BaseTft {
|
|||||||
if(pin != -1) {
|
if(pin != -1) {
|
||||||
char buffer[64];
|
char buffer[64];
|
||||||
snprintf_P(buffer, sizeof(buffer), PSTR("%-11s: %s (GPIO %02d)"), String(pinfunction).c_str(),
|
snprintf_P(buffer, sizeof(buffer), PSTR("%-11s: %s (GPIO %02d)"), String(pinfunction).c_str(),
|
||||||
halGpioName(pin).c_str(), pin);
|
haspDevice.gpio_name(pin).c_str(), pin);
|
||||||
LOG_VERBOSE(TAG_TFT, buffer);
|
LOG_VERBOSE(TAG_TFT, buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
#if defined(TOUCH_CS)
|
#if defined(TOUCH_CS)
|
||||||
|
|
||||||
#include "hal/hasp_hal.h" // for halGpioName()
|
|
||||||
#include "dev/device.h"
|
#include "dev/device.h"
|
||||||
#include "drv/tft_driver.h"
|
#include "drv/tft_driver.h"
|
||||||
|
|
||||||
|
@ -99,22 +99,22 @@ void halRestartMcu(void)
|
|||||||
} // halt
|
} // halt
|
||||||
}
|
}
|
||||||
|
|
||||||
String halGetResetInfo()
|
// String halGetResetInfo()
|
||||||
{
|
// {
|
||||||
#if defined(ARDUINO_ARCH_ESP32)
|
// #if defined(ARDUINO_ARCH_ESP32)
|
||||||
String resetReason((char*)0);
|
// String resetReason((char*)0);
|
||||||
resetReason.reserve(128);
|
// resetReason.reserve(128);
|
||||||
|
|
||||||
resetReason += String(esp32ResetReason(0));
|
// resetReason += String(esp32ResetReason(0));
|
||||||
resetReason += F(" / ");
|
// resetReason += F(" / ");
|
||||||
resetReason += String(esp32ResetReason(1));
|
// resetReason += String(esp32ResetReason(1));
|
||||||
return resetReason;
|
// return resetReason;
|
||||||
#elif defined(ARDUINO_ARCH_ESP8266)
|
// #elif defined(ARDUINO_ARCH_ESP8266)
|
||||||
return ESP.getResetInfo();
|
// return ESP.getResetInfo();
|
||||||
#else
|
// #else
|
||||||
return "";
|
// return "";
|
||||||
#endif
|
// #endif
|
||||||
}
|
// }
|
||||||
|
|
||||||
// String halGetCoreVersion()
|
// String halGetCoreVersion()
|
||||||
// {
|
// {
|
||||||
@ -127,48 +127,48 @@ String halGetResetInfo()
|
|||||||
// #endif
|
// #endif
|
||||||
// }
|
// }
|
||||||
|
|
||||||
String halGetChipModel()
|
// String halGetChipModel()
|
||||||
{
|
// {
|
||||||
String model((char*)0);
|
// String model((char*)0);
|
||||||
model.reserve(128);
|
// model.reserve(128);
|
||||||
|
|
||||||
#if defined(STM32F4xx)
|
// #if defined(STM32F4xx)
|
||||||
model = F("STM32");
|
// model = F("STM32");
|
||||||
#endif
|
// #endif
|
||||||
|
|
||||||
#if defined(STM32F4xx)
|
// #if defined(STM32F4xx)
|
||||||
model = F("STM32F4xx");
|
// model = F("STM32F4xx");
|
||||||
|
|
||||||
#elif defined(ARDUINO_ARCH_ESP8266)
|
// #elif defined(ARDUINO_ARCH_ESP8266)
|
||||||
model = F("ESP8266");
|
// model = F("ESP8266");
|
||||||
|
|
||||||
#elif defined(ARDUINO_ARCH_ESP32)
|
// #elif defined(ARDUINO_ARCH_ESP32)
|
||||||
esp_chip_info_t chip_info;
|
// esp_chip_info_t chip_info;
|
||||||
esp_chip_info(&chip_info);
|
// esp_chip_info(&chip_info);
|
||||||
|
|
||||||
model = chip_info.cores;
|
// model = chip_info.cores;
|
||||||
model += F("core ");
|
// model += F("core ");
|
||||||
switch(chip_info.model) {
|
// switch(chip_info.model) {
|
||||||
case CHIP_ESP32:
|
// case CHIP_ESP32:
|
||||||
model += F("ESP32");
|
// model += F("ESP32");
|
||||||
break;
|
// break;
|
||||||
#ifdef CHIP_ESP32S2
|
// #ifdef CHIP_ESP32S2
|
||||||
case CHIP_ESP32S2:
|
// case CHIP_ESP32S2:
|
||||||
model += F("ESP32-S2");
|
// model += F("ESP32-S2");
|
||||||
break;
|
// break;
|
||||||
#endif
|
// #endif
|
||||||
default:
|
// default:
|
||||||
model = F("Unknown ESP32");
|
// model = F("Unknown ESP32");
|
||||||
}
|
// }
|
||||||
model += F(" rev");
|
// model += F(" rev");
|
||||||
model += chip_info.revision;
|
// model += chip_info.revision;
|
||||||
|
|
||||||
#else
|
// #else
|
||||||
model = F("Unknown");
|
// model = F("Unknown");
|
||||||
#endif
|
// #endif
|
||||||
|
|
||||||
return model;
|
// return model;
|
||||||
}
|
// }
|
||||||
|
|
||||||
/*******************************/
|
/*******************************/
|
||||||
/* Memory Management Functions */
|
/* Memory Management Functions */
|
||||||
@ -216,43 +216,43 @@ int getMemFree() { // returns the amount of free memory in bytes
|
|||||||
return mi.fordblks + freeHighMemory();
|
return mi.fordblks + freeHighMemory();
|
||||||
} */
|
} */
|
||||||
|
|
||||||
size_t halGetMaxFreeBlock()
|
// size_t halGetMaxFreeBlock()
|
||||||
{
|
// {
|
||||||
#if defined(ARDUINO_ARCH_ESP32)
|
// #if defined(ARDUINO_ARCH_ESP32)
|
||||||
return ESP.getMaxAllocHeap();
|
// return ESP.getMaxAllocHeap();
|
||||||
#elif defined(ARDUINO_ARCH_ESP8266)
|
// #elif defined(ARDUINO_ARCH_ESP8266)
|
||||||
return ESP.getMaxFreeBlockSize();
|
// return ESP.getMaxFreeBlockSize();
|
||||||
#else
|
// #else
|
||||||
return freeHighMemory();
|
// return freeHighMemory();
|
||||||
#endif
|
// #endif
|
||||||
}
|
// }
|
||||||
|
|
||||||
size_t halGetFreeHeap(void)
|
// size_t halGetFreeHeap(void)
|
||||||
{
|
// {
|
||||||
#if defined(ARDUINO_ARCH_ESP32)
|
// #if defined(ARDUINO_ARCH_ESP32)
|
||||||
return ESP.getFreeHeap();
|
// return ESP.getFreeHeap();
|
||||||
#elif defined(ARDUINO_ARCH_ESP8266)
|
// #elif defined(ARDUINO_ARCH_ESP8266)
|
||||||
return ESP.getFreeHeap();
|
// return ESP.getFreeHeap();
|
||||||
#else
|
// #else
|
||||||
struct mallinfo chuncks = mallinfo();
|
// struct mallinfo chuncks = mallinfo();
|
||||||
|
|
||||||
// fordblks
|
// // fordblks
|
||||||
// This is the total size of memory occupied by free (not in use) chunks.
|
// // This is the total size of memory occupied by free (not in use) chunks.
|
||||||
|
|
||||||
return chuncks.fordblks + freeHighMemory();
|
// return chuncks.fordblks + freeHighMemory();
|
||||||
#endif
|
// #endif
|
||||||
}
|
// }
|
||||||
|
|
||||||
uint8_t halGetHeapFragmentation()
|
// uint8_t halGetHeapFragmentation()
|
||||||
{
|
// {
|
||||||
#if defined(ARDUINO_ARCH_ESP32)
|
// #if defined(ARDUINO_ARCH_ESP32)
|
||||||
return (int8_t)(100.00f - (float)ESP.getMaxAllocHeap() * 100.00f / (float)ESP.getFreeHeap());
|
// return (int8_t)(100.00f - (float)ESP.getMaxAllocHeap() * 100.00f / (float)ESP.getFreeHeap());
|
||||||
#elif defined(ARDUINO_ARCH_ESP8266)
|
// #elif defined(ARDUINO_ARCH_ESP8266)
|
||||||
return ESP.getHeapFragmentation();
|
// return ESP.getHeapFragmentation();
|
||||||
#else
|
// #else
|
||||||
return (int8_t)(100.00f - (float)freeHighMemory() * 100.00f / (float)halGetFreeHeap());
|
// return (int8_t)(100.00f - (float)freeHighMemory() * 100.00f / (float)halGetFreeHeap());
|
||||||
#endif
|
// #endif
|
||||||
}
|
// }
|
||||||
|
|
||||||
String halGetMacAddress(int start, const char* seperator)
|
String halGetMacAddress(int start, const char* seperator)
|
||||||
{
|
{
|
||||||
@ -284,14 +284,14 @@ String halGetMacAddress(int start, const char* seperator)
|
|||||||
return cMac;
|
return cMac;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t halGetCpuFreqMHz()
|
// uint16_t halGetCpuFreqMHz()
|
||||||
{
|
// {
|
||||||
#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_32)
|
// #if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_32)
|
||||||
return ESP.getCpuFreqMHz();
|
// return ESP.getCpuFreqMHz();
|
||||||
#else
|
// #else
|
||||||
return (F_CPU / 1000 / 1000);
|
// return (F_CPU / 1000 / 1000);
|
||||||
#endif
|
// #endif
|
||||||
}
|
// }
|
||||||
|
|
||||||
String halDisplayDriverName()
|
String halDisplayDriverName()
|
||||||
{
|
{
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
// void halRestartMcu(void);
|
// void halRestartMcu(void);
|
||||||
String halGetResetInfo(void);
|
// String halGetResetInfo(void);
|
||||||
// uint8_t halGetHeapFragmentation(void);
|
// uint8_t halGetHeapFragmentation(void);
|
||||||
// size_t halGetMaxFreeBlock(void);
|
// size_t halGetMaxFreeBlock(void);
|
||||||
// size_t halGetFreeHeap(void);
|
// size_t halGetFreeHeap(void);
|
||||||
@ -16,6 +16,6 @@ String halGetResetInfo(void);
|
|||||||
String halGetMacAddress(int start, const char* seperator);
|
String halGetMacAddress(int start, const char* seperator);
|
||||||
// uint16_t halGetCpuFreqMHz(void);
|
// uint16_t halGetCpuFreqMHz(void);
|
||||||
// String halDisplayDriverName(void);
|
// String halDisplayDriverName(void);
|
||||||
String halGpioName(uint8_t gpio);
|
// String halGpioName(uint8_t gpio);
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -801,7 +801,7 @@ void webHandleInfo()
|
|||||||
httpMessage += haspDevice.get_core_version();
|
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();
|
||||||
|
|
||||||
httpMessage += FPSTR(MAIN_MENU_BUTTON);
|
httpMessage += FPSTR(MAIN_MENU_BUTTON);
|
||||||
|
|
||||||
@ -1519,7 +1519,8 @@ void webHandleGpioConfig()
|
|||||||
hasp_gpio_config_t conf = gpioGetPinConfig(id);
|
hasp_gpio_config_t conf = gpioGetPinConfig(id);
|
||||||
if((conf.pin == gpio) && gpioConfigInUse(id) && gpioInUse(gpio) && !gpioIsSystemPin(gpio)) {
|
if((conf.pin == gpio) && gpioConfigInUse(id) && gpioInUse(gpio) && !gpioIsSystemPin(gpio)) {
|
||||||
httpMessage += F("<tr><td>");
|
httpMessage += F("<tr><td>");
|
||||||
httpMessage += halGpioName(gpio);
|
// httpMessage += halGpioName(gpio);
|
||||||
|
httpMessage += haspDevice.gpio_name(gpio).c_str();
|
||||||
httpMessage += F("</td><td>");
|
httpMessage += F("</td><td>");
|
||||||
|
|
||||||
switch(conf.type & 0xfe) {
|
switch(conf.type & 0xfe) {
|
||||||
@ -1643,7 +1644,7 @@ void webHandleGpioOptions()
|
|||||||
|
|
||||||
for(uint8_t io = 0; io < NUM_DIGITAL_PINS; io++) {
|
for(uint8_t io = 0; io < NUM_DIGITAL_PINS; io++) {
|
||||||
if(((conf.pin == io) || !gpioInUse(io)) && !gpioIsSystemPin(io)) {
|
if(((conf.pin == io) || !gpioInUse(io)) && !gpioIsSystemPin(io)) {
|
||||||
httpMessage += getOption(io, halGpioName(io), conf.pin == io);
|
httpMessage += getOption(io, haspDevice.gpio_name(io).c_str(), conf.pin == io);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
httpMessage += F("</select></p>");
|
httpMessage += F("</select></p>");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user