From 5f2a147c3eaf1ae09ad49107a68325835cdb8207 Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Fri, 3 Aug 2018 23:07:53 +0300 Subject: [PATCH 1/3] Turn off warnings only for external code --- code/extra_scripts.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/code/extra_scripts.py b/code/extra_scripts.py index 75fd5f9a42..c4946f2567 100644 --- a/code/extra_scripts.py +++ b/code/extra_scripts.py @@ -10,7 +10,7 @@ import distutils.spawn -Import("env") +Import("env", "projenv") # ------------------------------------------------------------------------------ # Utils @@ -86,6 +86,9 @@ def check_size(source, target, env): # Hooks # ------------------------------------------------------------------------------ +# Always show warnings for project code +projenv.ProcessUnFlags("-w") + remove_float_support() env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", check_size) From fab9c0f7414e07777f836af3b18999af3db17f24 Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Mon, 6 Aug 2018 09:31:08 +0300 Subject: [PATCH 2/3] Force to implement BaseSensor methods that return values --- code/espurna/sensors/BaseSensor.h | 10 +++++----- code/espurna/sensors/EmonSensor.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/code/espurna/sensors/BaseSensor.h b/code/espurna/sensors/BaseSensor.h index 9f3854f61b..e95a644a88 100644 --- a/code/espurna/sensors/BaseSensor.h +++ b/code/espurna/sensors/BaseSensor.h @@ -46,19 +46,19 @@ class BaseSensor { virtual void post() {} // Descriptive name of the sensor - virtual String description() {} + virtual String description() = 0; // Address of the sensor (it could be the GPIO or I2C address) - virtual String address(unsigned char index) {} + virtual String address(unsigned char index) = 0; // Descriptive name of the slot # index - virtual String slot(unsigned char index) {}; + virtual String slot(unsigned char index) = 0; // Type for slot # index - virtual unsigned char type(unsigned char index) {} + virtual unsigned char type(unsigned char index) = 0; // Current value for slot # index - virtual double value(unsigned char index) {} + virtual double value(unsigned char index) = 0; // Retrieve current instance configuration virtual void getConfig(JsonObject& root) {}; diff --git a/code/espurna/sensors/EmonSensor.h b/code/espurna/sensors/EmonSensor.h index 527a4bdaf6..13647f0de5 100644 --- a/code/espurna/sensors/EmonSensor.h +++ b/code/espurna/sensors/EmonSensor.h @@ -146,7 +146,7 @@ class EmonSensor : public I2CSensor { #endif } - virtual unsigned int readADC(unsigned char channel) {} + virtual unsigned int readADC(unsigned char channel) = 0; void calculateFactors(unsigned char channel) { From 8a0b3bca425f38266a40506e7c5a6559175fc7c8 Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Mon, 6 Aug 2018 09:57:42 +0300 Subject: [PATCH 3/3] Fix compiler warnings Add button definitions to the travis02 and travis03 IR_BUTTON should be uint32_t to properly work with new macro eepromRotate return value is not used --- code/espurna/config/general.h | 2 +- code/espurna/config/hardware.h | 10 ++++++++++ code/espurna/eeprom.ino | 2 +- code/espurna/i2c.ino | 4 ++-- code/espurna/ir.ino | 2 +- code/espurna/relay.ino | 2 +- code/espurna/sensor.ino | 12 +++++------- code/espurna/sensors/DHTSensor.h | 2 +- code/espurna/sensors/EmonSensor.h | 4 ++-- code/espurna/ssdp.ino | 2 +- 10 files changed, 25 insertions(+), 17 deletions(-) diff --git a/code/espurna/config/general.h b/code/espurna/config/general.h index 8bd98b620c..7c1725d9c0 100644 --- a/code/espurna/config/general.h +++ b/code/espurna/config/general.h @@ -1080,7 +1080,7 @@ #define IR_BUTTON_COUNT 24 - const unsigned long IR_BUTTON[IR_BUTTON_COUNT][3] PROGMEM = { + const uint32_t IR_BUTTON[IR_BUTTON_COUNT][3] PROGMEM = { { 0xFF906F, IR_BUTTON_MODE_BRIGHTER, 1 }, { 0xFFB847, IR_BUTTON_MODE_BRIGHTER, 0 }, diff --git a/code/espurna/config/hardware.h b/code/espurna/config/hardware.h index f512556666..6ff0972b90 100644 --- a/code/espurna/config/hardware.h +++ b/code/espurna/config/hardware.h @@ -2555,6 +2555,11 @@ #define MANUFACTURER "TravisCI" #define DEVICE "Virtual board 02" + // Some buttons - pin 0 + #define BUTTON1_PIN 0 + #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH + #define BUTTON1_RELAY 1 + // A bit of CSE7766 - pin 1 #ifndef CSE7766_SUPPORT #define CSE7766_SUPPORT 1 @@ -2622,6 +2627,11 @@ #define MANUFACTURER "TravisCI" #define DEVICE "Virtual board 03" + // Some buttons - pin 0 + #define BUTTON1_PIN 0 + #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH + #define BUTTON1_RELAY 1 + // MY9231 Light - pins 1,2 #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT #define LIGHT_PROVIDER LIGHT_PROVIDER_MY92XX diff --git a/code/espurna/eeprom.ino b/code/espurna/eeprom.ino index 2e79fcbb4e..2da7d6315a 100644 --- a/code/espurna/eeprom.ino +++ b/code/espurna/eeprom.ino @@ -8,7 +8,7 @@ EEPROM MODULE // ----------------------------------------------------------------------------- -bool eepromRotate(bool value) { +void eepromRotate(bool value) { // Enable/disable EEPROM rotation only if we are using more sectors than the // reserved by the memory layout if (EEPROMr.size() > EEPROMr.reserved()) { diff --git a/code/espurna/i2c.ino b/code/espurna/i2c.ino index 8300929a25..b614c69139 100644 --- a/code/espurna/i2c.ino +++ b/code/espurna/i2c.ino @@ -230,7 +230,7 @@ uint16_t i2c_read_uint16(uint8_t address, uint8_t reg) { void i2c_read_buffer(uint8_t address, uint8_t * buffer, size_t len) { Wire.beginTransmission((uint8_t) address); Wire.requestFrom(address, (uint8_t) len); - for (int i=0; iexpectedPower(0, value); setSetting("pwrRatioC", sensor->getCurrentRatio(0)); } @@ -807,17 +807,17 @@ void _sensorConfigure() { double value; CSE7766Sensor * sensor = (CSE7766Sensor *) _sensors[i]; - if (value = getSetting("pwrExpectedC", 0).toFloat()) { + if ((value = getSetting("pwrExpectedC", 0).toFloat())) { sensor->expectedCurrent(value); setSetting("pwrRatioC", sensor->getCurrentRatio()); } - if (value = getSetting("pwrExpectedV", 0).toInt()) { + if ((value = getSetting("pwrExpectedV", 0).toInt())) { sensor->expectedVoltage(value); setSetting("pwrRatioV", sensor->getVoltageRatio()); } - if (value = getSetting("pwrExpectedP", 0).toInt()) { + if ((value = getSetting("pwrExpectedP", 0).toInt())) { sensor->expectedPower(value); setSetting("pwrRatioP", sensor->getPowerRatio()); } @@ -1034,12 +1034,10 @@ void sensorLoop() { current = _magnitudeProcess(magnitude.type, current); _magnitudes[i].current = current; - unsigned char decimals = _magnitudeDecimals(magnitude.type); - // Debug #if SENSOR_DEBUG { - dtostrf(current, 1-sizeof(buffer), decimals, buffer); + dtostrf(current, 1-sizeof(buffer), _magnitudeDecimals(magnitude.type), buffer); DEBUG_MSG_P(PSTR("[SENSOR] %s - %s: %s%s\n"), magnitude.sensor->slot(magnitude.local).c_str(), magnitudeTopic(magnitude.type).c_str(), diff --git a/code/espurna/sensors/DHTSensor.h b/code/espurna/sensors/DHTSensor.h index 2651eadbfd..2455925243 100644 --- a/code/espurna/sensors/DHTSensor.h +++ b/code/espurna/sensors/DHTSensor.h @@ -221,7 +221,7 @@ class DHTSensor : public BaseSensor { } - unsigned long _signal(int usTimeOut, bool state) { + unsigned long _signal(unsigned long usTimeOut, bool state) { unsigned long uSec = 1; while (digitalRead(_gpio) == state) { if (++uSec > usTimeOut) return 0; diff --git a/code/espurna/sensors/EmonSensor.h b/code/espurna/sensors/EmonSensor.h index 13647f0de5..4bbfd2766a 100644 --- a/code/espurna/sensors/EmonSensor.h +++ b/code/espurna/sensors/EmonSensor.h @@ -154,8 +154,8 @@ class EmonSensor : public I2CSensor { unsigned int s = 1; unsigned int i = 1; - unsigned int m = s * i; - unsigned int multiplier; + unsigned int m = 1; + unsigned int multiplier = 1; while (m * _current_factor[channel] < 1) { multiplier = m; i = (i == 1) ? 2 : (i == 2) ? 5 : 1; diff --git a/code/espurna/ssdp.ino b/code/espurna/ssdp.ino index 6ecf0f58bc..56b4dbb28e 100644 --- a/code/espurna/ssdp.ino +++ b/code/espurna/ssdp.ino @@ -46,7 +46,7 @@ void ssdpSetup() { char response[strlen_P(_ssdp_template) + 100]; snprintf_P(response, sizeof(response), _ssdp_template, - WiFi.localIP().toString().c_str(), // ip + ip.toString().c_str(), // ip webPort(), // port SSDP_DEVICE_TYPE, // device type getSetting("hostname").c_str(), // friendlyName