From 63b6f46752e4df9848d3d6eda7c36fd3831bb5d5 Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Wed, 30 Sep 2020 10:07:01 +0300 Subject: [PATCH] Fix superfluous whitespaces and line endings resolve #2310 --- code/espurna/DebounceEvent.cpp | 2 +- code/espurna/broker.h | 2 +- code/espurna/button.cpp | 7 +- code/espurna/button.h | 2 +- code/espurna/config/custom.h.example | 192 +++++++++++------------ code/espurna/config/hardware.h | 4 +- code/espurna/curtain_kingart.cpp | 42 +++-- code/espurna/libs/AsyncClientHelpers.h | 2 - code/espurna/libs/DebounceEvent.h | 2 +- code/espurna/libs/Encoder.h | 8 +- code/espurna/mqtt.cpp | 2 +- code/espurna/ntp.cpp | 4 +- code/espurna/ntp_timelib.h | 6 +- code/espurna/sensors/AnalogSensor.h | 2 +- code/espurna/sensors/BMP180Sensor.h | 10 +- code/espurna/sensors/BaseEmonSensor.h | 2 +- code/espurna/sensors/DallasSensor.h | 34 ++-- code/espurna/sensors/PZEM004TV30Sensor.h | 10 +- code/espurna/sensors/SI1145Sensor.h | 8 +- code/espurna/settings.cpp | 2 +- code/espurna/settings_embedis.h | 1 - code/espurna/terminal.cpp | 2 +- code/espurna/thingspeak.cpp | 2 +- code/espurna/tuya_protocol.h | 2 +- code/espurna/tuya_transport.h | 4 +- code/espurna/utils.cpp | 4 +- code/test/unit/terminal/terminal.cpp | 2 +- 27 files changed, 176 insertions(+), 184 deletions(-) diff --git a/code/espurna/DebounceEvent.cpp b/code/espurna/DebounceEvent.cpp index 6bcc0a0c41..ae7bc57150 100644 --- a/code/espurna/DebounceEvent.cpp +++ b/code/espurna/DebounceEvent.cpp @@ -1,5 +1,5 @@ /* - + Original code: Debounce buttons and trigger events diff --git a/code/espurna/broker.h b/code/espurna/broker.h index 8fd9361c8c..9f9c61009c 100644 --- a/code/espurna/broker.h +++ b/code/espurna/broker.h @@ -64,7 +64,7 @@ struct TBroker { // TODO: since 1.14.0 we intoduced static syntax for Brokers, ::Register & ::Publish. // Preserve it (up to a point) when creating module-level objects. -// Provide a helper namespace with Register & Publish, instance and +// Provide a helper namespace with Register & Publish, instance and // To help out VS Code with argument discovery, put TArgs as the first template parameter. #define BrokerDeclare(Name, Signature) \ diff --git a/code/espurna/button.cpp b/code/espurna/button.cpp index c99308fac8..0db0b36e51 100644 --- a/code/espurna/button.cpp +++ b/code/espurna/button.cpp @@ -129,11 +129,11 @@ constexpr const debounce_event::types::Config _buttonDecodeConfigBitmask(const u ((bitmask & ButtonMask::Pushbutton) ? debounce_event::types::Mode::Pushbutton : debounce_event::types::Mode::Switch), - ((bitmask & ButtonMask::DefaultHigh) + ((bitmask & ButtonMask::DefaultHigh) ? debounce_event::types::PinValue::High : debounce_event::types::PinValue::Low), - ((bitmask & ButtonMask::SetPullup) ? debounce_event::types::PinMode::InputPullup - : (bitmask & ButtonMask::SetPulldown) ? debounce_event::types::PinMode::InputPulldown + ((bitmask & ButtonMask::SetPullup) ? debounce_event::types::PinMode::InputPullup + : (bitmask & ButtonMask::SetPulldown) ? debounce_event::types::PinMode::InputPulldown : debounce_event::types::PinMode::Input) }; } @@ -841,7 +841,6 @@ void buttonSetup() { actions, delays ); - } } #endif // BUTTON_PROVIDER_ITEAD_SONOFF_DUAL_SUPPORT || BUTTON_PROVIDER_FOXEL_LIGHTFOX_DUAL diff --git a/code/espurna/button.h b/code/espurna/button.h index c673468e05..951c8cc46e 100644 --- a/code/espurna/button.h +++ b/code/espurna/button.h @@ -54,7 +54,7 @@ struct button_event_delays_t { struct button_t { button_t(unsigned char relayID, const button_actions_t& actions, const button_event_delays_t& delays); - button_t(std::shared_ptr pin, const debounce_event::types::Config& config, + button_t(std::shared_ptr pin, const debounce_event::types::Config& config, unsigned char relayID, const button_actions_t& actions, const button_event_delays_t& delays); bool state(); diff --git a/code/espurna/config/custom.h.example b/code/espurna/config/custom.h.example index 30360d25bd..bf42eeb813 100644 --- a/code/espurna/config/custom.h.example +++ b/code/espurna/config/custom.h.example @@ -1,96 +1,96 @@ -// ------------------------------------------------------------------------------ -// Example file for custom.h -// Either copy and paste this file then rename removing the .example or create your -// own file: 'custom.h' -// This file allows users to create their own configurations. -// See 'code/espurna/config/general.h' for default settings. -// -// See: https://github.com/xoseperez/espurna/wiki/Software-features#enabling-features -// and 'code/platformio_override.ini.example' for more details. -// ------------------------------------------------------------------------------ - - -// Example of a Sonoff Basic board with some options disabled to reduce firmware size. - -#if defined(MY_SONOFF_BUILD01) // This section will be used when src_build_flags contains - // -DMY_SONOFF_BUILD01 in 'platformio_override.ini' - - #define MANUFACTURER "ITEAD" - #define DEVICE "SONOFF_BASIC_BUILD01" - - // Disable these - #define DEBUG_SERIAL_SUPPORT 0 - #define ALEXA_SUPPORT 0 - #define DOMOTICZ_SUPPORT 0 - #define HOMEASSISTANT_SUPPORT 0 - #define THINGSPEAK_SUPPORT 0 - - // Buttons - #define BUTTON1_PIN 0 - #define BUTTON1_CONFIG BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH - #define BUTTON1_RELAY 1 - - // Relays - #define RELAY1_PIN 12 - #define RELAY1_TYPE RELAY_TYPE_NORMAL - - // LEDs - #define LED1_PIN 13 - #define LED1_PIN_INVERSE 1 - - -// Example of the Sonoff Basic board above but with two buttons on different GPIOs. -// The two buttons both toggle the one RELAY but ALL button events send MQTT values. -// An MQTT based system can then carry out differnt functions depending on -// the 'DOUBLE CLICK, LONG CLICK OR LONG-LONG CLICK' trigger. A BMX280 environment -// sensor is also connected using I2C on GPIO 1 and 3. - -#elif defined(MY_SONOFF_BUILD02) // This section will be used when src_build_flags contains - // -DMY_SONOFF_BUILD02 in 'platformio_override.ini - - // Info - Custom Basic with BMX280 I2C on GPIO 1 and 3 - #define MANUFACTURER "ITEAD" - #define DEVICE "SONOFF_BASIC_BMX280" // You can use your own name here - - // Disable these - #define DEBUG_SERIAL_SUPPORT 0 - #define ALEXA_SUPPORT 0 - #define DOMOTICZ_SUPPORT 0 - #define HOMEASSISTANT_SUPPORT 0 - #define THINGSPEAK_SUPPORT 0 - - - // Buttons - #define BUTTON_MQTT_SEND_ALL_EVENTS 1 - #define BUTTON1_PIN 0 // Built in button. - #define BUTTON1_CONFIG BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH - #define BUTTON1_RELAY 1 - #define BUTTON1_PRESS BUTTON_MODE_NONE - #define BUTTON1_CLICK BUTTON_MODE_TOGGLE - #define BUTTON1_DBLCLICK BUTTON_MODE_NONE - #define BUTTON1_LNGCLICK BUTTON_MODE_OFF - #define BUTTON1_LNGLNGCLICK BUTTON_MODE_NONE - #define BUTTON2_PIN 2 // External push button connected between IO2 and GND. - #define BUTTON2_CONFIG BUTTON_PUSHBUTTON | BUTTON_SET_PULLUP | BUTTON_DEFAULT_HIGH - #define BUTTON2_RELAY 1 - #define BUTTON2_PRESS BUTTON_MODE_NONE - #define BUTTON2_CLICK BUTTON_MODE_TOGGLE - #define BUTTON2_DBLCLICK BUTTON_MODE_NONE - #define BUTTON2_LNGCLICK BUTTON_MODE_NONE - #define BUTTON2_LNGLNGCLICK BUTTON_MODE_NONE - - // Relays - #define RELAY1_PIN 12 - #define RELAY1_TYPE RELAY_TYPE_NORMAL - - // LEDs - #define LED1_PIN 13 - #define LED1_PIN_INVERSE 1 - - // Extras - #define BMX280_SUPPORT 1 - #define BMX280_ADDRESS 0x76 - #define I2C_SDA_PIN 1 //TX PIN **DISABLE DEBUG_SERIAL_SUPPORT** - #define I2C_SCL_PIN 3 //RX PIN **DISABLE DEBUG_SERIAL_SUPPORT** - -#endif +// ------------------------------------------------------------------------------ +// Example file for custom.h +// Either copy and paste this file then rename removing the .example or create your +// own file: 'custom.h' +// This file allows users to create their own configurations. +// See 'code/espurna/config/general.h' for default settings. +// +// See: https://github.com/xoseperez/espurna/wiki/Software-features#enabling-features +// and 'code/platformio_override.ini.example' for more details. +// ------------------------------------------------------------------------------ + + +// Example of a Sonoff Basic board with some options disabled to reduce firmware size. + +#if defined(MY_SONOFF_BUILD01) // This section will be used when src_build_flags contains + // -DMY_SONOFF_BUILD01 in 'platformio_override.ini' + + #define MANUFACTURER "ITEAD" + #define DEVICE "SONOFF_BASIC_BUILD01" + + // Disable these + #define DEBUG_SERIAL_SUPPORT 0 + #define ALEXA_SUPPORT 0 + #define DOMOTICZ_SUPPORT 0 + #define HOMEASSISTANT_SUPPORT 0 + #define THINGSPEAK_SUPPORT 0 + + // Buttons + #define BUTTON1_PIN 0 + #define BUTTON1_CONFIG BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH + #define BUTTON1_RELAY 1 + + // Relays + #define RELAY1_PIN 12 + #define RELAY1_TYPE RELAY_TYPE_NORMAL + + // LEDs + #define LED1_PIN 13 + #define LED1_PIN_INVERSE 1 + + +// Example of the Sonoff Basic board above but with two buttons on different GPIOs. +// The two buttons both toggle the one RELAY but ALL button events send MQTT values. +// An MQTT based system can then carry out differnt functions depending on +// the 'DOUBLE CLICK, LONG CLICK OR LONG-LONG CLICK' trigger. A BMX280 environment +// sensor is also connected using I2C on GPIO 1 and 3. + +#elif defined(MY_SONOFF_BUILD02) // This section will be used when src_build_flags contains + // -DMY_SONOFF_BUILD02 in 'platformio_override.ini + + // Info - Custom Basic with BMX280 I2C on GPIO 1 and 3 + #define MANUFACTURER "ITEAD" + #define DEVICE "SONOFF_BASIC_BMX280" // You can use your own name here + + // Disable these + #define DEBUG_SERIAL_SUPPORT 0 + #define ALEXA_SUPPORT 0 + #define DOMOTICZ_SUPPORT 0 + #define HOMEASSISTANT_SUPPORT 0 + #define THINGSPEAK_SUPPORT 0 + + + // Buttons + #define BUTTON_MQTT_SEND_ALL_EVENTS 1 + #define BUTTON1_PIN 0 // Built in button. + #define BUTTON1_CONFIG BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH + #define BUTTON1_RELAY 1 + #define BUTTON1_PRESS BUTTON_MODE_NONE + #define BUTTON1_CLICK BUTTON_MODE_TOGGLE + #define BUTTON1_DBLCLICK BUTTON_MODE_NONE + #define BUTTON1_LNGCLICK BUTTON_MODE_OFF + #define BUTTON1_LNGLNGCLICK BUTTON_MODE_NONE + #define BUTTON2_PIN 2 // External push button connected between IO2 and GND. + #define BUTTON2_CONFIG BUTTON_PUSHBUTTON | BUTTON_SET_PULLUP | BUTTON_DEFAULT_HIGH + #define BUTTON2_RELAY 1 + #define BUTTON2_PRESS BUTTON_MODE_NONE + #define BUTTON2_CLICK BUTTON_MODE_TOGGLE + #define BUTTON2_DBLCLICK BUTTON_MODE_NONE + #define BUTTON2_LNGCLICK BUTTON_MODE_NONE + #define BUTTON2_LNGLNGCLICK BUTTON_MODE_NONE + + // Relays + #define RELAY1_PIN 12 + #define RELAY1_TYPE RELAY_TYPE_NORMAL + + // LEDs + #define LED1_PIN 13 + #define LED1_PIN_INVERSE 1 + + // Extras + #define BMX280_SUPPORT 1 + #define BMX280_ADDRESS 0x76 + #define I2C_SDA_PIN 1 //TX PIN **DISABLE DEBUG_SERIAL_SUPPORT** + #define I2C_SCL_PIN 3 //RX PIN **DISABLE DEBUG_SERIAL_SUPPORT** + +#endif diff --git a/code/espurna/config/hardware.h b/code/espurna/config/hardware.h index 6d9996111d..080a98c599 100644 --- a/code/espurna/config/hardware.h +++ b/code/espurna/config/hardware.h @@ -3422,10 +3422,10 @@ #define DEBUG_SERIAL_SUPPORT 0 // ---------------------------------------------------------------------------------------- -// Power socket 16A similar to BLITZWOLF_BWSHPX but button pin differs +// Power socket 16A similar to BLITZWOLF_BWSHPX but button pin differs // IMPORTANT, This template is for hardware version SP111_A_Wifi_Ver1.1 (as printed on the PCB) // hhttps://www.amazon.de/-/en/Smallest-Consumption-Measuring-Function-Compatible/dp/B07PSMF47W -// ---------------------------------------------------------------------------------------- +// ---------------------------------------------------------------------------------------- #elif defined(GOSUND_SP111) diff --git a/code/espurna/curtain_kingart.cpp b/code/espurna/curtain_kingart.cpp index 0bedd35bb6..c9d13fb74e 100644 --- a/code/espurna/curtain_kingart.cpp +++ b/code/espurna/curtain_kingart.cpp @@ -49,7 +49,7 @@ Copyright (C) 2020 - Eric Chauvet char _KACurtainBuffer[KINGART_CURTAIN_BUFFER_SIZE]; bool _KACurtainNewData = false; -// Status vars - for curtain move detection : +// Status vars - for curtain move detection : int _curtain_position = CURTAIN_POSITION_UNKNOWN; int _curtain_last_position = CURTAIN_POSITION_UNKNOWN; int _curtain_button = CURTAIN_BUTTON_UNKNOWN; @@ -90,7 +90,7 @@ int setButtonFromSwitchText(String & text) { else return CURTAIN_BUTTON_UNKNOWN; } - + // ----------------------------------------------------------------------------- // Private // ----------------------------------------------------------------------------- @@ -98,9 +98,9 @@ int setButtonFromSwitchText(String & text) { //------------------------------------------------------------------------------ //This check that wa got latest and new stats from the AT+RESULT message bool _KAValidStatus() { - return _curtain_button != CURTAIN_BUTTON_UNKNOWN && - _curtain_last_button != CURTAIN_BUTTON_UNKNOWN && - _curtain_position != CURTAIN_POSITION_UNKNOWN && + return _curtain_button != CURTAIN_BUTTON_UNKNOWN && + _curtain_last_button != CURTAIN_BUTTON_UNKNOWN && + _curtain_position != CURTAIN_POSITION_UNKNOWN && _curtain_last_position != CURTAIN_POSITION_UNKNOWN; } @@ -166,7 +166,7 @@ void _KAStopMoving() { else if( _curtain_last_position != CURTAIN_POSITION_UNKNOWN) _curtain_position_set = _curtain_last_position; - if (!_curtain_initial_position_set) { //The curtain stopped moving for the first time, set the position back to + if (!_curtain_initial_position_set) { //The curtain stopped moving for the first time, set the position back to int init_position = getSetting("curtainBoot", 0); KINGART_DEBUG_MSG_P(PSTR("[KA] curtainBoot : %d, curtainBootPos : %d\n"), init_position, getSetting("curtainBootPos", 100)); if (init_position == CURTAIN_INIT_CLOSE) { @@ -226,7 +226,7 @@ The device will determine the direction all by itself. # Set the Cover / Shutter / Blind / Curtain run time -The factory default Open and Close run time for the switch is 50 seconds, and it must be set to +The factory default Open and Close run time for the switch is 50 seconds, and it must be set to an accurate run time for smooth working. Some motors do not have the resistance stop function, so when the Cover/Shutter/Blind/Curtain track open or close to the maximum length, but the motor keeps on running. This might cause damage on the motor and the switch, it also wastes a lot of energy. In order @@ -255,8 +255,8 @@ void _KACurtainResult() { const String buffer(_KACurtainBuffer); _curtain_button = CURTAIN_BUTTON_UNKNOWN; _curtain_position = CURTAIN_POSITION_UNKNOWN; - - + + if(buffer.indexOf("AT+RESULT") == 0) { //AT+RESULT is an acquitment of our command (MQTT or GUI) //Set the status on what we kown if( ( _curtain_last_button == CURTAIN_BUTTON_OPEN && _curtain_last_position == 0 ) || @@ -265,11 +265,11 @@ void _KACurtainResult() { _KAStopMoving(); } else { //Else it is probably moving _KASetMoving(); - /* + /* (*1) ATTENTION THERE : - Send immediatly a AT+START - we need to purge the first response. - It will return us the right direction of the switch but the position - we set instead of the real on. We take care of the switch response but + Send immediatly a AT+START - we need to purge the first response. + It will return us the right direction of the switch but the position + we set instead of the real on. We take care of the switch response but we ignore the position. */ _KACurtainSend("AT+START"); @@ -289,8 +289,7 @@ void _KACurtainResult() { switch_text = switch_text.substring(0, leftovers); _curtain_button = setButtonFromSwitchText(switch_text); } - - } + } // Get position from MCU int setclose_idx = buffer.indexOf("setclose"); if (setclose_idx > 0) { @@ -299,7 +298,7 @@ void _KACurtainResult() { if (leftovers > 0) { // Not found if finishing by setclose position = position.substring(0, leftovers); } - if(_curtain_ignore_next_position) { // (*1) + if(_curtain_ignore_next_position) { // (*1) _curtain_ignore_next_position = false; } else { _curtain_position = position.toInt(); @@ -314,7 +313,7 @@ void _KACurtainResult() { _KAStopMoving(); } else if(_curtain_moving ) { if(_KAValidStatus()) { - if(_curtain_last_button != _curtain_button) //Direction change? Reset the timer to know + if(_curtain_last_button != _curtain_button) //Direction change? Reset the timer to know _KASetMoving(); else if(_curtain_last_position == _curtain_position) //Same direction, same position - curtain is not moving anymore _KAStopMoving(); @@ -339,7 +338,7 @@ void _KACurtainResult() { } else if (_curtain_button != CURTAIN_BUTTON_UNKNOWN) { _curtain_last_button = _curtain_button; } - + // Handle configuration button presses if (buffer.indexOf("enterESPTOUCH") > 0) { wifiStartAP(); @@ -373,7 +372,6 @@ void _curtainMQTTCallback(unsigned int type, const char * topic, char * payload) } else { _curtain_position_set = String(payload).toInt(); _KACurtainSet(CURTAIN_BUTTON_UNKNOWN, _curtain_position_set); - } } } @@ -420,7 +418,7 @@ void _curtainWebSocketStatus(JsonObject& root) { //------------------------------------------------------------------------------ void _curtainWebSocketOnAction(uint32_t client_id, const char * action, JsonObject& data) { - + if (strcmp(action, "curtainAction") == 0) { if (data.containsKey("position")) { _curtain_position_set = data["position"].as(); @@ -473,13 +471,12 @@ void kingartCurtainSetup() { // Init port to receive and send messages KINGART_CURTAIN_PORT.begin(KINGART_CURTAIN_BAUDRATE); - + #if MQTT_SUPPORT // Register MQTT callback only when supported mqttRegister(_curtainMQTTCallback); #endif // MQTT_SUPPORT - #if WEB_SUPPORT // Websockets wsRegister() @@ -505,5 +502,4 @@ unsigned char curtainCount() { return 1; } - #endif // KINGART_CURTAIN_SUPPORT diff --git a/code/espurna/libs/AsyncClientHelpers.h b/code/espurna/libs/AsyncClientHelpers.h index 91d43786ec..3b14bf7515 100644 --- a/code/espurna/libs/AsyncClientHelpers.h +++ b/code/espurna/libs/AsyncClientHelpers.h @@ -10,5 +10,3 @@ enum class AsyncClientState { Connected, Disconnecting }; - - diff --git a/code/espurna/libs/DebounceEvent.h b/code/espurna/libs/DebounceEvent.h index 5b5d0e78e8..473cea7f06 100644 --- a/code/espurna/libs/DebounceEvent.h +++ b/code/espurna/libs/DebounceEvent.h @@ -1,5 +1,5 @@ /* - + Original code: Debounce buttons and trigger events diff --git a/code/espurna/libs/Encoder.h b/code/espurna/libs/Encoder.h index 7e24e1d581..66acd84d6e 100644 --- a/code/espurna/libs/Encoder.h +++ b/code/espurna/libs/Encoder.h @@ -7,17 +7,17 @@ * Version 1.2 - fix -2 bug in C-only code * Version 1.1 - expand to support boards with up to 60 interrupts * Version 1.0 - initial release - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -38,7 +38,7 @@ #pragma once -// _______ _______ +// _______ _______ // Pin1 ______| |_______| |______ Pin1 // negative <--- _______ _______ __ --> positive // Pin2 __| |_______| |_______| Pin2 diff --git a/code/espurna/mqtt.cpp b/code/espurna/mqtt.cpp index 62e0fdb65e..1b849a6487 100644 --- a/code/espurna/mqtt.cpp +++ b/code/espurna/mqtt.cpp @@ -315,7 +315,7 @@ void _mqttConfigure() { const auto qos = getSetting("mqttQoS", MQTT_QOS); const bool retain = getSetting("mqttRetain", 1 == MQTT_RETAIN); - + // Note: MQTT spec defines this as 2 bytes const auto keepalive = constrain( getSetting("mqttKeep", MQTT_KEEPALIVE), diff --git a/code/espurna/ntp.cpp b/code/espurna/ntp.cpp index c81a3d3b01..aa1875a0aa 100644 --- a/code/espurna/ntp.cpp +++ b/code/espurna/ntp.cpp @@ -181,7 +181,7 @@ String _ntpGetServer() { void _ntpReport() { if (!ntpSynced()) { - DEBUG_MSG_P(PSTR("[NTP] Not synced\n")); + DEBUG_MSG_P(PSTR("[NTP] Not synced\n")); return; } @@ -214,7 +214,7 @@ void _ntpConfigure() { setenv("TZ", cfg_tz.c_str(), 1); tzset(); } - + const auto cfg_server = getSetting("ntpServer", F(NTP_SERVER)); const auto active_server = _ntpGetServer(); if (cfg_tz != active_tz) { diff --git a/code/espurna/ntp_timelib.h b/code/espurna/ntp_timelib.h index 14ba052d3b..3dce5535a7 100644 --- a/code/espurna/ntp_timelib.h +++ b/code/espurna/ntp_timelib.h @@ -25,7 +25,7 @@ constexpr time_t secondsY2K = 946684800; // the time at the start of y2k template constexpr const T numberOfSeconds(T ts) { return (ts % (T)secondsPerMinute); -} +} template constexpr const T numberOfMinutes(T ts) { @@ -47,7 +47,7 @@ constexpr const int elapsedDays(uint32_t ts) { return (ts / secondsPerDay); } -// the number of seconds since last midnight +// the number of seconds since last midnight constexpr const uint32_t elapsedSecsToday(uint32_t ts) { return (ts % (uint32_t)secondsPerDay); } @@ -65,7 +65,7 @@ constexpr const time_t previousMidnight(time_t ts) { return ((ts / secondsPerDay) * secondsPerDay); } -// time at the end of the given day +// time at the end of the given day constexpr const time_t nextMidnight(time_t ts) { return previousMidnight(ts) + secondsPerDay; } diff --git a/code/espurna/sensors/AnalogSensor.h b/code/espurna/sensors/AnalogSensor.h index f38e7e72be..41d45299cb 100644 --- a/code/espurna/sensors/AnalogSensor.h +++ b/code/espurna/sensors/AnalogSensor.h @@ -68,7 +68,7 @@ class AnalogSensor : public BaseAnalogSensor { // --------------------------------------------------------------------- // Initialization method, must be idempotent - void begin() { + void begin() { _ready = true; } diff --git a/code/espurna/sensors/BMP180Sensor.h b/code/espurna/sensors/BMP180Sensor.h index de0a2188b7..23d76ba521 100644 --- a/code/espurna/sensors/BMP180Sensor.h +++ b/code/espurna/sensors/BMP180Sensor.h @@ -145,7 +145,7 @@ class BMP180Sensor : public I2CSensor<> { _bmp180_calib.ac1 = i2c_read_int16(_address, BMP180_REGISTER_CAL_AC1); _bmp180_calib.ac2 = i2c_read_int16(_address, BMP180_REGISTER_CAL_AC2); _bmp180_calib.ac3 = i2c_read_int16(_address, BMP180_REGISTER_CAL_AC3); - + _bmp180_calib.ac4 = i2c_read_uint16(_address, BMP180_REGISTER_CAL_AC4); _bmp180_calib.ac5 = i2c_read_uint16(_address, BMP180_REGISTER_CAL_AC5); _bmp180_calib.ac6 = i2c_read_uint16(_address, BMP180_REGISTER_CAL_AC6); @@ -157,9 +157,9 @@ class BMP180Sensor : public I2CSensor<> { _bmp180_calib.md = i2c_read_int16(_address, BMP180_REGISTER_CAL_MD); } - + // Compute B5 coefficient used in temperature & pressure calcs. - // Based on Adafruit_BMP085_Unified library + // Based on Adafruit_BMP085_Unified library long _computeB5(unsigned long t) { long X1 = (t - (long)_bmp180_calib.ac6) * ((long)_bmp180_calib.ac5) >> 15; long X2 = ((long)_bmp180_calib.mc << 11) / (X1+(long)_bmp180_calib.md); @@ -234,11 +234,11 @@ class BMP180Sensor : public I2CSensor<> { int16_t b1; int16_t b2; - + int16_t mb; int16_t mc; int16_t md; - + } bmp180_calib_t; bmp180_calib_t _bmp180_calib; diff --git a/code/espurna/sensors/BaseEmonSensor.h b/code/espurna/sensors/BaseEmonSensor.h index 4f68545945..4ca2f49c0b 100644 --- a/code/espurna/sensors/BaseEmonSensor.h +++ b/code/espurna/sensors/BaseEmonSensor.h @@ -71,7 +71,7 @@ class BaseEmonSensor : public BaseSensor { virtual double defaultVoltage() { return 0.0; } - + // when sensor needs explicit mains voltage value virtual void setVoltage(double) {} virtual void setVoltage(unsigned char index, double value) { diff --git a/code/espurna/sensors/DallasSensor.h b/code/espurna/sensors/DallasSensor.h index bddefa6c56..09362b4384 100644 --- a/code/espurna/sensors/DallasSensor.h +++ b/code/espurna/sensors/DallasSensor.h @@ -33,31 +33,31 @@ #define DS2406_CHANNEL_ACCESS 0xF5; // CHANNEL CONTROL BYTE -// 7 6 5 4 3 2 1 0 +// 7 6 5 4 3 2 1 0 // ALR IM TOG IC CHS1 CHS0 CRC1 CRC0 // 0 1 0 0 0 1 0 1 0x45 -// CHS1 CHS0 Description -// 0 0 (not allowed) -// 0 1 channel A only -// 1 0 channel B only -// 1 1 both channels interleaved +// CHS1 CHS0 Description +// 0 0 (not allowed) +// 0 1 channel A only +// 1 0 channel B only +// 1 1 both channels interleaved // TOG IM CHANNELS EFFECT -// 0 0 one channel Write all bits to the selected channel -// 0 1 one channel Read all bits from the selected channel -// 1 0 one channel Write 8 bits, read 8 bits, write, read, etc. to/from the selected channel -// 1 1 one channel Read 8 bits, write 8 bits, read, write, etc. from/to the selected channel -// 0 0 two channels Repeat: four times (write A, write B) -// 0 1 two channels Repeat: four times (read A, read B) -// 1 0 two channels Four times: (write A, write B), four times: (readA, read B), write, read, etc. +// 0 0 one channel Write all bits to the selected channel +// 0 1 one channel Read all bits from the selected channel +// 1 0 one channel Write 8 bits, read 8 bits, write, read, etc. to/from the selected channel +// 1 1 one channel Read 8 bits, write 8 bits, read, write, etc. from/to the selected channel +// 0 0 two channels Repeat: four times (write A, write B) +// 0 1 two channels Repeat: four times (read A, read B) +// 1 0 two channels Four times: (write A, write B), four times: (readA, read B), write, read, etc. // 1 1 two channels Four times: (read A, read B), four times: (write A, write B), read, write, etc. // CRC1 CRC0 Description // 0 0 CRC disabled (no CRC at all) // 0 1 CRC after every byte // 1 0 CRC after 8 bytes -// 1 1 CRC after 32 bytes +// 1 1 CRC after 32 bytes #define DS2406_CHANNEL_CONTROL_BYTE 0x45; #define DS2406_STATE_BUF_LEN 7 @@ -165,7 +165,7 @@ class DallasSensor : public BaseSensor { _devices[index].data[0] = _devices[index].data[0] + 1; return; } - + _wire->select(_devices[index].address); data[0] = DS2406_CHANNEL_ACCESS; @@ -261,8 +261,8 @@ class DallasSensor : public BaseSensor { return MAGNITUDE_DIGITAL; } else { return MAGNITUDE_TEMPERATURE; - } - } + } + } return MAGNITUDE_NONE; } diff --git a/code/espurna/sensors/PZEM004TV30Sensor.h b/code/espurna/sensors/PZEM004TV30Sensor.h index 4eee4c2f2b..e8626355f0 100644 --- a/code/espurna/sensors/PZEM004TV30Sensor.h +++ b/code/espurna/sensors/PZEM004TV30Sensor.h @@ -342,11 +342,11 @@ class PZEM004TV30Sensor : public BaseEmonSensor { // Quoting the README.md of the original library repo and datasheet, we have: // (name, measuring range, resolution, accuracy) - // 1. Voltage 80~260V 0.1V 0.5% - // 2. Current 0~10A or 0~100A* 0.01A or 0.02A* 0.5% - // 3. Active power 0~2.3kW or 0~23kW* 0.1W 0.5% - // 4. Active energy 0~9999.99kWh 1Wh 0.5% - // 5. Frequency 45~65Hz 0.1Hz 0.5% + // 1. Voltage 80~260V 0.1V 0.5% + // 2. Current 0~10A or 0~100A* 0.01A or 0.02A* 0.5% + // 3. Active power 0~2.3kW or 0~23kW* 0.1W 0.5% + // 4. Active energy 0~9999.99kWh 1Wh 0.5% + // 5. Frequency 45~65Hz 0.1Hz 0.5% // 6. Power factor 0.00~1.00 0.01 1% void parseMeasurements(buffer_type&& buffer, size_t size) { if (25 != size) { diff --git a/code/espurna/sensors/SI1145Sensor.h b/code/espurna/sensors/SI1145Sensor.h index 03775027f7..53e9ec3eae 100644 --- a/code/espurna/sensors/SI1145Sensor.h +++ b/code/espurna/sensors/SI1145Sensor.h @@ -23,7 +23,7 @@ class SI1145Sensor : public I2CSensor<> { _si1145 = new Adafruit_SI1145(); } - void begin() { + void begin() { static unsigned char addresses[1] = { SI1145_ADDRESS }; _address = _begin_i2c(_address, sizeof(addresses), addresses); if (_address == 0) return; @@ -68,13 +68,13 @@ class SI1145Sensor : public I2CSensor<> { // Current value for slot # index double value(unsigned char index) { - if (index == 0) return _uvi; + if (index == 0) return _uvi; return 0.0; } - protected: + protected: Adafruit_SI1145 * _si1145 = nullptr; double _uvi = 0.0; }; - + #endif // SENSOR_SUPPORT && SI1145_SUPPORT diff --git a/code/espurna/settings.cpp b/code/espurna/settings.cpp index bb4cad60b2..08eee12d05 100644 --- a/code/espurna/settings.cpp +++ b/code/espurna/settings.cpp @@ -162,7 +162,7 @@ struct SettingsKeys { } bool operator !=(iterator& const other) const { - return !(*this == other); + return !(*this == other); } using difference_type = size_t; diff --git a/code/espurna/settings_embedis.h b/code/espurna/settings_embedis.h index 8802186c30..e0b44f1695 100644 --- a/code/espurna/settings_embedis.h +++ b/code/espurna/settings_embedis.h @@ -523,7 +523,6 @@ class KeyValueStore { // implementation quirk is that `Cursor::operator=` won't work because of the `RawStorageBase&` member // right now, just construct in place and assume that compiler will inline things - // on one hand, we can implement it. but, we can't specifically KeyValueResult _read_kv() { auto key = _raw_read(); if (!key || !key.length) { diff --git a/code/espurna/terminal.cpp b/code/espurna/terminal.cpp index 253737e79c..6d4e67733c 100644 --- a/code/espurna/terminal.cpp +++ b/code/espurna/terminal.cpp @@ -651,5 +651,5 @@ void terminalSetup() { } -#endif // TERMINAL_SUPPORT +#endif // TERMINAL_SUPPORT diff --git a/code/espurna/thingspeak.cpp b/code/espurna/thingspeak.cpp index e5f6da9f36..ef713bfd5d 100644 --- a/code/espurna/thingspeak.cpp +++ b/code/espurna/thingspeak.cpp @@ -363,7 +363,7 @@ void _tspkPost(const String& address) { auto client = std::make_unique(); _tspkPost(*client.get(), url, false); return; - } + } } diff --git a/code/espurna/tuya_protocol.h b/code/espurna/tuya_protocol.h index bad394ac9f..fddc48cf78 100644 --- a/code/espurna/tuya_protocol.h +++ b/code/espurna/tuya_protocol.h @@ -99,7 +99,7 @@ namespace Tuya { template <> std::vector DataProtocol::serialize() { return std::vector { - _id, static_cast(Type::BOOL), 0x00, 0x01, + _id, static_cast(Type::BOOL), 0x00, 0x01, static_cast(_value) }; } diff --git a/code/espurna/tuya_transport.h b/code/espurna/tuya_transport.h index 9377786576..36da87d708 100644 --- a/code/espurna/tuya_transport.h +++ b/code/espurna/tuya_transport.h @@ -72,10 +72,10 @@ namespace Tuya { Output(Stream& stream) : - StreamWrapper(stream) + StreamWrapper(stream) {} - Output(StreamString& stream, size_t length) : + Output(StreamString& stream, size_t length) : Output(stream) { stream.reserve((length * 2) + 1); diff --git a/code/espurna/utils.cpp b/code/espurna/utils.cpp index 28257052fe..e290d5ccdf 100644 --- a/code/espurna/utils.cpp +++ b/code/espurna/utils.cpp @@ -220,7 +220,7 @@ unsigned int getInitialFreeHeap() { // ----------------------------------------------------------------------------- namespace Heartbeat { - enum Report : uint32_t { + enum Report : uint32_t { Status = 1 << 1, Ssid = 1 << 2, Ip = 1 << 3, @@ -434,7 +434,7 @@ void heartbeat() { if ((hb_cfg & Heartbeat::Vcc) && (ADC_MODE_VALUE == ADC_VCC)) idbSend(MQTT_TOPIC_VCC, String(ESP.getVcc()).c_str()); - + if (hb_cfg & Heartbeat::Loadavg) idbSend(MQTT_TOPIC_LOADAVG, String(systemLoadAverage()).c_str()); diff --git a/code/test/unit/terminal/terminal.cpp b/code/test/unit/terminal/terminal.cpp index f2c022e6a9..5f515d24a1 100644 --- a/code/test/unit/terminal/terminal.cpp +++ b/code/test/unit/terminal/terminal.cpp @@ -228,7 +228,7 @@ void test_case_insensitive() { str.out += String("TeSt.lOwErCaSe1\r\n"); TEST_ASSERT_EQUAL(terminal::Terminal::Result::Command, handler.processLine()); - + } // We can use command ctx.output to send something back into the stream