Merge branch 'mega' into feature/PWM_motor

This commit is contained in:
TD-er
2021-10-24 22:06:20 +02:00
committed by GitHub
14 changed files with 164 additions and 106 deletions
+3 -1
View File
@@ -365,7 +365,7 @@ static const char DATA_ESPEASY_DEFAULT_MIN_CSS[] PROGMEM = {
// #define USES_P100 // DS2423 counter
// #define USES_P101 // WakeOnLan
// #define USES_P102 // PZEM004Tv3
// #define USES_P103 // Atlas_EZO_pH_ORP_EC
// #define USES_P103 // Atlas Scientific EZO Sensors (pH, ORP, EZO, DO)
// #define USES_P104 // MAX7219 dotmatrix
// #define USES_P105 // AHT10/20/21
// #define USES_P106 // BME680
@@ -377,6 +377,8 @@ static const char DATA_ESPEASY_DEFAULT_MIN_CSS[] PROGMEM = {
// #define USES_P113 // VL53L1X ToF
// #define USES_P114 // VEML6075
// #define USES_P115 // MAX1704x
// #define USES_P119 // ITG3205 Gyro
// #define USES_P120 // ADXL345 Acceleration / Gravity
// Special plugins needing IR library
@@ -2,30 +2,32 @@
#ifdef USES_P103
// ########################################################################
// ################## Plugin 103 : Atlas Scientific EZO pH ORP EC sensors #
// ########################################################################
// ###########################################################################
// ################## Plugin 103 : Atlas Scientific EZO pH ORP EC DO sensors #
// ###########################################################################
// datasheet at https://atlas-scientific.com/files/pH_EZO_Datasheet.pdf
// datasheet at https://atlas-scientific.com/files/ORP_EZO_Datasheet.pdf
// datasheet at https://atlas-scientific.com/files/EC_EZO_Datasheet.pdf
// datasheet at https://atlas-scientific.com/files/DO_EZO_Datasheet.pdf
// works only in i2c mode
#include "src/Helpers/Rules_calculate.h"
#define PLUGIN_103
#define PLUGIN_ID_103 103
#define PLUGIN_NAME_103 "Environment - Atlas EZO pH ORP EC [TESTING]"
#define PLUGIN_NAME_103 "Environment - Atlas EZO pH ORP EC DO [TESTING]"
#define PLUGIN_VALUENAME1_103 "SensorData"
#define PLUGIN_VALUENAME2_103 "Voltage"
#define UNKNOWN 0
#define PH 1
#define ORP 2
#define EC 3
#define DO 4
#define ATLAS_EZO_RETURN_ARRAY_SIZE 33
#define _P103_ATLASEZO_I2C_NB_OPTIONS 3 // was: 6 see comment below at 'const int i2cAddressValues'
#define _P103_ATLASEZO_I2C_NB_OPTIONS 4 // was: 6 see comment below at 'const int i2cAddressValues'
#define FIXED_TEMP_VALUE 20 // Temperature correction for pH and EC sensor if no temperature is given from calculation
@@ -70,10 +72,10 @@ boolean Plugin_103(uint8_t function, struct EventStruct *event, String &string)
case PLUGIN_I2C_HAS_ADDRESS:
case PLUGIN_WEBFORM_SHOW_I2C_PARAMS:
{
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)
const uint8_t i2cAddressValues[] = {0x61, 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."));
addFormNote(F("pH: 0x63, ORP: 0x62, EC: 0x64, DO: 0x61. The plugin is able to detect the type of device automatically."));
} else {
success = intArrayContains(_P103_ATLASEZO_I2C_NB_OPTIONS, i2cAddressValues, event->Par1);
}
@@ -109,12 +111,16 @@ boolean Plugin_103(uint8_t function, struct EventStruct *event, String &string)
{
board_type = EC;
}
else if (board == F("D.O."))
{
board_type = DO;
}
PCONFIG(0) = board_type;
if (board_type == UNKNOWN)
{
addHtml(F("<span style='color:red'> WARNING : Board type should be 'pH' or 'ORP' or 'EC', check your i2c address? </span>"));
addHtml(F("<span style='color:red'> WARNING : Board type should be 'pH', 'ORP', 'EC' or 'DO', check your i2c address? </span>"));
}
addRowLabel(F("Board version"));
addHtml(version);
@@ -128,7 +134,7 @@ boolean Plugin_103(uint8_t function, struct EventStruct *event, String &string)
addHtml(F("<span style='color:red;'>Unable to send command to device</span>"));
if (board_type == UNKNOWN)
{
addHtml(F("<span style='color:red'> WARNING : Board type should be 'pH' or 'ORP' or 'EC', check your i2c address?</span>"));
addHtml(F("<span style='color:red'> WARNING : Board type should be 'pH', 'ORP', 'EC' or 'DO', check your i2c address? </span>"));
}
success = false;
break;
@@ -202,6 +208,11 @@ boolean Plugin_103(uint8_t function, struct EventStruct *event, String &string)
addUnit(F("&micro;S"));
break;
}
case DO:
{
addUnit(F("mg/L"));
break;
}
}
}
else
@@ -262,15 +273,22 @@ boolean Plugin_103(uint8_t function, struct EventStruct *event, String &string)
addFormSubHeader(F("EC Calibration"));
addCreateDryCalibration();
addCreate3PointCalibration(board_type, event, I2Cchoice, F("&micro;S"), 0.0, 500000.0, 0, 1.0);
break;
}
case DO:
{
addFormSubHeader(F("DO Calibration"));
addDOCalibration(I2Cchoice);
break;
}
break;
}
// Clear calibration
addClearCalibration();
// Temperature compensation
if (board_type == PH || board_type == EC)
if (board_type == PH || board_type == EC || board_type == DO)
{
double value;
char strValue[6] = {0};
@@ -371,6 +389,16 @@ boolean Plugin_103(uint8_t function, struct EventStruct *event, String &string)
cmd += PCONFIG_FLOAT(3);
triggerCalibrate = true;
}
else if (isFormItemChecked(F("Plugin_103_enable_cal_atm")))
{
triggerCalibrate = true;
}
else if (isFormItemChecked(F("Plugin_103_enable_cal_0")))
{
cmd += F("0");
triggerCalibrate = true;
}
if (triggerCalibrate)
{
@@ -378,7 +406,7 @@ boolean Plugin_103(uint8_t function, struct EventStruct *event, String &string)
_P103_send_I2C_command(I2Cchoice, cmd, calibration);
}
if (board_type == PH || board_type == EC)
if (board_type == PH || board_type == EC || board_type == DO)
{
char deviceTemperatureTemplate[40] = {0};
String tmpString = webArg(F("Plugin_103_temperature_template"));
@@ -404,7 +432,7 @@ boolean Plugin_103(uint8_t function, struct EventStruct *event, String &string)
String readCommand;
if (board_type == PH || board_type == EC)
if (board_type == PH || board_type == EC || board_type == DO)
{
// first set the temperature of reading
char deviceTemperatureTemplate[40] = {0};
@@ -580,6 +608,37 @@ void addClearCalibration()
addFormNote(F("Attention! This will reset all calibrated data. New calibration will be needed!!!"));
}
int addDOCalibration(uint8_t I2Cchoice)
{
int nb_calibration_points = getCalibrationPoints(I2Cchoice);
addRowLabel("Calibrated Points");
addHtmlInt(nb_calibration_points);
if (nb_calibration_points < 1)
{
addHtml(F("<span style='color:red'> Calibration needed</span>"));
}
addRowLabel(F("<strong>Calibrate to atmospheric oxygen levels</strong>"));
addFormCheckBox(F("Enable"), F("Plugin_103_enable_cal_atm"), false);
addHtml(F("\n<script type='text/javascript'>document.getElementById(\"Plugin_103_enable_cal_atm\").onclick=function() {document.getElementById(\"Plugin_103_enable_cal_0\").checked = false;document.getElementById(\"Plugin_103_enable_cal_clear\").checked = false;};</script>"));
addRowLabel(F("<strong>Calibrate device to 0 dissolved oxygen</strong>"));
addFormCheckBox(F("Enable"), F("Plugin_103_enable_cal_0"), false);
addHtml(F("\n<script type='text/javascript'>document.getElementById(\"Plugin_103_enable_cal_0\").onclick=function() {document.getElementById(\"Plugin_103_enable_cal_atm\").checked = false;document.getElementById(\"Plugin_103_enable_cal_clear\").checked = false;};</script>"));
if (nb_calibration_points > 0)
{
addHtml(F("&nbsp;<span style='color:green;'>OK</span>"));
}
else
{
addHtml(F("&nbsp;<span style='color:red;'>Not yet calibrated</span>"));
}
return nb_calibration_points;
}
void addCreateDryCalibration()
{
addRowLabel(F("<strong>Dry calibration</strong>"));
@@ -663,4 +722,4 @@ int addCreate3PointCalibration(uint8_t board_type, struct EventStruct *event, ui
return nb_calibration_points;
}
#endif // ifdef USES_P103
#endif // ifdef USES_P103
@@ -0,0 +1,59 @@
#include "../CustomBuild/CompiletimeDefines.h"
// This file will be "patched" at compiletime by
// tools/pio/generate-compiletime-defines.py
// Therefore this one may not include ESPEasy_common.h
//
// This Python script will define the following defines:
// # define SET_BUILD_BINARY_FILENAME "firmware.bin"
// # define SET_BUILD_PLATFORM "unknown"
// # define SET_BUILD_GIT_HEAD ""
// End of defines being patched by the Python build script.
// Need to add quotes around defines as the PIO build tools make it hard to include the string quotes.
#define STRINGIFY(s) STRINGIFY1(s)
#define STRINGIFY1(s) # s
const __FlashStringHelper* get_binary_filename() {
#ifndef SET_BUILD_BINARY_FILENAME
return F("firmware.bin");
#else // ifndef SET_BUILD_BINARY_FILENAME
return F(STRINGIFY(SET_BUILD_BINARY_FILENAME));
#endif // ifndef SET_BUILD_BINARY_FILENAME
}
const __FlashStringHelper* get_build_time() {
return F(__TIME__);
}
const __FlashStringHelper* get_build_date() {
return F(__DATE__);
}
const __FlashStringHelper* get_build_origin() {
#if defined(CONTINUOUS_INTEGRATION)
return F("GitHub Actions");
#elif defined(VAGRANT_BUILD)
return F("Vagrant");
#else // if defined(CONTINUOUS_INTEGRATION)
return F("Self built");
#endif // if defined(CONTINUOUS_INTEGRATION)
}
const __FlashStringHelper* get_build_platform() {
#ifndef SET_BUILD_PLATFORM
return F("");
#else // ifndef SET_BUILD_PLATFORM
return F(STRINGIFY(SET_BUILD_PLATFORM));
#endif // ifndef SET_BUILD_PLATFORM
}
const __FlashStringHelper* get_git_head() {
#ifndef SET_BUILD_GIT_HEAD
return F("");
#else // ifndef SET_BUILD_GIT_HEAD
return F(STRINGIFY(SET_BUILD_GIT_HEAD));
#endif // ifndef SET_BUILD_GIT_HEAD
}
+12 -6
View File
@@ -1113,7 +1113,7 @@ To create/register a plugin, you have to :
#define USES_P100 // Pulse Counter - DS2423
#define USES_P101 // Wake On Lan
#define USES_P103 // Atlas Scientific EZO Sensors (pH, ORP, EZO)
#define USES_P103 // Atlas Scientific EZO Sensors (pH, ORP, EZO, DO)
#define USES_P106 // BME680
#define USES_P107 // SI1145 UV index
#define USES_P108 // DDS238-x ZN MODBUS energy meter (was P224 in the Playground)
@@ -1381,10 +1381,16 @@ To create/register a plugin, you have to :
#define USES_P102 // PZEM004Tv3
#endif
#ifndef USES_P103
#define USES_P103 // Atlas EZO pH
#define USES_P103 // Atlas Scientific EZO Sensors (pH, ORP, EZO, DO)
#endif
#ifndef USES_P104
#define USES_P104 // Atlas EZO EC
#define USES_P104 //
#endif
#ifndef USES_P105
#define USES_P105 // AHT10/20/21
#endif
#ifndef USES_P104
#define USES_P104 //
#endif
#ifndef USES_P105
#define USES_P105 // AHT10/20/21
@@ -1423,10 +1429,10 @@ To create/register a plugin, you have to :
#define USES_P118 //
#endif
#ifndef USES_P119
#define USES_P119 //
#define USES_P119 // ITG3205 Gyro
#endif
#ifndef USES_P120
#define USES_P120 //
#define USES_P120 // ADXL345 Acceleration / Gravity
#endif
#ifndef USES_P121
#define USES_P121 //
@@ -1748,4 +1754,4 @@ To create/register a plugin, you have to :
#endif
#endif
#endif // DEFINE_PLUGIN_SETS_H
#endif // DEFINE_PLUGIN_SETS_H
-64
View File
@@ -1,64 +0,0 @@
#include "../Helpers/CompiletimeDefines.h"
// This file will be "patched" at compiletime by
// tools/pio/generate-compiletime-defines.py
// Therefore this one may not include ESPEasy_common.h
//
// This Python script will define the following defines:
#ifndef SET_BUILD_BINARY_FILENAME
# define SET_BUILD_BINARY_FILENAME "firmware.bin"
#endif // ifndef SET_BUILD_BINARY_FILENAME
#ifndef SET_BUILD_PLATFORM
# define SET_BUILD_PLATFORM "unknown"
#endif // ifndef SET_BUILD_PLATFORM
#ifndef SET_BUILD_GIT_HEAD
# define SET_BUILD_GIT_HEAD ""
#endif // ifndef SET_BUILD_GIT_HEAD
// End of defines being patched by the Python build script.
const __FlashStringHelper * get_binary_filename() {
#if !defined(CORE_POST_2_5_0) && !defined(ESP32) || defined(ESP32_STAGE)
return F("firmware.bin");
#else
return F(SET_BUILD_BINARY_FILENAME);
#endif
}
const __FlashStringHelper * get_build_time() {
return F(__TIME__);
}
const __FlashStringHelper * get_build_date() {
return F(__DATE__);
}
const __FlashStringHelper * get_build_origin() {
#if defined(CONTINUOUS_INTEGRATION)
return F("GitHub Actions");
#elif defined(VAGRANT_BUILD)
return F("Vagrant");
#else
return F("Self built");
#endif
}
const __FlashStringHelper * get_build_platform() {
#if !defined(CORE_POST_2_5_0) && !defined(ESP32) || defined(ESP32_STAGE)
return F("");
#else
return F(SET_BUILD_PLATFORM);
#endif
}
const __FlashStringHelper * get_git_head() {
#if !defined(CORE_POST_2_5_0) && !defined(ESP32) || defined(ESP32_STAGE)
return F("");
#else
return F(SET_BUILD_GIT_HEAD);
#endif
}
+2 -1
View File
@@ -6,6 +6,8 @@
#include "../../ESPEasy-Globals.h"
#include "../CustomBuild/CompiletimeDefines.h"
#include "../ESPEasyCore/ESPEasyNetwork.h"
#include "../ESPEasyCore/ESPEasyWifi.h"
#ifdef HAS_ETHERNET
@@ -20,7 +22,6 @@
#include "../Globals/Settings.h"
#include "../Globals/WiFi_AP_Candidates.h"
#include "../Helpers/CompiletimeDefines.h"
#include "../Helpers/Memory.h"
#include "../Helpers/Misc.h"
#include "../Helpers/Scheduler.h"
+2 -1
View File
@@ -5,6 +5,8 @@
#include "../../ESPEasy-Globals.h"
#include "../CustomBuild/CompiletimeDefines.h"
#include "../DataStructs/TimingStats.h"
#include "../ESPEasyCore/ESPEasy_Log.h"
@@ -21,7 +23,6 @@
#include "../Globals/Settings.h"
#include "../Globals/Statistics.h"
#include "../Helpers/CompiletimeDefines.h"
#include "../Helpers/Hardware.h"
#include "../Helpers/Misc.h"
#include "../Helpers/Numerical.h"
+1 -2
View File
@@ -2,7 +2,7 @@
#include "../../ESPEasy_common.h"
#include "../CustomBuild/CompiletimeDefines.h"
#include "../CustomBuild/ESPEasyLimits.h"
#include "../DataStructs/SecurityStruct.h"
@@ -21,7 +21,6 @@
#include "../Globals/SecuritySettings.h"
#include "../Globals/ESPEasyWiFiEvent.h"
#include "../Helpers/CompiletimeDefines.h"
#include "../Helpers/ESPEasy_time_calc.h"
#include "../Helpers/Misc.h"
#include "../Helpers/Network.h"
+2
View File
@@ -143,12 +143,14 @@ void handle_config() {
addFormPasswordBox(F("WPA Key"), F("key"), SecuritySettings.WifiKey, 63);
addFormTextBox(F("Fallback SSID"), F("ssid2"), SecuritySettings.WifiSSID2, 31);
addFormPasswordBox(F("Fallback WPA Key"), F("key2"), SecuritySettings.WifiKey2, 63);
addFormNote(F("WPA Key must be at least 8 characters long"));
addFormCheckBox(F("Include Hidden SSID"), F("hiddenssid"), Settings.IncludeHiddenSSID());
addFormNote(F("Must be checked to connect to a hidden SSID"));
addFormSeparator(2);
addFormPasswordBox(F("WPA AP Mode Key"), F("apkey"), SecuritySettings.WifiAPKey, 63);
addFormNote(F("WPA Key must be at least 8 characters long"));
addFormCheckBox(F("Don't force /setup in AP-Mode"), F("ApDontForceSetup"), Settings.ApDontForceSetup());
addFormNote(F("When set you can use the Sensor in AP-Mode without being forced to /setup. /setup can still be called."));
+3
View File
@@ -264,6 +264,9 @@ String getKnownI2Cdevice(uint8_t address) {
case 0x60:
result += F("Adafruit Motorshield v2,SI1145");
break;
case 0x61:
result += F("Atlas EZO DO");
break;
case 0x62:
result += F("Atlas EZO ORP");
break;
+2 -1
View File
@@ -10,6 +10,8 @@
#include "../Commands/Diagnostic.h"
#include "../CustomBuild/CompiletimeDefines.h"
#include "../DataStructs/RTCStruct.h"
#include "../ESPEasyCore/ESPEasyNetwork.h"
@@ -22,7 +24,6 @@
#include "../Globals/RTC.h"
#include "../Globals/Settings.h"
#include "../Helpers/CompiletimeDefines.h"
#include "../Helpers/ESPEasyStatistics.h"
#include "../Helpers/ESPEasy_Storage.h"
#include "../Helpers/Hardware.h"
+2 -1
View File
@@ -41,6 +41,8 @@
#include "../../_Plugin_Helper.h"
#include "../../ESPEasy_common.h"
#include "../CustomBuild/CompiletimeDefines.h"
#include "../DataStructs/TimingStats.h"
#include "../DataTypes/SettingsType.h"
@@ -61,7 +63,6 @@
#include "../Helpers/Networking.h"
#include "../Helpers/OTA.h"
#include "../Helpers/StringConverter.h"
#include "../Helpers/CompiletimeDefines.h"
#include "../Static/WebStaticData.h"
+3 -15
View File
@@ -34,17 +34,6 @@ def deduct_flags_from_pioenv():
print("\u001b[33m File System: \u001b[0m {}".format(fs_str))
# needed to wrap in a number of double quotes.
# one level for adding it to the list of defines
# another level to have the string quoted in the .cpp file
# somewhere along the line, another level is removed.
def wrap_quotes(str_value):
if platform.system() == 'Windows':
return "\"\"\"{}\"\"\"".format(str_value)
else:
return '\'\"\"\"{}\"\"\"\''.format(str_value)
def gen_compiletime_defines(node):
"""
`node.name` - a name of File System Node
@@ -63,9 +52,9 @@ def gen_compiletime_defines(node):
return env.Object(
node,
CPPDEFINES=env["CPPDEFINES"]
+ [("SET_BUILD_BINARY_FILENAME", wrap_quotes(create_binary_filename()))]
+ [("SET_BUILD_PLATFORM", wrap_quotes(platform.platform()))]
+ [("SET_BUILD_GIT_HEAD", wrap_quotes(get_git_description()))],
+ [("SET_BUILD_BINARY_FILENAME", create_binary_filename())]
+ [("SET_BUILD_PLATFORM", platform.platform())]
+ [("SET_BUILD_GIT_HEAD", get_git_description())],
CCFLAGS=env["CCFLAGS"]
)
@@ -79,5 +68,4 @@ print("\u001b[33m BUILD_PLATFORM: \u001b[0m {}".format(platform.platform()))
print("\u001b[33m GIT_HEAD: \u001b[0m {}".format(get_git_description()))
print("\u001b[32m ------------------------------- \u001b[0m")
env.AddBuildMiddleware(gen_compiletime_defines)