mirror of
https://github.com/letscontrolit/ESPEasy.git
synced 2026-07-28 04:07:47 +00:00
Merge branch 'mega' into mega
This commit is contained in:
Vendored
+143
@@ -1,3 +1,146 @@
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20211105 (since mega-20211005)
|
||||
-------------------------------------------------
|
||||
|
||||
Release date: vr 5 nov 2021 11:10:12 CET
|
||||
|
||||
Peter Kretz (4):
|
||||
[P103 AtlasEZO] Added Dissolved Oxygen Sensor DO
|
||||
Update platformio_esp32_envs.ini
|
||||
Update _P103_Atlas_EZO_pH_ORP_EC.ino
|
||||
Rename Plugin 103 : Atlas Scientific EZO pH ORP EC DO
|
||||
|
||||
TD-er (58):
|
||||
[P103] Perform manual merge of conflicting files
|
||||
[P103] Perform manual merge of P103...ino
|
||||
[PMSx003] Convert plugin into using multiple instances data_struct
|
||||
[PMSx003] Uncrustify .ino file
|
||||
[PMSx003] Cleanup naming of types and variables
|
||||
[ESP32] Revert to PlatformIO platform 3.3.0 to fix web login
|
||||
[PMSx003] Cleanup by turning sensor type into enum class
|
||||
[PMSx003] Add pin selection for PWR Set pin
|
||||
[Serial] Make serial selection more intuitive
|
||||
[PMSx003] Use defines when interpreting received data
|
||||
[PMSx003] Use enum class for event output selector
|
||||
[PMSx003] Add check for duplicate messages
|
||||
[PMSx003] Make output/event selector enums a bit more readable
|
||||
[PMSx003] Add commands for reset/sleep/wake + document them
|
||||
[Cleanup] Use PLUGIN_WEBFORM_SHOW_GPIO_DESCR to show all GPIO used
|
||||
[PMSx003] Add output selection for counted small particles 0.3 ... 2.5 u
|
||||
[PMSx003] Add explanation on particles measurement
|
||||
[PMSx003] Simplify event generation + update task value names
|
||||
[PMSx003] Update documentation
|
||||
[PMSx003] Ignore incompatible event out selections
|
||||
[ESPEasySerial] Fix issues on ESP32 with serial (restart serial)
|
||||
[ESPEasySerial] Fix issues on ESP32 with serial (restart serial)
|
||||
[PMSx003] Document new pmsx003,wake & pmsx003,wake commands
|
||||
[ESPEasySerial] Include v2.0.7 in the ESPEasy libs dir too
|
||||
[PMSx003] Add option to split counted data in bins
|
||||
[PMSx003] Add oversampling to average readings
|
||||
[PMSx003] Document new Data Processing features.
|
||||
[PMSx003] Add sensor init time option after wake up sensor
|
||||
[PMSx003] Add proper defaults when creating new task or loading old conf
|
||||
[PMSx003] Make 1M builds fit again
|
||||
[Cleanup] Remove PeriodicalScanWiFi
|
||||
[Cleanup] Fix compile warning and failed build on ESP8266 beta builds
|
||||
[ESP32] Update GPIO description docs & add event to get boot strap pins
|
||||
Reset former PeriodicalScanWiFi bit to 0
|
||||
[P046 Ventus] Fix UV only "binary" (#3073)
|
||||
[P046 Ventus] Minor cleanup of strange float casts
|
||||
[GPIO] Fix [Plugin#PCF#PinRange#x-y] (#3815)
|
||||
[Build] Fix build on Windows for ESP32 Max LittleFS builds
|
||||
[Build] Concat Globals .cpp files to help building in Windows
|
||||
Fix missing lib_debs
|
||||
[PVS Studio] Test using ESP32 max build + some suggested fixes
|
||||
[PVS Studio] Fix issues reported by PVS Studio
|
||||
[PVS Studio] Fix "dangerous" macros in IRremoteESP8266 library
|
||||
[Python] Update Python packages due to Sphinx build error on Python 3.10
|
||||
[PVS Studio] Fix some warnings made by PVS Studio.
|
||||
[Python] Update Python packages + missing Ubuntu packages
|
||||
[Build] Fix build fail due to warnings
|
||||
[Build] Fix CompiletimeDefines
|
||||
[Build] Fix quotes issue on compile time defines
|
||||
[Build] Cleanup of Compile time defines scripts
|
||||
[WiFi] Add note about minimal WPA key length
|
||||
[WebFlasher] Generate manifest.json file per build
|
||||
[Webflasher] Generate html page for web flasher
|
||||
[Build] Add option "esp8266" to be the same as "esp82xx"
|
||||
[build] Make sure Python requirements are installed
|
||||
[Webflasher] Add groups in selection combobox
|
||||
[Build] Include flash size on all PlatformIO envs
|
||||
[Webflasher] Do not create index.html during build
|
||||
|
||||
Ton Huisman (64):
|
||||
[P104] New plugin: MAX7219 dot matrix display
|
||||
[P104] Include plugin in Display builds
|
||||
[P104] Fixed zone initialization and brightness setup
|
||||
[P104] Code improvements
|
||||
[Helpers] Add helper getFormItemIntCustomArgName(int)
|
||||
[P104] Code improvements and optimizations
|
||||
[P104] Implement Clock and Date content, clear on plugin exit
|
||||
[P104] Use compiletime defines where appropriate
|
||||
[P104] Get settings defaults right
|
||||
[P104] Update MD_Parola library
|
||||
[P104] Implement PLUGIN_WRITE commands, add fonts, many improvements
|
||||
[P104] Fix issue with MD_Parola update
|
||||
[P104] Revert addition to MD_Parola made earlier
|
||||
[P104] Implement Repeat delay, add settxt command, edit active settings, update source doc, some source reorg.
|
||||
[P104] Format source
|
||||
[P104] Try to make build fit in ESP8266 display configuration
|
||||
[P104] Try to make build fit in ESP8266 display configuration
|
||||
[P104] Try to make build fit in ESP8266 display configuration
|
||||
[P104] Try to make build fit in ESP8266 display configuration
|
||||
[P104] Try to make build fit in ESP8266 display configuration
|
||||
[P104] Added time/date configuration options
|
||||
[P104] Adjust Custom-sample.h
|
||||
[P104] Add Bar-graph support and bar/setbar commands
|
||||
[P104] Add update command, bugfixes and improvements
|
||||
[P104] Implement 'direction' and 'barType' options for Bar-graph, many bugfixes
|
||||
[P104] Re-enble commands for 'display' build, many bugfixes
|
||||
[P104] Add Actions column, add Zone order, many bugfixes and improvements
|
||||
[P104] Bugfixes and minor improvements
|
||||
[P104] Bugfixes and improvements
|
||||
[P104] Allow up to 255 modules per zone.
|
||||
[P104] Limit settxt and setbar commands to max. input length
|
||||
[P104] Add 'p', comma and dash to num. double height font, some UI improvements
|
||||
[P104] Add documentation for Max7219 Dot matrix display
|
||||
[P104] Small optimizations, resolve some typos, documentation improvements
|
||||
[P104] Documentation - Add font overviews
|
||||
[P104] Bugfixes, add Text reverse option, update documentation
|
||||
[P104] Small improvements, check modules count on save
|
||||
[P104] Suggested small code optimizations
|
||||
[P104] Reformatted source (uncrustify needed an update)
|
||||
[P104] Fix compilation error after merge
|
||||
[P104] Code optimizations
|
||||
[P104] Bugfixes, optimizations and phase 1 of improvements
|
||||
[P104] Reworked saving and loading settings resolving stack issues
|
||||
[P104] Updates to documentation
|
||||
[Build] Apply LIMIT_BUILD_SIZE for ESP8266 Display build to fit in more plugins
|
||||
[P104] Reduce flashcounter on save, use LIMIT_BUILD_SIZE to fit in more features
|
||||
[P104] Simplify SPI pin display, small formatting changes (uncrustify)
|
||||
[P104] Add missing slash in numeric doubleheight font
|
||||
[P104] Update and improve documentation
|
||||
[P104] Code improvements and small optimizations
|
||||
[P104] Code improvements as suggested in reviews (nullptr checks, unneeded array, destructor, comparison)
|
||||
[P104] Minor improvements, memory handling
|
||||
[P104] Add Inverted option (dark on light), incl. docs
|
||||
[P073] Add 7output command
|
||||
[P073] Store via commands changes settings but not save them yet
|
||||
[P073] Reformat source (uncrustify and some manual adjustments)
|
||||
[Build] Re-enable IR plugins in custom_IR builds
|
||||
[Build] Enable IR plugins in MAX ESP32 builds
|
||||
[Build] Enable Blynk controller in MAX ESP32 builds
|
||||
[Docs] IR plugins are not in normal builds (for a long time)
|
||||
[Docs] IR plugins are not in normal builds (for a long time)
|
||||
[Docs] IR plugins are not in normal builds (for a long time)
|
||||
[Docs] IR plugins are not in normal builds (for a long time)
|
||||
[P119][P120] Register plugin IDs for ITG3205 and ADXL345
|
||||
|
||||
jimmys01 (2):
|
||||
[IR] Update IR library to the latest build
|
||||
Fix String ambiguous conversions in the lib
|
||||
|
||||
|
||||
-------------------------------------------------
|
||||
Changes in release mega-20211005 (since mega-20210802)
|
||||
-------------------------------------------------
|
||||
|
||||
+204
-3
@@ -23,15 +23,216 @@ Maintainer: |P082_maintainer|
|
||||
|
||||
Used libraries: |P082_usedlibraries|
|
||||
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
Almost all GPS modules on the market have a serial (UART) interface and without any configuration they output standard NMEA sentences at 9600 baud.
|
||||
|
||||
Some may differ in the quality of the GPS antenna and/or the generation of the used GPS receiver.
|
||||
|
||||
This often results in improved sensitivity and thus less time needed to get a fix, or maintaining a fix.
|
||||
|
||||
Controlling GPS Receiver
|
||||
------------------------
|
||||
|
||||
A lot of GPS modules sold are based on u-blox modules, or at least they claim to use u-blox modules as there are lots of couterfeit modules on the market.
|
||||
|
||||
Some (perfectly fine) modules are sold under a different name, but still use (real) u-blox modules.
|
||||
For example the BN-220 GPS modules are known to use u-blox modules and firmware from u-blox.
|
||||
These modules can thus be sent u-blox specific commands.
|
||||
|
||||
Currently the only u-blox specific commands supported by this plugin are to put the module in "backup mode".
|
||||
This is essentially turning off the entire module, except for the memory content with the satellite information.
|
||||
|
||||
See the commands section to manually control the GPS sleep mode.
|
||||
|
||||
|
||||
Time from GPS
|
||||
-------------
|
||||
|
||||
A GPS receiver is an excellent time source.
|
||||
The main advantage is that the time reported by a GPS receiver does not experience time drift.
|
||||
|
||||
Some GPS receivers have a pin labelled "PPS" which can be used to increase the accuracy even more.
|
||||
The accuracy can be at microseconds level when using the PPS pin.
|
||||
|
||||
The internal time of ESPEasy will be set by the GPS task when the GPS receiver has a fix.
|
||||
|
||||
|
||||
|
||||
|
||||
Tips for best performance
|
||||
-------------------------
|
||||
|
||||
Types of antennas
|
||||
^^^^^^^^^^^^^^^^^
|
||||
|
||||
Most GPS modules are sold including a GPS antenna.
|
||||
Pay attention to the ones sold with an external and detachable GPS antenna as quite a few are sold with really bad antennas
|
||||
|
||||
The size of the antenna is an important factor for the sensitivity.
|
||||
A rule of thumb is that bigger is better (up-to roughly 25x25 mm).
|
||||
But a lot of sellers on sites like Ali Express and others sell 25x25 ceramic antennas which perform really badly.
|
||||
Compared to these bad antennas, the often included small (12x6 mm) ceramic antenna does perform better.
|
||||
|
||||
Modules fixed mounted to the ceramic antenna, like the BN220, do have a relatively small ceramic antenna of 18x18 mm, but these do perform quite good.
|
||||
|
||||
Antenna Orientation
|
||||
^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The best orientation is to point the antenna to the open sky.
|
||||
Thus with the plane of the (ceramic) antenna parallel to the ground.
|
||||
|
||||
But for some use cases, a line of sight to the sky is more important than the orientation to the ground.
|
||||
|
||||
Do not cover the antenna with metal.
|
||||
|
||||
Starting from a "cold boot", it may take a while for the GPS receiver to get the first fix.
|
||||
If this takes longer than a few minutes, try taking the receiver outside, with as much non obstructed view to the sky as possible.
|
||||
|
||||
|
||||
Most GPS receivers do have a very small rechargable battery to keep the satellite trajectory information between runs.
|
||||
This may speed up the time to get a fix.
|
||||
However, those rechargable batteries take a long time to get charged (order of 50 hours) and they may sometimes be able to keep the data in the memory for about the same time.
|
||||
Thus when using the GPS for a short time and then disconnecting the power these batteries are quite useless.
|
||||
|
||||
When used in low-power setups, it is best to turn the GPS into "backup mode" to keep the memory powered.
|
||||
Another option is to remove these batteries and connect an external power source to power the RAM of the GPS module.
|
||||
When desoldering these batteries, try to remove them as quickly as possible, as they often are not designed to handle heat very well.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Configuration
|
||||
-------------
|
||||
|
||||
Sensor
|
||||
^^^^^^
|
||||
|
||||
Serial Port
|
||||
"""""""""""
|
||||
|
||||
The configuration of the serial port is the same as with any other sensor using a serial port.
|
||||
Only the TX pin on the ESP, connected to the RX pin on the GPS is optional.
|
||||
It only needs to be connected if commands have to be sent to the GPS.
|
||||
|
||||
The baud rate is not selectable for this plugin, as every plugin on the market does have a default setting of 9600 baud.
|
||||
|
||||
PPS pin
|
||||
"""""""
|
||||
|
||||
|
||||
Current Sensor Data
|
||||
^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
||||
|
||||
Reference Point
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
|
||||
Output Configuration
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Value N
|
||||
"""""""
|
||||
|
||||
Each of the 4 task values can be set to a specific measurement value.
|
||||
|
||||
* Longitude
|
||||
* Latitude
|
||||
* Altitude
|
||||
* Speed (m/s)
|
||||
* Satellites Visible
|
||||
* Satellites Tracked
|
||||
* HDOP - Horizontal Dilution Of Precision
|
||||
* Fix Quality
|
||||
* Max SNR in dBHz - Mainly used for diagnostics
|
||||
* Checksum Fail - Mainly used for diagnostics
|
||||
* Distance (ODO) - Trip distance in meters
|
||||
* Distance from Reference Point - See the Reference Point setting.
|
||||
|
||||
Most units of measure are clear, but some may need a bit more explanation.
|
||||
|
||||
**HDOP**
|
||||
|
||||
The HDOP value is a standard indicator for the accuracy of the position.
|
||||
It is the standard deviation for the position (in the horizontal plane, there is also a VDOP, which we don't use)
|
||||
|
||||
The deviation is multiplied with a factor to get the standard deviation in meters.
|
||||
This factor is usually around 5 - 10 meters, depending on the used GPS module.
|
||||
Just to simplify it, you can take roughly 7.5 meters.
|
||||
|
||||
The HDOP is computed by the GPS module depending on the angle between tracked GPS satellites.
|
||||
Just to get an idea of the concept, try to pinpoint the crossing point of 2 circles you draw on a piece of paper.
|
||||
If the centers of those circles are relatively close to each other, in relation to the radius, then there is a large part of the 2 circles where they cross each other.
|
||||
If the angle between the 2 radii and the point where they cross is roughly 90 degree, it is very easy to see where they cross.
|
||||
|
||||
The used computation is a bit more elaborate as the GPS may track upto 16 satellites and you may see some reflected signals, etc.
|
||||
But in principle it is just about how large the expected error is, related to the angle between the tracked satellites.
|
||||
|
||||
**Satellites Visible/Tracked**
|
||||
|
||||
A satellite must be "visible" to the GPS receiver, before it can be used to compute the location.
|
||||
If a satellite is actually used to determine the position, it is considered to be tracked.
|
||||
|
||||
Whether a satellite is usable to track, depends on a number of factors, which may differ among brands and models of GPS receivers.
|
||||
|
||||
For a 2D position fix, at least 3 satellites must be tracked.
|
||||
For a 3D position fix, at least 4 satellites must be tracked.
|
||||
|
||||
If just the bare minimum of satellites is being tracked, the GPS receiver may loose its fix quite often.
|
||||
|
||||
|
||||
|
||||
Distance Update Interval
|
||||
""""""""""""""""""""""""
|
||||
|
||||
Normally a task may send new values every set "Interval", or when ``TaskRun`` is called from the rules.
|
||||
On mobile units, it may be useful to also trigger sending a new value every N travelled meters.
|
||||
This way, samples can be taken at a fixed distance, regardless the speed.
|
||||
|
||||
If the unit is stationary, new values will still be sent every "Interval" number of seconds.
|
||||
|
||||
Typical use case is when the unit is mounted in a car, it isn't that useful to get new samples at a very high rate.
|
||||
A useful setting of the "Interval" can be every 900 seconds (15 minutes) and 100 m travelled.
|
||||
New samples will be sent by whichever of these two comes first.
|
||||
|
||||
This can also be useful to trigger a new reading of other sensors, to collect sensor data at a specific grid interval on the map.
|
||||
|
||||
Some controllers, like the LoRaWAN (TTN) controller allow to couple a counter to a set of samples.
|
||||
This is called the "Sample Set Initiator".
|
||||
On every new sample sent to this controller from a specific task, a counter is incremented.
|
||||
This was designed specifically for this use case where a new sample from a task, like the GPS, may trigger a number of new samples from other tasks.
|
||||
These other samples will then be accompanied by the same sample set counter.
|
||||
|
||||
Some packets of a controller like the LoRaWAN (TTN) controller, may get lost during transmission.
|
||||
This way the received samples can still be grouped together and if the travelled path is predictable these samples can even be tracked back to the most likely position where they may have been taken.
|
||||
|
||||
|
||||
Data Acquisition
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
The GPS receiver yields more measurement values than the max. 4 that can be used in a task.
|
||||
When the GPS receiver is linked to the LoRaWAN (TTN) controller, all relevant received data will be transmitted.
|
||||
This allows for more information to be processed on the receiving end, compared to other controllers.
|
||||
|
||||
|
||||
|
||||
Supported hardware
|
||||
------------------
|
||||
|
||||
|P082_usedby|
|
||||
|
||||
.. Commands available
|
||||
.. ^^^^^^^^^^^^^^^^^^
|
||||
Commands available
|
||||
^^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. .. include:: P082_commands.repl
|
||||
.. include:: P082_commands.repl
|
||||
|
||||
Events
|
||||
~~~~~~
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
.. csv-table::
|
||||
:header: "Command", "Extra information"
|
||||
:widths: 20, 30
|
||||
|
||||
"
|
||||
``gps,sleep``
|
||||
|
||||
","
|
||||
Send u-blox specific command to put the GPS in backup mode.
|
||||
This turns off all parts of the GPS, except for the last known satellite trajectories.
|
||||
|
||||
Use this to get a faster fix, compared to turning off the power to the GPS.
|
||||
|
||||
In order to send a command to the GPS, the GPS RX pin must be connected.
|
||||
|
||||
"
|
||||
"
|
||||
``gps,wake``
|
||||
|
||||
","
|
||||
Send just any character to the GPS to wake it from backup mode (see ``gps,sleep``)
|
||||
|
||||
This is u-blox specific.
|
||||
|
||||
In order to send a command to the GPS, the GPS RX pin must be connected.
|
||||
|
||||
"
|
||||
@@ -554,10 +554,10 @@ P065 :ref:`P065_page`
|
||||
.. .. include:: ../Plugin/P072_commands.repl
|
||||
|
||||
|
||||
.. P073 :ref:`P073_page`
|
||||
.. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
P073 :ref:`P073_page`
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. .. include:: ../Plugin/P073_commands.repl
|
||||
.. include:: ../Plugin/P073_commands.repl
|
||||
|
||||
|
||||
.. P074 :ref:`P074_page`
|
||||
@@ -608,10 +608,10 @@ P079 :ref:`P079_page`
|
||||
.. .. include:: ../Plugin/P081_commands.repl
|
||||
|
||||
|
||||
.. P082 :ref:`P082_page`
|
||||
.. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
P082 :ref:`P082_page`
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. .. include:: ../Plugin/P082_commands.repl
|
||||
.. include:: ../Plugin/P082_commands.repl
|
||||
|
||||
P088 :ref:`P088_page`
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
@@ -652,6 +652,12 @@ P101 :ref:`P101_page`
|
||||
.. include:: ../Plugin/P101_commands.repl
|
||||
|
||||
|
||||
P104 :ref:`P104_page`
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. include:: ../Plugin/P104_commands.repl
|
||||
|
||||
|
||||
|
||||
P115 :ref:`P115_page`
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
@@ -314,6 +314,26 @@ int ESPeasySerial::baudRate(void) {
|
||||
return getHW()->baudRate();
|
||||
}
|
||||
|
||||
bool ESPeasySerial::isTxEnabled(void) {
|
||||
if (!isValid()) {
|
||||
return false;
|
||||
}
|
||||
if (isI2Cserial()) {
|
||||
return true;
|
||||
}
|
||||
return _transmitPin != -1;
|
||||
}
|
||||
|
||||
bool ESPeasySerial::isRxEnabled(void) {
|
||||
if (!isValid()) {
|
||||
return false;
|
||||
}
|
||||
if (isI2Cserial()) {
|
||||
return true;
|
||||
}
|
||||
return _receivePin != -1;
|
||||
}
|
||||
|
||||
// Not supported in ESP32, since only HW serial is used.
|
||||
// Function included since it is used in some libraries.
|
||||
bool ESPeasySerial::listen() {
|
||||
|
||||
@@ -302,8 +302,12 @@ public:
|
||||
size_t size) override;
|
||||
|
||||
void setDebugOutput(bool);
|
||||
#endif
|
||||
|
||||
bool isTxEnabled(void);
|
||||
bool isRxEnabled(void);
|
||||
|
||||
#if defined(ESP8266)
|
||||
bool hasRxError(void);
|
||||
|
||||
void startDetectBaudrate();
|
||||
|
||||
@@ -375,16 +375,28 @@ void ESPeasySerial::setDebugOutput(bool enable) {
|
||||
}
|
||||
|
||||
bool ESPeasySerial::isTxEnabled(void) {
|
||||
if (!isValid() || isSWserial() || isI2Cserial()) {
|
||||
if (!isValid()) {
|
||||
return false;
|
||||
}
|
||||
if (isI2Cserial()) {
|
||||
return true;
|
||||
}
|
||||
if (isSWserial()) {
|
||||
return _transmitPin != -1;
|
||||
}
|
||||
return getHW()->isTxEnabled();
|
||||
}
|
||||
|
||||
bool ESPeasySerial::isRxEnabled(void) {
|
||||
if (!isValid() || isSWserial() || isI2Cserial()) {
|
||||
if (!isValid()) {
|
||||
return false;
|
||||
}
|
||||
if (isI2Cserial()) {
|
||||
return true;
|
||||
}
|
||||
if (isSWserial()) {
|
||||
return _receivePin != -1;
|
||||
}
|
||||
return getHW()->isRxEnabled();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ESPeasySerial",
|
||||
"version": "2.0.7",
|
||||
"version": "2.0.8",
|
||||
"keywords": [
|
||||
"serial", "io", "softwareserial", "hardwareserial"
|
||||
],
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
name=ESPeasySerial
|
||||
version=2.0.7
|
||||
version=2.0.8
|
||||
author=Gijs Noorlander
|
||||
maintainer=Gijs Noorlander <gijs.noorlander@gmail.com>
|
||||
sentence=Wrapper for SoftwareSerial, SC16IS752 I2C to UART bridge and HardwareSerial for ESP8266 and ESP32/ESP32S2.
|
||||
|
||||
@@ -272,6 +272,7 @@ public:
|
||||
MFRC522();
|
||||
MFRC522(uint8_t resetPowerDownPin);
|
||||
MFRC522(uint8_t chipSelectPin, uint8_t resetPowerDownPin);
|
||||
virtual ~MFRC522() {};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
// Basic interface functions for communicating with the MFRC522
|
||||
|
||||
@@ -71,6 +71,8 @@ bool TinyGPSPlus::encode(char c)
|
||||
{
|
||||
term[curTermOffset] = 0;
|
||||
isValidSentence = endOfTermHandler();
|
||||
} else if (curSentenceType == GPS_SENTENCE_GPTXT) {
|
||||
isValidSentence = endOfTermHandler();
|
||||
}
|
||||
++curTermNumber;
|
||||
curTermOffset = 0;
|
||||
@@ -203,6 +205,21 @@ bool TinyGPSPlus::endOfTermHandler()
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GPS_SENTENCE_GPGLL:
|
||||
date.commit();
|
||||
time.commit();
|
||||
if (sentenceHasFix && date.valid && time.valid)
|
||||
{
|
||||
location.commit();
|
||||
if (!(location.valid)) {
|
||||
// one of them is invalid, so consider the entire sentence invalid
|
||||
date.valid = false;
|
||||
time.valid = false;
|
||||
location.valid = false;
|
||||
++invalidDataCount;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case GPS_SENTENCE_GPGGA:
|
||||
time.commit();
|
||||
satellites.commit();
|
||||
@@ -232,6 +249,8 @@ bool TinyGPSPlus::endOfTermHandler()
|
||||
}
|
||||
hdop.commit();
|
||||
break;
|
||||
case GPS_SENTENCE_GPTXT:
|
||||
break;
|
||||
}
|
||||
|
||||
// Commit all custom listeners of this sentence type
|
||||
@@ -266,25 +285,31 @@ bool TinyGPSPlus::endOfTermHandler()
|
||||
{
|
||||
case COMBINE(GPS_SENTENCE_GPRMC, 1): // Time in both sentences
|
||||
case COMBINE(GPS_SENTENCE_GPGGA, 1):
|
||||
case COMBINE(GPS_SENTENCE_GPGLL, 5):
|
||||
time.setTime(term);
|
||||
break;
|
||||
case COMBINE(GPS_SENTENCE_GPRMC, 2): // GPRMC validity
|
||||
case COMBINE(GPS_SENTENCE_GPGLL, 6):
|
||||
sentenceHasFix = term[0] == 'A';
|
||||
break;
|
||||
case COMBINE(GPS_SENTENCE_GPRMC, 3): // Latitude
|
||||
case COMBINE(GPS_SENTENCE_GPGGA, 2):
|
||||
case COMBINE(GPS_SENTENCE_GPGLL, 1):
|
||||
location.setLatitude(term);
|
||||
break;
|
||||
case COMBINE(GPS_SENTENCE_GPRMC, 4): // N/S
|
||||
case COMBINE(GPS_SENTENCE_GPGGA, 3):
|
||||
case COMBINE(GPS_SENTENCE_GPGLL, 2):
|
||||
location.rawNewLatData.negative = term[0] == 'S';
|
||||
break;
|
||||
case COMBINE(GPS_SENTENCE_GPRMC, 5): // Longitude
|
||||
case COMBINE(GPS_SENTENCE_GPGGA, 4):
|
||||
case COMBINE(GPS_SENTENCE_GPGLL, 3):
|
||||
location.setLongitude(term);
|
||||
break;
|
||||
case COMBINE(GPS_SENTENCE_GPRMC, 6): // E/W
|
||||
case COMBINE(GPS_SENTENCE_GPGGA, 5):
|
||||
case COMBINE(GPS_SENTENCE_GPGLL, 4):
|
||||
location.rawNewLngData.negative = term[0] == 'W';
|
||||
break;
|
||||
case COMBINE(GPS_SENTENCE_GPRMC, 7): // Speed (GPRMC)
|
||||
@@ -698,6 +723,15 @@ void TinyGPSPlus::parseSentenceType(const char *term)
|
||||
{
|
||||
curSentenceType = GPS_SENTENCE_GPGSV;
|
||||
}
|
||||
else if (strcmp(&term[2], "TXT") == 0)
|
||||
{
|
||||
curSentenceType = GPS_SENTENCE_GPTXT;
|
||||
}
|
||||
else if (strcmp(&term[2], "GLL") == 0)
|
||||
{
|
||||
curSentenceType = GPS_SENTENCE_GPGLL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -316,6 +316,10 @@ private:
|
||||
GPS_SENTENCE_GPGSA, // GSA - GPS DOP and active satellites
|
||||
GPS_SENTENCE_GPGSV, // GSV - Satellites in view
|
||||
|
||||
GPS_SENTENCE_GPGLL, // GLL - Latitude and longitude, with time of position fix and status
|
||||
|
||||
GPS_SENTENCE_GPTXT, // Free format TXT field
|
||||
|
||||
GPS_SENTENCE_OTHER};
|
||||
|
||||
enum {
|
||||
|
||||
@@ -10,7 +10,7 @@ lib_ignore = ESP8266WiFi, ESP8266Ping, ESP8266WebServer, ESP8266H
|
||||
|
||||
[esp32_common]
|
||||
extends = common, core_esp32_3_3_0
|
||||
lib_deps = td-er/ESPeasySerial @ 2.0.7, adafruit/Adafruit ILI9341 @ ^1.5.6, Adafruit GFX Library, LOLIN_EPD, Adafruit BusIO, VL53L0X @ 1.3.0, SparkFun VL53L1X 4m Laser Distance Sensor @ 1.2.9, td-er/SparkFun MAX1704x Fuel Gauge Arduino Library @ ^1.0.1, ArduinoOTA, ESP32HTTPUpdateServer
|
||||
lib_deps = td-er/ESPeasySerial @ 2.0.8, adafruit/Adafruit ILI9341 @ ^1.5.6, Adafruit GFX Library, LOLIN_EPD, Adafruit BusIO, VL53L0X @ 1.3.0, SparkFun VL53L1X 4m Laser Distance Sensor @ 1.2.9, td-er/SparkFun MAX1704x Fuel Gauge Arduino Library @ ^1.0.1, ArduinoOTA, ESP32HTTPUpdateServer
|
||||
lib_ignore = ${esp32_always.lib_ignore}, ESP32_ping, IRremoteESP8266, HeatpumpIR
|
||||
board_build.f_flash = 80000000L
|
||||
board_build.flash_mode = dout
|
||||
|
||||
@@ -52,7 +52,7 @@ extends = common
|
||||
board_build.f_cpu = 80000000L
|
||||
build_flags = ${debug_flags.build_flags} ${mqtt_flags.build_flags} -DHTTPCLIENT_1_1_COMPATIBLE=0
|
||||
build_unflags = -DDEBUG_ESP_PORT
|
||||
lib_deps = td-er/ESPeasySerial @ 2.0.7, adafruit/Adafruit ILI9341 @ ^1.5.6, Adafruit GFX Library, LOLIN_EPD, Adafruit BusIO, bblanchon/ArduinoJson @ ^6.17.2, VL53L0X @ 1.3.0, SparkFun VL53L1X 4m Laser Distance Sensor @ 1.2.9, td-er/RABurton ESP8266 Mutex @ ^1.0.2, td-er/SparkFun MAX1704x Fuel Gauge Arduino Library @ ^1.0.1, ESP8266HTTPUpdateServer
|
||||
lib_deps = td-er/ESPeasySerial @ 2.0.8, adafruit/Adafruit ILI9341 @ ^1.5.6, Adafruit GFX Library, LOLIN_EPD, Adafruit BusIO, bblanchon/ArduinoJson @ ^6.17.2, VL53L0X @ 1.3.0, SparkFun VL53L1X 4m Laser Distance Sensor @ 1.2.9, td-er/RABurton ESP8266 Mutex @ ^1.0.2, td-er/SparkFun MAX1704x Fuel Gauge Arduino Library @ ^1.0.1, ESP8266HTTPUpdateServer
|
||||
lib_ignore = ${esp82xx_defaults.lib_ignore}, IRremoteESP8266, HeatpumpIR, LittleFS(esp8266), ServoESP32, TinyWireM
|
||||
board = esp12e
|
||||
monitor_filters = esp8266_exception_decoder
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ MarkupSafe==2.0.1
|
||||
marshmallow==3.14.0
|
||||
packaging==21.0
|
||||
pathtools==0.1.2
|
||||
platformio>=5.2.2
|
||||
platformio>=5.2.3
|
||||
port-for==0.6.1
|
||||
pycparser==2.20
|
||||
pyelftools==0.27
|
||||
|
||||
+3
-1
@@ -82,7 +82,9 @@ bool CPlugin_002(CPlugin::Function function, struct EventStruct *event, String&
|
||||
if (deserializeDomoticzJson(event->String2, idx, nvalue, nvaluealt, svalue1, switchtype)) {
|
||||
for (taskIndex_t x = 0; x < TASKS_MAX; x++) {
|
||||
// We need the index of the controller we are: 0...CONTROLLER_MAX
|
||||
if (Settings.TaskDeviceEnabled[x] && (Settings.TaskDeviceID[ControllerID][x] == idx)) // get idx for our controller index
|
||||
if (Settings.TaskDeviceEnabled[x] &&
|
||||
Settings.TaskDeviceSendData[ControllerID][x] &&
|
||||
(Settings.TaskDeviceID[ControllerID][x] == idx)) // get idx for our controller index
|
||||
{
|
||||
String action;
|
||||
bool mustSendEvent = false;
|
||||
|
||||
+4
-4
@@ -81,7 +81,7 @@ bool CPlugin_005(CPlugin::Function function, struct EventStruct *event, String&
|
||||
const int lastindex = event->String1.lastIndexOf('/');
|
||||
const String lastPartTopic = event->String1.substring(lastindex + 1);
|
||||
|
||||
if (lastPartTopic == F("cmd")) {
|
||||
if (lastPartTopic.equals(F("cmd"))) {
|
||||
// Example:
|
||||
// topic: ESP_Easy/Bathroom_pir_env/cmd
|
||||
// data: gpio,14,0
|
||||
@@ -116,14 +116,14 @@ bool CPlugin_005(CPlugin::Function function, struct EventStruct *event, String&
|
||||
|
||||
if (validTopic) {
|
||||
// in case of event, store to buffer and return...
|
||||
String command = parseString(cmd, 1);
|
||||
const String command = parseString(cmd, 1);
|
||||
|
||||
if ((command == F("event")) || (command == F("asyncevent"))) {
|
||||
if ((command.equals(F("event"))) || (command.equals(F("asyncevent")))) {
|
||||
if (Settings.UseRules) {
|
||||
eventQueue.addMove(parseStringToEnd(cmd, 2));
|
||||
}
|
||||
} else {
|
||||
ExecuteCommand(event->TaskIndex, EventValueSource::Enum::VALUE_SOURCE_MQTT, cmd.c_str(), true, true, true);
|
||||
ExecuteCommand_all(EventValueSource::Enum::VALUE_SOURCE_MQTT, cmd.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -92,9 +92,10 @@ bool CPlugin_006(CPlugin::Function function, struct EventStruct *event, String&
|
||||
cmd += topicSplit[6].toInt(); // Par1
|
||||
cmd += ',';
|
||||
|
||||
if ((event->String2 == F("false")) || (event->String2 == F("true")))
|
||||
if ((event->String2.equalsIgnoreCase(F("false"))) ||
|
||||
(event->String2.equalsIgnoreCase(F("true"))))
|
||||
{
|
||||
cmd += (event->String2 == F("true")) ? '1' : '0'; // Par2
|
||||
cmd += (event->String2.equalsIgnoreCase(F("true"))) ? '1' : '0'; // Par2
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
+16
-4
@@ -77,13 +77,25 @@ struct C018_data_struct {
|
||||
_baudrate = baudrate;
|
||||
|
||||
// FIXME TD-er: Make force SW serial a proper setting.
|
||||
if (C018_easySerial != nullptr) {
|
||||
delete C018_easySerial;
|
||||
}
|
||||
|
||||
C018_easySerial = new (std::nothrow) ESPeasySerial(static_cast<ESPEasySerialPort>(port), serial_rx, serial_tx, false, 64);
|
||||
|
||||
if (C018_easySerial != nullptr) {
|
||||
myLora = new rn2xx3(*C018_easySerial);
|
||||
myLora->setAsyncMode(true);
|
||||
myLora->setLastUsedJoinMode(joinIsOTAA);
|
||||
triggerAutobaud();
|
||||
if (myLora != nullptr) {
|
||||
delete myLora;
|
||||
}
|
||||
myLora = new (std::nothrow) rn2xx3(*C018_easySerial);
|
||||
if (myLora == nullptr) {
|
||||
delete C018_easySerial;
|
||||
C018_easySerial = nullptr;
|
||||
} else {
|
||||
myLora->setAsyncMode(true);
|
||||
myLora->setLastUsedJoinMode(joinIsOTAA);
|
||||
triggerAutobaud();
|
||||
}
|
||||
}
|
||||
return isInitialized();
|
||||
}
|
||||
|
||||
+1
-1
@@ -226,7 +226,7 @@ boolean Plugin_016(uint8_t function, struct EventStruct *event, String& string)
|
||||
addLog(LOG_LEVEL_INFO, F("INIT: IR RX"));
|
||||
addLog(LOG_LEVEL_INFO, F("IR lib Version: " _IRREMOTEESP8266_VERSION_));
|
||||
}
|
||||
irReceiver = new IRrecv(irPin, kCaptureBufferSize, P016_TIMEOUT, true);
|
||||
irReceiver = new (std::nothrow) IRrecv(irPin, kCaptureBufferSize, P016_TIMEOUT, true);
|
||||
# ifdef PLUGIN_016_DEBUG
|
||||
addLog(LOG_LEVEL_INFO, F("P016_PLUGIN_INIT IR receiver created"));
|
||||
# endif // PLUGIN_016_DEBUG
|
||||
|
||||
+24
-6
@@ -99,21 +99,23 @@ boolean Plugin_035(uint8_t function, struct EventStruct *event, String &command)
|
||||
case PLUGIN_INIT:
|
||||
{
|
||||
int irPin = CONFIG_PIN1;
|
||||
if (Plugin_035_irSender == 0 && validGpio(irPin))
|
||||
if (Plugin_035_irSender == nullptr && validGpio(irPin))
|
||||
{
|
||||
if (loglevelActiveFor(LOG_LEVEL_INFO)) {
|
||||
addLog(LOG_LEVEL_INFO, F("INIT: IR TX"));
|
||||
addLog(LOG_LEVEL_INFO, F("IR lib Version: " _IRREMOTEESP8266_VERSION_));
|
||||
addLog(LOG_LEVEL_INFO, String(F("Supported Protocols by IRSEND: ")) + listProtocols());
|
||||
}
|
||||
Plugin_035_irSender = new IRsend(irPin);
|
||||
Plugin_035_irSender->begin(); // Start the sender
|
||||
Plugin_035_irSender = new (std::nothrow) IRsend(irPin);
|
||||
if (Plugin_035_irSender != nullptr) {
|
||||
Plugin_035_irSender->begin(); // Start the sender
|
||||
}
|
||||
}
|
||||
if (Plugin_035_irSender != 0 && irPin == -1)
|
||||
if (Plugin_035_irSender != nullptr && irPin == -1)
|
||||
{
|
||||
addLog(LOG_LEVEL_INFO, F("INIT: IR TX Removed"));
|
||||
delete Plugin_035_irSender;
|
||||
Plugin_035_irSender = 0;
|
||||
Plugin_035_irSender = nullptr;
|
||||
}
|
||||
|
||||
#ifdef P016_P035_Extended_AC
|
||||
@@ -129,7 +131,7 @@ boolean Plugin_035(uint8_t function, struct EventStruct *event, String &command)
|
||||
{
|
||||
addLog(LOG_LEVEL_INFO, F("INIT AC: IR TX Removed"));
|
||||
delete Plugin_035_commonAc;
|
||||
Plugin_035_commonAc = 0;
|
||||
Plugin_035_commonAc = nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -137,6 +139,22 @@ boolean Plugin_035(uint8_t function, struct EventStruct *event, String &command)
|
||||
break;
|
||||
}
|
||||
|
||||
case PLUGIN_EXIT:
|
||||
{
|
||||
if (Plugin_035_irSender != nullptr) {
|
||||
delete Plugin_035_irSender;
|
||||
Plugin_035_irSender = nullptr;
|
||||
}
|
||||
#ifdef P016_P035_Extended_AC
|
||||
if (Plugin_035_commonAc != nullptr) {
|
||||
delete Plugin_035_commonAc;
|
||||
Plugin_035_commonAc = nullptr;
|
||||
}
|
||||
#endif
|
||||
success = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case PLUGIN_WRITE:
|
||||
{
|
||||
String cmdCode = parseString(command,1);
|
||||
|
||||
+19
-6
@@ -31,7 +31,7 @@
|
||||
|
||||
#include <Adafruit_NeoPixel.h>
|
||||
|
||||
Adafruit_NeoPixel *Plugin_038_pixels;
|
||||
Adafruit_NeoPixel *Plugin_038_pixels = nullptr;
|
||||
|
||||
#define PLUGIN_038
|
||||
#define PLUGIN_ID_038 38
|
||||
@@ -94,23 +94,36 @@ boolean Plugin_038(uint8_t function, struct EventStruct *event, String& string)
|
||||
|
||||
case PLUGIN_INIT:
|
||||
{
|
||||
if (!Plugin_038_pixels)
|
||||
if (Plugin_038_pixels == nullptr)
|
||||
{
|
||||
uint8_t striptype = PCONFIG(1);
|
||||
if (striptype == 1)
|
||||
Plugin_038_pixels = new Adafruit_NeoPixel(PCONFIG(0), CONFIG_PIN1, NEO_GRB + NEO_KHZ800);
|
||||
Plugin_038_pixels = new (std::nothrow) Adafruit_NeoPixel(PCONFIG(0), CONFIG_PIN1, NEO_GRB + NEO_KHZ800);
|
||||
else if (striptype == 2)
|
||||
Plugin_038_pixels = new Adafruit_NeoPixel(PCONFIG(0), CONFIG_PIN1, NEO_GRBW + NEO_KHZ800);
|
||||
Plugin_038_pixels = new (std::nothrow) Adafruit_NeoPixel(PCONFIG(0), CONFIG_PIN1, NEO_GRBW + NEO_KHZ800);
|
||||
else
|
||||
Plugin_038_pixels = new Adafruit_NeoPixel(PCONFIG(0), CONFIG_PIN1, NEO_GRB + NEO_KHZ800);
|
||||
Plugin_038_pixels = new (std::nothrow) Adafruit_NeoPixel(PCONFIG(0), CONFIG_PIN1, NEO_GRB + NEO_KHZ800);
|
||||
|
||||
Plugin_038_pixels->begin(); // This initializes the NeoPixel library.
|
||||
if (Plugin_038_pixels != nullptr) {
|
||||
Plugin_038_pixels->begin(); // This initializes the NeoPixel library.
|
||||
}
|
||||
}
|
||||
MaxPixels = PCONFIG(0);
|
||||
success = Plugin_038_pixels != nullptr;
|
||||
break;
|
||||
}
|
||||
|
||||
case PLUGIN_EXIT:
|
||||
{
|
||||
if (Plugin_038_pixels != nullptr) {
|
||||
delete Plugin_038_pixels;
|
||||
Plugin_038_pixels = nullptr;
|
||||
}
|
||||
success = true;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case PLUGIN_WRITE:
|
||||
{
|
||||
if (Plugin_038_pixels)
|
||||
|
||||
+15
-4
@@ -80,15 +80,26 @@ boolean Plugin_041(uint8_t function, struct EventStruct *event, String& string)
|
||||
|
||||
case PLUGIN_INIT:
|
||||
{
|
||||
if (!Plugin_041_pixels)
|
||||
if (Plugin_041_pixels == nullptr)
|
||||
{
|
||||
Plugin_041_pixels = new Adafruit_NeoPixel(NUM_LEDS, CONFIG_PIN1, NEO_GRB + NEO_KHZ800);
|
||||
Plugin_041_pixels->begin(); // This initializes the NeoPixel library.
|
||||
Plugin_041_pixels = new (std::nothrow) Adafruit_NeoPixel(NUM_LEDS, CONFIG_PIN1, NEO_GRB + NEO_KHZ800);
|
||||
if (Plugin_041_pixels != nullptr) {
|
||||
Plugin_041_pixels->begin(); // This initializes the NeoPixel library.
|
||||
}
|
||||
}
|
||||
Plugin_041_red = PCONFIG(0);
|
||||
Plugin_041_green = PCONFIG(1);
|
||||
Plugin_041_blue = PCONFIG(2);
|
||||
success = true;
|
||||
success = Plugin_041_pixels != nullptr;
|
||||
break;
|
||||
}
|
||||
|
||||
case PLUGIN_EXIT:
|
||||
{
|
||||
if (Plugin_041_pixels != nullptr) {
|
||||
delete Plugin_041_pixels;
|
||||
Plugin_041_pixels = nullptr;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
+16
-5
@@ -273,10 +273,12 @@ boolean Plugin_042(uint8_t function, struct EventStruct *event, String& string)
|
||||
if (Candle_pixels) {
|
||||
delete Candle_pixels;
|
||||
}
|
||||
Candle_pixels = new Adafruit_NeoPixel(NUM_PIXEL, CONFIG_PIN1, NEO_GRB + NEO_KHZ800);
|
||||
SetPixelsBlack();
|
||||
Candle_pixels->setBrightness(Candle_bright);
|
||||
Candle_pixels->begin();
|
||||
Candle_pixels = new (std::nothrow) Adafruit_NeoPixel(NUM_PIXEL, CONFIG_PIN1, NEO_GRB + NEO_KHZ800);
|
||||
if (Candle_pixels != nullptr) {
|
||||
SetPixelsBlack();
|
||||
Candle_pixels->setBrightness(Candle_bright);
|
||||
Candle_pixels->begin();
|
||||
}
|
||||
|
||||
#ifndef BUILD_NO_DEBUG
|
||||
if (loglevelActiveFor(LOG_LEVEL_DEBUG)) {
|
||||
@@ -287,7 +289,16 @@ boolean Plugin_042(uint8_t function, struct EventStruct *event, String& string)
|
||||
#endif
|
||||
}
|
||||
|
||||
success = true;
|
||||
success = Candle_pixels != nullptr;
|
||||
break;
|
||||
}
|
||||
|
||||
case PLUGIN_EXIT:
|
||||
{
|
||||
if (Candle_pixels != nullptr) {
|
||||
delete Candle_pixels;
|
||||
Candle_pixels = nullptr;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -279,7 +279,7 @@ boolean Plugin_046(uint8_t function, struct EventStruct *event, String& string)
|
||||
case PLUGIN_INIT:
|
||||
{
|
||||
if (!P046_data) {
|
||||
P046_data = new P046_data_struct();
|
||||
P046_data = new (std::nothrow) P046_data_struct();
|
||||
}
|
||||
|
||||
uint8_t choice = PCONFIG(0);
|
||||
|
||||
+6
-14
@@ -42,13 +42,13 @@ boolean Plugin_053(uint8_t function, struct EventStruct *event, String& string)
|
||||
Device[deviceCount].Ports = 0;
|
||||
Device[deviceCount].PullUpOption = false;
|
||||
Device[deviceCount].InverseLogicOption = false;
|
||||
# ifdef PLUGIN_053_ENABLE_EXTRA_SENSORS
|
||||
# ifdef PLUGIN_053_ENABLE_EXTRA_SENSORS
|
||||
Device[deviceCount].FormulaOption = true;
|
||||
Device[deviceCount].ValueCount = 4;
|
||||
# else // ifdef PLUGIN_053_ENABLE_EXTRA_SENSORS
|
||||
# else // ifdef PLUGIN_053_ENABLE_EXTRA_SENSORS
|
||||
Device[deviceCount].FormulaOption = false;
|
||||
Device[deviceCount].ValueCount = 3;
|
||||
# endif // ifdef PLUGIN_053_ENABLE_EXTRA_SENSORS
|
||||
# endif // ifdef PLUGIN_053_ENABLE_EXTRA_SENSORS
|
||||
Device[deviceCount].SendDataOption = true;
|
||||
Device[deviceCount].TimerOption = true;
|
||||
Device[deviceCount].GlobalSyncOption = true;
|
||||
@@ -166,27 +166,19 @@ boolean Plugin_053(uint8_t function, struct EventStruct *event, String& string)
|
||||
# ifdef PLUGIN_053_ENABLE_EXTRA_SENSORS
|
||||
{
|
||||
addFormSubHeader(F("Device"));
|
||||
# ifdef PLUGIN_053_ENABLE_S_AND_T
|
||||
int unitModelCount = 5;
|
||||
# else // ifdef PLUGIN_053_ENABLE_S_AND_T
|
||||
int unitModelCount = 3;
|
||||
# endif // ifdef PLUGIN_053_ENABLE_S_AND_T
|
||||
int unitModelCount = 5;
|
||||
const __FlashStringHelper *unitModels[] = {
|
||||
toString(PMSx003_type::PMS1003_5003_7003),
|
||||
toString(PMSx003_type::PMS2003_3003),
|
||||
# ifdef PLUGIN_053_ENABLE_S_AND_T
|
||||
toString(PMSx003_type::PMS5003_S),
|
||||
toString(PMSx003_type::PMS5003_T),
|
||||
# endif // ifdef PLUGIN_053_ENABLE_S_AND_T
|
||||
toString(PMSx003_type::PMS5003_ST)
|
||||
};
|
||||
const int unitModelOptions[] = {
|
||||
static_cast<int>(PMSx003_type::PMS1003_5003_7003),
|
||||
static_cast<int>(PMSx003_type::PMS2003_3003),
|
||||
# ifdef PLUGIN_053_ENABLE_S_AND_T
|
||||
static_cast<int>(PMSx003_type::PMS5003_S),
|
||||
static_cast<int>(PMSx003_type::PMS5003_T),
|
||||
# endif // ifdef PLUGIN_053_ENABLE_S_AND_T
|
||||
static_cast<int>(PMSx003_type::PMS5003_ST)
|
||||
};
|
||||
addFormSelector(F("Sensor model"), F("p053_model"), unitModelCount, unitModels, unitModelOptions, PLUGIN_053_SENSOR_MODEL_SELECTOR);
|
||||
@@ -314,9 +306,9 @@ boolean Plugin_053(uint8_t function, struct EventStruct *event, String& string)
|
||||
|
||||
PMSx003_type Plugin_053_sensortype = PMSx003_type::PMS1003_5003_7003;
|
||||
|
||||
# ifdef PLUGIN_053_ENABLE_EXTRA_SENSORS
|
||||
# ifdef PLUGIN_053_ENABLE_EXTRA_SENSORS
|
||||
Plugin_053_sensortype = GET_PLUGIN_053_SENSOR_MODEL_SELECTOR;
|
||||
# endif // ifdef PLUGIN_053_ENABLE_EXTRA_SENSORS
|
||||
# endif // ifdef PLUGIN_053_ENABLE_EXTRA_SENSORS
|
||||
|
||||
initPluginTaskData(
|
||||
event->TaskIndex,
|
||||
|
||||
@@ -127,10 +127,12 @@ boolean Plugin_054(uint8_t function, struct EventStruct *event, String& string)
|
||||
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);
|
||||
Plugin_054_DMXBuffer = new (std::nothrow) uint8_t[Plugin_054_DMXSize];
|
||||
if (Plugin_054_DMXBuffer != nullptr) {
|
||||
memset(Plugin_054_DMXBuffer, 0, Plugin_054_DMXSize);
|
||||
}
|
||||
|
||||
success = true;
|
||||
success = Plugin_054_DMXBuffer != nullptr;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
+40
-44
@@ -62,35 +62,20 @@
|
||||
class CPlugin_055_Data
|
||||
{
|
||||
public:
|
||||
long millisStateEnd;
|
||||
long millisChimeTime;
|
||||
long millisPauseTime;
|
||||
long millisStateEnd = 0;
|
||||
long millisChimeTime = 60;
|
||||
long millisPauseTime = 400;
|
||||
|
||||
int pin[4];
|
||||
uint8_t lowActive;
|
||||
uint8_t chimeClock;
|
||||
int pin[4] = {0};
|
||||
uint8_t lowActive = false;
|
||||
uint8_t chimeClock = true;
|
||||
|
||||
char FIFO[PLUGIN_055_FIFO_SIZE];
|
||||
uint8_t FIFO_IndexR;
|
||||
uint8_t FIFO_IndexW;
|
||||
|
||||
void Plugin_055_Data()
|
||||
{
|
||||
millisStateEnd = 0;
|
||||
millisChimeTime = 60;
|
||||
millisPauseTime = 400;
|
||||
|
||||
for (uint8_t i=0; i<4; i++)
|
||||
pin[i] = -1;
|
||||
lowActive = false;
|
||||
chimeClock = true;
|
||||
|
||||
FIFO_IndexR = 0;
|
||||
FIFO_IndexW = 0;
|
||||
}
|
||||
char FIFO[PLUGIN_055_FIFO_SIZE] = {0};
|
||||
uint8_t FIFO_IndexR = 0;
|
||||
uint8_t FIFO_IndexW = 0;
|
||||
};
|
||||
|
||||
static CPlugin_055_Data* Plugin_055_Data = NULL;
|
||||
static CPlugin_055_Data* Plugin_055_Data = nullptr;
|
||||
|
||||
|
||||
boolean Plugin_055(uint8_t function, struct EventStruct *event, String& string)
|
||||
@@ -188,31 +173,42 @@ boolean Plugin_055(uint8_t function, struct EventStruct *event, String& string)
|
||||
case PLUGIN_INIT:
|
||||
{
|
||||
if (!Plugin_055_Data)
|
||||
Plugin_055_Data = new CPlugin_055_Data();
|
||||
Plugin_055_Data = new (std::nothrow) CPlugin_055_Data();
|
||||
|
||||
Plugin_055_Data->lowActive = Settings.TaskDevicePin1Inversed[event->TaskIndex];
|
||||
Plugin_055_Data->millisChimeTime = PCONFIG(0);
|
||||
Plugin_055_Data->millisPauseTime = PCONFIG(1);
|
||||
Plugin_055_Data->chimeClock = PCONFIG(2);
|
||||
if (Plugin_055_Data != nullptr) {
|
||||
Plugin_055_Data->lowActive = Settings.TaskDevicePin1Inversed[event->TaskIndex];
|
||||
Plugin_055_Data->millisChimeTime = PCONFIG(0);
|
||||
Plugin_055_Data->millisPauseTime = PCONFIG(1);
|
||||
Plugin_055_Data->chimeClock = PCONFIG(2);
|
||||
|
||||
String log = F("Chime: GPIO: ");
|
||||
for (uint8_t i=0; i<4; i++)
|
||||
{
|
||||
int pin = Settings.TaskDevicePin[i][event->TaskIndex];
|
||||
Plugin_055_Data->pin[i] = pin;
|
||||
if (pin >= 0)
|
||||
String log = F("Chime: GPIO: ");
|
||||
for (uint8_t i=0; i<4; i++)
|
||||
{
|
||||
pinMode(pin, OUTPUT);
|
||||
digitalWrite(pin, Plugin_055_Data->lowActive);
|
||||
int pin = Settings.TaskDevicePin[i][event->TaskIndex];
|
||||
Plugin_055_Data->pin[i] = pin;
|
||||
if (pin >= 0)
|
||||
{
|
||||
pinMode(pin, OUTPUT);
|
||||
digitalWrite(pin, Plugin_055_Data->lowActive);
|
||||
}
|
||||
log += pin;
|
||||
log += ' ';
|
||||
}
|
||||
log += pin;
|
||||
log += ' ';
|
||||
if (Plugin_055_Data->lowActive)
|
||||
log += F("!");
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
success = true;
|
||||
}
|
||||
if (Plugin_055_Data->lowActive)
|
||||
log += F("!");
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
|
||||
success = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case PLUGIN_EXIT:
|
||||
{
|
||||
if (Plugin_055_Data != nullptr) {
|
||||
delete Plugin_055_Data;
|
||||
Plugin_055_Data = nullptr;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include "ESPEasy-Globals.h"
|
||||
|
||||
|
||||
CjkSDS011 *Plugin_056_SDS = NULL;
|
||||
CjkSDS011 *Plugin_056_SDS = nullptr;
|
||||
|
||||
|
||||
boolean Plugin_056(uint8_t function, struct EventStruct *event, String& string)
|
||||
@@ -105,12 +105,13 @@ boolean Plugin_056(uint8_t function, struct EventStruct *event, String& string)
|
||||
|
||||
case PLUGIN_INIT:
|
||||
{
|
||||
if (Plugin_056_SDS)
|
||||
if (Plugin_056_SDS) {
|
||||
delete Plugin_056_SDS;
|
||||
}
|
||||
const int16_t serial_rx = CONFIG_PIN1;
|
||||
const int16_t serial_tx = CONFIG_PIN2;
|
||||
const ESPEasySerialPort port = static_cast<ESPEasySerialPort>(CONFIG_PORT);
|
||||
Plugin_056_SDS = new CjkSDS011(port, serial_rx, serial_tx);
|
||||
Plugin_056_SDS = new (std::nothrow) CjkSDS011(port, serial_rx, serial_tx);
|
||||
String log = F("SDS : Init OK ESP GPIO-pin RX:");
|
||||
log += serial_rx;
|
||||
log += F(" TX:");
|
||||
@@ -124,6 +125,7 @@ boolean Plugin_056(uint8_t function, struct EventStruct *event, String& string)
|
||||
case PLUGIN_EXIT:
|
||||
{
|
||||
// //FIXME: if this plugin is used more than once at the same time, things go horribly wrong :)
|
||||
// FIXME TD-er: Must implement plugin_data_struct for this
|
||||
//
|
||||
// if (Plugin_056_SDS)
|
||||
// delete Plugin_056_SDS;
|
||||
|
||||
@@ -210,6 +210,7 @@ boolean Plugin_062(uint8_t function, struct EventStruct *event, String& string)
|
||||
SaveCustomTaskSettings(event->TaskIndex, reinterpret_cast<const uint8_t *>(&(P062_data->StoredSettings)), sizeof(P062_data->StoredSettings));
|
||||
if (!canCalibrate) {
|
||||
delete P062_data;
|
||||
P062_data = nullptr;
|
||||
} else {
|
||||
bool clearCalibration = isFormItemChecked(F("p062_clear_calibrate"));
|
||||
if (clearCalibration) {
|
||||
@@ -232,11 +233,12 @@ boolean Plugin_062(uint8_t function, struct EventStruct *event, String& string)
|
||||
P062_data_struct *P062_data = static_cast<P062_data_struct *>(getPluginTaskData(event->TaskIndex));
|
||||
|
||||
if (nullptr != P062_data) {
|
||||
success = true;
|
||||
if (!P062_data->init(event->TaskIndex, PCONFIG(0), PCONFIG(1), tbUseCalibration)) {
|
||||
clearPluginTaskData(event->TaskIndex);
|
||||
P062_data = nullptr;
|
||||
} else {
|
||||
success = true;
|
||||
|
||||
uint8_t touch_treshold = PCONFIG(2);
|
||||
if(touch_treshold == 0) {
|
||||
touch_treshold = P062_DEFAULT_TOUCH_TRESHOLD; //default value
|
||||
|
||||
@@ -121,6 +121,15 @@ boolean Plugin_065(uint8_t function, struct EventStruct *event, String& string)
|
||||
break;
|
||||
}
|
||||
|
||||
case PLUGIN_EXIT:
|
||||
{
|
||||
if (P065_easySerial != nullptr) {
|
||||
delete P065_easySerial;
|
||||
P065_easySerial = nullptr;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case PLUGIN_WRITE:
|
||||
{
|
||||
if (!P065_easySerial) {
|
||||
|
||||
@@ -217,7 +217,6 @@ boolean Plugin_078(uint8_t function, struct EventStruct *event, String& string)
|
||||
|
||||
case PLUGIN_INIT:
|
||||
{
|
||||
Plugin_078_init = true;
|
||||
if (Plugin_078_SoftSerial != NULL) {
|
||||
delete Plugin_078_SoftSerial;
|
||||
Plugin_078_SoftSerial=NULL;
|
||||
@@ -233,9 +232,10 @@ boolean Plugin_078(uint8_t function, struct EventStruct *event, String& string)
|
||||
delete Plugin_078_SDM;
|
||||
Plugin_078_SDM=NULL;
|
||||
}
|
||||
Plugin_078_SDM = new SDM(*Plugin_078_SoftSerial, baudrate, P078_DEPIN);
|
||||
Plugin_078_SDM = new (std::nothrow) SDM(*Plugin_078_SoftSerial, baudrate, P078_DEPIN);
|
||||
if (Plugin_078_SDM != nullptr) {
|
||||
Plugin_078_SDM->begin();
|
||||
Plugin_078_init = true;
|
||||
success = true;
|
||||
}
|
||||
break;
|
||||
|
||||
+96
-2
@@ -30,6 +30,9 @@
|
||||
# define PLUGIN_VALUENAME4_082 "Speed"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# define P082_TIMEOUT PCONFIG(0)
|
||||
# define P082_TIMEOUT_LABEL PCONFIG_LABEL(0)
|
||||
# define P082_BAUDRATE PCONFIG(1)
|
||||
@@ -42,6 +45,10 @@
|
||||
# define P082_QUERY4 PCONFIG(6)
|
||||
# define P082_LONG_REF PCONFIG_FLOAT(0)
|
||||
# define P082_LAT_REF PCONFIG_FLOAT(1)
|
||||
#ifdef P082_USE_U_BLOX_SPECIFIC
|
||||
# define P082_POWER_MODE PCONFIG(7)
|
||||
# define P082_DYNAMIC_MODEL PCONFIG_LONG(0)
|
||||
#endif // P082_USE_U_BLOX_SPECIFIC
|
||||
|
||||
# define P082_NR_OUTPUT_VALUES VARS_PER_TASK
|
||||
# define P082_QUERY1_CONFIG_POS 3
|
||||
@@ -53,7 +60,6 @@
|
||||
# define P082_QUERY3_DFLT P082_query::P082_QUERY_ALT
|
||||
# define P082_QUERY4_DFLT P082_query::P082_QUERY_SPD
|
||||
|
||||
|
||||
// Must use volatile declared variable (which will end up in iRAM)
|
||||
volatile unsigned long P082_pps_time = 0;
|
||||
void Plugin_082_interrupt() ICACHE_RAM_ATTR;
|
||||
@@ -164,6 +170,53 @@ boolean Plugin_082(uint8_t function, struct EventStruct *event, String& string)
|
||||
addFormNumericBox(F("Fix Timeout"), P082_TIMEOUT_LABEL, P082_TIMEOUT, 100, 10000);
|
||||
addUnit(F("ms"));
|
||||
|
||||
#ifdef P082_USE_U_BLOX_SPECIFIC
|
||||
|
||||
addFormSubHeader(F("U-Blox specific"));
|
||||
|
||||
{
|
||||
const __FlashStringHelper * options[3] = {
|
||||
toString(P082_PowerMode::Max_Performance),
|
||||
toString(P082_PowerMode::Power_Save),
|
||||
toString(P082_PowerMode::Eco)
|
||||
};
|
||||
const int indices[3] = {
|
||||
static_cast<int>(P082_PowerMode::Max_Performance),
|
||||
static_cast<int>(P082_PowerMode::Power_Save),
|
||||
static_cast<int>(P082_PowerMode::Eco)
|
||||
};
|
||||
addFormSelector(F("Power Mode"), F("pwrmode"), 3, options, indices, P082_POWER_MODE);
|
||||
}
|
||||
|
||||
{
|
||||
const __FlashStringHelper * options[10] = {
|
||||
toString(P082_DynamicModel::Portable),
|
||||
toString(P082_DynamicModel::Stationary),
|
||||
toString(P082_DynamicModel::Pedestrian),
|
||||
toString(P082_DynamicModel::Automotive),
|
||||
toString(P082_DynamicModel::Sea),
|
||||
toString(P082_DynamicModel::Airborne_1g),
|
||||
toString(P082_DynamicModel::Airborne_2g),
|
||||
toString(P082_DynamicModel::Airborne_4g),
|
||||
toString(P082_DynamicModel::Wrist),
|
||||
toString(P082_DynamicModel::Bike)
|
||||
};
|
||||
const int indices[10] = {
|
||||
static_cast<int>(P082_DynamicModel::Portable),
|
||||
static_cast<int>(P082_DynamicModel::Stationary),
|
||||
static_cast<int>(P082_DynamicModel::Pedestrian),
|
||||
static_cast<int>(P082_DynamicModel::Automotive),
|
||||
static_cast<int>(P082_DynamicModel::Sea),
|
||||
static_cast<int>(P082_DynamicModel::Airborne_1g),
|
||||
static_cast<int>(P082_DynamicModel::Airborne_2g),
|
||||
static_cast<int>(P082_DynamicModel::Airborne_4g),
|
||||
static_cast<int>(P082_DynamicModel::Wrist),
|
||||
static_cast<int>(P082_DynamicModel::Bike)
|
||||
};
|
||||
addFormSelector(F("Dynamic Platform Model"), F("dynmodel"), 10, options, indices, P082_DYNAMIC_MODEL);
|
||||
}
|
||||
#endif // P082_USE_U_BLOX_SPECIFIC
|
||||
|
||||
addFormSubHeader(F("Current Sensor Data"));
|
||||
|
||||
P082_html_show_stats(event);
|
||||
@@ -214,6 +267,10 @@ boolean Plugin_082(uint8_t function, struct EventStruct *event, String& string)
|
||||
}
|
||||
|
||||
case PLUGIN_WEBFORM_SAVE: {
|
||||
#ifdef P082_USE_U_BLOX_SPECIFIC
|
||||
P082_POWER_MODE = getFormItemInt(F("pwrmode"));
|
||||
P082_DYNAMIC_MODEL = getFormItemInt(F("dynmodel"));
|
||||
#endif // P082_USE_U_BLOX_SPECIFIC
|
||||
P082_TIMEOUT = getFormItemInt(P082_TIMEOUT_LABEL);
|
||||
P082_DISTANCE = getFormItemInt(P082_DISTANCE_LABEL);
|
||||
|
||||
@@ -255,6 +312,10 @@ boolean Plugin_082(uint8_t function, struct EventStruct *event, String& string)
|
||||
// pinMode(pps_pin, INPUT_PULLUP);
|
||||
attachInterrupt(pps_pin, Plugin_082_interrupt, RISING);
|
||||
}
|
||||
#ifdef P082_USE_U_BLOX_SPECIFIC
|
||||
P082_data->setPowerMode(static_cast<P082_PowerMode>(P082_POWER_MODE));
|
||||
P082_data->setDynamicModel(static_cast<P082_DynamicModel>(P082_DYNAMIC_MODEL));
|
||||
#endif // P082_USE_U_BLOX_SPECIFIC
|
||||
} else {
|
||||
clearPluginTaskData(event->TaskIndex);
|
||||
}
|
||||
@@ -277,7 +338,11 @@ boolean Plugin_082(uint8_t function, struct EventStruct *event, String& string)
|
||||
|
||||
if ((nullptr != P082_data) && P082_data->loop()) {
|
||||
# ifdef P082_SEND_GPS_TO_LOG
|
||||
addLog(LOG_LEVEL_DEBUG, P082_data->_lastSentence);
|
||||
if (P082_data->_lastSentence.substring(0,10).indexOf(F("TXT")) != -1) {
|
||||
addLog(LOG_LEVEL_INFO, P082_data->_lastSentence);
|
||||
} else {
|
||||
addLog(LOG_LEVEL_DEBUG, P082_data->_lastSentence);
|
||||
}
|
||||
# endif // ifdef P082_SEND_GPS_TO_LOG
|
||||
Scheduler.schedule_task_device_timer(event->TaskIndex, millis());
|
||||
delay(0); // Processing a full sentence may take a while, run some
|
||||
@@ -394,6 +459,35 @@ boolean Plugin_082(uint8_t function, struct EventStruct *event, String& string)
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PLUGIN_WRITE:
|
||||
{
|
||||
P082_data_struct *P082_data =
|
||||
static_cast<P082_data_struct *>(getPluginTaskData(event->TaskIndex));
|
||||
|
||||
if ((nullptr != P082_data) && P082_data->isInitialized()) {
|
||||
const String command = parseString(string, 1);
|
||||
const String subcommand = parseString(string, 2);
|
||||
|
||||
if (command.equals(F("gps"))) {
|
||||
if (subcommand.equals(F("wake"))) {
|
||||
success = P082_data->wakeUp();
|
||||
} else if (subcommand.equals(F("sleep"))) {
|
||||
success = P082_data->powerDown();
|
||||
}
|
||||
#ifdef P082_USE_U_BLOX_SPECIFIC
|
||||
else if (subcommand.equals(F("maxperf"))) {
|
||||
success = P082_data->setPowerMode(P082_PowerMode::Max_Performance);
|
||||
} else if (subcommand.equals(F("powersave"))) {
|
||||
success = P082_data->setPowerMode(P082_PowerMode::Power_Save);
|
||||
} else if (subcommand.equals(F("eco"))) {
|
||||
success = P082_data->setPowerMode(P082_PowerMode::Eco);
|
||||
}
|
||||
#endif // P082_USE_U_BLOX_SPECIFIC
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
# ifdef USES_PACKED_RAW_DATA
|
||||
case PLUGIN_GET_PACKED_RAW_DATA:
|
||||
{
|
||||
|
||||
@@ -207,9 +207,10 @@ boolean Plugin_088(uint8_t function, struct EventStruct *event, String& string)
|
||||
{
|
||||
addLog(LOG_LEVEL_INFO, F("P088: Heatpump IR transmitter deactivated"));
|
||||
|
||||
if (Plugin_088_irSender != NULL)
|
||||
if (Plugin_088_irSender != nullptr)
|
||||
{
|
||||
delete Plugin_088_irSender;
|
||||
Plugin_088_irSender = nullptr;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
@@ -232,7 +232,7 @@ boolean Plugin_102(uint8_t function, struct EventStruct *event, String& string)
|
||||
}
|
||||
|
||||
// Hardware serial is RX on 3 and TX on 1
|
||||
P102_PZEM_sensor = new PZEM004Tv30(port, rxPin, txPin);
|
||||
P102_PZEM_sensor = new (std::nothrow) PZEM004Tv30(port, rxPin, txPin);
|
||||
|
||||
// Sequence for changing PZEM address
|
||||
if (P102_PZEM_ADDR_SET == 1) // if address programming confirmed
|
||||
|
||||
@@ -279,9 +279,12 @@ boolean Plugin_109(byte function, struct EventStruct *event, String& string)
|
||||
uint8_t OLED_address = Settings.TaskDevicePluginConfig[event->TaskIndex][0];
|
||||
|
||||
if (Settings.TaskDevicePluginConfig[event->TaskIndex][2] == 1) {
|
||||
P109_display = new SSD1306Wire(OLED_address, Settings.Pin_i2c_sda, Settings.Pin_i2c_scl);
|
||||
P109_display = new (std::nothrow) SSD1306Wire(OLED_address, Settings.Pin_i2c_sda, Settings.Pin_i2c_scl);
|
||||
} else {
|
||||
P109_display = new SH1106Wire(OLED_address, Settings.Pin_i2c_sda, Settings.Pin_i2c_scl);
|
||||
P109_display = new (std::nothrow) SH1106Wire(OLED_address, Settings.Pin_i2c_sda, Settings.Pin_i2c_scl);
|
||||
}
|
||||
if (P109_display == nullptr) {
|
||||
break;
|
||||
}
|
||||
P109_display->init(); // call to local override of init function
|
||||
P109_display->displayOn();
|
||||
|
||||
@@ -8,13 +8,26 @@
|
||||
Modbus::Modbus() : ModbusClient(nullptr), errcnt(0), timeout(0),
|
||||
TXRXstate(MODBUS_IDLE), RXavailable(0), payLoad(0) {}
|
||||
|
||||
Modbus::~Modbus() {
|
||||
if (ModbusClient) {
|
||||
ModbusClient->flush();
|
||||
ModbusClient->stop();
|
||||
delete (ModbusClient);
|
||||
delay(1);
|
||||
ModbusClient = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
bool Modbus::begin(uint8_t function, uint8_t ModbusID, uint16_t ModbusRegister, MODBUS_registerTypes_t type, char *IPaddress)
|
||||
{
|
||||
currentRegister = ModbusRegister;
|
||||
currentFunction = function;
|
||||
incomingValue = type;
|
||||
resultReceived = false;
|
||||
ModbusClient = new WiFiClient();
|
||||
ModbusClient = new (std::nothrow) WiFiClient();
|
||||
if (ModbusClient == nullptr) {
|
||||
return false;
|
||||
}
|
||||
ModbusClient->setNoDelay(true);
|
||||
ModbusClient->setTimeout(CONTROLLER_CLIENTTIMEOUT_DFLT);
|
||||
timeout = millis();
|
||||
|
||||
@@ -14,6 +14,7 @@ class Modbus {
|
||||
public:
|
||||
|
||||
Modbus(void);
|
||||
~Modbus();
|
||||
bool handle();
|
||||
bool begin(uint8_t function,
|
||||
uint8_t ModbusID,
|
||||
|
||||
@@ -627,13 +627,17 @@ static const IPAddress SSDP_MULTICAST_ADDR(239, 255, 255, 250);
|
||||
bool SSDP_begin() {
|
||||
_pending = false;
|
||||
|
||||
if (_server) {
|
||||
if (_server != nullptr) {
|
||||
_server->unref();
|
||||
// FIXME TD-er: Shouldn't this also call delete _server ?
|
||||
|
||||
_server = 0;
|
||||
_server = nullptr;
|
||||
}
|
||||
|
||||
_server = new UdpContext;
|
||||
_server = new (std::nothrow) UdpContext;
|
||||
if (_server == nullptr) {
|
||||
return false;
|
||||
}
|
||||
_server->ref();
|
||||
|
||||
ip_addr_t ifaddr;
|
||||
|
||||
@@ -20,6 +20,7 @@ P020_Task::P020_Task(taskIndex_t taskIndex) : _taskIndex(taskIndex) {
|
||||
|
||||
P020_Task::~P020_Task() {
|
||||
stopServer();
|
||||
serialEnd();
|
||||
}
|
||||
|
||||
bool P020_Task::serverActive(WiFiServer *server) {
|
||||
|
||||
@@ -19,6 +19,7 @@ P044_Task::P044_Task() {
|
||||
|
||||
P044_Task::~P044_Task() {
|
||||
stopServer();
|
||||
serialEnd();
|
||||
}
|
||||
|
||||
bool P044_Task::serverActive(WiFiServer *server) {
|
||||
|
||||
@@ -46,17 +46,17 @@ P053_data_struct::P053_data_struct(
|
||||
int8_t pwrPin,
|
||||
PMSx003_type sensortype,
|
||||
uint32_t delay_read_after_wakeup_ms
|
||||
# ifdef PLUGIN_053_ENABLE_EXTRA_SENSORS
|
||||
# ifdef PLUGIN_053_ENABLE_EXTRA_SENSORS
|
||||
, bool oversample
|
||||
, bool splitCntBins
|
||||
# endif // ifdef PLUGIN_053_ENABLE_EXTRA_SENSORS
|
||||
# endif // ifdef PLUGIN_053_ENABLE_EXTRA_SENSORS
|
||||
)
|
||||
: _taskIndex(TaskIndex),
|
||||
_sensortype(sensortype),
|
||||
# ifdef PLUGIN_053_ENABLE_EXTRA_SENSORS
|
||||
# ifdef PLUGIN_053_ENABLE_EXTRA_SENSORS
|
||||
_oversample(oversample),
|
||||
_splitCntBins(splitCntBins),
|
||||
# endif // ifdef PLUGIN_053_ENABLE_EXTRA_SENSORS
|
||||
# endif // ifdef PLUGIN_053_ENABLE_EXTRA_SENSORS
|
||||
_delay_read_after_wakeup_ms(delay_read_after_wakeup_ms),
|
||||
_resetPin(resetPin), _pwrPin(pwrPin)
|
||||
{
|
||||
@@ -129,7 +129,7 @@ void P053_data_struct::SerialRead16(uint16_t& value, uint16_t *checksum)
|
||||
*checksum += data_low;
|
||||
}
|
||||
|
||||
# ifdef P053_LOW_LEVEL_DEBUG
|
||||
# ifdef P053_LOW_LEVEL_DEBUG
|
||||
|
||||
// Low-level logging to see data from sensor
|
||||
String log = F("PMSx003 : uint8_t high=0x");
|
||||
@@ -139,7 +139,7 @@ void P053_data_struct::SerialRead16(uint16_t& value, uint16_t *checksum)
|
||||
log += F(" result=0x");
|
||||
log += String(value, HEX);
|
||||
addLog(LOG_LEVEL_INFO, log);
|
||||
# endif // ifdef P053_LOW_LEVEL_DEBUG
|
||||
# endif // ifdef P053_LOW_LEVEL_DEBUG
|
||||
}
|
||||
|
||||
void P053_data_struct::SerialFlush() {
|
||||
@@ -260,8 +260,16 @@ bool P053_data_struct::processData(struct EventStruct *event) {
|
||||
SerialRead16(data[i], &checksum);
|
||||
}
|
||||
|
||||
# ifndef BUILD_NO_DEBUG
|
||||
# ifdef P053_LOW_LEVEL_DEBUG
|
||||
# ifdef PLUGIN_053_ENABLE_EXTRA_SENSORS
|
||||
|
||||
if (GET_PLUGIN_053_SENSOR_MODEL_SELECTOR == PMSx003_type::PMS5003_T) {
|
||||
data[PMS_Temp_C] = data[PMS_T_Temp_C]; // Move data to the 'usual' location for Temp/Hum
|
||||
data[PMS_Hum_pct] = data[PMS_T_Hum_pct];
|
||||
}
|
||||
# endif // ifdef PLUGIN_053_ENABLE_EXTRA_SENSORS
|
||||
|
||||
# ifndef BUILD_NO_DEBUG
|
||||
# ifdef P053_LOW_LEVEL_DEBUG
|
||||
|
||||
if (loglevelActiveFor(LOG_LEVEL_DEBUG)) { // Available on all supported sensor models
|
||||
String log;
|
||||
@@ -281,7 +289,7 @@ bool P053_data_struct::processData(struct EventStruct *event) {
|
||||
addLog(LOG_LEVEL_DEBUG, log);
|
||||
}
|
||||
|
||||
# ifdef PLUGIN_053_ENABLE_EXTRA_SENSORS
|
||||
# ifdef PLUGIN_053_ENABLE_EXTRA_SENSORS
|
||||
|
||||
if (loglevelActiveFor(LOG_LEVEL_DEBUG)
|
||||
&& (GET_PLUGIN_053_SENSOR_MODEL_SELECTOR != PMSx003_type::PMS2003_3003)) { // 'Count' values not available on
|
||||
@@ -304,24 +312,26 @@ bool P053_data_struct::processData(struct EventStruct *event) {
|
||||
addLog(LOG_LEVEL_DEBUG, log);
|
||||
}
|
||||
|
||||
# ifdef PLUGIN_053_ENABLE_S_AND_T
|
||||
|
||||
if (loglevelActiveFor(LOG_LEVEL_DEBUG)
|
||||
&& (GET_PLUGIN_053_SENSOR_MODEL_SELECTOR == PMSx003_type::PMS5003_ST)) { // Values only available on PMS5003ST
|
||||
&& ((GET_PLUGIN_053_SENSOR_MODEL_SELECTOR == PMSx003_type::PMS5003_ST)
|
||||
|| (GET_PLUGIN_053_SENSOR_MODEL_SELECTOR == PMSx003_type::PMS5003_T))) { // Values only available on PMS5003ST & PMS5003T
|
||||
String log;
|
||||
log.reserve(45);
|
||||
log = F("PMSx003 : temp=");
|
||||
log += static_cast<float>(data[PMS_Temp_C]) / 10.0f;
|
||||
log += F(", humi=");
|
||||
log += static_cast<float>(data[PMS_Hum_pct]) / 10.0f;
|
||||
log += F(", hcho=");
|
||||
log += static_cast<float>(data[PMS_Formaldehyde_mg_m3]) / 1000.0f;
|
||||
|
||||
if (GET_PLUGIN_053_SENSOR_MODEL_SELECTOR == PMSx003_type::PMS5003_ST) {
|
||||
log += F(", hcho=");
|
||||
log += static_cast<float>(data[PMS_Formaldehyde_mg_m3]) / 1000.0f;
|
||||
}
|
||||
addLog(LOG_LEVEL_DEBUG, log);
|
||||
}
|
||||
# endif // ifdef PLUGIN_053_ENABLE_S_AND_T
|
||||
# endif // ifdef PLUGIN_053_ENABLE_EXTRA_SENSORS
|
||||
# endif // ifdef P053_LOW_LEVEL_DEBUG
|
||||
# endif // ifndef BUILD_NO_DEBUG
|
||||
# endif // ifdef PLUGIN_053_ENABLE_EXTRA_SENSORS
|
||||
# endif // ifdef P053_LOW_LEVEL_DEBUG
|
||||
# endif // ifndef BUILD_NO_DEBUG
|
||||
|
||||
// Compare checksums
|
||||
SerialRead16(checksum2, nullptr);
|
||||
@@ -350,14 +360,14 @@ bool P053_data_struct::processData(struct EventStruct *event) {
|
||||
# endif // ifndef BUILD_NO_DEBUG
|
||||
return false;
|
||||
}
|
||||
# ifndef PLUGIN_053_ENABLE_EXTRA_SENSORS
|
||||
# ifndef PLUGIN_053_ENABLE_EXTRA_SENSORS
|
||||
|
||||
// Data is checked and good, fill in output
|
||||
UserVar[event->BaseVarIndex] = data[PMS_PM1_0_ug_m3_normal];
|
||||
UserVar[event->BaseVarIndex + 1] = data[PMS_PM2_5_ug_m3_normal];
|
||||
UserVar[event->BaseVarIndex + 2] = data[PMS_PM10_0_ug_m3_normal];
|
||||
_values_received = 1;
|
||||
# else // ifndef PLUGIN_053_ENABLE_EXTRA_SENSORS
|
||||
# else // ifndef PLUGIN_053_ENABLE_EXTRA_SENSORS
|
||||
|
||||
// Store in the averaging buffer to process later
|
||||
if (!_oversample) {
|
||||
@@ -368,7 +378,7 @@ bool P053_data_struct::processData(struct EventStruct *event) {
|
||||
_data[i] += data[i];
|
||||
}
|
||||
++_values_received;
|
||||
# endif // ifndef PLUGIN_053_ENABLE_EXTRA_SENSORS
|
||||
# endif // ifndef PLUGIN_053_ENABLE_EXTRA_SENSORS
|
||||
|
||||
|
||||
// Store new checksum, to help detect duplicates.
|
||||
@@ -606,11 +616,14 @@ bool P053_data_struct::getValue(uint8_t index, float& value) {
|
||||
if (!hasFormaldehyde()) { return false; }
|
||||
value = _data[index] / 1000.0f;
|
||||
break;
|
||||
case PMS_cnt5_0_100ml:
|
||||
case PMS_cnt10_0_100ml: // this option was missing :-|
|
||||
|
||||
if (_sensortype == PMSx003_type::PMS5003_T) { return false; } // else: fall through
|
||||
case PMS_cnt0_3_100ml:
|
||||
case PMS_cnt0_5_100ml:
|
||||
case PMS_cnt1_0_100ml:
|
||||
case PMS_cnt2_5_100ml:
|
||||
case PMS_cnt5_0_100ml:
|
||||
value = _data[index];
|
||||
|
||||
if (_splitCntBins) {
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
// Difference in build size is roughly 4k
|
||||
# define PLUGIN_053_ENABLE_EXTRA_SENSORS
|
||||
|
||||
// #define PLUGIN_053_ENABLE_S_AND_T // Enable setting to support S and T types, in addition to bas PMSx003 and PMSx003ST
|
||||
|
||||
# if !defined(PLUGIN_BUILD_CUSTOM) && defined(SIZE_1M) && defined(PLUGIN_053_ENABLE_EXTRA_SENSORS) // Turn off for 1M OTA builds
|
||||
# undef PLUGIN_053_ENABLE_EXTRA_SENSORS
|
||||
# endif // if defined(SIZE_1M) && defined(PLUGIN_BUILD_MINIMAL_OTA) && defined(PLUGIN_053_ENABLE_EXTRA_SENSORS)
|
||||
@@ -108,7 +106,9 @@ const __FlashStringHelper* toString(PMSx003_event_datatype selection);
|
||||
|
||||
# define PMS_Formaldehyde_mg_m3 12
|
||||
# define PMS_Temp_C 13
|
||||
# define PMS_T_Temp_C 10
|
||||
# define PMS_Hum_pct 14
|
||||
# define PMS_T_Hum_pct 11
|
||||
# define PMS_Reserved 15
|
||||
# define PMS_FW_rev_error 16
|
||||
# define PMS_RECEIVE_BUFFER_SIZE ((PMS5003_ST_SIZE / 2) - 3)
|
||||
@@ -125,13 +125,13 @@ public:
|
||||
int8_t resetPin,
|
||||
int8_t pwrPin,
|
||||
PMSx003_type sensortype,
|
||||
uint32_t delay_read_after_wakeup_ms
|
||||
# ifdef PLUGIN_053_ENABLE_EXTRA_SENSORS
|
||||
uint32_t delay_read_after_wakeup_ms
|
||||
# ifdef PLUGIN_053_ENABLE_EXTRA_SENSORS
|
||||
,
|
||||
bool oversample
|
||||
,
|
||||
bool splitCntBins
|
||||
# endif // ifdef PLUGIN_053_ENABLE_EXTRA_SENSORS
|
||||
# endif // ifdef PLUGIN_053_ENABLE_EXTRA_SENSORS
|
||||
);
|
||||
|
||||
P053_data_struct() = delete;
|
||||
@@ -155,13 +155,13 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
# ifdef PLUGIN_053_ENABLE_EXTRA_SENSORS
|
||||
# ifdef PLUGIN_053_ENABLE_EXTRA_SENSORS
|
||||
void sendEvent(const String& baseEvent,
|
||||
uint8_t index);
|
||||
|
||||
bool hasFormaldehyde() const;
|
||||
bool hasTempHum() const;
|
||||
# endif // ifdef PLUGIN_053_ENABLE_EXTRA_SENSORS
|
||||
# endif // ifdef PLUGIN_053_ENABLE_EXTRA_SENSORS
|
||||
|
||||
public:
|
||||
|
||||
@@ -183,14 +183,14 @@ private:
|
||||
|
||||
void requestData();
|
||||
|
||||
# ifdef PLUGIN_053_ENABLE_EXTRA_SENSORS
|
||||
# ifdef PLUGIN_053_ENABLE_EXTRA_SENSORS
|
||||
|
||||
float getValue(uint8_t index);
|
||||
|
||||
bool getValue(uint8_t index,
|
||||
float & value);
|
||||
|
||||
# endif // ifdef PLUGIN_053_ENABLE_EXTRA_SENSORS
|
||||
# endif // ifdef PLUGIN_053_ENABLE_EXTRA_SENSORS
|
||||
void clearReceivedData();
|
||||
|
||||
public:
|
||||
|
||||
@@ -14,6 +14,13 @@ P062_data_struct::P062_data_struct() {
|
||||
clearCalibrationData(); // Reset
|
||||
}
|
||||
|
||||
P062_data_struct::~P062_data_struct() {
|
||||
if (keypad != nullptr) {
|
||||
delete keypad;
|
||||
keypad = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
bool P062_data_struct::init(taskIndex_t taskIndex,
|
||||
uint8_t i2c_addr,
|
||||
bool scancode,
|
||||
@@ -26,7 +33,7 @@ bool P062_data_struct::init(taskIndex_t taskIndex,
|
||||
_keepCalibrationData = keepCalibrationData;
|
||||
|
||||
if (!keypad) {
|
||||
keypad = new Adafruit_MPR121();
|
||||
keypad = new (std::nothrow) Adafruit_MPR121();
|
||||
}
|
||||
if (keypad) {
|
||||
keypad->begin(_i2c_addr);
|
||||
|
||||
@@ -14,6 +14,7 @@ struct P062_data_struct : public PluginTaskData_base {
|
||||
public:
|
||||
|
||||
P062_data_struct();
|
||||
~P062_data_struct();
|
||||
bool init(taskIndex_t taskIndex,
|
||||
uint8_t i2c_addr,
|
||||
bool scancode,
|
||||
|
||||
@@ -27,10 +27,35 @@ const __FlashStringHelper * Plugin_082_valuename(P082_query value_nr, bool displ
|
||||
return F("");
|
||||
}
|
||||
|
||||
const __FlashStringHelper* toString(P082_PowerMode mode) {
|
||||
switch (mode) {
|
||||
case P082_PowerMode::Max_Performance: return F("Max Performance");
|
||||
case P082_PowerMode::Power_Save: return F("Power Save");
|
||||
case P082_PowerMode::Eco: return F("ECO");
|
||||
}
|
||||
return F("");
|
||||
}
|
||||
|
||||
const __FlashStringHelper* toString(P082_DynamicModel model) {
|
||||
switch (model) {
|
||||
case P082_DynamicModel::Portable: return F("Portable");
|
||||
case P082_DynamicModel::Stationary: return F("Stationary");
|
||||
case P082_DynamicModel::Pedestrian: return F("Pedestrian");
|
||||
case P082_DynamicModel::Automotive: return F("Automotive");
|
||||
case P082_DynamicModel::Sea: return F("Sea");
|
||||
case P082_DynamicModel::Airborne_1g: return F("Airborne_1g");
|
||||
case P082_DynamicModel::Airborne_2g: return F("Airborne_2g");
|
||||
case P082_DynamicModel::Airborne_4g: return F("Airborne_4g");
|
||||
case P082_DynamicModel::Wrist: return F("Wrist");
|
||||
case P082_DynamicModel::Bike: return F("Bike");
|
||||
}
|
||||
return F("");
|
||||
}
|
||||
|
||||
P082_data_struct::P082_data_struct() : gps(nullptr), easySerial(nullptr) {}
|
||||
|
||||
P082_data_struct::~P082_data_struct() {
|
||||
powerDown();
|
||||
reset();
|
||||
}
|
||||
|
||||
@@ -51,11 +76,12 @@ bool P082_data_struct::init(ESPEasySerialPort port, const int16_t serial_rx, con
|
||||
return false;
|
||||
}
|
||||
reset();
|
||||
gps = new (std::nothrow) TinyGPSPlus();
|
||||
gps = new (std::nothrow) TinyGPSPlus();
|
||||
easySerial = new (std::nothrow) ESPeasySerial(port, serial_rx, serial_tx);
|
||||
|
||||
if (easySerial != nullptr) {
|
||||
easySerial->begin(9600);
|
||||
wakeUp();
|
||||
}
|
||||
return isInitialized();
|
||||
}
|
||||
@@ -76,24 +102,78 @@ bool P082_data_struct::loop() {
|
||||
|
||||
while (available > 0 && timePassedSince(startLoop) < 10) {
|
||||
--available;
|
||||
char c = easySerial->read();
|
||||
int c = easySerial->read();
|
||||
if (c >= 0) {
|
||||
# ifdef P082_SEND_GPS_TO_LOG
|
||||
if (_currentSentence.length() <= 80) {
|
||||
// No need to capture more than 80 bytes as a NMEA message is never that long.
|
||||
_currentSentence += c;
|
||||
}
|
||||
if (_currentSentence.length() <= 80) {
|
||||
// No need to capture more than 80 bytes as a NMEA message is never that long.
|
||||
if (c != 0) {
|
||||
_currentSentence += static_cast<char>(c);
|
||||
}
|
||||
}
|
||||
# endif // ifdef P082_SEND_GPS_TO_LOG
|
||||
|
||||
if (gps->encode(c)) {
|
||||
// Full sentence received
|
||||
if (c == 0x85) {
|
||||
// Found possible start of u-blox message
|
||||
unsigned long timeout = millis() + 200;
|
||||
unsigned int bytesRead = 0;
|
||||
bool done = false;
|
||||
bool ack_nak_read = false;
|
||||
while (!timeOutReached(timeout) && !done)
|
||||
{
|
||||
if (available == 0) {
|
||||
available = easySerial->available();
|
||||
} else {
|
||||
const int c = easySerial->read();
|
||||
if (c >= 0) {
|
||||
switch (bytesRead) {
|
||||
case 0:
|
||||
if (c != 0x62) {
|
||||
done = true;
|
||||
}
|
||||
++bytesRead;
|
||||
break;
|
||||
case 1:
|
||||
if (c != 0x05) {
|
||||
done = true;
|
||||
}
|
||||
++bytesRead;
|
||||
break;
|
||||
case 2:
|
||||
if (c == 0x01) {
|
||||
ack_nak_read = true;
|
||||
addLog(LOG_LEVEL_INFO, F("GPS : ACK-ACK"));
|
||||
} else if (c == 0x00) {
|
||||
ack_nak_read = true;
|
||||
addLog(LOG_LEVEL_ERROR, F("GPS : ACK-NAK"));
|
||||
}
|
||||
done = true;
|
||||
break;
|
||||
default:
|
||||
done = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!done) {
|
||||
addLog(LOG_LEVEL_ERROR, F("GPS : Ack/Nack timeout"));
|
||||
} else if (!ack_nak_read) {
|
||||
addLog(LOG_LEVEL_ERROR, F("GPS : Unexpected reply"));
|
||||
}
|
||||
}
|
||||
|
||||
if (gps->encode(c)) {
|
||||
// Full sentence received
|
||||
# ifdef P082_SEND_GPS_TO_LOG
|
||||
_lastSentence = _currentSentence;
|
||||
_currentSentence = "";
|
||||
_lastSentence = _currentSentence;
|
||||
_currentSentence.clear();
|
||||
# endif // ifdef P082_SEND_GPS_TO_LOG
|
||||
completeSentence = true;
|
||||
} else {
|
||||
if (available == 0) {
|
||||
available = easySerial->available();
|
||||
completeSentence = true;
|
||||
} else {
|
||||
if (available == 0) {
|
||||
available = easySerial->available();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -179,4 +259,102 @@ bool P082_data_struct::getDateTime(struct tm& dateTime, uint32_t& age, bool& pps
|
||||
return true;
|
||||
}
|
||||
|
||||
bool P082_data_struct::powerDown() {
|
||||
const uint8_t UBLOX_GPSStandby[] = {0xB5, 0x62, 0x02, 0x41, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x4D, 0x3B};
|
||||
return writeToGPS(UBLOX_GPSStandby, sizeof(UBLOX_GPSStandby));
|
||||
}
|
||||
|
||||
bool P082_data_struct::wakeUp() {
|
||||
if (isInitialized()) {
|
||||
if (easySerial->isTxEnabled()) {
|
||||
easySerial->println(); // Send some character to wake it up.
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef P082_USE_U_BLOX_SPECIFIC
|
||||
bool P082_data_struct::setPowerMode(P082_PowerMode mode) {
|
||||
switch (mode) {
|
||||
case P082_PowerMode::Max_Performance:
|
||||
{
|
||||
const uint8_t UBLOX_command[] = {0xB5, 0x62, 0x06, 0x11, 0x02, 0x00, 0x08, 0x00, 0x21, 0x91};
|
||||
return writeToGPS(UBLOX_command, sizeof(UBLOX_command));
|
||||
}
|
||||
case P082_PowerMode::Power_Save:
|
||||
{
|
||||
const uint8_t UBLOX_command[] = {0xB5, 0x62, 0x06, 0x11, 0x02, 0x00, 0x08, 0x01, 0x22, 0x92};
|
||||
return writeToGPS(UBLOX_command, sizeof(UBLOX_command));
|
||||
}
|
||||
case P082_PowerMode::Eco:
|
||||
{
|
||||
const uint8_t UBLOX_command[] = {0xB5, 0x62, 0x06, 0x11, 0x02, 0x00, 0x08, 0x04, 0x25, 0x95};
|
||||
return writeToGPS(UBLOX_command, sizeof(UBLOX_command));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool P082_data_struct::setDynamicModel(P082_DynamicModel model) {
|
||||
|
||||
const uint8_t dynModel = static_cast<uint8_t>(model);
|
||||
if (dynModel == 1 || dynModel > 10) {
|
||||
return false;
|
||||
}
|
||||
|
||||
uint8_t UBLOX_command[] = {
|
||||
0xB5, 0x62, // header
|
||||
0x06, // class
|
||||
0x24, // ID, UBX-CFG-NAV5
|
||||
0x24, 0x00, // length
|
||||
0x01, 0x00, // mask
|
||||
dynModel, // dynModel
|
||||
0x03, // fixMode auto 2D/3D
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
setUbloxChecksum(UBLOX_command, sizeof(UBLOX_command));
|
||||
return writeToGPS(UBLOX_command, sizeof(UBLOX_command));
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef P082_USE_U_BLOX_SPECIFIC
|
||||
void P082_data_struct::computeUbloxChecksum(const uint8_t* data, size_t size, uint8_t & CK_A, uint8_t & CK_B) {
|
||||
CK_A = 0;
|
||||
CK_B = 0;
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
CK_A = CK_A + data[i];
|
||||
CK_B = CK_B + CK_A;
|
||||
}
|
||||
}
|
||||
|
||||
void P082_data_struct::setUbloxChecksum(uint8_t* data, size_t size) {
|
||||
uint8_t CK_A;
|
||||
uint8_t CK_B;
|
||||
computeUbloxChecksum(data + 2, size - 4, CK_A, CK_B);
|
||||
data[size - 2] = CK_A;
|
||||
data[size - 1] = CK_B;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool P082_data_struct::writeToGPS(const uint8_t* data, size_t size) {
|
||||
if (isInitialized()) {
|
||||
if (easySerial->isTxEnabled()) {
|
||||
if (size != easySerial->write(data, size)) {
|
||||
addLog(LOG_LEVEL_ERROR, F("GPS : Written less bytes than expected"));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
addLog(LOG_LEVEL_ERROR, F("GPS : Cannot send to GPS"));
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif // ifdef USES_P082
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#ifndef LIMIT_BUILD_SIZE
|
||||
# define P082_SEND_GPS_TO_LOG
|
||||
//# define P082_USE_U_BLOX_SPECIFIC // TD-er: Disabled for now, as it is not working reliable/predictable
|
||||
#endif
|
||||
|
||||
# define P082_TIMESTAMP_AGE 1500
|
||||
@@ -34,8 +35,35 @@ enum class P082_query : uint8_t {
|
||||
const __FlashStringHelper * Plugin_082_valuename(P082_query value_nr, bool displayString);
|
||||
|
||||
|
||||
enum class P082_PowerMode : uint8_t {
|
||||
Max_Performance = 0,
|
||||
Power_Save = 1,
|
||||
Eco = 2
|
||||
};
|
||||
|
||||
const __FlashStringHelper* toString(P082_PowerMode mode);
|
||||
|
||||
|
||||
enum class P082_DynamicModel : uint8_t {
|
||||
Portable = 0,
|
||||
Stationary = 2,
|
||||
Pedestrian = 3,
|
||||
Automotive = 4,
|
||||
Sea = 5,
|
||||
Airborne_1g = 6, // airborne with <1g acceleration
|
||||
Airborne_2g = 7, // airborne with <2g acceleration
|
||||
Airborne_4g = 8, // airborne with <4g acceleration
|
||||
Wrist = 9, // Only recommended for wrist-worn applications. Receiver will filter out armmotion (just available for protocol version > 17).
|
||||
Bike = 10 // Used for applications with equivalent dynamics to those of a motor bike. Lowvertical acceleration assumed. (supported in protocol versions 19.2)
|
||||
};
|
||||
|
||||
const __FlashStringHelper* toString(P082_DynamicModel model);
|
||||
|
||||
struct P082_data_struct : public PluginTaskData_base {
|
||||
|
||||
// Enum is being stored, so don't change int values
|
||||
|
||||
|
||||
P082_data_struct();
|
||||
|
||||
~P082_data_struct();
|
||||
@@ -65,6 +93,34 @@ struct P082_data_struct : public PluginTaskData_base {
|
||||
uint32_t & age,
|
||||
bool & pps_sync);
|
||||
|
||||
// Send command to GPS to put it in PMREQ backup mode (UBLOX only)
|
||||
// @retval true when successful in sending command
|
||||
bool powerDown();
|
||||
|
||||
// Send some characters to GPS to wake up
|
||||
bool wakeUp();
|
||||
#ifdef P082_USE_U_BLOX_SPECIFIC
|
||||
bool setPowerMode(P082_PowerMode mode);
|
||||
|
||||
bool setDynamicModel(P082_DynamicModel model);
|
||||
#endif
|
||||
|
||||
private:
|
||||
#ifdef P082_USE_U_BLOX_SPECIFIC
|
||||
// Compute checksum
|
||||
// Caller should offset the data pointer to the correct start where the CRC should start.
|
||||
// @param size The length over which the CRC should be computed
|
||||
// @param CK_A, CK_B The 2 checksum bytes.
|
||||
static void computeUbloxChecksum(const uint8_t* data, size_t size, uint8_t & CK_A, uint8_t & CK_B);
|
||||
|
||||
// Set checksum.
|
||||
// First 2 bytes of the array are skipped
|
||||
static void setUbloxChecksum(uint8_t* data, size_t size);
|
||||
#endif
|
||||
|
||||
bool writeToGPS(const uint8_t* data, size_t size);
|
||||
public:
|
||||
|
||||
TinyGPSPlus *gps = nullptr;
|
||||
ESPeasySerial *easySerial = nullptr;
|
||||
|
||||
|
||||
@@ -11,9 +11,20 @@
|
||||
P111_data_struct::P111_data_struct(uint8_t csPin, uint8_t rstPin) : mfrc522(nullptr), _csPin(csPin), _rstPin(rstPin)
|
||||
{}
|
||||
|
||||
P111_data_struct::~P111_data_struct() {
|
||||
if (mfrc522 != nullptr) {
|
||||
delete mfrc522;
|
||||
mfrc522 = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void P111_data_struct::init() {
|
||||
if (mfrc522 == nullptr){
|
||||
mfrc522 = new MFRC522 (_csPin, _rstPin); // Instantiate a MFRC522
|
||||
if (mfrc522 != nullptr) {
|
||||
delete mfrc522;
|
||||
mfrc522 = nullptr;
|
||||
}
|
||||
mfrc522 = new (std::nothrow) MFRC522(_csPin, _rstPin); // Instantiate a MFRC522
|
||||
if (mfrc522 != nullptr) {
|
||||
mfrc522->PCD_Init(); // Initialize MFRC522 reader
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,11 +9,12 @@
|
||||
struct P111_data_struct : public PluginTaskData_base {
|
||||
|
||||
P111_data_struct(uint8_t csPin, uint8_t rstPin);
|
||||
~P111_data_struct();
|
||||
void init();
|
||||
uint8_t readCardStatus(unsigned long *key, bool *removedTag);
|
||||
String getCardName();
|
||||
|
||||
MFRC522 *mfrc522;
|
||||
MFRC522 *mfrc522 = nullptr;
|
||||
|
||||
uint8_t counter = 0;
|
||||
|
||||
|
||||
@@ -31,7 +31,9 @@ else:
|
||||
"-DUSES_P026", # System info
|
||||
"-DUSES_P027", # INA219
|
||||
"-DUSES_P028", # BME280
|
||||
"-DUSES_P033", # Dummy
|
||||
"-DUSES_P036", # FrameOLED
|
||||
"-DUSES_P038", # Neopixel
|
||||
"-DUSES_P045", # MPU6050
|
||||
"-DUSES_P049", # MHZ19
|
||||
"-DUSES_P052", # SenseAir
|
||||
|
||||
Reference in New Issue
Block a user