Change some more defines to const

Change some more defines to const
This commit is contained in:
Theo Arends 2019-03-31 11:59:04 +02:00
parent 7faa6f9808
commit f7c30250c1
13 changed files with 51 additions and 58 deletions

View File

@ -20,7 +20,7 @@
#ifndef _SETTINGS_H_ #ifndef _SETTINGS_H_
#define _SETTINGS_H_ #define _SETTINGS_H_
#define PARAM8_SIZE 18 // Number of param bytes (SetOption) const uint8_t PARAM8_SIZE = 18; // Number of param bytes (SetOption)
typedef union { // Restricted by MISRA-C Rule 18.4 but so useful... typedef union { // Restricted by MISRA-C Rule 18.4 but so useful...
uint32_t data; // Allow bit manipulation using SetOption uint32_t data; // Allow bit manipulation using SetOption
@ -397,7 +397,7 @@ struct XDRVMAILBOX {
char *data; char *data;
} XdrvMailbox; } XdrvMailbox;
#define MAX_RULES_FLAG 7 // Number of bits used in RulesBitfield (tricky I know...) const uint8_t MAX_RULES_FLAG = 7; // Number of bits used in RulesBitfield (tricky I know...)
typedef union { // Restricted by MISRA-C Rule 18.4 but so useful... typedef union { // Restricted by MISRA-C Rule 18.4 but so useful...
uint16_t data; // Allow bit manipulation uint16_t data; // Allow bit manipulation
struct { struct {

View File

@ -69,7 +69,7 @@
* RTC memory * RTC memory
\*********************************************************************************************/ \*********************************************************************************************/
#define RTC_MEM_VALID 0xA55A const uint16_t RTC_MEM_VALID = 0xA55A;
uint32_t rtc_settings_crc = 0; uint32_t rtc_settings_crc = 0;
@ -168,12 +168,12 @@ extern "C" {
extern "C" uint32_t _SPIFFS_end; extern "C" uint32_t _SPIFFS_end;
// From libraries/EEPROM/EEPROM.cpp EEPROMClass // From libraries/EEPROM/EEPROM.cpp EEPROMClass
#define SPIFFS_END ((uint32_t)&_SPIFFS_end - 0x40200000) / SPI_FLASH_SEC_SIZE const uint32_t SPIFFS_END = ((uint32_t)&_SPIFFS_end - 0x40200000) / SPI_FLASH_SEC_SIZE;
// Version 4.2 config = eeprom area // Version 4.2 config = eeprom area
#define SETTINGS_LOCATION SPIFFS_END // No need for SPIFFS as it uses EEPROM area const uint32_t SETTINGS_LOCATION = SPIFFS_END; // No need for SPIFFS as it uses EEPROM area
// Version 5.2 allow for more flash space // Version 5.2 allow for more flash space
#define CFG_ROTATES 8 // Number of flash sectors used (handles uploads) const uint8_t CFG_ROTATES = 8; // Number of flash sectors used (handles uploads)
/*********************************************************************************************\ /*********************************************************************************************\
* EEPROM support based on EEPROM library and tuned for Tasmota * EEPROM support based on EEPROM library and tuned for Tasmota

View File

@ -20,11 +20,6 @@
#ifndef _SONOFF_VERSION_H_ #ifndef _SONOFF_VERSION_H_
#define _SONOFF_VERSION_H_ #define _SONOFF_VERSION_H_
#define VERSION 0x06050003 const uint32_t VERSION = 0x06050003;
#define D_PROGRAMNAME "Sonoff-Tasmota"
#define D_AUTHOR "Theo Arends"
//#define D_WEBLINK "https://github.com/arendst/Sonoff-Tasmota"
#define D_WEBLINK "https://bit.ly/tasmota"
#endif // _SONOFF_VERSION_H_ #endif // _SONOFF_VERSION_H_

View File

@ -28,7 +28,7 @@ uint32_t syslog_host_hash = 0; // Syslog host name hash
Ticker tickerOSWatch; Ticker tickerOSWatch;
#define OSWATCH_RESET_TIME 120 const uint32_t OSWATCH_RESET_TIME = 120;
static unsigned long oswatch_last_loop_time; static unsigned long oswatch_last_loop_time;
uint8_t oswatch_blocked_loop = 0; uint8_t oswatch_blocked_loop = 0;
@ -996,7 +996,7 @@ void SetNextTimeInterval(unsigned long& timer, const unsigned long step)
\*********************************************************************************************/ \*********************************************************************************************/
#ifdef USE_I2C #ifdef USE_I2C
#define I2C_RETRY_COUNTER 3 const uint8_t I2C_RETRY_COUNTER = 3;
uint32_t i2c_buffer = 0; uint32_t i2c_buffer = 0;

View File

@ -25,7 +25,7 @@
* Inspired by (https://github.com/OLIMEX/olimex-iot-firmware-esp8266/blob/master/olimex/user/user_switch2.c) * Inspired by (https://github.com/OLIMEX/olimex-iot-firmware-esp8266/blob/master/olimex/user/user_switch2.c)
\*********************************************************************************************/ \*********************************************************************************************/
#define SWITCH_PROBE_INTERVAL 10 // Time in milliseconds between switch input probe const uint8_t SWITCH_PROBE_INTERVAL = 10; // Time in milliseconds between switch input probe
#include <Ticker.h> #include <Ticker.h>

View File

@ -28,9 +28,9 @@
#define WIFI_RESCAN_MINUTES 44 // Number of minutes between wifi network rescan #define WIFI_RESCAN_MINUTES 44 // Number of minutes between wifi network rescan
#endif #endif
#define WIFI_CONFIG_SEC 180 // seconds before restart const uint8_t WIFI_CONFIG_SEC = 180; // seconds before restart
#define WIFI_CHECK_SEC 20 // seconds const uint8_t WIFI_CHECK_SEC = 20; // seconds
#define WIFI_RETRY_OFFSET_SEC 20 // seconds const uint8_t WIFI_RETRY_OFFSET_SEC = 20; // seconds
/* /*
// This worked for 2_5_0_BETA2 but fails since then. Waiting for a solution from core team (#4952) // This worked for 2_5_0_BETA2 but fails since then. Waiting for a solution from core team (#4952)

View File

@ -27,13 +27,13 @@
#define XDRV_01 1 #define XDRV_01 1
#define CHUNKED_BUFFER_SIZE 400 // Chunk buffer size
#ifndef WIFI_SOFT_AP_CHANNEL #ifndef WIFI_SOFT_AP_CHANNEL
#define WIFI_SOFT_AP_CHANNEL 1 // Soft Access Point Channel number between 1 and 11 as used by SmartConfig web GUI #define WIFI_SOFT_AP_CHANNEL 1 // Soft Access Point Channel number between 1 and 11 as used by SmartConfig web GUI
#endif #endif
#define HTTP_REFRESH_TIME 2345 // milliseconds const uint16_t CHUNKED_BUFFER_SIZE = 400; // Chunk buffer size (should be smaller than half mqtt_date size)
const uint16_t HTTP_REFRESH_TIME = 2345; // milliseconds
#define HTTP_RESTART_RECONNECT_TIME 9000 // milliseconds #define HTTP_RESTART_RECONNECT_TIME 9000 // milliseconds
#define HTTP_OTA_RESTART_RECONNECT_TIME 20000 // milliseconds #define HTTP_OTA_RESTART_RECONNECT_TIME 20000 // milliseconds
@ -376,7 +376,7 @@ const char HTTP_COUNTER[] PROGMEM =
"<br/><div id='t' name='t' style='text-align:center;'></div>"; "<br/><div id='t' name='t' style='text-align:center;'></div>";
const char HTTP_END[] PROGMEM = const char HTTP_END[] PROGMEM =
"<div style='text-align:right;font-size:11px;'><hr/><a href='" D_WEBLINK "' target='_blank' style='color:#aaa;'>" D_PROGRAMNAME " %s " D_BY " " D_AUTHOR "</a></div>" "<div style='text-align:right;font-size:11px;'><hr/><a href='https://bit.ly/tasmota' target='_blank' style='color:#aaa;'>Sonoff-Tasmota %s " D_BY " Theo Arends</a></div>"
"</div>" "</div>"
"</body>" "</body>"
"</html>"; "</html>";
@ -413,7 +413,7 @@ const char kUploadErrors[] PROGMEM =
#endif #endif
; ;
#define DNS_PORT 53 const uint16_t DNS_PORT = 53;
enum HttpOptions {HTTP_OFF, HTTP_USER, HTTP_ADMIN, HTTP_MANAGER, HTTP_MANAGER_RESET_ONLY}; enum HttpOptions {HTTP_OFF, HTTP_USER, HTTP_ADMIN, HTTP_MANAGER, HTTP_MANAGER_RESET_ONLY};
DNSServer *DnsServer; DNSServer *DnsServer;

View File

@ -420,7 +420,6 @@ void MqttReconnect(void)
#endif // USE_EMULATION #endif // USE_EMULATION
AddLog_P(LOG_LEVEL_INFO, S_LOG_MQTT, PSTR(D_ATTEMPTING_CONNECTION)); AddLog_P(LOG_LEVEL_INFO, S_LOG_MQTT, PSTR(D_ATTEMPTING_CONNECTION));
// AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_MQTT "(%d) " D_ATTEMPTING_CONNECTION), ESP.getFreeHeap()/1024);
mqtt_connected = false; mqtt_connected = false;
mqtt_retry_counter = Settings.mqtt_retry; mqtt_retry_counter = Settings.mqtt_retry;

View File

@ -56,7 +56,7 @@
#define XDRV_04 4 #define XDRV_04 4
#define WS2812_SCHEMES 7 // Number of additional WS2812 schemes supported by xdrv_ws2812.ino const uint8_t WS2812_SCHEMES = 7; // Number of additional WS2812 schemes supported by xdrv_ws2812.ino
enum LightCommands { enum LightCommands {
CMND_COLOR, CMND_COLORTEMPERATURE, CMND_DIMMER, CMND_LED, CMND_LEDTABLE, CMND_FADE, CMND_COLOR, CMND_COLORTEMPERATURE, CMND_DIMMER, CMND_LED, CMND_LEDTABLE, CMND_FADE,
@ -70,23 +70,23 @@ const char kLightCommands[] PROGMEM =
struct LRgbColor { struct LRgbColor {
uint8_t R, G, B; uint8_t R, G, B;
}; };
#define MAX_FIXED_COLOR 12 const uint8_t MAX_FIXED_COLOR = 12;
const LRgbColor kFixedColor[MAX_FIXED_COLOR] PROGMEM = const LRgbColor kFixedColor[MAX_FIXED_COLOR] PROGMEM =
{ 255,0,0, 0,255,0, 0,0,255, 228,32,0, 0,228,32, 0,32,228, 188,64,0, 0,160,96, 160,32,240, 255,255,0, 255,0,170, 255,255,255 }; { 255,0,0, 0,255,0, 0,0,255, 228,32,0, 0,228,32, 0,32,228, 188,64,0, 0,160,96, 160,32,240, 255,255,0, 255,0,170, 255,255,255 };
struct LWColor { struct LWColor {
uint8_t W; uint8_t W;
}; };
#define MAX_FIXED_WHITE 4 const uint8_t MAX_FIXED_WHITE = 4;
const LWColor kFixedWhite[MAX_FIXED_WHITE] PROGMEM = { 0, 255, 128, 32 }; const LWColor kFixedWhite[MAX_FIXED_WHITE] PROGMEM = { 0, 255, 128, 32 };
struct LCwColor { struct LCwColor {
uint8_t C, W; uint8_t C, W;
}; };
#define MAX_FIXED_COLD_WARM 4 const uint8_t MAX_FIXED_COLD_WARM = 4;
const LCwColor kFixedColdWarm[MAX_FIXED_COLD_WARM] PROGMEM = { 0,0, 255,0, 0,255, 128,128 }; const LCwColor kFixedColdWarm[MAX_FIXED_COLD_WARM] PROGMEM = { 0,0, 255,0, 0,255, 128,128 };
uint8_t ledTable[] = { const uint8_t ledTable[] = {
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4,
@ -132,11 +132,11 @@ unsigned long strip_timer_counter = 0; // Bars and Gradient
* Arilux LC11 Rf support stripped from RCSwitch library * Arilux LC11 Rf support stripped from RCSwitch library
\*********************************************************************************************/ \*********************************************************************************************/
#define ARILUX_RF_TIME_AVOID_DUPLICATE 1000 // Milliseconds const uint32_t ARILUX_RF_TIME_AVOID_DUPLICATE = 1000; // Milliseconds
#define ARILUX_RF_MAX_CHANGES 51 // Pulses (sync + 2 x 24 bits) const uint8_t ARILUX_RF_MAX_CHANGES = 51; // Pulses (sync + 2 x 24 bits)
#define ARILUX_RF_SEPARATION_LIMIT 4300 // Microseconds const uint32_t ARILUX_RF_SEPARATION_LIMIT = 4300; // Microseconds
#define ARILUX_RF_RECEIVE_TOLERANCE 60 // Percentage const uint32_t ARILUX_RF_RECEIVE_TOLERANCE = 60; // Percentage
unsigned int arilux_rf_timings[ARILUX_RF_MAX_CHANGES]; unsigned int arilux_rf_timings[ARILUX_RF_MAX_CHANGES];

View File

@ -42,17 +42,17 @@ enum IrHvacVendors { VNDR_TOSHIBA, VNDR_MITSUBISHI, VNDR_LG, VNDR_FUJITSU };
const char kIrHvacVendors[] PROGMEM = "Toshiba|Mitsubishi|LG|Fujitsu" ; const char kIrHvacVendors[] PROGMEM = "Toshiba|Mitsubishi|LG|Fujitsu" ;
// HVAC TOSHIBA_ // HVAC TOSHIBA_
#define HVAC_TOSHIBA_HDR_MARK 4400 const uint16_t HVAC_TOSHIBA_HDR_MARK = 4400;
#define HVAC_TOSHIBA_HDR_SPACE 4300 const uint16_t HVAC_TOSHIBA_HDR_SPACE = 4300;
#define HVAC_TOSHIBA_BIT_MARK 543 const uint16_t HVAC_TOSHIBA_BIT_MARK = 543;
#define HVAC_TOSHIBA_ONE_SPACE 1623 const uint16_t HVAC_TOSHIBA_ONE_SPACE = 1623;
#define HVAC_MISTUBISHI_ZERO_SPACE 472 const uint16_t HVAC_MISTUBISHI_ZERO_SPACE = 472;
#define HVAC_TOSHIBA_RPT_MARK 440 const uint16_t HVAC_TOSHIBA_RPT_MARK = 440;
#define HVAC_TOSHIBA_RPT_SPACE 7048 // Above original iremote limit const uint16_t HVAC_TOSHIBA_RPT_SPACE = 7048; // Above original iremote limit
#define HVAC_TOSHIBA_DATALEN 9 const uint8_t HVAC_TOSHIBA_DATALEN = 9;
// HVAC LG // HVAC LG
#define HVAC_LG_DATALEN 7 const uint8_t HVAC_LG_DATALEN = 7;
IRMitsubishiAC *mitsubir = nullptr; IRMitsubishiAC *mitsubir = nullptr;
@ -84,9 +84,8 @@ void IrSendInit(void)
* IR Receive * IR Receive
\*********************************************************************************************/ \*********************************************************************************************/
#define IR_RCV_SAVE_BUFFER 0 // 0 = do not use buffer, 1 = use buffer for decoding const bool IR_RCV_SAVE_BUFFER = false; // false = do not use buffer, true = use buffer for decoding
const uint32_t IR_TIME_AVOID_DUPLICATE = 500; // Milliseconds
#define IR_TIME_AVOID_DUPLICATE 500 // Milliseconds
#include <IRrecv.h> #include <IRrecv.h>

View File

@ -23,7 +23,7 @@
#define XDRV_06 6 #define XDRV_06 6
#define SFB_TIME_AVOID_DUPLICATE 2000 // Milliseconds const uint32_t SFB_TIME_AVOID_DUPLICATE = 2000; // Milliseconds
enum SonoffBridgeCommands { enum SonoffBridgeCommands {
CMND_RFSYNC, CMND_RFLOW, CMND_RFHIGH, CMND_RFHOST, CMND_RFCODE, CMND_RFKEY, CMND_RFRAW }; CMND_RFSYNC, CMND_RFLOW, CMND_RFHIGH, CMND_RFHOST, CMND_RFCODE, CMND_RFKEY, CMND_RFRAW };
@ -51,8 +51,8 @@ unsigned long sonoff_bridge_last_learn_time = 0;
#include "ihx.h" #include "ihx.h"
#include "c2.h" #include "c2.h"
#define RF_RECORD_NO_START_FOUND -1 const ssize_t RF_RECORD_NO_START_FOUND = -1;
#define RF_RECORD_NO_END_FOUND -2 const ssize_t RF_RECORD_NO_END_FOUND = -2;
ssize_t rf_find_hex_record_start(uint8_t *buf, size_t size) ssize_t rf_find_hex_record_start(uint8_t *buf, size_t size)
{ {

View File

@ -24,7 +24,7 @@
#define XDRV_08 8 #define XDRV_08 8
#define SERIAL_BRIDGE_BUFFER_SIZE 130 const uint8_t SERIAL_BRIDGE_BUFFER_SIZE = 130;
#include <TasmotaSerial.h> #include <TasmotaSerial.h>

View File

@ -22,11 +22,11 @@
#define XDRV_13 13 #define XDRV_13 13
#define DISPLAY_MAX_DRIVERS 16 // Max number of display drivers/models supported by xdsp_interface.ino const uint8_t DISPLAY_MAX_DRIVERS = 16; // Max number of display drivers/models supported by xdsp_interface.ino
#define DISPLAY_MAX_COLS 44 // Max number of columns allowed with command DisplayCols const uint8_t DISPLAY_MAX_COLS = 44; // Max number of columns allowed with command DisplayCols
#define DISPLAY_MAX_ROWS 32 // Max number of lines allowed with command DisplayRows const uint8_t DISPLAY_MAX_ROWS = 32; // Max number of lines allowed with command DisplayRows
#define DISPLAY_LOG_ROWS 32 // Number of lines in display log buffer const uint8_t DISPLAY_LOG_ROWS = 32; // Number of lines in display log buffer
#define D_CMND_DISPLAY "Display" #define D_CMND_DISPLAY "Display"
#define D_CMND_DISP_ADDRESS "Address" #define D_CMND_DISP_ADDRESS "Address"