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;
typedef struct PACKED {
typedef struct {
uint8_t fnid = 0;
uint8_t dpid = 0;
} 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 uint8_t MAX_TUYA_FUNCTIONS = 16;
struct PACKED SYSCFG {
struct SYSCFG {
uint16_t cfg_holder; // 000 v6 header
uint16_t cfg_size; // 002
unsigned long save_flag; // 004
@ -369,7 +369,13 @@ struct PACKED SYSCFG {
uint8_t module; // 474
uint8_t ws_color[4][3]; // 475
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
uint16_t light_pixels; // 496
uint8_t light_color[5]; // 498
@ -397,7 +403,14 @@ struct PACKED SYSCFG {
uint32_t ip_address[4]; // 544
unsigned long energy_kWhtotal; // 554
#ifdef ESP8266
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
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
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 web_color[18][3]; // 73E
uint16_t display_width; // 774
@ -507,8 +525,9 @@ struct PACKED SYSCFG {
uint8_t zb_free_byte; // F33
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_high; // FBA
uint32_t keeloq_master_msb; // FBC

View File

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