More ESP32 compatibility

More ESP32 compatibility (breaks current ESP32 configuration again!)
This commit is contained in:
Theo Arends 2020-04-16 14:59:01 +02:00
parent 5c43f4c4c2
commit d2b7b4012f
2 changed files with 45 additions and 8 deletions

View File

@ -245,7 +245,7 @@ typedef struct {
} EnergyUsage; } EnergyUsage;
typedef struct PACKED { typedef struct {
uint8_t fnid = 0; uint8_t fnid = 0;
uint8_t dpid = 0; uint8_t dpid = 0;
} TuyaFnidDpidMap; } TuyaFnidDpidMap;
@ -253,7 +253,7 @@ typedef struct PACKED {
const uint32_t settings_text_size = 699; // Settings.text_pool[size] = Settings.display_model (2D2) - Settings.text_pool (017) const uint32_t settings_text_size = 699; // Settings.text_pool[size] = Settings.display_model (2D2) - Settings.text_pool (017)
const uint8_t MAX_TUYA_FUNCTIONS = 16; const uint8_t MAX_TUYA_FUNCTIONS = 16;
struct PACKED SYSCFG { struct SYSCFG {
uint16_t cfg_holder; // 000 v6 header uint16_t cfg_holder; // 000 v6 header
uint16_t cfg_size; // 002 uint16_t cfg_size; // 002
unsigned long save_flag; // 004 unsigned long save_flag; // 004
@ -369,7 +369,13 @@ struct PACKED SYSCFG {
uint8_t module; // 474 uint8_t module; // 474
uint8_t ws_color[4][3]; // 475 uint8_t ws_color[4][3]; // 475
uint8_t ws_width[3]; // 481 uint8_t ws_width[3]; // 481
myio my_gp; // 484
#ifdef ESP8266
myio my_gp; // 484 - 17 bytes (ESP8266)
#else // ESP32
uint8_t free_esp32_484[17]; // 484
#endif // ESP8266 - ESP32
uint8_t my_adc0; // 495 uint8_t my_adc0; // 495
uint16_t light_pixels; // 496 uint16_t light_pixels; // 496
uint8_t light_color[5]; // 498 uint8_t light_color[5]; // 498
@ -397,7 +403,14 @@ struct PACKED SYSCFG {
uint32_t ip_address[4]; // 544 uint32_t ip_address[4]; // 544
unsigned long energy_kWhtotal; // 554 unsigned long energy_kWhtotal; // 554
#ifdef ESP8266
char ex_mqtt_fulltopic[100]; // 558 char ex_mqtt_fulltopic[100]; // 558
#else // ESP32
myio my_gp; // 558 - 40 bytes (ESP32)
mytmplt user_template; // 580 - 35 bytes (ESP32)
uint8_t free_esp32_5a3[25]; // 5A3
#endif // ESP8266 - ESP32
SysBitfield2 flag2; // 5BC SysBitfield2 flag2; // 5BC
unsigned long pulse_counter[MAX_COUNTERS]; // 5C0 unsigned long pulse_counter[MAX_COUNTERS]; // 5C0
@ -423,7 +436,12 @@ struct PACKED SYSCFG {
char user_template_name[15]; // 720 15 bytes - Backward compatibility since v8.2.0.3 char user_template_name[15]; // 720 15 bytes - Backward compatibility since v8.2.0.3
mytmplt user_template; // 72F 14 bytes #ifdef ESP8266
mytmplt user_template; // 72F 14 bytes (ESP8266)
#else // ESP32
uint8_t free_esp32_72f[14]; // 72F
#endif // ESP8266 - ESP32
uint8_t novasds_startingoffset; // 73D uint8_t novasds_startingoffset; // 73D
uint8_t web_color[18][3]; // 73E uint8_t web_color[18][3]; // 73E
uint16_t display_width; // 774 uint16_t display_width; // 774
@ -507,8 +525,9 @@ struct PACKED SYSCFG {
uint8_t zb_free_byte; // F33 uint8_t zb_free_byte; // F33
uint16_t pms_wake_interval; // F34 uint16_t pms_wake_interval; // F34
uint8_t free_f36[130]; // F36 uint8_t free_f36[130]; // F36 - Decrement if adding new Setting variables just above and below
// Only 32 bit boundary variables below
uint16_t pulse_counter_debounce_low; // FB8 uint16_t pulse_counter_debounce_low; // FB8
uint16_t pulse_counter_debounce_high; // FBA uint16_t pulse_counter_debounce_high; // FBA
uint32_t keeloq_master_msb; // FBC uint32_t keeloq_master_msb; // FBC

View File

@ -172,11 +172,11 @@ void CpuLoadLoop(void)
CPU_loops ++; CPU_loops ++;
if ((CPU_last_millis + (CPU_load_check *1000)) <= CPU_last_loop_time) { if ((CPU_last_millis + (CPU_load_check *1000)) <= CPU_last_loop_time) {
#if defined(F_CPU) && (F_CPU == 160000000L) #if defined(F_CPU) && (F_CPU == 160000000L)
int CPU_load = 100 - ( (CPU_loops*(1 + 30*sleep)) / (CPU_load_check *800) ); int CPU_load = 100 - ( (CPU_loops*(1 + 30*ssleep)) / (CPU_load_check *800) );
CPU_loops = CPU_loops / CPU_load_check; CPU_loops = CPU_loops / CPU_load_check;
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "FreeRam %d, CPU %d%%(160MHz), Loops/sec %d"), ESP.getFreeHeap(), CPU_load, CPU_loops); AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "FreeRam %d, CPU %d%%(160MHz), Loops/sec %d"), ESP.getFreeHeap(), CPU_load, CPU_loops);
#else #else
int CPU_load = 100 - ( (CPU_loops*(1 + 30*sleep)) / (CPU_load_check *400) ); int CPU_load = 100 - ( (CPU_loops*(1 + 30*ssleep)) / (CPU_load_check *400) );
CPU_loops = CPU_loops / CPU_load_check; CPU_loops = CPU_loops / CPU_load_check;
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "FreeRam %d, CPU %d%%(80MHz), Loops/sec %d"), ESP.getFreeHeap(), CPU_load, CPU_loops); AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "FreeRam %d, CPU %d%%(80MHz), Loops/sec %d"), ESP.getFreeHeap(), CPU_load, CPU_loops);
#endif #endif
@ -188,6 +188,7 @@ void CpuLoadLoop(void)
/*******************************************************************************************/ /*******************************************************************************************/
#ifdef ESP8266
#if defined(ARDUINO_ESP8266_RELEASE_2_3_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_1) #if defined(ARDUINO_ESP8266_RELEASE_2_3_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_1)
// All version before core 2.4.2 // All version before core 2.4.2
// https://github.com/esp8266/Arduino/issues/2557 // https://github.com/esp8266/Arduino/issues/2557
@ -224,10 +225,20 @@ void DebugFreeMem(void)
#endif // ARDUINO_ESP8266_RELEASE_2_x_x #endif // ARDUINO_ESP8266_RELEASE_2_x_x
#else // ESP32
void DebugFreeMem(void)
{
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "FreeRam %d"), ESP.getFreeHeap());
}
#endif // ESP8266 - ESP32
/*******************************************************************************************/ /*******************************************************************************************/
void DebugRtcDump(char* parms) void DebugRtcDump(char* parms)
{ {
#ifdef ESP8266
#define CFG_COLS 16 #define CFG_COLS 16
uint16_t idx; uint16_t idx;
@ -283,6 +294,7 @@ void DebugRtcDump(char* parms)
snprintf_P(log_data, sizeof(log_data), PSTR("%s|"), log_data); snprintf_P(log_data, sizeof(log_data), PSTR("%s|"), log_data);
AddLog(LOG_LEVEL_INFO); AddLog(LOG_LEVEL_INFO);
} }
#endif // ESP8266
} }
/*******************************************************************************************/ /*******************************************************************************************/
@ -385,6 +397,7 @@ void DebugCfgPoke(char* parms)
void SetFlashMode(uint8_t mode) void SetFlashMode(uint8_t mode)
{ {
#ifdef ESP8266
uint8_t *_buffer; uint8_t *_buffer;
uint32_t address; uint32_t address;
@ -400,6 +413,7 @@ void SetFlashMode(uint8_t mode)
} }
} }
delete[] _buffer; delete[] _buffer;
#endif // ESP8266
} }
/*********************************************************************************************\ /*********************************************************************************************\
@ -503,6 +517,7 @@ uint32_t DebugSwap32(uint32_t x) {
void CmndFlashDump(void) void CmndFlashDump(void)
{ {
#ifdef ESP8266
// FlashDump // FlashDump
// FlashDump 0xFF000 // FlashDump 0xFF000
// FlashDump 0xFC000 10 // FlashDump 0xFC000 10
@ -533,6 +548,7 @@ void CmndFlashDump(void)
DebugSwap32(values[4]), DebugSwap32(values[5]), DebugSwap32(values[6]), DebugSwap32(values[7])); DebugSwap32(values[4]), DebugSwap32(values[5]), DebugSwap32(values[6]), DebugSwap32(values[7]));
} }
ResponseCmndDone(); ResponseCmndDone();
#endif // ESP8266
} }
#ifdef USE_I2C #ifdef USE_I2C
@ -600,10 +616,12 @@ void CmndI2cRead(void)
void CmndI2cStretch(void) void CmndI2cStretch(void)
{ {
#ifdef ESP8266
if (i2c_flg && (XdrvMailbox.payload > 0)) { if (i2c_flg && (XdrvMailbox.payload > 0)) {
Wire.setClockStretchLimit(XdrvMailbox.payload); Wire.setClockStretchLimit(XdrvMailbox.payload);
} }
ResponseCmndDone(); ResponseCmndDone();
#endif // ESP8266
} }
void CmndI2cClock(void) void CmndI2cClock(void)