Merge branch 'mega' into feature/ESP32_S2_support
@@ -137,7 +137,7 @@ NB: Only acceptable channel checkboxes (0-7/0-3/0-1) will be shown, depending on
|
||||
SPI Interface
|
||||
-------------
|
||||
|
||||
When using devices that are connected via the SPI interface (`Wikipedia: SPI <https://en.wikipedia.org/wiki/Serial_Peripheral_Interface>`_), the interface must be initialized during boot. This can be enabled here. For ESP32 there is the option to select either the Hardware SPI (HSPI) interface or the Virtual SPI (VSPI) interface (software controlled).
|
||||
When using devices that are connected via the SPI interface (`Wikipedia: SPI <https://en.wikipedia.org/wiki/Serial_Peripheral_Interface>`_), the interface must be initialized during boot. This can be enabled here. For ESP32 there is the option to select the HSPI (often called Hardware SPI) interface, the VSPI (often called Virtual SPI) interface, or select User-defined GPIO pins for the ``SCLK``, ``MISO`` and ``MOSI`` signals.
|
||||
|
||||
The common SPI pins are shown here.
|
||||
|
||||
@@ -151,11 +151,30 @@ Other SPI pins to be used are device specific, and need to be configured from th
|
||||
|
||||
.. image:: Hardware_SPIInterfaceESP32.png
|
||||
|
||||
*For ESP32, select the desired interface:*
|
||||
*For ESP32, select the desired configuration:*
|
||||
|
||||
.. image:: Hardware_SPIInterfaceESP32_Select.png
|
||||
|
||||
NB: When using the VSPI interface and also the I2C interface is used, another pin has to be selected for I2C GPIO -> SCL, as its configuration is fixed for the VSPI setting.
|
||||
NB: When using the VSPI configuration and also the I2C interface is used, another pin has to be selected for I2C GPIO -> SCL, as its configuration is fixed for the VSPI setting.
|
||||
|
||||
When selecting the *User-defined* options, 3 extra input fields are displayed, where the ``SCLK``, ``MISO`` and ``MOSI`` GPIO pins have to be selected. Nearly all pins can be used, but for the output signals ``SCLK`` and ``MOSI`` **no** *input-only* pins should be selected!
|
||||
|
||||
.. image:: Hardware_SPIInterfaceESP32_UserDefined.png
|
||||
|
||||
.. warning::
|
||||
When changing the setting for **Init SPI**, or changing any of the User-defined GPIO pins, the ESP32 unit needs a hardware reset. This can be achieved by pressing the reset button (when available, sometimes labelled ``EN`` or ``RST``), or by completely removing the power for ~30 seconds. Also take into account here that units with a backup battery (f.e. some LilyGo and Waveshare ESP32 models) may keep power on the unit, so specific measures may have to be taken!
|
||||
|
||||
NB: When selecting the *User-defined* option, **all 3 GPIO pins should be set**, or an error message will be displayed when the page is saved, and the SPI interface will not be enabled at the next boot.
|
||||
|
||||
.. image:: Hardware_SPIpinsError.png
|
||||
|
||||
-------
|
||||
SD Card
|
||||
-------
|
||||
|
||||
When the compile-time option for SD-card support is enabled, the ``CS`` pin for the SD-card interface can be configured here. For the SD-card interface to work, **Init SPI** should also be enabled.
|
||||
|
||||
.. image:: Hardware_SDCard.png
|
||||
|
||||
--------
|
||||
Ethernet
|
||||
|
||||
|
After Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 7.2 KiB After Width: | Height: | Size: 8.3 KiB |
|
Before Width: | Height: | Size: 9.6 KiB After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 2.0 KiB |
@@ -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
|
||||
...
|
||||
|
||||
|
||||
@@ -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`
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 °);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -403,7 +403,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);
|
||||
|
||||
@@ -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 °);
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ boolean Plugin_105(uint8_t function, struct EventStruct *event, String& string)
|
||||
case PLUGIN_I2C_HAS_ADDRESS:
|
||||
case PLUGIN_WEBFORM_SHOW_I2C_PARAMS:
|
||||
{
|
||||
const int i2cAddressValues[2] = { 0x38, 0x39 };
|
||||
const uint8_t i2cAddressValues[2] = { 0x38, 0x39 };
|
||||
|
||||
if (function == PLUGIN_WEBFORM_SHOW_I2C_PARAMS) {
|
||||
addFormSelectorI2C(F("i2c_addr"), 2, i2cAddressValues, PCONFIG(0));
|
||||
|
||||
@@ -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"));
|
||||
|
||||
@@ -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: ");
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#endif // if defined(ESP32)
|
||||
|
||||
|
||||
#define BUILD 20114 // git version e.g. "20103" can be read as "2.1.03" (stored in int16_t)
|
||||
#define BUILD 20115 // git version e.g. "20103" can be read as "2.1.03" (stored in int16_t)
|
||||
#ifndef BUILD_NOTES
|
||||
#if defined(ESP8266)
|
||||
# define BUILD_NOTES " - Mega"
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "../Globals/CPlugins.h"
|
||||
#include "../CustomBuild/ESPEasyLimits.h"
|
||||
#include "../DataStructs/DeviceStruct.h"
|
||||
#include "../DataTypes/SPI_options.h"
|
||||
#include "../../ESPEasy_common.h"
|
||||
|
||||
template<unsigned int N_TASKS>
|
||||
@@ -540,23 +541,31 @@ bool SettingsStruct_tmpl<N_TASKS>::getSPI_pins(int8_t spi_gpios[3]) const {
|
||||
spi_gpios[0] = -1;
|
||||
spi_gpios[1] = -1;
|
||||
spi_gpios[2] = -1;
|
||||
if (InitSPI > 0) {
|
||||
if (isSPI_valid()) {
|
||||
# ifdef ESP32
|
||||
switch (InitSPI) {
|
||||
case 1:
|
||||
const SPI_Options_e SPI_selection = static_cast<SPI_Options_e>(InitSPI);
|
||||
switch (SPI_selection) {
|
||||
case SPI_Options_e::Vspi:
|
||||
{
|
||||
spi_gpios[0] = 18; spi_gpios[1] = 19; spi_gpios[2] = 23;
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
case SPI_Options_e::Hspi:
|
||||
{
|
||||
spi_gpios[0] = 14; // HSPI_SCLK
|
||||
spi_gpios[1] = 12; // HSPI_MISO
|
||||
spi_gpios[2] = 13; // HSPI_MOSI
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
case SPI_Options_e::UserDefined:
|
||||
{
|
||||
spi_gpios[0] = SPI_SCLK_pin;
|
||||
spi_gpios[1] = SPI_MISO_pin;
|
||||
spi_gpios[2] = SPI_MOSI_pin;
|
||||
break;
|
||||
}
|
||||
case SPI_Options_e::None:
|
||||
return false;
|
||||
}
|
||||
# endif // ifdef ESP32
|
||||
# ifdef ESP8266
|
||||
@@ -579,6 +588,18 @@ bool SettingsStruct_tmpl<N_TASKS>::isSPI_pin(int8_t pin) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
template<unsigned int N_TASKS>
|
||||
bool SettingsStruct_tmpl<N_TASKS>::isSPI_valid() const {
|
||||
return !((InitSPI == static_cast<int>(SPI_Options_e::None)) ||
|
||||
((InitSPI == static_cast<int>(SPI_Options_e::UserDefined)) &&
|
||||
((SPI_SCLK_pin == -1) ||
|
||||
(SPI_MISO_pin == -1) ||
|
||||
(SPI_MOSI_pin == -1) ||
|
||||
(SPI_SCLK_pin == SPI_MISO_pin) ||
|
||||
(SPI_MISO_pin == SPI_MOSI_pin) ||
|
||||
(SPI_MOSI_pin == SPI_SCLK_pin)))); // Checks
|
||||
}
|
||||
|
||||
template<unsigned int N_TASKS>
|
||||
bool SettingsStruct_tmpl<N_TASKS>::isI2C_pin(int8_t pin) const {
|
||||
if (pin < 0) return false;
|
||||
|
||||
@@ -179,6 +179,9 @@ class SettingsStruct_tmpl
|
||||
// Return true when pin is one of the SPI pins and SPI is enabled
|
||||
bool isSPI_pin(int8_t pin) const;
|
||||
|
||||
// Return true when SPI enabled and opt. user defined pins valid.
|
||||
bool isSPI_valid() const;
|
||||
|
||||
// Return true when pin is one of the configured I2C pins.
|
||||
bool isI2C_pin(int8_t pin) const;
|
||||
|
||||
@@ -238,7 +241,7 @@ class SettingsStruct_tmpl
|
||||
unsigned long ConnectionFailuresThreshold;
|
||||
int16_t TimeZone;
|
||||
boolean MQTTRetainFlag_unused;
|
||||
uint8_t InitSPI; //0 = disabled, 1= enabled but for ESP32 there is option 2= SPI2
|
||||
uint8_t InitSPI; //0 = disabled, 1= enabled but for ESP32 there is option 2= SPI2 9 = User defined, see src/src/WebServer/HardwarePage.h enum SPI_Options_e
|
||||
// FIXME TD-er: Must change to cpluginID_t, but then also another check must be added since changing the pluginID_t will also render settings incompatible
|
||||
uint8_t Protocol[CONTROLLER_MAX];
|
||||
uint8_t Notification[NOTIFICATION_MAX]; //notifications, point to a NPLUGIN id
|
||||
@@ -320,6 +323,10 @@ class SettingsStruct_tmpl
|
||||
uint8_t WiFi_TX_power = 70; // 70 = 17.5dBm. unit: 0.25 dBm
|
||||
int8_t WiFi_sensitivity_margin = 3; // Margin in dBm on top of sensitivity.
|
||||
uint8_t NumberExtraWiFiScans = 0;
|
||||
int8_t SPI_SCLK_pin = -1;
|
||||
int8_t SPI_MISO_pin = -1;
|
||||
int8_t SPI_MOSI_pin = -1;
|
||||
int8_t alignmentFiller0; // Should be reused, just added to keep up with alignment
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
#include "../DataTypes/SPI_options.h"
|
||||
|
||||
#ifdef ESP32
|
||||
const __FlashStringHelper* getSPI_optionToString(SPI_Options_e option) {
|
||||
switch (option) {
|
||||
case SPI_Options_e::None:
|
||||
return F("Disabled");
|
||||
case SPI_Options_e::Vspi:
|
||||
return F("VSPI: CLK=GPIO-18, MISO=GPIO-19, MOSI=GPIO-23");
|
||||
case SPI_Options_e::Hspi:
|
||||
return F("HSPI: CLK=GPIO-14, MISO=GPIO-12, MOSI=GPIO-13");
|
||||
case SPI_Options_e::UserDefined:
|
||||
return F("User-defined: CLK, MISO, MOSI GPIO-pins");
|
||||
}
|
||||
}
|
||||
|
||||
const __FlashStringHelper* getSPI_optionToShortString(SPI_Options_e option) {
|
||||
switch (option) {
|
||||
case SPI_Options_e::None:
|
||||
return F("Disabled");
|
||||
case SPI_Options_e::Vspi:
|
||||
return F("VSPI");
|
||||
case SPI_Options_e::Hspi:
|
||||
return F("HSPI");
|
||||
case SPI_Options_e::UserDefined:
|
||||
return F("User-defined SPI");
|
||||
}
|
||||
}
|
||||
|
||||
#endif // ifdef ESP32
|
||||
@@ -0,0 +1,18 @@
|
||||
#ifndef DATASTRUCTS_SPI_OPTIONS_H
|
||||
#define DATASTRUCTS_SPI_OPTIONS_H
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
enum class SPI_Options_e { // Do not change values as this is stored in the settings!
|
||||
None = 0,
|
||||
Vspi = 1,
|
||||
Hspi = 2,
|
||||
UserDefined = 9 // Leave some room for other, possible future, hardware-related options
|
||||
};
|
||||
|
||||
#ifdef ESP32
|
||||
const __FlashStringHelper* getSPI_optionToString(SPI_Options_e option);
|
||||
const __FlashStringHelper* getSPI_optionToShortString(SPI_Options_e option);
|
||||
#endif // ifdef ESP32
|
||||
|
||||
#endif // ifndef DATASTRUCTS_SPI_OPTIONS_H
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "../DataStructs/ESPEasy_EventStruct.h"
|
||||
|
||||
#include "../DataTypes/ESPEasy_plugin_functions.h"
|
||||
#include "../DataTypes/SPI_options.h"
|
||||
|
||||
#include "../ESPEasyCore/ESPEasyRules.h"
|
||||
#include "../ESPEasyCore/Serial.h"
|
||||
@@ -48,7 +49,7 @@ void sendData(struct EventStruct *event)
|
||||
createRuleEvents(event);
|
||||
}
|
||||
|
||||
if (Settings.UseValueLogger && (Settings.InitSPI > 0) && (Settings.Pin_sd_cs >= 0)) {
|
||||
if (Settings.UseValueLogger && (Settings.InitSPI > static_cast<int>(SPI_Options_e::None)) && (Settings.Pin_sd_cs >= 0)) {
|
||||
SendValueLogger(event->TaskIndex);
|
||||
}
|
||||
|
||||
|
||||
@@ -616,7 +616,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) {
|
||||
@@ -637,18 +637,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);
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
|
||||
#include "../DataStructs/TimingStats.h"
|
||||
|
||||
#include "../DataTypes/SPI_options.h"
|
||||
|
||||
#include "../ESPEasyCore/ESPEasy_Log.h"
|
||||
#include "../ESPEasyCore/ESPEasyNetwork.h"
|
||||
#include "../ESPEasyCore/ESPEasyWifi.h"
|
||||
@@ -289,6 +291,13 @@ String BuildFixes()
|
||||
// Disable periodical scanning as it does cause lots of strange issues.
|
||||
Settings.PeriodicalScanWiFi(false);
|
||||
}
|
||||
if (Settings.Build < 20115) {
|
||||
if (Settings.InitSPI != static_cast<int>(SPI_Options_e::UserDefined)) { // User-defined SPI pins set to None
|
||||
Settings.SPI_SCLK_pin = -1;
|
||||
Settings.SPI_MISO_pin = -1;
|
||||
Settings.SPI_MOSI_pin = -1;
|
||||
}
|
||||
}
|
||||
|
||||
Settings.Build = BUILD;
|
||||
return SaveSettings();
|
||||
|
||||
@@ -71,10 +71,10 @@ void run_compiletime_checks() {
|
||||
check_size<CRCStruct, 204u>();
|
||||
check_size<SecurityStruct, 593u>();
|
||||
#ifdef ESP32
|
||||
const unsigned int SettingsStructSize = (312 + 84 * TASKS_MAX);
|
||||
const unsigned int SettingsStructSize = (316 + 84 * TASKS_MAX);
|
||||
#endif
|
||||
#ifdef ESP8266
|
||||
const unsigned int SettingsStructSize = (288 + 84 * TASKS_MAX);
|
||||
const unsigned int SettingsStructSize = (292 + 84 * TASKS_MAX);
|
||||
#endif
|
||||
check_size<SettingsStruct, SettingsStructSize>();
|
||||
check_size<ControllerSettingsStruct, 820u>();
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "../Commands/GPIO.h"
|
||||
#include "../CustomBuild/ESPEasyLimits.h"
|
||||
#include "../DataTypes/SPI_options.h"
|
||||
#include "../ESPEasyCore/ESPEasyGPIO.h"
|
||||
#include "../ESPEasyCore/ESPEasy_Log.h"
|
||||
|
||||
@@ -120,23 +121,38 @@ void hardwareInit()
|
||||
initI2C();
|
||||
|
||||
// SPI Init
|
||||
if (Settings.InitSPI > 0)
|
||||
if (Settings.isSPI_valid())
|
||||
{
|
||||
SPI.setHwCs(false);
|
||||
|
||||
// MFD: for ESP32 enable the SPI on HSPI as the default is VSPI
|
||||
#ifdef ESP32
|
||||
|
||||
if (Settings.InitSPI == 2)
|
||||
{
|
||||
# define HSPI_MISO 12
|
||||
# define HSPI_MOSI 13
|
||||
# define HSPI_SCLK 14
|
||||
# define HSPI_SS 15
|
||||
SPI.begin(HSPI_SCLK, HSPI_MISO, HSPI_MOSI); // HSPI
|
||||
}
|
||||
else {
|
||||
SPI.begin(); // VSPI
|
||||
const SPI_Options_e SPI_selection = static_cast<SPI_Options_e>(Settings.InitSPI);
|
||||
switch (SPI_selection) {
|
||||
case SPI_Options_e::Hspi:
|
||||
{
|
||||
# define HSPI_MISO 12
|
||||
# define HSPI_MOSI 13
|
||||
# define HSPI_SCLK 14
|
||||
# define HSPI_SS 15
|
||||
SPI.begin(HSPI_SCLK, HSPI_MISO, HSPI_MOSI); // HSPI
|
||||
break;
|
||||
}
|
||||
case SPI_Options_e::UserDefined:
|
||||
{
|
||||
SPI.begin(Settings.SPI_SCLK_pin,
|
||||
Settings.SPI_MISO_pin,
|
||||
Settings.SPI_MOSI_pin); // User-defined SPI
|
||||
break;
|
||||
}
|
||||
case SPI_Options_e::Vspi:
|
||||
{
|
||||
SPI.begin(); // VSPI
|
||||
break;
|
||||
}
|
||||
case SPI_Options_e::None:
|
||||
break;
|
||||
}
|
||||
#else // ifdef ESP32
|
||||
SPI.begin();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -787,19 +787,7 @@ void format_SPI_port_description(int8_t spi_gpios[3])
|
||||
return;
|
||||
}
|
||||
# ifdef ESP32
|
||||
|
||||
switch (Settings.InitSPI) {
|
||||
case 1:
|
||||
{
|
||||
addHtml(F("VSPI"));
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
addHtml(F("HSPI"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
addHtml(getSPI_optionToShortString(static_cast<SPI_Options_e>(Settings.InitSPI)));
|
||||
# endif // ifdef ESP32
|
||||
# ifdef ESP8266
|
||||
addHtml(F("SPI"));
|
||||
@@ -815,7 +803,7 @@ void format_I2C_pin_description()
|
||||
|
||||
void format_SPI_pin_description(int8_t spi_gpios[3], taskIndex_t x)
|
||||
{
|
||||
if (Settings.InitSPI > 0) {
|
||||
if (Settings.InitSPI > static_cast<int>(SPI_Options_e::None)) {
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
const String pin_descr = formatGpioLabel(spi_gpios[i], false);
|
||||
switch (i) {
|
||||
@@ -1009,7 +997,7 @@ void devicePage_show_pin_config(taskIndex_t taskIndex, deviceIndex_t DeviceIndex
|
||||
if (((Device[DeviceIndex].Type == DEVICE_TYPE_SPI)
|
||||
|| (Device[DeviceIndex].Type == DEVICE_TYPE_SPI2)
|
||||
|| (Device[DeviceIndex].Type == DEVICE_TYPE_SPI3))
|
||||
&& (Settings.InitSPI == 0)) {
|
||||
&& (Settings.InitSPI == static_cast<int>(SPI_Options_e::None))) {
|
||||
addFormNote(F("SPI Interface is not configured yet (Hardware page)."));
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ void handle_hardware() {
|
||||
|
||||
if (isFormItem(F("psda")))
|
||||
{
|
||||
String error;
|
||||
Settings.Pin_status_led = getFormItemInt(F("pled"));
|
||||
Settings.Pin_status_led_Inversed = isFormItemChecked(F("pledi"));
|
||||
Settings.Pin_Reset = getFormItemInt(F("pres"));
|
||||
@@ -51,7 +52,15 @@ void handle_hardware() {
|
||||
Settings.I2C_Multiplexer_ResetPin = getFormItemInt(F("pi2cmuxreset"));
|
||||
#endif
|
||||
#ifdef ESP32
|
||||
Settings.InitSPI = getFormItemInt(F("initspi"), 0);
|
||||
Settings.InitSPI = getFormItemInt(F("initspi"), static_cast<int>(SPI_Options_e::None));
|
||||
if (Settings.InitSPI == static_cast<int>(SPI_Options_e::UserDefined)) { // User-define SPI GPIO pins
|
||||
Settings.SPI_SCLK_pin = getFormItemInt(F("spipinsclk"), -1);
|
||||
Settings.SPI_MISO_pin = getFormItemInt(F("spipinmiso"), -1);
|
||||
Settings.SPI_MOSI_pin = getFormItemInt(F("spipinmosi"), -1);
|
||||
if (!Settings.isSPI_valid()) { // Checks
|
||||
error += F("User-defined SPI pins not configured correctly!\n");
|
||||
}
|
||||
}
|
||||
#else //for ESP8266 we keep the old UI
|
||||
Settings.InitSPI = isFormItemChecked(F("initspi")); // SPI Init
|
||||
#endif
|
||||
@@ -79,7 +88,7 @@ void handle_hardware() {
|
||||
}
|
||||
++gpio;
|
||||
}
|
||||
String error = SaveSettings();
|
||||
error += SaveSettings();
|
||||
addHtmlError(error);
|
||||
if (error.isEmpty()) {
|
||||
// Apply I2C settings.
|
||||
@@ -155,20 +164,36 @@ void handle_hardware() {
|
||||
addFormSubHeader(F("SPI Interface"));
|
||||
#ifdef ESP32
|
||||
{
|
||||
const __FlashStringHelper * spi_options[3] = {
|
||||
F("Disabled"),
|
||||
F("VSPI: CLK=GPIO-18, MISO=GPIO-19, MOSI=GPIO-23"),
|
||||
F("HSPI: CLK=GPIO-14, MISO=GPIO-12, MOSI=GPIO-13")};
|
||||
addFormSelector(F("Init SPI"), F("initspi"), 3, spi_options, NULL, Settings.InitSPI);
|
||||
addFormNote(F("Changing SPI settings requires to manualy restart"));
|
||||
// Script to show GPIO pins for User-defined SPI GPIOs
|
||||
html_add_script(F("function spiOptionChanged(elem) {var spipinstyle = elem.value == 9 ? '' : 'none';document.getElementById('tr_spipinsclk').style.display = spipinstyle;document.getElementById('tr_spipinmiso').style.display = spipinstyle;document.getElementById('tr_spipinmosi').style.display = spipinstyle;}"),
|
||||
false);
|
||||
const String spi_options[] = {
|
||||
getSPI_optionToString(SPI_Options_e::None),
|
||||
getSPI_optionToString(SPI_Options_e::Vspi),
|
||||
getSPI_optionToString(SPI_Options_e::Hspi),
|
||||
getSPI_optionToString(SPI_Options_e::UserDefined)};
|
||||
const int spi_index[] = {
|
||||
static_cast<int>(SPI_Options_e::None),
|
||||
static_cast<int>(SPI_Options_e::Vspi),
|
||||
static_cast<int>(SPI_Options_e::Hspi),
|
||||
static_cast<int>(SPI_Options_e::UserDefined)
|
||||
};
|
||||
addFormSelector_script(F("Init SPI"), F("initspi"), 4, spi_options, spi_index, NULL, Settings.InitSPI, F("spiOptionChanged(this)"));
|
||||
// User-defined pins
|
||||
addFormPinSelect(PinSelectPurpose::SPI, formatGpioName_output(F("CLK")), F("spipinsclk"), Settings.SPI_SCLK_pin);
|
||||
addFormPinSelect(PinSelectPurpose::SPI, formatGpioName_input(F("MISO")), F("spipinmiso"), Settings.SPI_MISO_pin);
|
||||
addFormPinSelect(PinSelectPurpose::SPI, formatGpioName_output(F("MOSI")), F("spipinmosi"), Settings.SPI_MOSI_pin);
|
||||
html_add_script(F("document.getElementById('initspi').onchange();"), false); // Initial trigger onchange script
|
||||
addFormNote(F("Changing SPI settings requires to press the hardware-reset button or power off-on!"));
|
||||
}
|
||||
#else //for ESP8266 we keep the existing UI
|
||||
addFormCheckBox(F("Init SPI"), F("initspi"), Settings.InitSPI>0);
|
||||
addFormCheckBox(F("Init SPI"), F("initspi"), Settings.InitSPI > static_cast<int>(SPI_Options_e::None));
|
||||
addFormNote(F("CLK=GPIO-14 (D5), MISO=GPIO-12 (D6), MOSI=GPIO-13 (D7)"));
|
||||
#endif
|
||||
addFormNote(F("Chip Select (CS) config must be done in the plugin"));
|
||||
|
||||
#ifdef FEATURE_SD
|
||||
addFormSubHeader(F("SD Card"));
|
||||
addFormPinSelect(PinSelectPurpose::Generic_output, formatGpioName_output(F("SD Card CS")), F("sd"), Settings.Pin_sd_cs);
|
||||
#endif // ifdef FEATURE_SD
|
||||
|
||||
|
||||
@@ -459,7 +459,7 @@ void addFormSelector_script(const String & label,
|
||||
)
|
||||
{
|
||||
addRowLabel_tr_id(label, id);
|
||||
do_addSelector_Head(id, EMPTY_STRING, onChangeCall, false
|
||||
do_addSelector_Head(id, F("wide"), onChangeCall, false
|
||||
#ifdef ENABLE_TOOLTIPS
|
||||
, tooltip
|
||||
#endif // ifdef ENABLE_TOOLTIPS
|
||||
|
||||
@@ -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"));
|
||||
|
||||
@@ -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);
|
||||
|
||||