Merge branch 'mega' into feature/PWM_motor

This commit is contained in:
TD-er
2021-09-07 10:14:40 +02:00
committed by GitHub
83 changed files with 823 additions and 188 deletions
+41 -4
View File
@@ -1,4 +1,4 @@
.. include:: ../Plugin/_plugin_substitutions_p03x.repl
.. include:: ../Plugin/_plugin_substitutions_p03x.repl
.. _P033_page:
|P033_typename|
@@ -21,10 +21,44 @@ Maintainer: |P033_maintainer|
Used libraries: |P033_usedlibraries|
Supported hardware
------------------
Description
------------
|P033_usedby|
You can use a special dummy device within ESP Easy to provide additional features to the rules engine. A dummy device contains 1 (Single) to 4 (Quad) sensor values, depending on the Output Data Type selected, that can be used as variables to store custom numerical data. (floating point values, like 123.50)
The dummy device can be used like any other sensor to send it's data to a Controller. But this is not mandatory if you only want to use it within your own rules section.
The dummy device has it's own special command to set values from rules:
.. code-block:: none
TaskValueSet <task nr/task name>,<value nr/value name>,<value|formula>
A few examples:
You run your dummy device from task number 3 and the first value should contain something calculated from a temperature sensor labeled "Outdoor":
.. code-block:: none
TaskValueSet 3,1,[Outdoor#Temperature]-10
To make the variable to set and the task number independent, the name of the task and/or value can be used instead of the numbers.
So for a Dummy device named ``Dummy``, Output Data Type set to Temp / Hum, and Values named ``Temp`` and ``Hum``, setting the Temperature value:
.. code-block:: none
TaskValueSet,Dummy,temp,[Outdoor#Temperature]-10
(task name and value name are not case sensitive)
Note: You can use multiple Dummy devices if needed!
.. Supported hardware
.. ------------------
.. .. |P033_usedby|
.. Commands available
.. ^^^^^^^^^^^^^^^^^^
@@ -42,6 +76,9 @@ Change log
.. versionchanged:: 2.0
...
|improved|
2021-08-18 Make Interval optional, so no interval (0) can be used.
|added|
Major overhaul for 2.0 release.
+10 -9
View File
@@ -26,13 +26,8 @@ Plugin is based on `Arduino library to control Mitsubishi Heat Pumps <https://gi
Supported hardware
------------------
Plugin should support all Mitsubishi heat pump units with a CN105 connector:
* `P-Series <https://www.mitsubishicomfort.com/sites/default/themes/mitsubishicomfort/pdf/2018-01_P-Series_Controls-Compatibility-Chart.pdf>`_,
* `M-Series <https://www.mitsubishicomfort.com/sites/default/themes/mitsubishicomfort/pdf/2018-01_M-Series_Controls-Compatibility-Chart.pdf>`_,
* `CITY MULTI <https://www.mitsubishicomfort.com/sites/default/themes/mitsubishicomfort/pdf/Controller_Compatibility_Chart_2017-12_CITY_MULTI.pdf>`_.
Open issue, where users can report models they are using - `list <https://github.com/SwiCago/HeatPump/issues/13>`_.
Plugin should support all Mitsubishi heat pump units with a CN105 connector- git issue, where users can report models they are
using - `list <https://github.com/SwiCago/HeatPump/issues/13>`_.
How to connect
~~~~~~~~~~~~~~
@@ -77,7 +72,7 @@ The Mitsubishi Heatpump plugin can be added as simple as selecting it from the l
Once we hit submit, the plugin will start sending messages through controller, i.e. MQTT with payload:
``{"roomTemperature":23.0,"wideVane":"|","power":"OFF","mode":"AUTO","fan":"QUIET","vane":"AUTO","iSee":false,"temperature":24.0}``
``{"roomTemperature":25.5,"wideVane":"|","power":"OFF","mode":"COOL","fan":"AUTO","vane":"AUTO","iSee":true,"operating":true,"compressorFrequency":5,"temperature":24.0}``
Message is send every time a change is detected (i.e. one changes settings using IR remote control) and every X seconds, as set in the settings (60 seconds in above screenshot).
@@ -101,12 +96,18 @@ Special thanks
* to SwiCago and other maintainers and contributors of the *Arduino library to control Mitsubishi Heat Pumps* from https://github.com/SwiCago/HeatPump/,
* to Chris Davis for his great `blog <https://chrdavis.github.io/hacking-a-mitsubishi-heat-pump-Part-1/>`_,
* to Hadley from New Zealand for his *hacking* https://nicegear.co.nz/blog/hacking-a-mitsubishi-heat-pump-air-conditioner/,
* to Hadley from New Zealand for his *hacking*.
* and all others that contributed on this subject.
Change log
----------
.. versionchanged:: 2021/08/03
...
|added|
Status of operating and compressor frequency.
.. versionadded:: 2020/03/07
...
+54 -5
View File
@@ -21,18 +21,67 @@ Maintainer: |P105_maintainer|
Used libraries: |P105_usedlibraries|
Datasheet: |P105_datasheet|
Datasheet: |P105_datasheet| |P105_datasheet2| |P105_datasheet3|
Description
-----------
The AHT10/AHT20/AHT21 sensors provide Temperature and Humidity measurements (factory calibrated), via an I2C bus connection.
.. warning::
.. Events
.. ~~~~~~
* The **AHT10** device does sometimes not 'play nice' when there are also other I2C devices on the same bus (many complaints can be found on the internet). NB: This may be hardware-, vendor-, or chip-revision-specific.
.. .. include:: P105_events.repl
Because of this peculiarity, other sensors may be more appropriate, like the AHT20/AHT21 also supported by this plugin, or :ref:`P028_page`, :ref:`P106_page`, :ref:`P014_page`, :ref:`P034_page`, :ref:`P051_page`, :ref:`P068_page` or :ref:`P072_page`.
This plugin tries to avoid such situations (I2C bus lock) by (soft) resetting the sensor if it doesn't respond for some time.
Settings
--------
.. image:: P105_DeviceConfiguration.png
**Name**: The name for this task, should be unique.
**Enabled**: Allows to enable/disable the device.
I2C Options
^^^^^^^^^^^^
The available settings here depend on the build used. At least the **Force Slow I2C speed** option is available, but selections for the I2C Multiplexer can also be shown. For details see the :ref:`Hardware_page`
**I2C Address**: The address the device is using. The AHT10 sensor allows to select a secondary address by pulling the AO (sometimes marked as A0) pin to high (3.3V) to select the secondary address. That address should then be selected here too. The AHT20/AHT21 sensors only support a single I2C address, so it will be forced to the default address.
Device Settings
^^^^^^^^^^^^^^^^
If the plugin is configured for **Sensor model** AHT10 and other devices configured in a task use the I2C bus, a warning is displayed (see example below) that combining them with this device may cause issues on the I2C bus, resulting in all I2C devices no longer working as intended. This may occur immediately, or only after some time, like 10 minutes or an hour.
.. image:: P105_DeviceWarning.png
**Sensor model** Selection of the connected type of hardware. (AHT2x sensors have a slightly different intialization.)
Available options:
.. image:: P105_SensorModelOptions.png
**AHT10** This sensor model should better be avoided, as it doesn't always work with other devices on the same I2C bus. Also, the AHT15 can be used, but that has similar issues.
**AHT20** An more modern version of the sensor.
**AHT20** An more modern version of the sensor, very similar to the AHT20, in a more compact chip package.
Data Acquisition
^^^^^^^^^^^^^^^^
This group of settings, **Single event with all values**, **Send to Controller** and **Interval** settings are standard available configuration items. Send to Controller is only visible when one or more Controllers are configured.
**Interval** By default, Interval will be set to 60 sec. It is the frequency used to read sensor values and send these to any Controllers configured for this device.
Values
^^^^^^
The names for the values are initially set to a default name, but can be changed if desired. Also, a formula can be entered to re-calculate the value before display/sending to a controller, and the number of decimals can be changed, for Temperature, usually 1 decimal is enough to be displayed (value will be rounded).
Change log
@@ -41,4 +90,4 @@ Change log
.. versionchanged:: 2.0
...
|added| 2020-04-25
|added| 2021-08-01 Moved from ESPEasy PluginPlayground to the main repository.
Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

@@ -39,8 +39,8 @@
.. |P093_type| replace:: :cyan:`Energy (Heat)`
.. |P093_typename| replace:: :cyan:`Energy (Heat) - Mitsubishi Heat Pump`
.. |P093_status| replace:: :yellow:`ENERGY, TESTING D`
.. |P093_github| replace:: P093_MitsubishiAC.ino
.. _P093_github: https://github.com/letscontrolit/ESPEasy/blob/mega/src/_P093_MitsubishiAC.ino
.. |P093_github| replace:: P093_MitsubishiHP.ino
.. _P093_github: https://github.com/letscontrolit/ESPEasy/blob/mega/src/_P093_MitsubishiHP.ino
.. |P093_usedby| replace:: `.`
.. |P093_shortinfo| replace:: `Should support all Mitsubishi heatpump units with a CN105 connector`
.. |P093_maintainer| replace:: `crnjan`
@@ -66,19 +66,21 @@
.. |P104_datasheet| replace:: https://atlas-scientific.com/files/electrically-isolated-ezo-carrier-board.pdf
.. |P105_name| replace:: :cyan:`Atlas Scientific EZO ORP`
.. |P105_name| replace:: :cyan:`AHT10/20/21`
.. |P105_type| replace:: :cyan:`Environment`
.. |P105_typename| replace:: :cyan:`Environment - Atlas Scientific EZO ORP`
.. |P105_typename| replace:: :cyan:`Environment - AHT10/20/21`
.. |P105_porttype| replace:: `.`
.. |P105_status| replace:: :yellow:`MAX`
.. |P105_github| replace:: P105_Atlas_EZO_ORP.ino
.. _P105_github: https://github.com/letscontrolit/ESPEasy/blob/mega/src/_P105_Atlas_EZO_ORP.ino
.. |P105_status| replace:: :yellow:`TESTING A`
.. |P105_github| replace:: P105_AHT.ino
.. _P105_github: https://github.com/letscontrolit/ESPEasy/blob/mega/src/_P105_AHT.ino
.. |P105_usedby| replace:: `.`
.. |P105_shortinfo| replace:: `.`
.. |P105_maintainer| replace:: TD-er
.. |P105_maintainer| replace:: sakinit tonhuisman
.. |P105_compileinfo| replace:: `.`
.. |P105_usedlibraries| replace:: `.`
.. |P105_datasheet| replace:: https://atlas-scientific.com/files/ORP_EZO_Datasheet.pdf
.. |P105_datasheet| replace:: http://www.aosong.com/en/products-40.html
.. |P105_datasheet2| replace:: http://www.aosong.com/en/products-32.html
.. |P105_datasheet3| replace:: http://www.aosong.com/en/products-60.html
.. |P106_name| replace:: :cyan:`BME680`
+2 -2
View File
@@ -640,12 +640,12 @@ Metrics are exposed on the prometheus standard /metrics url
System metrics exposed are:
* uptime
* Uptime
* CPU load
* RAM free
* Stack free
* Wifi Strength
* WIfi connection time
* Wifi connection time
* Wifi reconnection count (since boot)
In Addition, device values are exposed.
@@ -42,14 +42,14 @@ void Adafruit_MS_PWMServoDriver::setPWMFreq(float freq) {
//Serial.print("Attempting to set freq ");
//Serial.println(freq);
freq *= 0.9; // Correct for overshoot in the frequency setting (see issue #11).
freq *= 0.9f; // Correct for overshoot in the frequency setting (see issue #11).
float prescaleval = 25000000;
prescaleval /= 4096;
prescaleval /= freq;
prescaleval -= 1;
//Serial.print("Estimated pre-scale: "); Serial.println(prescaleval);
uint8_t prescale = floor(prescaleval + 0.5);
uint8_t prescale = floor(prescaleval + 0.5f);
//Serial.print("Final pre-scale: "); Serial.println(prescale);
uint8_t oldmode = read8(PCA9685_MODE1);
+2 -2
View File
@@ -486,7 +486,7 @@ uint16_t Adafruit_TCS34725::calculateLux(uint16_t r, uint16_t g, uint16_t b)
* @return ATIME value
*/
uint8_t Adafruit_TCS34725::calculateIntegrationConstant(float it_msec) {
int atime = 258.59 - it_msec / 2.475;
int atime = 258.59f - it_msec / 2.475f;
atime = atime < 0 ? 0 : atime;
atime = atime > 255 ? 255 : atime;
return (uint8_t) atime;
@@ -501,7 +501,7 @@ uint8_t Adafruit_TCS34725::calculateIntegrationConstant(float it_msec) {
float Adafruit_TCS34725::calculateIntegrationTime(uint8_t atime) {
/* equation according to datasheet is 2.4 * (256 - atime), but that seems to be inaccurate
*/
return 2.475 * (258.59 - atime);
return 2.475f * (258.59f - atime);
}
/*!
@@ -325,7 +325,7 @@ double TinyGPSPlus::courseTo(double lat1, double long1, double lat2, double long
return degrees(a2);
}
const char *TinyGPSPlus::cardinal(double course)
const char *TinyGPSPlus::cardinal(float course)
{
static const char* directions[] = {"N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE", "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW"};
int direction = (int)((course + 11.25f) / 22.5f);
@@ -231,7 +231,7 @@ public:
static double distanceBetween(double lat1, double long1, double lat2, double long2);
static double courseTo(double lat1, double long1, double lat2, double long2);
static const char *cardinal(double course);
static const char *cardinal(float course);
static int32_t parseDecimal(const char *term);
static void parseDegrees(const char *term, RawDegrees &deg);
+2 -2
View File
@@ -144,8 +144,8 @@ void CjkSDS011::Process()
switch(_data[1]) {
case 0xC0: // SDS011 or SDS018?
_pm2_5 = (float)((_data[3] << 8) | _data[2]) * 0.1;
_pm10_ = (float)((_data[5] << 8) | _data[4]) * 0.1;
_pm2_5 = (float)((_data[3] << 8) | _data[2]) * 0.1f;
_pm10_ = (float)((_data[5] << 8) | _data[4]) * 0.1f;
_available = true;
break;
case 0xCF: // SDS198?
@@ -114,7 +114,7 @@ float SFE_MAX1704X::getVoltage()
// 2.5mV on the MAX17044
vCell = (vCell) >> 4; // Align the 12 bits
float divider = 4096.0 / _full_scale;
float divider = 4096.0f / _full_scale;
return (((float)vCell) / divider);
}
@@ -124,7 +124,7 @@ float SFE_MAX1704X::getVoltage()
// i.e. 78.125uV per LSB on the MAX17048
// i.e. 156.25uV per LSB on the MAX17049
float divider = 65536.0 / _full_scale;
float divider = 65536.0f / _full_scale;
return (((float)vCell) / divider);
}
@@ -136,7 +136,7 @@ float SFE_MAX1704X::getSOC()
float percent;
soc = read16(MAX17043_SOC);
percent = (float)((soc & 0xFF00) >> 8);
percent += ((float)(soc & 0x00FF)) / 256.0;
percent += ((float)(soc & 0x00FF)) / 256.0f;
return percent;
}
@@ -184,7 +184,7 @@ uint8_t SFE_MAX1704X::setResetVoltage(uint8_t threshold)
uint8_t SFE_MAX1704X::setResetVoltage(float threshold)
{
// 7 bits. LSb = 40mV
uint8_t thresh = (uint8_t)(constrain(threshold, 0.0, 5.08) / 0.04);
uint8_t thresh = (uint8_t)(constrain(threshold, 0.0f, 5.08f) / 0.04f);
return setResetVoltage(thresh);
}
@@ -243,11 +243,11 @@ float SFE_MAX1704X::getChangeRate(void)
{
_debugPort->println(F("getChangeRate: not supported on this device"));
}
return (0.0);
return (0.0f);
}
int16_t changeRate = read16(MAX17048_CRATE);
float changerate_f = changeRate * 0.208;
float changerate_f = changeRate * 0.208f;
return (changerate_f);
}
@@ -613,7 +613,7 @@ uint8_t SFE_MAX1704X::setVALRTMax(uint8_t threshold)
}
uint8_t SFE_MAX1704X::setVALRTMax(float threshold)
{
uint8_t thresh = (uint8_t)(constrain(threshold, 0.0, 5.1) / 0.02);
uint8_t thresh = (uint8_t)(constrain(threshold, 0.0f, 5.1f) / 0.02f);
return setVALRTMax(thresh);
}
@@ -651,7 +651,7 @@ uint8_t SFE_MAX1704X::setVALRTMin(uint8_t threshold)
}
uint8_t SFE_MAX1704X::setVALRTMin(float threshold)
{
uint8_t thresh = (uint8_t)(constrain(threshold, 0.0, 5.1) / 0.02);
uint8_t thresh = (uint8_t)(constrain(threshold, 0.0f, 5.1f) / 0.02f);
return setVALRTMin(thresh);
}
@@ -721,7 +721,7 @@ uint8_t SFE_MAX1704X::setHIBRTActThr(uint8_t threshold)
uint8_t SFE_MAX1704X::setHIBRTActThr(float threshold)
{
// LSb = 1.25mV
uint8_t thresh = (uint8_t)(constrain(threshold, 0.0, 0.31875) / 0.00125);
uint8_t thresh = (uint8_t)(constrain(threshold, 0.0f, 0.31875f) / 0.00125f);
return setHIBRTActThr(thresh);
}
@@ -760,7 +760,7 @@ uint8_t SFE_MAX1704X::setHIBRTHibThr(uint8_t threshold)
uint8_t SFE_MAX1704X::setHIBRTHibThr(float threshold)
{
// LSb = 0.208%/hr
uint8_t thresh = (uint8_t)(constrain(threshold, 0.0, 53.04) / 0.208);
uint8_t thresh = (uint8_t)(constrain(threshold, 0.0f, 53.04f) / 0.208f);
return setHIBRTHibThr(thresh);
}
+1 -1
View File
@@ -400,7 +400,7 @@ double TinyGPSPlus::courseTo(double lat1, double long1, double lat2, double long
return degrees(a2);
}
const char *TinyGPSPlus::cardinal(double course)
const char *TinyGPSPlus::cardinal(float course)
{
static const char* directions[] = {"N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE", "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW"};
int direction = (int)((course + 11.25f) / 22.5f);
+1 -1
View File
@@ -297,7 +297,7 @@ public:
static double distanceBetween(double lat1, double long1, double lat2, double long2);
static double courseTo(double lat1, double long1, double lat2, double long2);
static const char *cardinal(double course);
static const char *cardinal(float course);
static int32_t parseDecimal(const char *term);
static void parseDegrees(const char *term, RawDegrees &deg);
+1 -1
View File
@@ -409,7 +409,7 @@ void VL53L0X::readMulti(uint8_t reg, uint8_t * dst, uint8_t count)
// Defaults to 0.25 MCPS as initialized by the ST API and this library.
bool VL53L0X::setSignalRateLimit(float limit_Mcps)
{
if (limit_Mcps < 0 || limit_Mcps > 511.99) { return false; }
if (limit_Mcps < 0 || limit_Mcps > 511.99f) { return false; }
// Q9.7 fixed point format (9 integer bits, 7 fractional bits)
writeReg16Bit(FINAL_RANGE_CONFIG_MIN_COUNT_RATE_RTN_LIMIT, limit_Mcps * (1 << 7));
+4
View File
@@ -366,12 +366,16 @@ static const char DATA_ESPEASY_DEFAULT_MIN_CSS[] PROGMEM = {
// #define USES_P101 // WakeOnLan
// #define USES_P102 // PZEM004Tv3
// #define USES_P103 // Atlas_EZO_pH_ORP_EC
// #define USES_P104 // Atlas_EZO_EC
// #define USES_P105 // AHT10/20/21
// #define USES_P106 // BME680
// #define USES_P107 // Si1145
// #define USES_P109 // ThermoOLED
// #define USES_P110 // VL53L0X Time of Flight sensor
// #define USES_P111 // RF522 RFID reader
// #define USES_P112 // AS7265x
// #define USES_P113 // VL53L1X ToF
// #define USES_P114 // VEML6075
// #define USES_P115 // MAX1704x
+2 -2
View File
@@ -663,7 +663,7 @@ bool CPlugin_018(CPlugin::Function function, struct EventStruct *event, String&
addHtml(C018_data->sysver());
addRowLabel(F("Voltage"));
addHtml(String(static_cast<float>(C018_data->getVbat()) / 1000.0, 3));
addHtml(String(static_cast<float>(C018_data->getVbat()) / 1000.0f, 3));
addRowLabel(F("Dev Addr"));
addHtml(C018_data->getDevaddr());
@@ -921,7 +921,7 @@ bool do_process_c018_delay_queue(int controller_number, const C018_queue_element
success = C018_data->txHexBytes(element.packed, ControllerSettings.Port);
if (success) {
if (airtime_ms > 0.0) {
if (airtime_ms > 0.0f) {
ADD_TIMER_STAT(C018_AIR_TIME, static_cast<unsigned long>(airtime_ms * 1000));
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
+2 -2
View File
@@ -652,8 +652,8 @@ boolean Plugin_001(uint8_t function, struct EventStruct *event, String& string)
addLog(LOG_LEVEL_INFO, log);
}
#endif
// send task event
sendData(event);
// send task event: DO NOT SEND TASK EVENT
//sendData(event);
// send monitor event
if (currentStatus.monitor) sendMonitorEvent(monitorEventString.c_str(), CONFIG_PIN1, SAFE_BUTTON_EVENT);
+1 -1
View File
@@ -58,7 +58,7 @@ boolean Plugin_007(uint8_t function, struct EventStruct *event, String& string)
portNames[x] = 'A';
portNames[x] += x;
}
int optionValues[8] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f };
uint8_t optionValues[8] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f };
addFormSelectorI2C(F("plugin_007_i2c"), 8, optionValues, address);
addFormSelector(F("Port"), F("plugin_007_port"), 4, portNames, portValues, port);
+2 -2
View File
@@ -453,8 +453,8 @@ boolean Plugin_009(uint8_t function, struct EventStruct *event, String& string)
log += tempUserVar;
addLog(LOG_LEVEL_INFO, log);
}
// send task event
sendData(event);
// send task event: DO NOT SEND TASK EVENT
//sendData(event);
// send monitor event
if (currentStatus.monitor) sendMonitorEvent(monitorEventString.c_str(), CONFIG_PORT, 4);
+1 -1
View File
@@ -52,7 +52,7 @@ boolean Plugin_010(uint8_t function, struct EventStruct *event, String& string)
case PLUGIN_I2C_HAS_ADDRESS:
case PLUGIN_WEBFORM_SHOW_I2C_PARAMS:
{
const int i2cAddressValues[] = { BH1750_DEFAULT_I2CADDR, BH1750_SECOND_I2CADDR };
const uint8_t i2cAddressValues[] = { BH1750_DEFAULT_I2CADDR, BH1750_SECOND_I2CADDR };
if (function == PLUGIN_WEBFORM_SHOW_I2C_PARAMS) {
addFormSelectorI2C(F("i2c_addr"), 2, i2cAddressValues, PCONFIG(0));
addFormNote(F("ADDR Low=0x23, High=0x5c"));
+1 -1
View File
@@ -68,7 +68,7 @@ boolean Plugin_012(uint8_t function, struct EventStruct *event, String& string)
case PLUGIN_I2C_HAS_ADDRESS:
case PLUGIN_WEBFORM_SHOW_I2C_PARAMS:
{
const int i2cAddressValues[] = { 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f };
const uint8_t i2cAddressValues[] = { 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f };
if (function == PLUGIN_WEBFORM_SHOW_I2C_PARAMS) {
addFormSelectorI2C(F("i2c_addr"), 16, i2cAddressValues, P012_I2C_ADDR);
} else {
+1 -1
View File
@@ -68,7 +68,7 @@ boolean Plugin_015(uint8_t function, struct EventStruct *event, String& string)
case PLUGIN_I2C_HAS_ADDRESS:
case PLUGIN_WEBFORM_SHOW_I2C_PARAMS:
{
const int i2cAddressValues[] = { TSL2561_ADDR, TSL2561_ADDR_1, TSL2561_ADDR_0 };
const uint8_t i2cAddressValues[] = { TSL2561_ADDR, TSL2561_ADDR_1, TSL2561_ADDR_0 };
if (function == PLUGIN_WEBFORM_SHOW_I2C_PARAMS) {
addFormSelectorI2C(F("i2c_addr"), 3, i2cAddressValues, P015_I2C_ADDR);
} else {
+2 -2
View File
@@ -511,8 +511,8 @@ boolean Plugin_019(uint8_t function, struct EventStruct *event, String& string)
log += tempUserVar;
addLog(LOG_LEVEL_INFO, log);
}
// send task event
sendData(event);
// send task event: DO NOT SEND TASK EVENT
//sendData(event);
// send monitor event
if (currentStatus.monitor) sendMonitorEvent(monitorEventString.c_str(), CONFIG_PORT, SAFE_BUTTON_EVENT);
+2 -2
View File
@@ -80,9 +80,9 @@ boolean Plugin_022(uint8_t function, struct EventStruct *event, String& string)
case PLUGIN_WEBFORM_SHOW_I2C_PARAMS:
{
int optionValues[PCA9685_NUMS_ADDRESS];
uint8_t optionValues[PCA9685_NUMS_ADDRESS];
for (int i = 0; i < PCA9685_NUMS_ADDRESS; i++)
for (uint8_t i = 0; i < PCA9685_NUMS_ADDRESS; i++)
{
optionValues[i] = PCA9685_ADDRESS + i;
}
+1 -1
View File
@@ -56,7 +56,7 @@ boolean Plugin_023(uint8_t function, struct EventStruct *event, String& string)
case PLUGIN_I2C_HAS_ADDRESS:
case PLUGIN_WEBFORM_SHOW_I2C_PARAMS:
{
const int i2cAddressValues[] = { 0x3C, 0x3D };
const uint8_t i2cAddressValues[] = { 0x3C, 0x3D };
if (function == PLUGIN_WEBFORM_SHOW_I2C_PARAMS) {
addFormSelectorI2C(F("i2c_addr"), 2, i2cAddressValues, PCONFIG(0));
} else {
+1 -1
View File
@@ -53,7 +53,7 @@ boolean Plugin_025(uint8_t function, struct EventStruct *event, String& string)
case PLUGIN_WEBFORM_SHOW_I2C_PARAMS:
{
#define ADS1115_I2C_OPTION 4
const int i2cAddressValues[] = { 0x48, 0x49, 0x4A, 0x4B };
const uint8_t i2cAddressValues[] = { 0x48, 0x49, 0x4A, 0x4B };
if (function == PLUGIN_WEBFORM_SHOW_I2C_PARAMS) {
addFormSelectorI2C(F("i2c_addr"), ADS1115_I2C_OPTION, i2cAddressValues, PCONFIG(0));
} else {
+1 -1
View File
@@ -56,7 +56,7 @@ boolean Plugin_027(uint8_t function, struct EventStruct *event, String& string)
case PLUGIN_I2C_HAS_ADDRESS:
case PLUGIN_WEBFORM_SHOW_I2C_PARAMS:
{
const int i2cAddressValues[] = { INA219_ADDRESS, INA219_ADDRESS2, INA219_ADDRESS3, INA219_ADDRESS4 };
const uint8_t i2cAddressValues[] = { INA219_ADDRESS, INA219_ADDRESS2, INA219_ADDRESS3, INA219_ADDRESS4 };
if (function == PLUGIN_WEBFORM_SHOW_I2C_PARAMS) {
addFormSelectorI2C(F("i2c_addr"), 4, i2cAddressValues, P027_I2C_ADDR);
} else {
+1 -1
View File
@@ -70,7 +70,7 @@ boolean Plugin_028(uint8_t function, struct EventStruct *event, String& string)
case PLUGIN_I2C_HAS_ADDRESS:
case PLUGIN_WEBFORM_SHOW_I2C_PARAMS:
{
const int i2cAddressValues[] = { 0x76, 0x77 };
const uint8_t i2cAddressValues[] = { 0x76, 0x77 };
if (function == PLUGIN_WEBFORM_SHOW_I2C_PARAMS) {
addFormSelectorI2C(F("i2c_addr"), 2, i2cAddressValues, PCONFIG(0));
} else {
+3 -3
View File
@@ -105,7 +105,7 @@ boolean Plugin_030(uint8_t function, struct EventStruct *event, String& string)
case PLUGIN_I2C_HAS_ADDRESS:
case PLUGIN_WEBFORM_SHOW_I2C_PARAMS:
{
const int i2cAddressValues[] = { 0x76, 0x77 };
const uint8_t i2cAddressValues[] = { 0x76, 0x77 };
if (function == PLUGIN_WEBFORM_SHOW_I2C_PARAMS) {
addFormSelectorI2C(F("i2c_addr"), 2, i2cAddressValues, PCONFIG(0));
addFormNote(F("SDO Low=0x76, High=0x77"));
@@ -328,14 +328,14 @@ float Plugin_030_readAltitude(float seaLevel)
{
float atmospheric = Plugin_030_readPressure(bmp280_i2caddr & 0x01) / 100.0F;
return 44330.0f * (1.0f - pow(atmospheric / seaLevel, 0.1903f));
return 44330.0f * (1.0f - powf(atmospheric / seaLevel, 0.1903f));
}
// **************************************************************************/
// MSL pressure formula
// **************************************************************************/
float Plugin_030_pressureElevation(float atmospheric, int altitude) {
return atmospheric / pow(1.0f - (altitude / 44330.0f), 5.255f);
return atmospheric / powf(1.0f - (altitude / 44330.0f), 5.255f);
}
#endif // USES_P030
+1 -1
View File
@@ -53,7 +53,7 @@ boolean Plugin_032(uint8_t function, struct EventStruct *event, String& string)
case PLUGIN_I2C_HAS_ADDRESS:
case PLUGIN_WEBFORM_SHOW_I2C_PARAMS:
{
const int i2cAddressValues[] = { 0x77, 0x76 };
const uint8_t i2cAddressValues[] = { 0x77, 0x76 };
if (function == PLUGIN_WEBFORM_SHOW_I2C_PARAMS) {
addFormSelectorI2C(F("i2c_addr"), 2, i2cAddressValues, PCONFIG(0));
} else {
+2 -1
View File
@@ -28,6 +28,7 @@ boolean Plugin_033(uint8_t function, struct EventStruct *event, String& string)
Device[deviceCount].ValueCount = 4;
Device[deviceCount].SendDataOption = true;
Device[deviceCount].TimerOption = true;
Device[deviceCount].TimerOptional = true;
Device[deviceCount].GlobalSyncOption = true;
Device[deviceCount].OutputDataType = Output_Data_type_t::All;
break;
@@ -72,7 +73,7 @@ boolean Plugin_033(uint8_t function, struct EventStruct *event, String& string)
event->sensorType = static_cast<Sensor_VType>(PCONFIG(0));
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
for (uint8_t x = 0; x < getValueCountFromSensorType(static_cast<Sensor_VType>(PCONFIG(0))); x++)
for (uint8_t x = 0; x < getValueCountFromSensorType(static_cast < Sensor_VType > (PCONFIG(0))); x++)
{
String log = F("Dummy: value ");
log += x + 1;
+1 -1
View File
@@ -173,7 +173,7 @@ boolean Plugin_036(uint8_t function, struct EventStruct *event, String& string)
case PLUGIN_I2C_HAS_ADDRESS:
case PLUGIN_WEBFORM_SHOW_I2C_PARAMS:
{
const int i2cAddressValues[] = { 0x3c, 0x3d };
const uint8_t i2cAddressValues[] = { 0x3c, 0x3d };
if (function == PLUGIN_WEBFORM_SHOW_I2C_PARAMS) {
addFormSelectorI2C(F("i2c_addr"), 2, i2cAddressValues, P036_ADR);
} else {
+1 -1
View File
@@ -1457,7 +1457,7 @@ float Plugin_039_convert_to_temperature(uint32_t l_rawvalue, float RTDnominal, f
Z4 = 2 * RTD_B;
temp = Z2 + (Z3 * Rt);
temp = (sqrt(temp) + Z1) / Z4;
temp = (sqrtf(temp) + Z1) / Z4;
if (temp >= 0)
return temp;
+1 -1
View File
@@ -105,7 +105,7 @@ boolean Plugin_045(uint8_t function, struct EventStruct *event, String& string)
case PLUGIN_I2C_HAS_ADDRESS:
case PLUGIN_WEBFORM_SHOW_I2C_PARAMS:
{
const int i2cAddressValues[] = { 0x68, 0x69 };
const uint8_t i2cAddressValues[] = { 0x68, 0x69 };
if (function == PLUGIN_WEBFORM_SHOW_I2C_PARAMS) {
addFormSelectorI2C(F("i2c_addr"), 2, i2cAddressValues, PCONFIG(0));
addFormNote(F("ADDR Low=0x68, High=0x69"));
+12 -12
View File
@@ -212,11 +212,11 @@ boolean Plugin_053_process_data(struct EventStruct *event) {
String log;
log.reserve(45);
log = F("PMSx003 : temp=");
log += static_cast<float>(data[13]) / 10.0;
log += static_cast<float>(data[13]) / 10.0f;
log += F(", humi=");
log += static_cast<float>(data[14]) / 10.0;
log += static_cast<float>(data[14]) / 10.0f;
log += F(", hcho=");
log += static_cast<float>(data[12]) / 1000.0;
log += static_cast<float>(data[12]) / 1000.0f;
addLog(LOG_LEVEL_DEBUG, log);
}
#endif // ifdef PLUGIN_053_ENABLE_EXTRA_SENSORS
@@ -242,9 +242,9 @@ boolean Plugin_053_process_data(struct EventStruct *event) {
case PLUGIN_053_OUTPUT_THC:
{
UserVar[event->BaseVarIndex] = data[4];
UserVar[event->BaseVarIndex + 1] = static_cast<float>(data[13]) / 10.0; // TEMP
UserVar[event->BaseVarIndex + 2] = static_cast<float>(data[14]) / 10.0; // HUMI
UserVar[event->BaseVarIndex + 3] = static_cast<float>(data[12]) / 1000.0; // HCHO
UserVar[event->BaseVarIndex + 1] = static_cast<float>(data[13]) / 10.0f; // TEMP
UserVar[event->BaseVarIndex + 2] = static_cast<float>(data[14]) / 10.0f; // HUMI
UserVar[event->BaseVarIndex + 3] = static_cast<float>(data[12]) / 1000.0f; // HCHO
break;
}
case PLUGIN_053_OUTPUT_CNT:
@@ -268,11 +268,11 @@ boolean Plugin_053_process_data(struct EventStruct *event) {
case PLUGIN_053_OUTPUT_PART:
{
// Temperature
Plugin_053_SendEvent(baseEvent, F("Temp"), static_cast<float>(data[13]) / 10.0);
Plugin_053_SendEvent(baseEvent, F("Temp"), static_cast<float>(data[13]) / 10.0f);
// Humidity
Plugin_053_SendEvent(baseEvent, F("Humi"), static_cast<float>(data[14]) / 10.0);
Plugin_053_SendEvent(baseEvent, F("Humi"), static_cast<float>(data[14]) / 10.0f);
// Formaldebyde (HCHO)
Plugin_053_SendEvent(baseEvent, F("HCHO"), static_cast<float>(data[12]) / 1000.0);
Plugin_053_SendEvent(baseEvent, F("HCHO"), static_cast<float>(data[12]) / 1000.0f);
if (PCONFIG(2) == PLUGIN_053_OUTPUT_CNT) {
// Particle count per 0.1 L > 1.0 micron
@@ -314,11 +314,11 @@ boolean Plugin_053_process_data(struct EventStruct *event) {
// Particles > 10 um/m3
Plugin_053_SendEvent(baseEvent, F("pm10"), data[5]);
// Temperature
Plugin_053_SendEvent(baseEvent, F("Temp"), static_cast<float>(data[13]) / 10.0);
Plugin_053_SendEvent(baseEvent, F("Temp"), static_cast<float>(data[13]) / 10.0f);
// Humidity
Plugin_053_SendEvent(baseEvent, F("Humi"), static_cast<float>(data[14]) / 10.0);
Plugin_053_SendEvent(baseEvent, F("Humi"), static_cast<float>(data[14]) / 10.0f);
// Formaldebyde (HCHO)
Plugin_053_SendEvent(baseEvent, F("HCHO"), static_cast<float>(data[12]) / 1000.0);
Plugin_053_SendEvent(baseEvent, F("HCHO"), static_cast<float>(data[12]) / 1000.0f);
break;
}
default:
+10 -1
View File
@@ -124,8 +124,9 @@ boolean Plugin_054(uint8_t function, struct EventStruct *event, String& string)
CONFIG_PIN1 = 2; //TX1 fix to GPIO2 (D4) == onboard LED
Plugin_054_DMXSize = PCONFIG(0);
if (Plugin_054_DMXBuffer)
if (Plugin_054_DMXBuffer) {
delete [] Plugin_054_DMXBuffer;
}
Plugin_054_DMXBuffer = new uint8_t[Plugin_054_DMXSize];
memset(Plugin_054_DMXBuffer, 0, Plugin_054_DMXSize);
@@ -133,6 +134,14 @@ boolean Plugin_054(uint8_t function, struct EventStruct *event, String& string)
break;
}
case PLUGIN_EXIT:
{
if (Plugin_054_DMXBuffer) {
delete [] Plugin_054_DMXBuffer;
}
break;
}
case PLUGIN_WRITE:
{
String lowerString=string;
+1 -1
View File
@@ -104,7 +104,7 @@ boolean Plugin_057(uint8_t function, struct EventStruct *event, String& string)
case PLUGIN_I2C_HAS_ADDRESS:
case PLUGIN_WEBFORM_SHOW_I2C_PARAMS:
{
const int i2cAddressValues[] = { 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77 };
const uint8_t i2cAddressValues[] = { 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77 };
if (function == PLUGIN_WEBFORM_SHOW_I2C_PARAMS) {
addFormSelectorI2C(F("i2c_addr"), 8, i2cAddressValues, PCONFIG(0));
} else {
+1 -1
View File
@@ -76,7 +76,7 @@ boolean Plugin_058(uint8_t function, struct EventStruct *event, String& string)
case PLUGIN_I2C_HAS_ADDRESS:
case PLUGIN_WEBFORM_SHOW_I2C_PARAMS:
{
const int i2cAddressValues[] = { 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77 };
const uint8_t i2cAddressValues[] = { 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77 };
if (function == PLUGIN_WEBFORM_SHOW_I2C_PARAMS) {
addFormSelectorI2C(F("i2c_addr"), 8, i2cAddressValues, PCONFIG(0));
} else {
+1 -1
View File
@@ -54,7 +54,7 @@ boolean Plugin_060(uint8_t function, struct EventStruct *event, String& string)
case PLUGIN_I2C_HAS_ADDRESS:
case PLUGIN_WEBFORM_SHOW_I2C_PARAMS:
{
const int i2cAddressValues[] = { 0x4D, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4E, 0x4F };
const uint8_t i2cAddressValues[] = { 0x4D, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4E, 0x4F };
if (function == PLUGIN_WEBFORM_SHOW_I2C_PARAMS) {
addFormSelectorI2C(F("i2c_addr"), 8, i2cAddressValues, PCONFIG(0));
} else {
+1 -1
View File
@@ -100,7 +100,7 @@ boolean Plugin_061(uint8_t function, struct EventStruct *event, String& string)
case PLUGIN_I2C_HAS_ADDRESS:
case PLUGIN_WEBFORM_SHOW_I2C_PARAMS:
{
const int i2cAddressValues[] = { 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F };
const uint8_t i2cAddressValues[] = { 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F };
if (function == PLUGIN_WEBFORM_SHOW_I2C_PARAMS) {
addFormSelectorI2C(F("i2c_addr"), (PCONFIG(1) == 0) ? 8 : 16, i2cAddressValues, PCONFIG(0));
+1 -1
View File
@@ -73,7 +73,7 @@ boolean Plugin_062(uint8_t function, struct EventStruct *event, String& string)
case PLUGIN_I2C_HAS_ADDRESS:
case PLUGIN_WEBFORM_SHOW_I2C_PARAMS:
{
const int i2cAddressValues[] = { 0x5A, 0x5B, 0x5C, 0x5D };
const uint8_t i2cAddressValues[] = { 0x5A, 0x5B, 0x5C, 0x5D };
if (function == PLUGIN_WEBFORM_SHOW_I2C_PARAMS) {
addFormSelectorI2C(F("i2c_addr"), 4, i2cAddressValues, PCONFIG(0));
} else {
+1 -1
View File
@@ -100,7 +100,7 @@ boolean Plugin_064(uint8_t function, struct EventStruct *event, String& string)
case PLUGIN_I2C_HAS_ADDRESS:
case PLUGIN_WEBFORM_SHOW_I2C_PARAMS:
{
const int i2cAddressValues[] = { 0x39 };
const uint8_t i2cAddressValues[] = { 0x39 };
if (function == PLUGIN_WEBFORM_SHOW_I2C_PARAMS) {
addFormSelectorI2C(F("i2c_addr"), 1, i2cAddressValues, 0x39); // Only for display I2C address
} else {
+5 -5
View File
@@ -65,7 +65,7 @@ boolean Plugin_066(uint8_t function, struct EventStruct *event, String& string)
case PLUGIN_I2C_HAS_ADDRESS:
case PLUGIN_WEBFORM_SHOW_I2C_PARAMS:
{
const int i2cAddressValues[] = { VEML6040_ADDR };
const uint8_t i2cAddressValues[] = { VEML6040_ADDR };
if (function == PLUGIN_WEBFORM_SHOW_I2C_PARAMS) {
addFormSelectorI2C(F("i2c_addr"), 1, i2cAddressValues, VEML6040_ADDR); // Only for display I2C address
} else {
@@ -145,9 +145,9 @@ boolean Plugin_066(uint8_t function, struct EventStruct *event, String& string)
}
case 2:
{
UserVar[event->BaseVarIndex + 0] = pow(Plugin_066_CalcRelW(R, W), 0.4545) * 100.0f;
UserVar[event->BaseVarIndex + 1] = pow(Plugin_066_CalcRelW(G, W), 0.4545) * 100.0f;
UserVar[event->BaseVarIndex + 2] = pow(Plugin_066_CalcRelW(B, W), 0.4545) * 100.0f;
UserVar[event->BaseVarIndex + 0] = powf(Plugin_066_CalcRelW(R, W), 0.4545) * 100.0f;
UserVar[event->BaseVarIndex + 1] = powf(Plugin_066_CalcRelW(G, W), 0.4545) * 100.0f;
UserVar[event->BaseVarIndex + 2] = powf(Plugin_066_CalcRelW(B, W), 0.4545) * 100.0f;
UserVar[event->BaseVarIndex + 3] = W;
break;
}
@@ -222,7 +222,7 @@ float Plugin_066_CalcCCT(float R, float G, float B)
}
float CCTi = (R - B) / G + 0.5f;
float CCT = 4278.6f * pow(CCTi, -1.2455f);
float CCT = 4278.6f * powf(CCTi, -1.2455f);
return CCT;
}
+1 -1
View File
@@ -186,7 +186,7 @@ boolean Plugin_068(uint8_t function, struct EventStruct *event, String& string)
case PLUGIN_I2C_HAS_ADDRESS:
case PLUGIN_WEBFORM_SHOW_I2C_PARAMS:
{
const int i2cAddressValues[] = { 0x44, 0x45 };
const uint8_t i2cAddressValues[] = { 0x44, 0x45 };
if (function == PLUGIN_WEBFORM_SHOW_I2C_PARAMS) {
addFormSelectorI2C(F("i2c_addr"), 2, i2cAddressValues, PCONFIG(0));
} else {
+1 -1
View File
@@ -59,7 +59,7 @@ boolean Plugin_069(uint8_t function, struct EventStruct *event, String& string)
case PLUGIN_I2C_HAS_ADDRESS:
case PLUGIN_WEBFORM_SHOW_I2C_PARAMS:
{
const int i2cAddressValues[] = { 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F };
const uint8_t i2cAddressValues[] = { 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F };
if (function == PLUGIN_WEBFORM_SHOW_I2C_PARAMS) {
addFormSelectorI2C(F("i2c_addr"), 8, i2cAddressValues, PCONFIG(0));
} else {
+2 -2
View File
@@ -83,7 +83,7 @@ boolean Plugin_072(uint8_t function, struct EventStruct *event, String& string)
hdc1080_msb = Wire.read();
hdc1080_lsb = Wire.read();
hdc1080_rawtemp = hdc1080_msb << 8 | hdc1080_lsb;
hdc1080_temp = (hdc1080_rawtemp / pow(2, 16)) * 165 - 40;
hdc1080_temp = (static_cast<float>(hdc1080_rawtemp) / 65526.0f) * 165.0f - 40.0f;
Wire.beginTransmission(HDC1080_I2C_ADDRESS); // start transmission to device
Wire.write(0x01); // sends HDC1080_HUMIDITY
@@ -93,7 +93,7 @@ boolean Plugin_072(uint8_t function, struct EventStruct *event, String& string)
hdc1080_msb = Wire.read();
hdc1080_lsb = Wire.read();
hdc1080_rawhum = hdc1080_msb << 8 | hdc1080_lsb;
hdc1080_hum = (hdc1080_rawhum / pow(2, 16)) * 100;
hdc1080_hum = (static_cast<float>(hdc1080_rawhum) / 65536.0f) * 100.0f;
UserVar[event->BaseVarIndex] = hdc1080_temp;
UserVar[event->BaseVarIndex + 1] = hdc1080_hum;
+1 -1
View File
@@ -148,7 +148,7 @@ boolean Plugin_074(uint8_t function, struct EventStruct *event, String& string)
case PLUGIN_I2C_HAS_ADDRESS:
case PLUGIN_WEBFORM_SHOW_I2C_PARAMS:
{
const int i2cAddressValues[] = { TSL2591_ADDR };
const uint8_t i2cAddressValues[] = { TSL2591_ADDR };
if (function == PLUGIN_WEBFORM_SHOW_I2C_PARAMS) {
addFormSelectorI2C(F("i2c_addr"), 1, i2cAddressValues,
TSL2591_ADDR); // Only for display I2C address
+6 -6
View File
@@ -256,7 +256,7 @@ boolean Plugin_076(uint8_t function, struct EventStruct *event, String &string)
hlwMultipliers[0] = getFormItemFloat(F("p076_currmult"));
hlwMultipliers[1] = getFormItemFloat(F("p076_voltmult"));
hlwMultipliers[2] = getFormItemFloat(F("p076_powmult"));
if (hlwMultipliers[0] > 1.0f && hlwMultipliers[1] > 1.0f && hlwMultipliers[2] > 1.0f) {
if (hlwMultipliers[0] > 1.0 && hlwMultipliers[1] > 1.0 && hlwMultipliers[2] > 1.0) {
SaveCustomTaskSettings(event->TaskIndex, reinterpret_cast<const uint8_t *>(&hlwMultipliers),
sizeof(hlwMultipliers));
if (PLUGIN_076_DEBUG) {
@@ -455,7 +455,7 @@ boolean Plugin_076(uint8_t function, struct EventStruct *event, String &string)
Plugin_076_hlw->expectedVoltage(CalibVolt);
changed = true;
}
if (CalibCurr > 0.0f) {
if (CalibCurr > 0.0) {
Plugin_076_hlw->expectedCurrent(CalibCurr);
changed = true;
}
@@ -519,16 +519,16 @@ bool Plugin076_LoadMultipliers(taskIndex_t TaskIndex, double& current, double& v
double hlwMultipliers[3];
LoadCustomTaskSettings(TaskIndex, reinterpret_cast<uint8_t *>(&hlwMultipliers),
sizeof(hlwMultipliers));
if (hlwMultipliers[0] > 1.0f) {
if (hlwMultipliers[0] > 1.0) {
current = hlwMultipliers[0];
}
if (hlwMultipliers[1] > 1.0f) {
if (hlwMultipliers[1] > 1.0) {
voltage = hlwMultipliers[1];
}
if (hlwMultipliers[2] > 1.0f) {
if (hlwMultipliers[2] > 1.0) {
power = hlwMultipliers[2];
}
return (current > 1.0f) && (voltage > 1.0f) && (power > 1.0f);
return (current > 1.0) && (voltage > 1.0) && (power > 1.0);
}
void Plugin076_Reset(taskIndex_t TaskIndex) {
+2 -2
View File
@@ -429,8 +429,8 @@ boolean Plugin_082(uint8_t function, struct EventStruct *event, String& string)
}
bool P082_referencePointSet(struct EventStruct *event) {
return ! ((P082_LONG_REF < 0.1) && (P082_LONG_REF > -0.1)
&& (P082_LAT_REF < 0.1) && (P082_LAT_REF > -0.1) );
return ! ((P082_LONG_REF < 0.1f) && (P082_LONG_REF > -0.1f)
&& (P082_LAT_REF < 0.1f) && (P082_LAT_REF > -0.1f) );
}
void P082_setOutputValue(struct EventStruct *event, uint8_t outputType, float value) {
+50 -18
View File
@@ -11,6 +11,9 @@
#define PLUGIN_NAME_093 "Energy (Heat) - Mitsubishi Heat Pump [TESTING]"
#define PLUGIN_VALUENAME1_093 "settings"
#define P093_REQUEST_STATUS PCONFIG(0)
#define P093_REQUEST_STATUS_LABEL PCONFIG_LABEL(0)
#define PLUGIN_093_DEBUG
/*
@@ -29,12 +32,13 @@ static const uint8_t READ_BUFFER_LEN = 32;
static const uint8_t INFOMODE[] = {
0x02, // request a settings packet
0x03 // request the current room temp
0x03, // request the current room temp
0x06 // request status
};
struct P093_data_struct : public PluginTaskData_base {
P093_data_struct(const ESPEasySerialPort port, const int16_t serialRx, const int16_t serialTx) :
_serial(new (std::nothrow) ESPeasySerial(port, serialRx, serialTx)),
P093_data_struct(const ESPEasySerialPort port, const int16_t serialRx, const int16_t serialTx, bool includeStatus) :
_serial(port, serialRx, serialTx),
_state(NotConnected),
_fastBaudRate(false),
_readPos(0),
@@ -43,15 +47,12 @@ struct P093_data_struct : public PluginTaskData_base {
_statusUpdateTimeout(0),
_tempMode(false),
_wideVaneAdj(false),
_valuesInitialized(false) {
_valuesInitialized(false),
_includeStatus(includeStatus) {
setState(Connecting);
}
virtual ~P093_data_struct() {
delete _serial;
}
boolean sync() {
if (_statusUpdateTimeout != 0) {
if (_writeStatus.isDirty()) {
@@ -91,6 +92,12 @@ struct P093_data_struct : public PluginTaskData_base {
result += map(_currentValues.vane, _mappings.vane);
result += F("\",\"iSee\":");
result += boolToString(_currentValues.iSee);
if (_includeStatus) {
result += F(",\"operating\":");
result += boolToString(_currentValues.operating);
result += F(",\"compressorFrequency\":");
result += _currentValues.compressorFrequency;
}
result += F(",\"temperature\":");
result += toString(_currentValues.temperature, 1) + '}';
@@ -220,6 +227,8 @@ private:
uint8_t vane;
uint8_t wideVane;
float roomTemperature;
boolean operating;
uint8_t compressorFrequency;
Values() :
power(0),
@@ -229,7 +238,9 @@ private:
fan(0),
vane(0),
wideVane(0),
roomTemperature(0) {
roomTemperature(0),
operating(false),
compressorFrequency(0) {
}
boolean operator!=(const Values& rhs) const {
@@ -240,7 +251,9 @@ private:
vane != rhs.vane ||
wideVane != rhs.wideVane ||
iSee != rhs.iSee ||
roomTemperature != rhs.roomTemperature;
roomTemperature != rhs.roomTemperature ||
operating != rhs.operating ||
compressorFrequency != rhs.compressorFrequency;
}
};
@@ -321,9 +334,10 @@ private:
updateStatus();
break;
case StatusUpdated:
case StatusUpdated: {
responseReceived();
_infoModeIndex = (_infoModeIndex + 1) % sizeof(INFOMODE);
const int infoModeCount = _includeStatus ? sizeof(INFOMODE) : sizeof(INFOMODE) - 1;
_infoModeIndex = (_infoModeIndex + 1) % infoModeCount;
if (_infoModeIndex != 0) {
setState(UpdatingStatus);
} else {
@@ -331,6 +345,7 @@ private:
setState(ScheduleNextStatusUpdate);
}
break;
}
case ScheduleNextStatusUpdate:
_statusUpdateTimeout = millis() + 1000;
@@ -450,7 +465,7 @@ private:
void connect() {
addLog(LOG_LEVEL_DEBUG, String(F("M-AC: Connect ")) + getBaudRate());
_serial->begin(getBaudRate(), SERIAL_8E1);
_serial.begin(getBaudRate(), SERIAL_8E1);
const uint8_t buffer[] = { 0xfc, 0x5a, 0x01, 0x30, 0x02, 0xca, 0x01, 0xa8 };
sendPacket(buffer, sizeof(buffer));
}
@@ -464,7 +479,7 @@ private:
addLog(LOG_LEVEL_DEBUG_MORE, dumpOutgoingPacket(packet, size));
#endif
_serial->write(packet, size);
_serial.write(packet, size);
_writeTimeout = millis() + 2000;
}
@@ -488,8 +503,8 @@ private:
static const uint8_t DATA_LEN_INDEX = 4;
while(_serial->available() > 0) {
uint8_t value = _serial->read();
while(_serial.available() > 0) {
uint8_t value = _serial.read();
if (_readPos == 0) {
// Wait for start uint8_t.
@@ -572,6 +587,14 @@ private:
return true;
}
break;
case 0x06:
if (length > 4) {
_currentValues.operating = data[4];
_currentValues.compressorFrequency = data[3];
return true;
}
break;
}
addLog(LOG_LEVEL_DEBUG, F("M-AC: PV(1)"));
@@ -674,7 +697,7 @@ private:
#endif
private:
ESPeasySerial* _serial;
ESPeasySerial _serial;
State _state;
boolean _fastBaudRate;
uint8_t _readBuffer[READ_BUFFER_LEN];
@@ -687,6 +710,7 @@ private:
boolean _tempMode;
boolean _wideVaneAdj;
boolean _valuesInitialized;
boolean _includeStatus;
WriteStatus _writeStatus;
const Mappings _mappings;
};
@@ -728,19 +752,27 @@ boolean Plugin_093(uint8_t function, struct EventStruct *event, String& string)
break;
}
case PLUGIN_SET_DEFAULTS: {
P093_REQUEST_STATUS = 0;
success = true;
break;
}
case PLUGIN_WEBFORM_LOAD: {
addFormCheckBox(F("Include AC status"), P093_REQUEST_STATUS_LABEL, P093_REQUEST_STATUS);
success = true;
break;
}
case PLUGIN_WEBFORM_SAVE: {
P093_REQUEST_STATUS = isFormItemChecked(P093_REQUEST_STATUS_LABEL);
success = true;
break;
}
case PLUGIN_INIT: {
const ESPEasySerialPort port = static_cast<ESPEasySerialPort>(CONFIG_PORT);
initPluginTaskData(event->TaskIndex, new (std::nothrow) P093_data_struct(port, CONFIG_PIN1, CONFIG_PIN2));
initPluginTaskData(event->TaskIndex, new (std::nothrow) P093_data_struct(port, CONFIG_PIN1, CONFIG_PIN2, P093_REQUEST_STATUS));
success = getPluginTaskData(event->TaskIndex) != nullptr;
break;
}
+1 -1
View File
@@ -70,7 +70,7 @@ boolean Plugin_103(uint8_t function, struct EventStruct *event, String &string)
case PLUGIN_I2C_HAS_ADDRESS:
case PLUGIN_WEBFORM_SHOW_I2C_PARAMS:
{
const int i2cAddressValues[] = {0x62, 0x63, 0x64}; // , 0x65, 0x66, 0x67}; // Disabled unsupported devices as discussed here: https://github.com/letscontrolit/ESPEasy/pull/3733 (review comment by TD-er)
const uint8_t i2cAddressValues[] = {0x62, 0x63, 0x64}; // , 0x65, 0x66, 0x67}; // Disabled unsupported devices as discussed here: https://github.com/letscontrolit/ESPEasy/pull/3733 (review comment by TD-er)
if (function == PLUGIN_WEBFORM_SHOW_I2C_PARAMS) {
addFormSelectorI2C(F("plugin_103_i2c"), _P103_ATLASEZO_I2C_NB_OPTIONS, i2cAddressValues, PCONFIG(1));
addFormNote(F("pH: 0x63, ORP: 0x62, EC: 0x64. The plugin is able to detect the type of device automatically."));
+214
View File
@@ -0,0 +1,214 @@
#include "_Plugin_Helper.h"
#ifdef USES_P105
// #######################################################################################################
// ######################## Plugin 105 AHT I2C Temperature and Humidity Sensor ##########################
// #######################################################################################################
// data sheet AHT10: https://wiki.liutyi.info/display/ARDUINO/AHT10
// device AHT10: http://www.aosong.com/en/products-40.html
// device and manual AHT20: http://www.aosong.com/en/products-32.html
// device and manual AHT21: http://www.aosong.com/en/products-60.html
/* AHT10/15/20 - Temperature and Humidity
*
* (Comment copied from _P248_TempHumidity_AHT1x.ino)
*
* AHT1x I2C Address: 0x38, 0x39
* the driver supports two I2c adresses but only one Sensor allowed.
*
* ATTENTION: The AHT10/15 Sensor is incompatible with other I2C devices on I2C bus.
*
* The Datasheet write:
* "Only a single AHT10 can be connected to the I2C bus and no other I2C
* devices can be connected".
*
* after lot of search and tests, now is confirmed that works only reliable with one sensor
* on I2C Bus
*/
// History:
// 2021-08-01 tonhuisman: Plugin migrated from ESPEsyPluginPlayground repository
// Minor adjustments, changed castings to use static_cast<type>(var) method,
// Added check for other I2C devoces configured on ESPEasy tasks to give a warning
// about I2C incmopatibility, for AHT10 device only
// 2021-03 sakinit: Initial plugin, added on ESPEasyPluginPlayground
# include "src/PluginStructs/P105_data_struct.h"
# define PLUGIN_105
# define PLUGIN_ID_105 105
# define PLUGIN_NAME_105 "Environment - AHT10/20/21 [TESTING]"
# define PLUGIN_VALUENAME1_105 "Temperature"
# define PLUGIN_VALUENAME2_105 "Humidity"
boolean Plugin_105(uint8_t function, struct EventStruct *event, String& string)
{
boolean success = false;
switch (function)
{
case PLUGIN_DEVICE_ADD:
{
Device[++deviceCount].Number = PLUGIN_ID_105;
Device[deviceCount].Type = DEVICE_TYPE_I2C;
Device[deviceCount].VType = Sensor_VType::SENSOR_TYPE_TEMP_HUM;
Device[deviceCount].Ports = 0;
Device[deviceCount].PullUpOption = false;
Device[deviceCount].InverseLogicOption = false;
Device[deviceCount].FormulaOption = true;
Device[deviceCount].ValueCount = 2;
Device[deviceCount].SendDataOption = true;
Device[deviceCount].TimerOption = true;
Device[deviceCount].GlobalSyncOption = true;
break;
}
case PLUGIN_GET_DEVICENAME:
{
string = F(PLUGIN_NAME_105);
break;
}
case PLUGIN_GET_DEVICEVALUENAMES:
{
strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[0], PSTR(PLUGIN_VALUENAME1_105));
strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[1], PSTR(PLUGIN_VALUENAME2_105));
break;
}
case PLUGIN_I2C_HAS_ADDRESS:
case PLUGIN_WEBFORM_SHOW_I2C_PARAMS:
{
const int i2cAddressValues[2] = { 0x38, 0x39 };
if (function == PLUGIN_WEBFORM_SHOW_I2C_PARAMS) {
addFormSelectorI2C(F("i2c_addr"), 2, i2cAddressValues, PCONFIG(0));
addFormNote(F("SDO Low=0x38, High=0x39. NB: Only available on AHT10 sensors."));
} else {
success = intArrayContains(2, i2cAddressValues, event->Par1);
}
break;
}
case PLUGIN_WEBFORM_LOAD:
{
if (static_cast<AHTx_device_type>(PCONFIG(1)) == AHTx_device_type::AHT10_DEVICE) {
bool hasOtherI2CDevices = false;
for (taskIndex_t x = 0; validTaskIndex(x) && !hasOtherI2CDevices; x++) {
const deviceIndex_t DeviceIndex = getDeviceIndex_from_TaskIndex(x);
if (validDeviceIndex(DeviceIndex)
&& (Settings.TaskDeviceDataFeed[x] == 0)
&& ((Device[DeviceIndex].Type == DEVICE_TYPE_I2C)
# ifdef PLUGIN_USES_SERIAL // Has I2C Serial option
|| (Device[DeviceIndex].Type == DEVICE_TYPE_SERIAL)
|| (Device[DeviceIndex].Type == DEVICE_TYPE_SERIAL_PLUS1)
# endif // ifdef PLUGIN_USES_SERIAL
)
) {
hasOtherI2CDevices = true;
}
}
if (hasOtherI2CDevices) {
addRowLabel(EMPTY_STRING, EMPTY_STRING);
addHtmlDiv(F("note warning"),
F("Attention: Sensor model AHT10 may cause I2C issues when combined with other I2C devices on the same bus!"));
}
}
{
const __FlashStringHelper *options[] = { F("AHT10"), F("AHT20"), F("AHT21") };
const int indices[] = { static_cast<int>(AHTx_device_type::AHT10_DEVICE),
static_cast<int>(AHTx_device_type::AHT20_DEVICE),
static_cast<int>(AHTx_device_type::AHT21_DEVICE) };
addFormSelector(F("Sensor model"), F("p105_ahttype"), 3, options, indices, PCONFIG(1), true);
addFormNote(F("Changing Sensor model will reload the page."));
}
success = true;
break;
}
case PLUGIN_WEBFORM_SAVE:
{
PCONFIG(1) = getFormItemInt(F("p105_ahttype"));
if (static_cast<AHTx_device_type>(PCONFIG(1)) != AHTx_device_type::AHT10_DEVICE) {
PCONFIG(0) = 0x38; // AHT20/AHT21 only support a single I2C address.
} else {
PCONFIG(0) = getFormItemInt(F("i2c_addr"));
}
success = true;
break;
}
case PLUGIN_INIT:
{
initPluginTaskData(event->TaskIndex,
new (std::nothrow) P105_data_struct(PCONFIG(0), static_cast<AHTx_device_type>(PCONFIG(1))));
P105_data_struct *P105_data =
static_cast<P105_data_struct *>(getPluginTaskData(event->TaskIndex));
if (nullptr == P105_data) {
return success;
}
success = true;
break;
}
case PLUGIN_ONCE_A_SECOND:
{
P105_data_struct *P105_data =
static_cast<P105_data_struct *>(getPluginTaskData(event->TaskIndex));
if (nullptr != P105_data) {
if (P105_data->updateMeasurements(event->TaskIndex)) {
// Update was succesfull, schedule a read.
Scheduler.schedule_task_device_timer(event->TaskIndex, millis() + 10);
}
}
break;
}
case PLUGIN_READ:
{
P105_data_struct *P105_data =
static_cast<P105_data_struct *>(getPluginTaskData(event->TaskIndex));
if (nullptr != P105_data) {
if (P105_data->state != AHTx_state::AHTx_New_values) {
success = false;
break;
}
P105_data->state = AHTx_state::AHTx_Values_read;
UserVar[event->BaseVarIndex] = P105_data->getTemperature();
UserVar[event->BaseVarIndex + 1] = P105_data->getHumidity();
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
String log;
log.reserve(60); // Prevent re-allocation
log = P105_data->getDeviceName();
log += F(" : Addr: 0x");
log += String(PCONFIG(0), HEX);
addLog(LOG_LEVEL_INFO, log);
log = P105_data->getDeviceName();
log += F(" : Temperature: ");
log += formatUserVarNoCheck(event->TaskIndex, 0);
log += F(" : Humidity: ");
log += formatUserVarNoCheck(event->TaskIndex, 1);
addLog(LOG_LEVEL_INFO, log);
}
success = true;
}
break;
}
}
return success;
}
#endif // USES_P105
+1 -1
View File
@@ -67,7 +67,7 @@ boolean Plugin_106(uint8_t function, struct EventStruct *event, String& string)
case PLUGIN_I2C_HAS_ADDRESS:
case PLUGIN_WEBFORM_SHOW_I2C_PARAMS:
{
const int i2cAddressValues[] = { 0x77, 0x76 };
const uint8_t i2cAddressValues[] = { 0x77, 0x76 };
if (function == PLUGIN_WEBFORM_SHOW_I2C_PARAMS) {
addFormSelectorI2C(F("i2c_addr"), 2, i2cAddressValues, PCONFIG(0));
addFormNote(F("SDO Low=0x76, High=0x77"));
+2 -2
View File
@@ -160,7 +160,7 @@ boolean Plugin_109(byte function, struct EventStruct *event, String& string)
case PLUGIN_I2C_HAS_ADDRESS:
case PLUGIN_WEBFORM_SHOW_I2C_PARAMS:
{
const int i2cAddressValues[] = { 0x3c, 0x3d };
const uint8_t i2cAddressValues[] = { 0x3c, 0x3d };
if (function == PLUGIN_WEBFORM_SHOW_I2C_PARAMS) {
addFormSelectorI2C(F("plugin_109_adr"), 2, i2cAddressValues, PCONFIG(0));
} else {
@@ -511,7 +511,7 @@ boolean Plugin_109(byte function, struct EventStruct *event, String& string)
if ((atempstr.length() > 0) && (Plugin_109_prev_temp != 99)) { // do not switch until the first temperature data arrives
float atemp = atempstr.toFloat();
if (atemp != 0.0) {
if (atemp != 0.0f) {
if ((UserVar[event->BaseVarIndex] > atemp) && (UserVar[event->BaseVarIndex + 1] < 1))
{
P109_setHeater(F("1"));
+1 -1
View File
@@ -63,7 +63,7 @@ boolean Plugin_110(uint8_t function, struct EventStruct *event, String& string)
case PLUGIN_I2C_HAS_ADDRESS:
case PLUGIN_WEBFORM_SHOW_I2C_PARAMS:
{
const int i2cAddressValues[] = { 0x29, 0x30 };
const uint8_t i2cAddressValues[] = { 0x29, 0x30 };
if (function == PLUGIN_WEBFORM_SHOW_I2C_PARAMS) {
addFormSelectorI2C(F("plugin_110_vl53l0x_i2c"), 2, i2cAddressValues, PCONFIG(0));
addFormNote(F("SDO Low=0x29, High=0x30"));
+1 -1
View File
@@ -64,7 +64,7 @@ boolean Plugin_112(uint8_t function, struct EventStruct *event, String& string)
case PLUGIN_I2C_HAS_ADDRESS:
case PLUGIN_WEBFORM_SHOW_I2C_PARAMS:
{
const int i2cAddressValues[1] = { AS7265X_ADDR };
const uint8_t i2cAddressValues[1] = { AS7265X_ADDR };
if (function == PLUGIN_WEBFORM_SHOW_I2C_PARAMS) {
addFormSelectorI2C(F("i2c_addr"), 1, i2cAddressValues, AS7265X_ADDR);
} else {
+1 -1
View File
@@ -58,7 +58,7 @@ boolean Plugin_113(uint8_t function, struct EventStruct *event, String& string)
case PLUGIN_I2C_HAS_ADDRESS:
case PLUGIN_WEBFORM_SHOW_I2C_PARAMS:
{
const int i2cAddressValues[] = { 0x29, 0x30 };
const uint8_t i2cAddressValues[] = { 0x29, 0x30 };
if (function == PLUGIN_WEBFORM_SHOW_I2C_PARAMS) {
addFormSelectorI2C(F("plugin_113_vl53l1x_i2c"), 2, i2cAddressValues, PCONFIG(0));
} else {
+2 -2
View File
@@ -58,7 +58,7 @@ boolean Plugin_114(uint8_t function, struct EventStruct *event, String& string)
case PLUGIN_I2C_HAS_ADDRESS:
case PLUGIN_WEBFORM_SHOW_I2C_PARAMS:
{
const int i2cAddressValues[2] = { 0x10, 0x11 };
const uint8_t i2cAddressValues[2] = { 0x10, 0x11 };
if (function == PLUGIN_WEBFORM_SHOW_I2C_PARAMS) {
addFormSelectorI2C(F("plugin_114_veml6075_i2c"), 2, i2cAddressValues, PCONFIG(0));
addFormNote(F("SDO Low=0x10, High=0x11"));
@@ -154,7 +154,7 @@ boolean Plugin_114(uint8_t function, struct EventStruct *event, String& string)
log += F(" / Dynamic Mode: ");
log += PCONFIG(2);
log += F(" / divisor: ");
log += String(pow(2, PCONFIG(1) - 1));
log += String(1 << (PCONFIG(1) - 1));
log += F(" / UVA: ");
log += UserVar[event->BaseVarIndex];
log += F(" / UVB: ");
+1 -1
View File
@@ -92,7 +92,7 @@ boolean Plugin_115(uint8_t function, struct EventStruct *event, String& string)
{
/*
uint8_t choice = P115_I2CADDR;
int optionValues[1] = { 0x36 };
uint8_t optionValues[1] = { 0x36 };
addFormSelectorI2C(F("plugin_115_i2c"), 1, optionValues, choice);
*/
break;
+1 -1
View File
@@ -138,7 +138,7 @@ boolean Plugin_xxx(uint8_t function, struct EventStruct *event, String& string)
// Called to show the I2C parameters in the web interface (only called for I2C devices)
uint8_t choice = Pxxx_I2C_ADDR; // define to get the stored I2C address (e.g. PCONFIG(1))
int optionValues[16];
uint8_t optionValues[16];
for (uint8_t x = 0; x < 16; x++)
{
+3 -2
View File
@@ -1101,6 +1101,7 @@ To create/register a plugin, you have to :
#define USES_P097 // Touch (ESP32)
//#define USES_P099 // XPT2046 Touchscreen
#define USES_P098 // PWM motor (relies on iRAM, cannot be combined with all other plugins)
#define USES_P105 // AHT10/20/21
#endif
#ifdef PLUGIN_SET_TESTING_B
@@ -1377,7 +1378,7 @@ To create/register a plugin, you have to :
#define USES_P104 // Atlas EZO EC
#endif
#ifndef USES_P105
#define USES_P105 // Atlas EZO_ORP
#define USES_P105 // AHT10/20/21
#endif
#ifndef USES_P108
#define USES_P108 // DDS238-x ZN MODBUS energy meter (was P224 in the Playground)
@@ -1401,7 +1402,7 @@ To create/register a plugin, you have to :
#define USES_P114 // VEML6075 UVA/UVB sensor
#endif
#ifndef USES_P115
#define USES_P115 //
#define USES_P115 // Fuel gauge MAX1704x
#endif
#ifndef USES_P116
#define USES_P116 //
+5 -5
View File
@@ -613,7 +613,7 @@ void SetWiFiTXpower(float dBm, float rssi) {
if (dBm < 0) {
val = WIFI_POWER_MINUS_1dBm;
dBm = -1;
} else if (dBm < 3.5) {
} else if (dBm < 3.5f) {
val = WIFI_POWER_2dBm;
dBm = 2;
} else if (dBm < 6) {
@@ -634,18 +634,18 @@ void SetWiFiTXpower(float dBm, float rssi) {
} else if (dBm < 16) {
val = WIFI_POWER_15dBm;
dBm = 15;
} else if (dBm < 17.75) {
} else if (dBm < 17.75f) {
val = WIFI_POWER_17dBm;
dBm = 17;
} else if (dBm < 18.75) {
} else if (dBm < 18.75f) {
val = WIFI_POWER_18_5dBm;
dBm = 18.5;
} else if (dBm < 19.25) {
} else if (dBm < 19.25f) {
val = WIFI_POWER_19dBm;
dBm = 19;
} else {
val = WIFI_POWER_19_5dBm;
dBm = 19.5;
dBm = 19.5f;
}
esp_wifi_set_max_tx_power(val);
//esp_wifi_get_max_tx_power(&val);
+4 -4
View File
@@ -168,7 +168,7 @@ String format_msec_duration(int64_t duration) {
// Formula: http://www.ajdesigner.com/phphumidity/dewpoint_equation_dewpoint_temperature.php
// Td = (f/100)^(1/8) * (112 + 0.9*T) + 0.1*T - 112
float compute_dew_point_temp(float temperature, float humidity_percentage) {
return pow(humidity_percentage / 100.0f, 0.125f) *
return powf(humidity_percentage / 100.0f, 0.125f) *
(112.0f + 0.9f*temperature) + 0.1f*temperature - 112.0f;
}
@@ -176,7 +176,7 @@ float compute_dew_point_temp(float temperature, float humidity_percentage) {
// Formula: http://www.ajdesigner.com/phphumidity/dewpoint_equation_relative_humidity.php
// f = 100 * ((112 - 0.1*T + Td) / (112 + 0.9 * T))^8
float compute_humidity_from_dewpoint(float temperature, float dew_temperature) {
return 100.0f * pow((112.0f - 0.1f * temperature + dew_temperature) /
return 100.0f * powf((112.0f - 0.1f * temperature + dew_temperature) /
(112.0f + 0.9f * temperature), 8);
}
@@ -192,7 +192,7 @@ float pressureElevation(float atmospheric, float altitude) {
// Note that using the equation from wikipedia can give bad results
// at high altitude. See this thread for more information:
// http://forums.adafruit.com/viewtopic.php?f=22&t=58064
return atmospheric / pow(1.0f - (altitude / 44330.0f), 5.255f);
return atmospheric / powf(1.0f - (altitude / 44330.0f), 5.255f);
}
float altitudeFromPressure(float atmospheric, float seaLevel)
@@ -203,7 +203,7 @@ float altitudeFromPressure(float atmospheric, float seaLevel)
// Note that using the equation from wikipedia can give bad results
// at high altitude. See this thread for more information:
// http://forums.adafruit.com/viewtopic.php?f=22&t=58064
return 44330.0f * (1.0f - pow(atmospheric / seaLevel, 0.1903f));
return 44330.0f * (1.0f - powf(atmospheric / seaLevel, 0.1903f));
}
+2 -2
View File
@@ -374,7 +374,7 @@ bool Dallas_readTemp(const uint8_t ROM[8], float *value, int8_t gpio_pin_rx, int
if (DSTemp == 0x550) { // power-on reset value
return false;
}
*value = (float(DSTemp) * 0.0625);
*value = (float(DSTemp) * 0.0625f);
}
else if (ROM[0] == 0x10) // DS1820 DS18S20
{
@@ -384,7 +384,7 @@ bool Dallas_readTemp(const uint8_t ROM[8], float *value, int8_t gpio_pin_rx, int
DSTemp = (ScratchPad[1] << 11) | ScratchPad[0] << 3;
DSTemp = ((DSTemp & 0xfff0) << 3) - 16 +
(((ScratchPad[7] - ScratchPad[6]) << 7) / ScratchPad[7]);
*value = float(DSTemp) * 0.0078125;
*value = float(DSTemp) * 0.0078125f;
}
return true;
}
+3 -3
View File
@@ -158,7 +158,7 @@ unsigned long ESPEasy_time::now() {
if (statusNTPInitialized && time_offset < 1.0) {
// Clock instability in msec/second
timeWander = ((time_offset * 1000000.0f) / timePassedSince(lastTimeWanderCalculation));
timeWander = ((time_offset * 1000000.0) / timePassedSince(lastTimeWanderCalculation));
}
lastTimeWanderCalculation = millis();
@@ -199,7 +199,7 @@ unsigned long ESPEasy_time::now() {
if ((-86400 < time_offset) && (time_offset < 86400)) {
// Only useful to show adjustment if it is less than a day.
log += F(" Time adjusted by ");
log += String(time_offset * 1000.0f);
log += String(time_offset * 1000.0);
log += F(" msec. Wander: ");
log += String(timeWander, 3);
log += F(" msec/second");
@@ -277,7 +277,7 @@ bool ESPEasy_time::systemTimePresent() const {
case timeSource_t::Manual_set:
return true;
}
return nextSyncTime > 0 || Settings.UseNTP() || externalUnixTime_d > 0.0f;
return nextSyncTime > 0 || Settings.UseNTP() || externalUnixTime_d > 0.0;
}
bool ESPEasy_time::getNtpTime(double& unixTime_d)
+21 -13
View File
@@ -343,18 +343,18 @@ void HSV2RGB(float H, float S, float I, int rgb[3]) {
// Math! Thanks in part to Kyle Miller.
if (H < 2.09439f) {
r = 255 * I / 3 * (1 + S * cos(H) / cos(1.047196667f - H));
g = 255 * I / 3 * (1 + S * (1 - cos(H) / cos(1.047196667f - H)));
r = 255 * I / 3 * (1 + S * cosf(H) / cosf(1.047196667f - H));
g = 255 * I / 3 * (1 + S * (1 - cosf(H) / cosf(1.047196667f - H)));
b = 255 * I / 3 * (1 - S);
} else if (H < 4.188787f) {
H = H - 2.09439f;
g = 255 * I / 3 * (1 + S * cos(H) / cos(1.047196667f - H));
b = 255 * I / 3 * (1 + S * (1 - cos(H) / cos(1.047196667f - H)));
g = 255 * I / 3 * (1 + S * cosf(H) / cosf(1.047196667f - H));
b = 255 * I / 3 * (1 + S * (1 - cosf(H) / cosf(1.047196667f - H)));
r = 255 * I / 3 * (1 - S);
} else {
H = H - 4.188787f;
b = 255 * I / 3 * (1 + S * cos(H) / cos(1.047196667f - H));
r = 255 * I / 3 * (1 + S * (1 - cos(H) / cos(1.047196667f - H)));
b = 255 * I / 3 * (1 + S * cosf(H) / cosf(1.047196667f - H));
r = 255 * I / 3 * (1 + S * (1 - cosf(H) / cosf(1.047196667f - H)));
g = 255 * I / 3 * (1 - S);
}
rgb[0] = r;
@@ -377,24 +377,24 @@ void HSV2RGBW(float H, float S, float I, int rgbw[4]) {
I = I > 0 ? (I < 1 ? I : 1) : 0;
if (H < 2.09439f) {
cos_h = cos(H);
cos_1047_h = cos(1.047196667f - H);
cos_h = cosf(H);
cos_1047_h = cosf(1.047196667f - H);
r = S * 255 * I / 3 * (1 + cos_h / cos_1047_h);
g = S * 255 * I / 3 * (1 + (1 - cos_h / cos_1047_h));
b = 0;
w = 255 * (1 - S) * I;
} else if (H < 4.188787f) {
H = H - 2.09439f;
cos_h = cos(H);
cos_1047_h = cos(1.047196667f - H);
cos_h = cosf(H);
cos_1047_h = cosf(1.047196667f - H);
g = S * 255 * I / 3 * (1 + cos_h / cos_1047_h);
b = S * 255 * I / 3 * (1 + (1 - cos_h / cos_1047_h));
r = 0;
w = 255 * (1 - S) * I;
} else {
H = H - 4.188787f;
cos_h = cos(H);
cos_1047_h = cos(1.047196667f - H);
cos_h = cosf(H);
cos_1047_h = cosf(1.047196667f - H);
b = S * 255 * I / 3 * (1 + cos_h / cos_1047_h);
r = S * 255 * I / 3 * (1 + (1 - cos_h / cos_1047_h));
g = 0;
@@ -447,13 +447,21 @@ int getUptimeMinutes() {
/******************************************************************************
* scan an int array of specified size for a value
*****************************************************************************/
bool intArrayContains(const int arraySize, const int array[], const int value){
bool intArrayContains(const int arraySize, const int array[], const int& value){
for(int i = 0; i < arraySize; i++) {
if (array[i] == value) return true;
}
return false;
}
bool intArrayContains(const int arraySize, const uint8_t array[], const uint8_t& value) {
for(int i = 0; i < arraySize; i++) {
if (array[i] == value) return true;
}
return false;
}
#ifndef BUILD_NO_RAM_TRACKER
void logMemUsageAfter(const __FlashStringHelper * function, int value) {
// Store free memory in an int, as subtracting may sometimes result in negative value.
+2 -1
View File
@@ -177,7 +177,8 @@ int getLoopCountPerSec();
int getUptimeMinutes();
bool intArrayContains(const int arraySize, const int array[], const int value);
bool intArrayContains(const int arraySize, const int array[], const int& value);
bool intArrayContains(const int arraySize, const uint8_t array[], const uint8_t& value);
#ifndef BUILD_NO_RAM_TRACKER
void logMemUsageAfter(const __FlashStringHelper * function, int value = -1);
+1 -1
View File
@@ -528,7 +528,7 @@ String send_via_http(const String& logIdentifier,
#if defined(CORE_POST_2_6_0) || defined(ESP32)
http.begin(client, host, port, uri, false); // HTTP
#else
http.begin(host, port, uri);
http.begin(client, host, port, uri);
#endif
{
+1 -1
View File
@@ -374,7 +374,7 @@ void P015_data_struct::getLux(unsigned char gain,
// Determine lux per datasheet equations:
if (ratio < 0.5f)
{
lux = 0.0304f * d0 - 0.062f * d0 * pow(ratio, 1.4);
lux = 0.0304f * d0 - 0.062f * d0 * powf(ratio, 1.4f);
} else if (ratio < 0.61f)
{
lux = 0.0224f * d0 - 0.031f * d1;
+1 -1
View File
@@ -162,7 +162,7 @@ void P020_Task::handleSerialIn(struct EventStruct *event) {
do {
if (ser2netSerial->available()) {
if (serial_buffer.length() > P020_RX_BUFFER) {
if (serial_buffer.length() > static_cast<size_t>(P020_RX_BUFFER)) {
addLog(LOG_LEVEL_DEBUG, F("Ser2Net : Error: Buffer overflow, discarded input."));
ser2netSerial->read();
}
+1 -1
View File
@@ -97,7 +97,7 @@ void P022_data_struct::Plugin_022_Frequency(int address, uint16_t freq)
int i2cAddress = address;
Plugin_022_writeRegister(i2cAddress, PLUGIN_022_PCA9685_MODE1, (uint8_t)0x0);
freq *= 0.9;
freq *= 0.9f;
// prescale = 25000000 / 4096;
uint16_t prescale = 6103;
+191
View File
@@ -0,0 +1,191 @@
#include "../PluginStructs/P105_data_struct.h"
#ifdef USES_P105
# include "../Helpers/Convert.h"
struct AHTx_Status {
inline AHTx_Status(uint8_t stat) : status(stat) {}
inline bool valid() const {
return status != 0xFF;
}
inline bool calibrated() const {
return (status & (1 << 3)) != 0;
}
inline bool busy() const {
return (status & (1 << 7)) != 0;
}
const uint8_t status;
};
AHTx_Device::AHTx_Device(uint8_t addr, AHTx_device_type type) :
i2cAddress(addr),
device_type(type),
last_hum_val(0.0f),
last_temp_val(0.0f) {}
const __FlashStringHelper * AHTx_Device::getDeviceName() const {
switch (device_type) {
case AHTx_device_type::AHT10_DEVICE: return F("AHT10");
case AHTx_device_type::AHT20_DEVICE: return F("AHT20");
case AHTx_device_type::AHT21_DEVICE: return F("AHT21");
}
return F("AHTx");
}
bool AHTx_Device::initialize() {
const uint8_t cmd_init = (device_type == AHTx_device_type::AHT10_DEVICE) ? 0xE1 : 0xBE;
return I2C_write16_reg(i2cAddress, cmd_init, 0x0800);
}
bool AHTx_Device::triggerMeasurement() {
return I2C_write16_reg(i2cAddress, 0xAC, 0x3300); // measurement time takes over 80 msec
}
bool AHTx_Device::softReset() {
return I2C_write8(i2cAddress, 0xBA); // soft reset takes less than 20 msec
}
uint8_t AHTx_Device::readStatus() {
return I2C_read8(i2cAddress, NULL);
}
bool AHTx_Device::readData() {
const uint8_t data_len = 6;
// I2C_read8 len
if (Wire.requestFrom(i2cAddress, data_len) == 0) {
return false;
}
uint8_t data[data_len];
for (uint8_t i = 0; i < data_len; ++i) {
data[i] = Wire.read();
}
// check status
AHTx_Status status = data[0];
if (!(status.valid() && status.calibrated())) {
return false;
}
// 20 bits humidity value
uint32_t value = data[1];
value = (value << 8) | data[2];
value = (value << 4) | (data[3] >> 4);
last_hum_val = (static_cast<float>(value) / (1 << 20)) * 100.0f;
// 20 bits temperature value
value = data[3] & 0x0F;
value = (value << 8) | data[4];
value = (value << 8) | data[5];
last_temp_val = ((static_cast<float>(value) / (1 << 20)) * 200.0f) - 50.0f;
return true;
}
P105_data_struct::P105_data_struct(uint8_t addr, AHTx_device_type dev) :
device(addr, dev),
state(AHTx_state::AHTx_Uninitialized),
last_measurement(0),
trigger_time(0) {}
bool P105_data_struct::initialized() const {
return state != AHTx_state::AHTx_Uninitialized;
}
void P105_data_struct::setUninitialized() {
state = AHTx_state::AHTx_Uninitialized;
}
// Perform the measurements with interval
bool P105_data_struct::updateMeasurements(unsigned long task_index) {
const unsigned long current_time = millis();
if (!initialized()) {
String log;
log.reserve(30);
if (!device.initialize()) {
log = getDeviceName();
log += F(" : unable to initialize");
addLog(LOG_LEVEL_ERROR, log);
return false;
}
log = getDeviceName();
log += F(" : initialized");
addLog(LOG_LEVEL_INFO, log);
trigger_time = current_time;
state = AHTx_state::AHTx_Trigger_measurement;
return false;
}
if ((state != AHTx_state::AHTx_Wait_for_samples) && (state != AHTx_state::AHTx_Trigger_measurement)) {
if (!timeOutReached(last_measurement + (Settings.TaskDeviceTimer[task_index] * 1000))) {
// Timeout has not yet been reached.
return false;
}
trigger_time = current_time;
state = AHTx_state::AHTx_Trigger_measurement;
}
// state: AHTx_Wait_for_samples or AHTx_Trigger_measurement
AHTx_Status status = device.readStatus();
if (status.valid() && status.calibrated() && !status.busy()) {
if (state == AHTx_state::AHTx_Trigger_measurement) {
device.triggerMeasurement();
trigger_time = current_time;
state = AHTx_state::AHTx_Wait_for_samples;
return false;
}
// state: AHTx_Wait_for_samples
if (!device.readData()) {
return false;
}
last_measurement = current_time;
state = AHTx_state::AHTx_New_values;
if (loglevelActiveFor(LOG_LEVEL_DEBUG)) { // Log raw measuerd values only on level DEBUG
String log;
log.reserve(50); // Prevent re-allocation
log = getDeviceName();
log += F(" : humidity ");
log += device.getHumidity();
log += F("% temperature ");
log += device.getTemperature();
log += 'C';
addLog(LOG_LEVEL_DEBUG, log);
}
return true;
}
if (timePassedSince(trigger_time) > 1000) {
// should not happen
String log;
log.reserve(15); // Prevent re-allocation
log = getDeviceName();
log += F(" : reset");
addLog(LOG_LEVEL_ERROR, log);
device.softReset();
state = AHTx_state::AHTx_Uninitialized;
}
return false;
}
#endif // ifdef USES_P105
+83
View File
@@ -0,0 +1,83 @@
#ifndef PLUGINSTRUCTS_P105_DATA_STRUCT_H
#define PLUGINSTRUCTS_P105_DATA_STRUCT_H
#include "../../_Plugin_Helper.h"
#ifdef USES_P105
enum class AHTx_device_type {
AHT10_DEVICE = 10,
AHT20_DEVICE = 20,
AHT21_DEVICE = 21,
};
enum class AHTx_state {
AHTx_Uninitialized = 0,
AHTx_Initialized,
AHTx_Trigger_measurement,
AHTx_Wait_for_samples,
AHTx_New_values,
AHTx_Values_read
};
class AHTx_Device {
public:
AHTx_Device(uint8_t addr,
AHTx_device_type type);
const __FlashStringHelper* getDeviceName() const;
inline float getHumidity() const {
return last_hum_val;
}
inline float getTemperature() const {
return last_temp_val;
}
bool initialize();
bool triggerMeasurement();
bool softReset();
uint8_t readStatus();
bool readData();
protected:
const uint8_t i2cAddress;
const AHTx_device_type device_type;
float last_hum_val;
float last_temp_val;
};
struct P105_data_struct : public PluginTaskData_base {
P105_data_struct(uint8_t addr,
AHTx_device_type dev);
inline String getDeviceName() const {
return device.getDeviceName();
}
inline float getHumidity() const {
return device.getHumidity();
}
inline float getTemperature() const {
return device.getTemperature();
}
bool initialized() const;
void setUninitialized();
// Perform the measurements with interval
bool updateMeasurements(unsigned long task_index);
AHTx_Device device;
AHTx_state state;
unsigned long last_measurement;
unsigned long trigger_time;
};
#endif // ifdef USES_P105
#endif // PLUGINSTRUCTS_P105_DATA_STRUCT_H
+3 -3
View File
@@ -38,10 +38,10 @@ bool P114_data_struct::read_sensor(float& _UVA, float& _UVB, float& _UVIndex) {
// Calculate the UV Index, valid in open air not behind glass!
UVAComp = (UVData[0] - UVData[1]) - ACoef * (UVData[3] - UVData[1]) - BCoef * (UVData[4] - UVData[1]);
UVBComp = (UVData[2] - UVData[1]) - CCoef * (UVData[3] - UVData[1]) - DCoef * (UVData[4] - UVData[1]);
_UVIndex = ((UVBComp * UVBresponsivity) + (UVAComp * UVAresponsivity)) / 2.;
_UVIndex = ((UVBComp * UVBresponsivity) + (UVAComp * UVAresponsivity)) / 2.0f;
_UVA = UVData[0] / pow(2, IT - 1); // UVA light sensitivity increases linear with integration time
_UVB = UVData[2] / pow(2, IT - 1); // UVB light sensitivity increases linear with integration time
_UVA = static_cast<float>(UVData[0]) / static_cast<float>(1 << (IT - 1)); // UVA light sensitivity increases linear with integration time
_UVB = static_cast<float>(UVData[2]) / static_cast<float>(1 << (IT - 1)); // UVB light sensitivity increases linear with integration time
// float UVASensitivity = 0.93/(static_cast<float>(IT + 1)); // UVA light sensitivity increases with integration time
// float UVBSensitivity = 2.10/(static_cast<float>(IT + 1)); // UVB light sensitivity increases with integration time
+3 -1
View File
@@ -200,6 +200,8 @@ String getKnownI2Cdevice(uint8_t address) {
result += F("MAX1704x");
break;
case 0x38:
result = F("PCF8574A,AHT10/20/21");
break;
case 0x3A:
case 0x3B:
case 0x3E:
@@ -207,7 +209,7 @@ String getKnownI2Cdevice(uint8_t address) {
result += F("PCF8574A");
break;
case 0x39:
result += F("PCF8574A,TSL2561,APDS9960");
result = F("PCF8574A,TSL2561,APDS9960,AHT10");
break;
case 0x3C:
case 0x3D:
+1 -1
View File
@@ -331,7 +331,7 @@ void addFormPinSelectI2C(const String& label, const String& id, int choice)
addPinSelect(PinSelectPurpose::I2C, id, choice);
}
void addFormSelectorI2C(const String& id, int addressCount, const int addresses[], int selectedIndex
void addFormSelectorI2C(const String& id, int addressCount, const uint8_t addresses[], int selectedIndex
#ifdef ENABLE_TOOLTIPS
, const String& tooltip
#endif // ifdef ENABLE_TOOLTIPS
+1 -1
View File
@@ -207,7 +207,7 @@ void addFormPinSelectI2C(const String& label,
void addFormSelectorI2C(const String& id,
int addressCount,
const int addresses[],
const uint8_t addresses[],
int selectedIndex
#ifdef ENABLE_TOOLTIPS
,
+1 -1
View File
@@ -42,7 +42,7 @@ void handle_timingstats() {
const float timespan = timeSinceLastReset / 1000.0f;
addFormHeader(F("Statistics"));
addRowLabel(F("Start Period"));
struct tm startPeriod = node_time.addSeconds(node_time.tm, -1.0 * timespan, false);
struct tm startPeriod = node_time.addSeconds(node_time.tm, -1.0f * timespan, false);
addHtml(ESPEasy_time::getDateTimeString(startPeriod, '-', ':', ' ', false));
addRowLabelValue(LabelType::LOCAL_TIME);
addRowLabel(F("Time span"));
+5 -5
View File
@@ -1152,7 +1152,7 @@ void getWiFi_RSSI_icon(int rssi, int width_pixels)
{
const int nbars_filled = (rssi + 100) / 8;
int nbars = 5;
int white_between_bar = (static_cast<float>(width_pixels) / nbars) * 0.2;
int white_between_bar = (static_cast<float>(width_pixels) / nbars) * 0.2f;
if (white_between_bar < 1) { white_between_bar = 1; }
const int barWidth = (width_pixels - (nbars - 1) * white_between_bar) / nbars;
@@ -1203,7 +1203,7 @@ void getConfig_dat_file_layout() {
// Text labels
float textXoffset = SVG_BAR_WIDTH + 2;
float textYoffset = yOffset + 0.9 * SVG_BAR_HEIGHT;
float textYoffset = yOffset + 0.9f * SVG_BAR_HEIGHT;
createSvgTextElement(SettingsType::getSettingsFileName(SettingsType::Enum::TaskSettings_Type), textXoffset, textYoffset);
addHtml(F("</svg>\n"));
@@ -1236,7 +1236,7 @@ void getStorageTableSVG(SettingsType::Enum settingsType) {
// Text labels
float textXoffset = SVG_BAR_WIDTH + 2;
float textYoffset = yOffset + 0.9 * SVG_BAR_HEIGHT;
float textYoffset = yOffset + 0.9f * SVG_BAR_HEIGHT;
createSvgTextElement(formatHumanReadable(offset, 1024), textXoffset, textYoffset);
textXoffset = SVG_BAR_WIDTH + 60;
createSvgTextElement(formatHumanReadable(max_size, 1024), textXoffset, textYoffset);
@@ -1255,7 +1255,7 @@ void getStorageTableSVG(SettingsType::Enum settingsType) {
// Text labels
float textXoffset = SVG_BAR_WIDTH + 2;
float textYoffset = yOffset + 0.9 * SVG_BAR_HEIGHT;
float textYoffset = yOffset + 0.9f * SVG_BAR_HEIGHT;
if (struct_size != 0) {
String text = formatHumanReadable(struct_size, 1024);
@@ -1309,7 +1309,7 @@ void getPartitionTableSVG(uint8_t pType, unsigned int partitionColor) {
createSvgHorRectPath(0xcdcdcd, 0, yOffset, realSize, SVG_BAR_HEIGHT - 2, realSize, SVG_BAR_WIDTH);
createSvgHorRectPath(partitionColor, _mypart->address, yOffset, _mypart->size, SVG_BAR_HEIGHT - 2, realSize, SVG_BAR_WIDTH);
float textXoffset = SVG_BAR_WIDTH + 2;
float textYoffset = yOffset + 0.9 * SVG_BAR_HEIGHT;
float textYoffset = yOffset + 0.9f * SVG_BAR_HEIGHT;
createSvgTextElement(formatHumanReadable(_mypart->size, 1024), textXoffset, textYoffset);
textXoffset = SVG_BAR_WIDTH + 60;
createSvgTextElement(_mypart->label, textXoffset, textYoffset);