Compare commits

...
Author SHA1 Message Date
Edwin Eefting e10a6e6f55 automaticly updated release notes for v2.0.0-dev10 2017-05-29 22:53:54 +02:00
krikkandDatuX f0ed209ba6 reverted change, this fix seems to have exactly opposite outcome than expected... with the fix applied i get errors, without is i get no errors... (#320) 2017-05-29 22:31:28 +02:00
Jochen KrapfandDatuX 2672558bfe Rework of plugin ADC (#319)
Minor changes of ADS1115
2017-05-29 22:30:14 +02:00
DatuXandGitHub ffe2f3f775 Update README.md 2017-05-28 23:52:55 +02:00
Edwin Eefting 92816f1a9f automaticly updated release notes for v2.0.0-dev9 2017-05-28 15:16:00 +02:00
Edwin Eefting 43ef90f688 also distribute ESP8285 binaries 2017-05-28 15:15:06 +02:00
Jochen KrapfandDatuX 2c6096dd31 Rework of plugin ADS1115 (#315)
* Fixed some minor HTML syntax bugs

* Fixed some minor HTML syntax bugs

* Rework of plugin ADS1115
2017-05-28 12:06:52 +02:00
krikkandDatuX 1cefa5eb1b AM2320: negative temperature fix... (#312)
* switched the library, now uses a library which correctly handles negative temperatures

* minor change
2017-05-27 17:55:13 +02:00
DatuXandGitHub a8e39b1899 Update README.md 2017-05-27 16:45:17 +02:00
DatuXandGitHub b1a47e4c3a Update README.md 2017-05-27 16:08:19 +02:00
Jochen KrapfandDatuX b7d881d136 Fixed some minor HTML syntax bugs (#310)
* Fixed some minor HTML syntax bugs

* Fixed some minor HTML syntax bugs
2017-05-26 11:14:06 +02:00
Alex Schwantes 67c3a166f5 Implemented use of addFormSelector methods to _P004_Dallas plugin.
Changed the device select box to show the one wire address for each connected sensor instead of just a number.
Added a blank option to the device address select box so that in the event that multiple devices are present and the configured device is not currently available, the select box will be blank instead of selecting a different device.
2017-05-23 03:41:13 +02:00
Jochen KrapfandDatuX 060b72e88b Pimp device-GUI and optimized HTML (#306)
* First draft

* work release

* work release (not working)

* optimized css

* Pimp device-GUI and optimized HTML

* Handle cppcheck error

* Round help button

* Minor bug fixes
2017-05-22 23:31:58 +02:00
Edwin Eefting 36550511f5 fixing cpp check 2017-05-18 23:00:29 +02:00
Edwin Eefting fb8188b14b fixing cpp check 2017-05-18 22:44:20 +02:00
Edwin Eefting 436564ba51 fixing cpp check 2017-05-18 22:39:48 +02:00
Edwin Eefting 9016f1b53e fixing cpp check 2017-05-18 22:25:46 +02:00
Edwin Eefting 0404a871f2 fixed a few out of bounds bugs in Misc.ino _P023_OLED.ino _P035_IRTX.ino _P037_MQTTImport.ino with cppcheck. also added cppcheck to travis to prevent such cases in the future 2017-05-18 22:21:01 +02:00
krikkandDatuX 1413c92678 do a dns lookup on every request, solves issue #261 (#302) 2017-05-16 21:13:06 +02:00
PieVoandDatuX 28208ac7a2 Plantower (#300)
* + pmsx005: add all values as output

* - PMSx005: remove additional measurements from values

* + PMSx005: fix return values for plugin function

* * PMSx003: rename filename to match devices (PMS3003, 5003, 7003, A003)

* * PMSx003: fix valuecount and prevent sending to controllen when nothing recveid yet

* * PMSx003: rename _P050 to _P053

* + PMSx003: add PLUGIN_BUILD_TESTING

* - PMSx003: remove old _P050 that made place for _P053
2017-05-14 19:47:04 +02:00
DatuXandGitHub 168a2c343c Update CONTRIBUTING.md 2017-05-14 11:53:06 +02:00
Jochen KrapfandDatuX a873e920d4 Fixed rules bug #297 (#299) 2017-05-14 11:42:27 +02:00
beicandDatuX 10838d544c Some little description corrections (#297) 2017-05-13 23:45:38 +02:00
Daniel TedenljungandDatuX ab48fc0dfd New look on Tools page (#296)
* New look on Tools page

* Smal adjustment
2017-05-13 23:01:15 +02:00
Jochen KrapfandDatuX bcf6521ef9 Added HTML templates for customization (#290)
* First draft of templates

* Added templates for customization

* Fixed dept_onchange(frmselect)

* Moved javascript to sendWebPage()

* moved javascript to template var

* Preparation for selected menus

and bugfix if 2 vars are stand near together

* removed libs from prev. commit

* rework of menu

* Some cleanup
2017-05-13 22:56:28 +02:00
krikkandDatuX 6f8d7d1ada i don't like hidden features, added a json button to the tools menu, next to the advanced button (#292) 2017-05-13 09:37:03 +02:00
Daniel TedenljungandDatuX c6f03551c5 addSubmitButton function added (#289) 2017-05-11 15:13:48 +02:00
Edwin Eefting b2a9679488 nicer sleep messages 2017-05-11 02:18:45 +02:00
Edwin Eefting b66d983060 bugfix in rtc checksum 2017-05-11 01:59:27 +02:00
Edwin Eefting 2b16ddedbf reboot and wifidisconnect should be handled by / 2017-05-11 01:54:44 +02:00
Daniel TedenljungandDatuX dbd89deb7b GUI touchup on Tools (#286)
* GUI touchup on Tools

I added some space between settings-firmware and firmware-filesystem to
make it look nicer (my opinion).

* Implemented addButton function
2017-05-11 00:40:30 +02:00
Jochen KrapfandDatuX 6c52721ed1 Limits to NumericBox and a bit of security to PasswordBox (#281)
* Limits to NumericBox and a bit of security to PasswordBox

* Limits to NumericBox and a bit of security to PasswordBox

Password handling: Deliver "*****" to password box accept changes if not equal to "*****"

* solved merge conflicts
2017-05-11 00:39:33 +02:00
Blair ThompsonandDatuX 03fbe8fcca Added Par4 and Par5 Variables (#248)
I am working on an RGBW lightbulb plugin and 3 variables are not enough
to control it.  Rather than add variables in the plugin (like neopixel
does) i think it is better to add them to EventStruct.  I only needed 4,
but neopixel uses 5
2017-05-11 00:14:28 +02:00
krikkandDatuX 9e0af20343 DHT plugin fix 'NaN' issue (#285)
issue https://github.com/letscontrolit/ESPEasy/issues/284 seems valid to me, implemented...
2017-05-10 23:40:26 +02:00
Daniel TedenljungandDatuX aa0b4d0fce P052: More descriptive log messages (#283)
* Better log messages

* Missed semicolon...
2017-05-10 23:38:47 +02:00
krikkandDatuX a9f6605065 addHelpButton Function and a new Help Button for the Rules and Hardware Page (#282) 2017-05-10 23:36:39 +02:00
krikkandDatuX 26b073ba34 make the Settings - Save. Filename more descriptive... (#273)
* make the Settings - Save. Filename more descriptive, didn't like this also. solves issue: #241

* added getDateString + getTimeString + getDateTimeString Functions and replaced dublicate code with the new functions...

* more comments :)
2017-05-10 23:34:40 +02:00
Jochen KrapfandDatuX 27bba1b628 Fixed readUserVarFromRTC() #265 (#280)
Uses checksum to verify user var buffer and fill with zero
2017-05-09 20:50:15 +02:00
Jochen KrapfandDatuX 6131ebca73 Replaced HTML code with addFormSelector() in all plugins (#278)
and added function addFormSelectorI2C()

Note: not all plugins can be tested :(
2017-05-09 20:47:05 +02:00
krikkandDatuX 01b42a6dfb addFormNumeric with min and max & More Form-Function replacements (#272)
* add getFormItemFloat, because we have some float input also

* more form-functions optimizations...

* addFormNumeric with min and max parameters

* ...and more formFunctions replacements

* ...and more formFunctions replacements

* ...and more formFunctions replacements

* ...and more formFunctions replacements

* ...so first round done...  will do another round when addFormSelector is merged...

* and a few controller text boxes can be replaced also...

* one char to much...
2017-05-09 00:19:03 +02:00
Jochen KrapfandDatuX 23be929f72 Preliminary final draft of bugfix #264 (#271)
Group name can be changed during merge in... ;)
2017-05-09 00:16:01 +02:00
Jochen KrapfandDatuX b536770a07 Added function addFormSelector (#270)
* Added function addFormSelector

usage:
        const String options[] = { F("DHT 11"), F("DHT 22"), F("DHT 12") };
        int indices[] = { 11, 22, 12 };

        addFormSelector(string, F("DHT Type"), F("plugin_005_dhttype"), 3, options, indices, choice );

or with zero based index:
        String options[4] = { F("Delta"), F("Delta/Total/Time"), F("Total"), F("Delta/Total") };

        addFormSelector(string, F("Counter Type"), F("plugin_003_countertype"), 4, options, NULL, choice );

+ minor HTML fixes in addFormSubHeader and addFormSeparator

* additional params to addSelector()

* replaced more HTML with Selector functions
2017-05-09 00:12:41 +02:00
Daniel TedenljungandDatuX 792982262b Updated wrong plugin number. (#269)
* Moving plugin from playground

I am now moving this plugin from playground to main repo. It is tested
for long time and works fine.

* Forgot #endif

* Exclude readme.

* Wrong plugin number
2017-05-05 00:12:43 +02:00
krikkandDatuX 541d50e6bb bug fix wrong return type + form function fixes (#266)
* seems to be a type, but return type must be int!

* for form-function optimizations

* even more form-functions....

* even more form-functions + type fix

* lots of form-functions...
2017-05-05 00:05:33 +02:00
Bartlomiej ZimonandEdwin Eefting c8d88140f7 Add backup Wifi network to Settings command 2017-05-04 16:54:38 +02:00
Bartlomiej ZimonandEdwin Eefting d3fdf27746 Add WifiSSID2,WifiKey2 commands 2017-05-04 16:53:53 +02:00
Bartlomiej ZimonandEdwin Eefting afb6860156 Push ProtocolIndex and ControllerIndex into CPLUGIN_WEBFORM_SAVE/LOAD 2017-05-04 16:52:42 +02:00
Bartlomiej ZimonandEdwin Eefting 48563bade6 Custom Controller Settings - add controller index 2017-05-04 16:50:47 +02:00
Bartlomiej ZimonandEdwin Eefting 017019e122 - Misc: typo 2017-05-04 16:06:32 +02:00
Edwin Eefting 8e0d78af7b Merge branch 'mega' of github.com:letscontrolit/ESPEasy into mega 2017-05-04 15:46:48 +02:00
Edwin Eefting 66531d46bd comments. checkudp only in backgroundtasks() 2017-05-04 15:46:38 +02:00
tedendaandDatuX 83dbb63d13 Moving plugin from Playground into main repo. (#262)
* Moving plugin from playground

I am now moving this plugin from playground to main repo. It is tested
for long time and works fine.

* Forgot #endif
2017-05-04 01:21:09 +02:00
krikkandDatuX 771f981c13 replaced static html code with the new addForm* Functions 2017-05-03 23:10:44 +02:00
JKandDatuX 9d5afd1e2a Fixed #196 and rework of IDX display 2017-05-03 11:52:26 +02:00
DatuXandGitHub 33ac272804 Update issue_template.md 2017-05-02 23:53:35 +02:00
DatuXandGitHub 30a1e4c7c3 Update README.md 2017-05-02 21:24:29 +02:00
Jochen KrapfandDatuX 1d97f08b34 Added addForm*-functions for easy web-interface and pimp GUI (#259)
* first draft

* work release

* work release

* work release

* work release

* work release

* work release

* Added addForm*-functions for easy web-interface and pimp GUI

Changes many HTML-code to function calls for less code and more readability. More changes are coming soon.
Some groupings in Web-Interface.
2017-05-02 21:10:54 +02:00
Edwin Eefting 752a741e60 input box fix on setting pages 2017-05-02 20:30:20 +02:00
krikkandDatuX 9eaf88abad another fix to http advanced...
never do code changes without testing it... fixed http get, but broke http post, now its working again
2017-05-02 08:39:22 +02:00
krikkandDatuX f5ffcf5454 use the new addCheckBox function and better display of device config page 2017-05-02 02:11:58 +02:00
Edwin Eefting e8c5a02ead timer boundschecker was off by one. fixed memanalyser total 2017-05-02 01:27:53 +02:00
Edwin Eefting 5c9d00c0a9 publish MQTT Connected message 2017-05-02 00:47:04 +02:00
Edwin Eefting 9b8d5bba4c cosmetic buildlog fix 2017-05-02 00:18:49 +02:00
Edwin Eefting 5f8e2a70d0 more details in memory analyser. run memory analyser via Travis 2017-05-02 00:10:03 +02:00
Edwin Eefting 19b1316205 fixed issue #253 (memory leaks/crashes) 2017-05-01 23:00:24 +02:00
krikkandDatuX b9f47d3cf2 i2c Temperatur & Humidity Sensor Am2320 (#251)
* add support for i2c am2320 temperature and humidity sensor based on this https://github.com/hibikiledo/AM2320 library

* add i2cScanner detection of AM2320 Sensor

* minor
2017-05-01 11:58:13 +02:00
krikkandDatuX 75067cd33f http advanced controller, correct passing of hostname (#250)
* http advanced controller, correct passing of hostname

fixes an error reported by mikrom in the forum: https://www.letscontrolit.com/forum/viewtopic.php?f=4&t=2973

* http request must close mit double newline...

wrong newline in case of get request without body
the request ends with a double newline, each in the form of a carriage return followed by a line feed
2017-04-30 12:54:37 +02:00
JKandDatuX 25477a1232 solved my commit mismatch 2017-04-27 11:20:44 +02:00
JKandDatuX 4b9b3f5a37 fine tuning of status LED and pimp hardware web site 2017-04-27 11:20:44 +02:00
JKandDatuX c0d147f3df added checkbox for status LED inversed 2017-04-27 11:20:44 +02:00
JKandDatuX 228f782762 added functions addCheckBox and addNumericBox 2017-04-27 11:04:52 +02:00
Edwin Eefting e952bb8731 cleaned up messagedelay: use the same function everywhere. and do serial processing as well during the messagedelay 2017-04-24 22:19:26 +02:00
65 changed files with 3384 additions and 2542 deletions
+1 -1
View File
@@ -20,7 +20,7 @@ Also there are more people on the forum that can help you with support.
* Dont combine a lot of different stuff in one huge pull request.
* Incomplete or unstable plugins should have a PLUGIN_BUILD_DEV ifdef around them.
* Incomplete or unstable plugins should have a PLUGIN_BUILD_DEV #ifdef around them. Also add [DEVELOPMENT] to the name.
* New plugins that seem to be working correctly should have a PLUGIN_BUILD_TESTING around until they are tested enough.
+2
View File
@@ -1,6 +1,8 @@
### Steps to reproduce
How can we trigger this problem?
Does the problem presist after powering off and on? (just resetting isnt enough sometimes)
### Expected behavior
Tell us what should happen?
+2
View File
@@ -2,3 +2,5 @@
.clang_complete
.gcc-flags.json
.piolibdeps
lib/readme.txt
+21 -3
View File
@@ -1,15 +1,33 @@
language: python
python:
- '2.7'
- '2.7'
#we want a newer cppcheck, so use trusty
dist: trusty
sudo: false
cache:
directories:
- "~/.platformio"
- "./.pioenvs"
addons:
apt:
packages:
- cppcheck
install:
- pip install -U platformio
- pip install -U platformio
script:
- platformio run
- cppcheck --enable=warning src/*.ino -q --force -I src --include=src/ESPEasy.ino --error-exitcode=1
- ./memanalyzer.py ~/.platformio/packages/toolchain-xtensa/bin/xtensa-lx106-elf-objdump
- platformio run -s
before_deploy:
- ./before_deploy
+32 -1
View File
@@ -2,13 +2,44 @@
Build status: [![Build Status](https://travis-ci.org/letscontrolit/ESPEasy.svg?branch=mega)](https://travis-ci.org/letscontrolit/ESPEasy)
Introduction and wiki: https://www.letscontrolit.com/wiki/index.php/ESPEasy#Introduction
This is the development branch for the next upcoming release (2.0.0). This is also known as ESPEasyMega.
Check here to learn how to use this branch and help us improving ESPEasy: http://www.letscontrolit.com/wiki/index.php/ESPEasy#Source_code_development
## Versions
* v2.0.0-devX: these are the current development releases. use these if you want bleeding edge features, or if you want to help us testing and developing. new release every month.
* v2.0.0-betaX: as soon as we think its stable/complete enough for real testing, we will start numbering beta's.
* v2.0.0-rcX: release candidates (probably stable)
* v2.0.0: This will be the first stable release
After this we will use more standard numbering. Next bugfix release will probably be 2.0.1.
## Firmware binary releases
Binary development releases are here: https://github.com/letscontrolit/ESPEasy/releases
Depending on your needs, we release different types of files.
For version 2.0.0-dev9 and higer:
Firmware name | Hardware | Included plugins |
-------------------------------------|-------------------------|-----------------------------|
ESPEasy_v2.0.0-dev9_dev_1024.bin | ESP8266 with 1Mb flash | Stable + Test + Development |
ESPEasy_v2.0.0-dev9_test_1024.bin | ESP8266 with 1Mb flash | Stable + Test |
ESPEasy_v2.0.0-dev9_normal_1024.bin | ESP8266 with 1Mb flash | Stable |
ESPEasy_v2.0.0-dev9_dev_4096.bin | ESP8266 with 4Mb flash | Stable + Test + Development |
ESPEasy_v2.0.0-dev9_test_4096.bin | ESP8266 with 4Mb flash | Stable + Test |
ESPEasy_v2.0.0-dev9_normal_4096.bin | ESP8266 with 4Mb flash | Stable |
ESPEasy_v2.0.0-dev9_dev_8285.bin | ESP8285 | Stable + Test + Development |
ESPEasy_v2.0.0-dev9_test_8285.bin | ESP8285 | Stable + Test |
ESPEasy_v2.0.0-dev9_normal_8285.bin | ESP8285 | Stable |
## More info
Details and discussion are on the Experimental forum: http://www.letscontrolit.com/forum/viewtopic.php?f=18&t=2257&p=13600#p13600
We're also on IRC: #ESPEasy @freenode
+3
View File
@@ -7,12 +7,15 @@ echo "Creating release archives for $VERSION ..."
cp .pioenvs/normal_1024/firmware.bin dist/"ESPEasy_$VERSION""_normal_1024.bin"
cp .pioenvs/normal_4096/firmware.bin dist/"ESPEasy_$VERSION""_normal_4096.bin"
cp .pioenvs/normal_8285/firmware.bin dist/"ESPEasy_$VERSION""_normal_8285.bin"
cp .pioenvs/test_1024/firmware.bin dist/"ESPEasy_$VERSION""_test_1024.bin"
cp .pioenvs/test_4096/firmware.bin dist/"ESPEasy_$VERSION""_test_4096.bin"
cp .pioenvs/test_8285/firmware.bin dist/"ESPEasy_$VERSION""_test_8285.bin"
cp .pioenvs/dev_1024/firmware.bin dist/"ESPEasy_$VERSION""_dev_1024.bin"
cp .pioenvs/dev_4096/firmware.bin dist/"ESPEasy_$VERSION""_dev_4096.bin"
cp .pioenvs/dev_8285/firmware.bin dist/"ESPEasy_$VERSION""_dev_8285.bin"
#create a source structure that is the same as the original ESPEasy project (and works with the howto on the wiki)
rm -rf dist/Source 2>/dev/null
+113
View File
@@ -1,3 +1,116 @@
-----------------------------
Changes in release v2.0.0-dev10
-----------------------------
Release date: Mon May 29 22:53:54 CEST 2017
DatuX (1):
Update README.md
Jochen Krapf (1):
Rework of plugin ADC (#319)
krikk (1):
reverted change, this fix seems to have exactly opposite outcome than expected... with the fix applied i get errors, without is i get no errors... (#320)
-----------------------------
Changes in release v2.0.0-dev9
-----------------------------
Release date: Sun May 28 15:16:00 CEST 2017
Alex Schwantes (1):
Implemented use of addFormSelector methods to _P004_Dallas plugin. Changed the device select box to show the one wire address for each connected sensor instead of just a number. Added a blank option to the device address select box so that in the event that multiple devices are present and the configured device is not currently available, the select box will be blank instead of selecting a different device.
Bartlomiej Zimon (5):
- Misc: typo
Custom Controller Settings - add controller index
Push ProtocolIndex and ControllerIndex into CPLUGIN_WEBFORM_SAVE/LOAD
Add WifiSSID2,WifiKey2 commands
Add backup Wifi network to Settings command
Blair Thompson (1):
Added Par4 and Par5 Variables (#248)
Daniel Tedenljung (5):
Updated wrong plugin number. (#269)
P052: More descriptive log messages (#283)
GUI touchup on Tools (#286)
addSubmitButton function added (#289)
New look on Tools page (#296)
DatuX (5):
Update README.md
Update issue_template.md
Update CONTRIBUTING.md
Update README.md
Update README.md
Edwin Eefting (17):
cleaned up messagedelay: use the same function everywhere. and do serial processing as well during the messagedelay
fixed issue #253 (memory leaks/crashes)
more details in memory analyser. run memory analyser via Travis
cosmetic buildlog fix
publish MQTT Connected message
timer boundschecker was off by one. fixed memanalyser total
input box fix on setting pages
comments. checkudp only in backgroundtasks()
reboot and wifidisconnect should be handled by /
bugfix in rtc checksum
nicer sleep messages
fixed a few out of bounds bugs in Misc.ino _P023_OLED.ino _P035_IRTX.ino _P037_MQTTImport.ino with cppcheck. also added cppcheck to travis to prevent such cases in the future
fixing cpp check
fixing cpp check
fixing cpp check
fixing cpp check
also distribute ESP8285 binaries
JK (5):
added functions addCheckBox and addNumericBox
added checkbox for status LED inversed
fine tuning of status LED and pimp hardware web site
solved my commit mismatch
Fixed #196 and rework of IDX display
Jochen Krapf (11):
Added addForm*-functions for easy web-interface and pimp GUI (#259)
Added function addFormSelector (#270)
Preliminary final draft of bugfix #264 (#271)
Replaced HTML code with addFormSelector() in all plugins (#278)
Fixed readUserVarFromRTC() #265 (#280)
Limits to NumericBox and a bit of security to PasswordBox (#281)
Added HTML templates for customization (#290)
Fixed rules bug #297 (#299)
Pimp device-GUI and optimized HTML (#306)
Fixed some minor HTML syntax bugs (#310)
Rework of plugin ADS1115 (#315)
PieVo (1):
Plantower (#300)
beic (1):
Some little description corrections (#297)
krikk (13):
http advanced controller, correct passing of hostname (#250)
i2c Temperatur & Humidity Sensor Am2320 (#251)
use the new addCheckBox function and better display of device config page
another fix to http advanced...
replaced static html code with the new addForm* Functions
bug fix wrong return type + form function fixes (#266)
addFormNumeric with min and max & More Form-Function replacements (#272)
make the Settings - Save. Filename more descriptive... (#273)
addHelpButton Function and a new Help Button for the Rules and Hardware Page (#282)
DHT plugin fix 'NaN' issue (#285)
i don't like hidden features, added a json button to the tools menu, next to the advanced button (#292)
do a dns lookup on every request, solves issue #261 (#302)
AM2320: negative temperature fix... (#312)
tedenda (1):
Moving plugin from Playground into main repo. (#262)
-----------------------------
Changes in release v2.0.0-dev8
-----------------------------
+59
View File
@@ -0,0 +1,59 @@
#include "AM2320.h"
#include <Wire.h>
//
// AM2321 Temperature & Humidity Sensor library for Arduino
// Сделана Тимофеевым Е.Н. из AM2320-master
unsigned int CRC16(byte *ptr, byte length)
{
unsigned int crc = 0xFFFF;
uint8_t s = 0x00;
while(length--) {
crc ^= *ptr++;
for(s = 0; s < 8; s++) {
if((crc & 0x01) != 0) {
crc >>= 1;
crc ^= 0xA001;
} else crc >>= 1;
}
}
return crc;
}
AM2320::AM2320()
{
}
int AM2320::Read()
{
byte buf[8];
for(int s = 0; s < 8; s++) buf[s] = 0x00;
Wire.beginTransmission(AM2320_address);
Wire.endTransmission();
// запрос 4 байт (температуры и влажности)
Wire.beginTransmission(AM2320_address);
Wire.write(0x03);// запрос
Wire.write(0x00); // с 0-го адреса
Wire.write(0x04); // 4 байта
if (Wire.endTransmission(1) != 0) return 1;
delayMicroseconds(1600); //>1.5ms
// считываем результаты запроса
Wire.requestFrom(AM2320_address, 0x08);
for (int i = 0; i < 0x08; i++) buf[i] = Wire.read();
// CRC check
unsigned int Rcrc = buf[7] << 8;
Rcrc += buf[6];
if (Rcrc == CRC16(buf, 6)) {
unsigned int temperature = ((buf[4] & 0x7F) << 8) + buf[5];
t = temperature / 10.0;
t = ((buf[4] & 0x80) >> 7) == 1 ? t * (-1) : t;
unsigned int humidity = (buf[2] << 8) + buf[3];
h = humidity / 10.0;
return 0;
}
return 2;
}
+17
View File
@@ -0,0 +1,17 @@
#ifndef AM2320_H
#define AM2320_H
#include <Arduino.h>
#define AM2320_address (0xB8 >> 1)
class AM2320
{
public:
AM2320();
float t;
float h;
int Read(void);
};
#endif
@@ -0,0 +1,29 @@
#include <Wire.h>
#include <AM2320.h>
AM2320 th;
void setup() {
Serial.begin(9600);
Wire.begin();
}
void loop() {
switch(th.Read()) {
case 2:
Serial.println("CRC failed");
break;
case 1:
Serial.println("Sensor offline");
break;
case 0:
Serial.print("humidity: ");
Serial.print(th.h);
Serial.print("%, temperature: ");
Serial.print(th.t);
Serial.println("*C");
break;
}
delay(200);
}
+4
View File
@@ -0,0 +1,4 @@
AM2320 KEYWORD1
getTemperature KEYWORD2
getHumidity KEYWORD2
CRCCheck KEYWORD2
+36 -13
View File
@@ -122,17 +122,6 @@ try:
objectDumpBin = sys.argv[1]
output_format="{:<30}|{:<11}|{:<11}|{:<11}|{:<11}|{:<11}"
print(output_format.format(
"plugin",
"cache IRAM",
"init RAM",
"r.o. RAM",
"uninit RAM",
"Flash ROM",
))
enable_all()
@@ -152,6 +141,7 @@ try:
test_plugins=plugins
test_plugins.sort()
print("Analysing ESPEasy memory usage for env {} ...\n".format(env))
#### disable all plugins and to get base size
for plugin in test_plugins:
@@ -161,7 +151,7 @@ try:
# for lib in libs:
# disable_lib(lib)
#build without plugins to get base memory usage
#just build the core without plugins to get base memory usage
subprocess.check_call("platformio run --silent --environment "+env, shell=True)
# #two times, sometimes it changes a few bytes somehow
# SEEMS TO BE NOT USEFULL
@@ -169,6 +159,27 @@ try:
base=analyse_memory(".pioenvs/"+env+"/firmware.elf")
output_format="{:<30}|{:<11}|{:<11}|{:<11}|{:<11}|{:<11}"
print(output_format.format(
"module",
"cache IRAM",
"init RAM",
"r.o. RAM",
"uninit RAM",
"Flash ROM",
))
print(output_format.format(
"CORE",
base['text'],
base['data'],
base['rodata'],
base['bss'],
base['irom0_text'],
))
# note: unused libs never use any memory, so dont have to test this
# ##### test per lib
# results={}
@@ -218,13 +229,23 @@ try:
total=analyse_memory(".pioenvs/"+env+"/firmware.elf")
print(output_format.format(
"ALL",
"ALL PLUGINS",
total['text']-base['text'],
total['data']-base['data'],
total['rodata']-base['rodata'],
total['bss']-base['bss'],
total['irom0_text']-base['irom0_text'],
))
print(output_format.format(
"ESPEasy",
total['text'],
total['data'],
total['rodata'],
total['bss'],
total['irom0_text'],
))
except:
enable_all()
@@ -232,3 +253,5 @@ except:
enable_all()
print("\n")
+20 -2
View File
@@ -290,7 +290,7 @@ void ExecuteCommand(byte source, const char *Line)
if (strcasecmp_P(Command, PSTR("TimerSet")) == 0)
{
if (Par1>=0 && Par1<RULES_TIMER_MAX)
if (Par1>=1 && Par1<=RULES_TIMER_MAX)
{
success = true;
if (Par2)
@@ -300,12 +300,16 @@ void ExecuteCommand(byte source, const char *Line)
//disable existing timer
RulesTimer[Par1 - 1] = 0L;
}
else
{
addLog(LOG_LEVEL_ERROR, F("TIMER: invalid timer number"));
}
}
if (strcasecmp_P(Command, PSTR("Delay")) == 0)
{
success = true;
delayMillis(Par1);
delayBackground(Par1);
}
if (strcasecmp_P(Command, PSTR("Rules")) == 0)
@@ -420,6 +424,18 @@ void ExecuteCommand(byte source, const char *Line)
strcpy(SecuritySettings.WifiKey, Line + 8);
}
if (strcasecmp_P(Command, PSTR("WifiSSID2")) == 0)
{
success = true;
strcpy(SecuritySettings.WifiSSID2, Line + 10);
}
if (strcasecmp_P(Command, PSTR("WifiKey2")) == 0)
{
success = true;
strcpy(SecuritySettings.WifiKey2, Line + 9);
}
if (strcasecmp_P(Command, PSTR("WifiScan")) == 0)
{
success = true;
@@ -506,6 +522,8 @@ void ExecuteCommand(byte source, const char *Line)
Serial.print(F(" Unit : ")); Serial.println((int)Settings.Unit);
Serial.print(F(" WifiSSID : ")); Serial.println(SecuritySettings.WifiSSID);
Serial.print(F(" WifiKey : ")); Serial.println(SecuritySettings.WifiKey);
Serial.print(F(" WifiSSID2 : ")); Serial.println(SecuritySettings.WifiSSID2);
Serial.print(F(" WifiKey2 : ")); Serial.println(SecuritySettings.WifiKey2);
Serial.print(F(" Free mem : ")); Serial.println(FreeMem());
}
+10 -6
View File
@@ -19,12 +19,13 @@ boolean sendData(struct EventStruct *event)
if (dif < Settings.MessageDelay)
{
uint16_t delayms = Settings.MessageDelay - dif;
// char log[30];
// sprintf_P(log, PSTR("CTRL : Message delay %u ms"), delayms);
addLog(LOG_LEVEL_DEBUG_MORE, String(F("CTRL : Message delay (ms): "))+delayms);
unsigned long timer = millis() + delayms;
while (millis() < timer)
backgroundtasks();
//this is logged nowhere else, so might as well disable it here also:
// addLog(LOG_LEVEL_DEBUG_MORE, String(F("CTRL : Message delay (ms): "))+delayms);
delayBackground(delayms);
// unsigned long timer = millis() + delayms;
// while (millis() < timer)
// backgroundtasks();
}
}
@@ -129,6 +130,9 @@ void MQTTConnect()
log = F("Subscribed to: ");
log += subscribeTo;
addLog(LOG_LEVEL_INFO, log);
MQTTclient.publish(LWTTopic.c_str(), "Connected");
statusLED(true);
break; // end loop if succesfull
}
+17 -8
View File
@@ -263,13 +263,15 @@
#define DAT_TASKS_SIZE 2048
#define DAT_TASKS_CUSTOM_OFFSET 1024
#define DAT_CUSTOM_CONTROLLER_SIZE 1024
#define DAT_CONTROLLER_SIZE 1024
#define DAT_NOTIFICATION_SIZE 1024
#define DAT_OFFSET_TASKS 4096 // each task = 2k, (1024 basic + 1024 bytes custom), 12 max
#define DAT_OFFSET_CONTROLLER 28672 // each controller = 1k, 4 max
#define DAT_OFFSET_CUSTOMCONTROLLER 32768 // custom controller config = 4k, currently only one can use it.
#define DAT_OFFSET_CUSTOM_CONTROLLER 32768 // each custom controller config = 1k, 4 max.
#include "lwip/tcp_impl.h"
#include <ESP8266WiFi.h>
#include <DNSServer.h>
#include <WiFiUdp.h>
@@ -296,6 +298,7 @@ ADC_MODE(ADC_VCC);
#include "lwip/udp.h"
#include "lwip/igmp.h"
#include "include/UdpContext.h"
#include "limits.h"
extern "C" {
#include "user_interface.h"
@@ -322,7 +325,7 @@ PubSubClient MQTTclient(mqtt);
// WebServer
ESP8266WebServer WebServer(80);
// syslog stuff
// udp protocol stuff (syslog, global sync, node info list, ntp time)
WiFiUDP portUDP;
@@ -415,6 +418,7 @@ struct SettingsStruct
boolean NotificationEnabled[NOTIFICATION_MAX];
unsigned int TaskDeviceID[CONTROLLER_MAX][TASKS_MAX];
boolean TaskDeviceSendData[CONTROLLER_MAX][TASKS_MAX];
boolean Pin_status_led_Inversed;
} Settings;
struct ControllerSettingsStruct
@@ -465,6 +469,8 @@ struct EventStruct
int Par1;
int Par2;
int Par3;
int Par4;
int Par5;
byte OriginTaskIndex;
String String1;
String String2;
@@ -550,7 +556,7 @@ struct RTCStruct
{
byte ID1;
byte ID2;
boolean valid;
boolean valid; // not used?
byte factoryResetCounter;
byte deepSleepState;
byte rebootCounter; //not used yet?
@@ -787,6 +793,7 @@ void setup()
RTC.deepSleepState=0;
saveToRTC();
}
@@ -804,10 +811,6 @@ void loop()
wifiSetupConnect = false;
}
if (Settings.UseSerial)
if (Serial.available())
if (!PluginCall(PLUGIN_SERIAL_IN, 0, dummyString))
serial();
// Deep sleep mode, just run all tasks one time and go back to sleep as fast as possible
if (isDeepSleepEnabled())
@@ -860,7 +863,6 @@ void run10TimesPerSecond()
start = micros();
timer100ms = millis() + 100;
PluginCall(PLUGIN_TEN_PER_SECOND, 0, dummyString);
checkUDP();
if (Settings.UseRules && eventBuffer.length() > 0)
{
rulesProcessing(eventBuffer);
@@ -1164,6 +1166,13 @@ boolean checkSystemTimers()
\*********************************************************************************************/
void backgroundtasks()
{
tcpCleanup();
if (Settings.UseSerial)
if (Serial.available())
if (!PluginCall(PLUGIN_SERIAL_IN, 0, dummyString))
serial();
// process DNS, only used if the ESP has no valid WiFi config
if (wifiSetup)
dnsServer.processNextRequest();
+144 -42
View File
@@ -1,4 +1,16 @@
// clean up tcp connections that are in TIME_WAIT status, to conserve memory
// In future versions of WiFiClient it should be possible to call abort(), but
// this feature is not in all upstream versions yet.
// See https://github.com/esp8266/Arduino/issues/1923
// and https://github.com/letscontrolit/ESPEasy/issues/253
void tcpCleanup()
{
while(tcp_tw_pcbs!=NULL)
{
tcp_abort(tcp_tw_pcbs);
}
}
bool isDeepSleepEnabled()
{
@@ -11,14 +23,14 @@ bool isDeepSleepEnabled()
// short 2-3 to cancel sleep loop for modifying settings
pinMode(16,INPUT_PULLUP);
if (!digitalRead(16))
{
return false;
}
return true;
}
void deepSleep(int delay)
{
String log;
if (!isDeepSleepEnabled())
{
@@ -29,20 +41,17 @@ void deepSleep(int delay)
//first time deep sleep? offer a way to escape
if (lastBootCause!=BOOT_CAUSE_DEEP_SLEEP)
{
log = F("Entering deep sleep in 30 seconds.");
addLog(LOG_LEVEL_INFO, log);
delayMillis(30000);
addLog(LOG_LEVEL_INFO, F("SLEEP: Entering deep sleep in 30 seconds."));
delayBackground(30000);
//disabled?
if (!isDeepSleepEnabled())
{
log = F("Deep sleep disabled.");
addLog(LOG_LEVEL_INFO, log);
addLog(LOG_LEVEL_INFO, F("SLEEP: Deep sleep cancelled (GPIO16 connected to GND)"));
return;
}
}
log = F("Entering deep sleep...");
addLog(LOG_LEVEL_INFO, log);
addLog(LOG_LEVEL_INFO, F("SLEEP: Entering deep sleep..."));
RTC.deepSleepState = 1;
saveToRTC();
@@ -346,7 +355,6 @@ boolean timeOut(unsigned long timer)
/********************************************************************************************\
Status LED
\*********************************************************************************************/
#define STATUS_PWM_LOWACTIVE
#define STATUS_PWM_NORMALVALUE (PWMRANGE>>2)
#define STATUS_PWM_NORMALFADE (PWMRANGE>>8)
#define STATUS_PWM_TRAFFICRISE (PWMRANGE>>1)
@@ -398,9 +406,8 @@ void statusLED(boolean traffic)
long pwm = nStatusValue * nStatusValue; //simple gamma correction
pwm >>= 10;
#ifdef STATUS_PWM_LOWACTIVE
pwm = PWMRANGE-pwm;
#endif
if (Settings.Pin_status_led_Inversed)
pwm = PWMRANGE-pwm;
analogWrite(Settings.Pin_status_led, pwm);
}
@@ -410,7 +417,7 @@ void statusLED(boolean traffic)
/********************************************************************************************\
delay in milliseconds with background processing
\*********************************************************************************************/
void delayMillis(unsigned long delay)
void delayBackground(unsigned long delay)
{
unsigned long timer = millis() + delay;
while (millis() < timer)
@@ -432,10 +439,14 @@ void parseCommandString(struct EventStruct *event, String& string)
event->Par1 = 0;
event->Par2 = 0;
event->Par3 = 0;
event->Par4 = 0;
event->Par5 = 0;
if (GetArgv(command, TmpStr1, 2)) event->Par1 = str2int(TmpStr1);
if (GetArgv(command, TmpStr1, 3)) event->Par2 = str2int(TmpStr1);
if (GetArgv(command, TmpStr1, 4)) event->Par3 = str2int(TmpStr1);
if (GetArgv(command, TmpStr1, 5)) event->Par4 = str2int(TmpStr1);
if (GetArgv(command, TmpStr1, 6)) event->Par5 = str2int(TmpStr1);
}
/********************************************************************************************\
@@ -719,7 +730,7 @@ boolean SaveCustomTaskSettings(int TaskIndex, byte* memAddress, int datasize)
/********************************************************************************************\
Save Custom Task settings to SPIFFS
Load Custom Task settings to SPIFFS
\*********************************************************************************************/
void LoadCustomTaskSettings(int TaskIndex, byte* memAddress, int datasize)
{
@@ -740,7 +751,7 @@ boolean SaveControllerSettings(int ControllerIndex, byte* memAddress, int datasi
/********************************************************************************************\
Save Controller settings to SPIFFS
Load Controller settings to SPIFFS
\*********************************************************************************************/
void LoadControllerSettings(int ControllerIndex, byte* memAddress, int datasize)
{
@@ -752,22 +763,22 @@ void LoadControllerSettings(int ControllerIndex, byte* memAddress, int datasize)
/********************************************************************************************\
Save Custom Controller settings to SPIFFS
\*********************************************************************************************/
boolean SaveCustomControllerSettings(byte* memAddress, int datasize)
boolean SaveCustomControllerSettings(int ControllerIndex,byte* memAddress, int datasize)
{
if (datasize > 4096)
if (datasize > DAT_CUSTOM_CONTROLLER_SIZE)
return false;
return SaveToFile((char*)"config.dat", DAT_OFFSET_CUSTOMCONTROLLER, memAddress, datasize);
return SaveToFile((char*)"config.dat", DAT_OFFSET_CUSTOM_CONTROLLER + (ControllerIndex * DAT_CUSTOM_CONTROLLER_SIZE), memAddress, datasize);
}
/********************************************************************************************\
Save Custom Controller settings to SPIFFS
Load Custom Controller settings to SPIFFS
\*********************************************************************************************/
void LoadCustomControllerSettings(byte* memAddress, int datasize)
void LoadCustomControllerSettings(int ControllerIndex,byte* memAddress, int datasize)
{
if (datasize > 4096)
if (datasize > DAT_CUSTOM_CONTROLLER_SIZE)
return;
LoadFromFile((char*)"config.dat", DAT_OFFSET_CUSTOMCONTROLLER, memAddress, datasize);
LoadFromFile((char*)"config.dat", DAT_OFFSET_CUSTOM_CONTROLLER + (ControllerIndex * DAT_CUSTOM_CONTROLLER_SIZE), memAddress, datasize);
}
/********************************************************************************************\
@@ -782,7 +793,7 @@ boolean SaveNotificationSettings(int NotificationIndex, byte* memAddress, int da
/********************************************************************************************\
Save Controller settings to SPIFFS
Load Controller settings to SPIFFS
\*********************************************************************************************/
void LoadNotificationSettings(int NotificationIndex, byte* memAddress, int datasize)
{
@@ -948,6 +959,7 @@ void ResetFactory(void)
Settings.Pin_i2c_sda = 4;
Settings.Pin_i2c_scl = 5;
Settings.Pin_status_led = -1;
Settings.Pin_status_led_Inversed = true;
Settings.Pin_sd_cs = -1;
Settings.Protocol[0] = DEFAULT_PROTOCOL;
strcpy_P(Settings.Name, PSTR(DEFAULT_NAME));
@@ -1032,6 +1044,7 @@ float ul2float(unsigned long ul)
return f;
}
/********************************************************************************************\
Init critical variables for logging (important during initial factory reset stuff )
\*********************************************************************************************/
@@ -1043,7 +1056,7 @@ void initLog()
Settings.SerialLogLevel=2; //logging during initialisation
Settings.WebLogLevel=2;
Settings.SDLogLevel=0;
for (int l; l<9; l++)
for (int l=0; l<10; l++)
{
Logging[l].Message=0;
}
@@ -1115,13 +1128,14 @@ void delayedReboot(int rebootDelay)
/********************************************************************************************\
Save RTC struct to RTC memory
\*********************************************************************************************/
//user-area of the esp starts at block 64 (bytes = block * 4)
#define RTC_BASE_STRUCT 64
void saveToRTC()
boolean saveToRTC()
{
RTC.ID1 = 0xAA;
RTC.ID2 = 0x55;
RTC.valid = true;
system_rtc_mem_write(RTC_BASE_STRUCT, (byte*)&RTC, sizeof(RTC));
return(system_rtc_mem_write(RTC_BASE_STRUCT, (byte*)&RTC, sizeof(RTC)));
}
@@ -1130,7 +1144,9 @@ void saveToRTC()
\*********************************************************************************************/
boolean readFromRTC()
{
system_rtc_mem_read(RTC_BASE_STRUCT, (byte*)&RTC, sizeof(RTC));
if (!system_rtc_mem_read(RTC_BASE_STRUCT, (byte*)&RTC, sizeof(RTC)))
return(false);
if (RTC.ID1 == 0xAA && RTC.ID2 == 0x55)
{
RTC.valid = false;
@@ -1142,20 +1158,47 @@ boolean readFromRTC()
/********************************************************************************************\
Save values to RTC memory
\*********************************************************************************************/
\*********************************************************************************************/
#define RTC_BASE_USERVAR 74
void saveUserVarToRTC()
boolean saveUserVarToRTC()
{
system_rtc_mem_write(RTC_BASE_USERVAR, (byte*)&UserVar, sizeof(UserVar));
//addLog(LOG_LEVEL_DEBUG, F("RTCMEM: saveUserVarToRTC"));
byte* buffer = (byte*)&UserVar;
size_t size = sizeof(UserVar);
uint32 sum = getChecksum(buffer, size);
boolean ret = system_rtc_mem_write(RTC_BASE_USERVAR, buffer, size);
ret &= system_rtc_mem_write(RTC_BASE_USERVAR+(size>>2), (byte*)&sum, 4);
return ret;
}
/********************************************************************************************\
Read RTC struct from RTC memory
\*********************************************************************************************/
\*********************************************************************************************/
boolean readUserVarFromRTC()
{
system_rtc_mem_read(RTC_BASE_USERVAR, (byte*)&UserVar, sizeof(UserVar));
//addLog(LOG_LEVEL_DEBUG, F("RTCMEM: readUserVarFromRTC"));
byte* buffer = (byte*)&UserVar;
size_t size = sizeof(UserVar);
boolean ret = system_rtc_mem_read(RTC_BASE_USERVAR, buffer, size);
uint32 sumRAM = getChecksum(buffer, size);
uint32 sumRTC = 0;
ret &= system_rtc_mem_read(RTC_BASE_USERVAR+(size>>2), (byte*)&sumRTC, 4);
if (!ret || sumRTC != sumRAM)
{
addLog(LOG_LEVEL_ERROR, F("RTC : Checksum error on reading RTC user var"));
memset(buffer, 0, size);
}
return ret;
}
uint32 getChecksum(byte* buffer, size_t size)
{
uint32 sum = 0x82662342; //some magic to avoid valid checksum on new, uninitialized ESP
for (size_t i=0; i<size; i++)
sum += buffer[i];
return sum;
}
@@ -1264,6 +1307,68 @@ String timeLong2String(unsigned long lngTime)
return time;
}
// returns the current Date separated by the given delimiter
// date format example with '-' delimiter: 2016-12-31 (YYYY-MM-DD)
String getDateString(char delimiter)
{
String reply = String(year());
if (delimiter != '\0')
reply += delimiter;
if (month() < 10)
reply += "0";
reply += month();
if (delimiter != '\0')
reply += delimiter;
if (day() < 10)
reply += F("0");
reply += day();
return reply;
}
// returns the current Date without delimiter
// date format example: 20161231 (YYYYMMDD)
String getDateString()
{
return getDateString('\0');
}
// returns the current Time separated by the given delimiter
// time format example with ':' delimiter: 23:59:59 (HH:MM:SS)
String getTimeString(char delimiter)
{
String reply;
if (hour() < 10)
reply += F("0");
reply += String(hour());
if (delimiter != '\0')
reply += delimiter;
if (minute() < 10)
reply += F("0");
reply += minute();
if (delimiter != '\0')
reply += delimiter;
reply += second();
return reply;
}
// returns the current Time without delimiter
// time format example: 235959 (HHMMSS)
String getTimeString()
{
return getTimeString('\0');
}
// returns the current Date and Time separated by the given delimiter
// if called like this: getDateTimeString('\0', '\0', '\0');
// it will give back this: 20161231235959 (YYYYMMDDHHMMSS)
String getDateTimeString(char dateDelimiter, char timeDelimiter, char dateTimeDelimiter)
{
String ret = getDateString(dateDelimiter);
if (dateTimeDelimiter != '\0')
ret += dateTimeDelimiter;
ret += getTimeString(timeDelimiter);
return ret;
}
/********************************************************************************************\
Match clock event
@@ -1381,15 +1486,7 @@ String parseTemplate(String &tmpString, byte lineSize)
// replace other system variables like %sysname%, %systime%, %ip%
newString.replace(F("%sysname%"), Settings.Name);
String strTime = "";
if (hour() < 10)
strTime += " ";
strTime += hour();
strTime += ":";
if (minute() < 10)
strTime += "0";
strTime += minute();
newString.replace(F("%systime%"), strTime);
newString.replace(F("%systime%"), getTimeString(':'));
newString.replace(F("%uptime%"), String(wdcounter / 2));
@@ -1813,6 +1910,11 @@ byte minute()
return tm.Minute;
}
byte second()
{
return tm.Second;
}
int weekday()
{
return tm.Wday;
+10 -2
View File
@@ -48,8 +48,10 @@ struct dataStruct
float Values[VARS_PER_TASK];
};
//TODO: add sysinfoStruct
/*********************************************************************************************\
Check UDP messages
Check UDP messages (ESPEasy propiertary protocol)
\*********************************************************************************************/
void checkUDP()
{
@@ -98,6 +100,8 @@ void checkUDP()
// binary data!
switch (packetBuffer[1])
{
//TODO: use a nice struct for it
case 1: // sysinfo message
{
byte mac[6];
@@ -289,7 +293,7 @@ void SendUDPCommand(byte destUnit, char* data, byte dataLength)
/*********************************************************************************************\
Send UDP message
Send UDP message (unit 255=broadcast)
\*********************************************************************************************/
void sendUDP(byte unit, byte* data, byte size)
{
@@ -330,12 +334,16 @@ void refreshNodeList()
}
}
/*********************************************************************************************\
Broadcast system info to other nodes. (to update node lists)
\*********************************************************************************************/
void sendSysInfoUDP(byte repeats)
{
char log[80];
if (Settings.UDPPort == 0)
return;
// TODO: make a nice struct of it and clean up
// 1 byte 'binary token 255'
// 1 byte id '1'
// 6 byte mac
+1189 -676
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -37,7 +37,7 @@ boolean CPlugin_001(byte function, struct EventStruct *event, String& string)
LoadControllerSettings(event->ControllerIndex, (byte*)&ControllerSettings, sizeof (ControllerSettings));
String authHeader = "";
if ((SecuritySettings.ControllerUser[event->ProtocolIndex][0] != 0) && (SecuritySettings.ControllerPassword[event->ProtocolIndex][0] != 0))
if ((SecuritySettings.ControllerUser[event->ControllerIndex][0] != 0) && (SecuritySettings.ControllerPassword[event->ControllerIndex][0] != 0))
{
base64 encoder;
String auth = SecuritySettings.ControllerUser[event->ControllerIndex];
+4 -3
View File
@@ -49,9 +49,10 @@ boolean CPlugin_008(byte function, struct EventStruct *event, String& string)
HTTPSend(event, x, UserVar[event->BaseVarIndex + x], 0);
if (valueCount > 1)
{
unsigned long timer = millis() + Settings.MessageDelay;
while (millis() < timer)
backgroundtasks();
delayBackground(Settings.MessageDelay);
// unsigned long timer = millis() + Settings.MessageDelay;
// while (millis() < timer)
// backgroundtasks();
}
}
break;
+4 -3
View File
@@ -48,9 +48,10 @@ boolean CPlugin_010(byte function, struct EventStruct *event, String& string)
C010_Send(event, x, UserVar[event->BaseVarIndex + x], 0);
if (valueCount > 1)
{
unsigned long timer = millis() + Settings.MessageDelay;
while (millis() < timer)
backgroundtasks();
delayBackground(Settings.MessageDelay);
// unsigned long timer = millis() + Settings.MessageDelay;
// while (millis() < timer)
// backgroundtasks();
}
}
break;
+14 -23
View File
@@ -49,7 +49,8 @@ boolean CPlugin_011(byte function, struct EventStruct *event, String& string)
String escapeBuffer;
P011_ConfigStruct customConfig;
LoadCustomControllerSettings((byte*)&customConfig, sizeof(customConfig));
LoadCustomControllerSettings(event->ControllerIndex,(byte*)&customConfig, sizeof(customConfig));
String methods[] = { F("GET"), F("POST"), F("PUT"), F("HEAD"), F("PATCH") };
string += F("<TR><TD>HTTP Method :<TD><select name='P011httpmethod'>");
for (byte i = 0; i < 5; i++)
@@ -95,11 +96,12 @@ boolean CPlugin_011(byte function, struct EventStruct *event, String& string)
String httpuri = WebServer.arg(F("P011httpuri"));
String httpheader = WebServer.arg(F("P011httpheader"));
String httpbody = WebServer.arg(F("P011httpbody"));
strlcpy(customConfig.HttpMethod, httpmethod.c_str(), sizeof(customConfig.HttpMethod));
strlcpy(customConfig.HttpUri, httpuri.c_str(), sizeof(customConfig.HttpUri));
strlcpy(customConfig.HttpHeader, httpheader.c_str(), sizeof(customConfig.HttpHeader));
strlcpy(customConfig.HttpBody, httpbody.c_str(), sizeof(customConfig.HttpBody));
SaveCustomControllerSettings((byte*)&customConfig, sizeof(customConfig));
SaveCustomControllerSettings(event->ControllerIndex,(byte*)&customConfig, sizeof(customConfig));
break;
}
@@ -134,23 +136,18 @@ boolean HTTPSend011(struct EventStruct *event)
}
P011_ConfigStruct customConfig;
LoadCustomControllerSettings((byte*)&customConfig, sizeof(customConfig));
LoadCustomControllerSettings(event->ControllerIndex,(byte*)&customConfig, sizeof(customConfig));
// char log[80];
boolean success = false;
// char host[20];
IPAddress host(ControllerSettings.IP[0], ControllerSettings.IP[1], ControllerSettings.IP[2], ControllerSettings.IP[3]);
// sprintf_P(host, PSTR("%u.%u.%u.%u"), ControllerSettings.IP[0], ControllerSettings.IP[1], ControllerSettings.IP[2], ControllerSettings.IP[3]);
// char tmp[22];
// strcpy_P(tmp, PSTR("HTTP : connecting to "));
// sprintf_P(log, PSTR("%s%s using port %u"), tmp, host, ControllerSettings.Port);
// addLog(LOG_LEVEL_DEBUG, log);
addLog(LOG_LEVEL_DEBUG, String(F("HTTP : connecting to "))+host.toString()+":"+ControllerSettings.Port);
IPAddress host(ControllerSettings.IP[0], ControllerSettings.IP[1], ControllerSettings.IP[2], ControllerSettings.IP[3]);
addLog(LOG_LEVEL_DEBUG, String(F("HTTP : connecting to "))+
(ControllerSettings.UseDNS ? ControllerSettings.HostName : host.toString() ) +":"+ControllerSettings.Port);
// Use WiFiClient class to create TCP connections
WiFiClient client;
if (!client.connect(host, ControllerSettings.Port))
if (ControllerSettings.UseDNS ? !client.connect(ControllerSettings.HostName, ControllerSettings.Port) : !client.connect(host, ControllerSettings.Port))
{
connectionFailures++;
addLog(LOG_LEVEL_ERROR, F("HTTP : connection failed"));
@@ -165,7 +162,7 @@ boolean HTTPSend011(struct EventStruct *event)
String hostName = host.toString();
if (ControllerSettings.UseDNS)
hostName = ControllerSettings.HostName[event->ProtocolIndex];
hostName = ControllerSettings.HostName;
String payload = String(customConfig.HttpMethod) + " /";
payload += customConfig.HttpUri;
@@ -189,6 +186,7 @@ boolean HTTPSend011(struct EventStruct *event)
payload += F("\r\n\r\n");
payload += body;
}
payload += F("\r\n");
// This will send the request to the server
client.print(payload);
@@ -310,15 +308,8 @@ void ReplaceTokenByValue(String& s, struct EventStruct *event)
addLog(LOG_LEVEL_DEBUG_MORE, s);
//NOTE: cant we just call parseTemplate() for all the standard stuff??
String strTime = "";
if (hour() < 10)
strTime += F(" ");
strTime += hour();
strTime += F(":");
if (minute() < 10)
strTime += F("0");
strTime += minute();
s.replace(F("%systime%"), strTime);
s.replace(F("%systime%"), getTimeString(':'));
#if FEATURE_ADC_VCC
newString.replace(F("%vcc%"), String(vcc));
+10 -46
View File
@@ -52,22 +52,8 @@ boolean Plugin_001(byte function, struct EventStruct *event, String& string)
String options[2];
options[0] = F("Switch");
options[1] = F("Dimmer");
int optionValues[2];
optionValues[0] = 1;
optionValues[1] = 2;
string += F("<TR><TD>Switch Type:<TD><select name='plugin_001_type'>");
for (byte x = 0; x < 2; x++)
{
string += F("<option value='");
string += optionValues[x];
string += "'";
if (choice == optionValues[x])
string += F(" selected");
string += ">";
string += options[x];
string += F("</option>");
}
string += F("</select>");
int optionValues[2] = { 1, 2 };
addFormSelector(string, F("Switch Type"), F("plugin_001_type"), 2, options, optionValues, choice);
if (Settings.TaskDevicePluginConfig[event->TaskIndex][0] == 2)
{
@@ -81,29 +67,10 @@ boolean Plugin_001(byte function, struct EventStruct *event, String& string)
buttonOptions[0] = F("Normal Switch");
buttonOptions[1] = F("Push Button Active Low");
buttonOptions[2] = F("Push Button Active High");
int buttonOptionValues[3];
buttonOptionValues[0] = 0;
buttonOptionValues[1] = 1;
buttonOptionValues[2] = 2;
string += F("<TR><TD>Switch Button Type:<TD><select name='plugin_001_button'>");
for (byte x = 0; x < 3; x++)
{
string += F("<option value='");
string += buttonOptionValues[x];
string += "'";
if (choice == buttonOptionValues[x])
string += F(" selected");
string += ">";
string += buttonOptions[x];
string += F("</option>");
}
string += F("</select>");
addFormSelector(string, F("Switch Button Type"), F("plugin_001_button"), 3, buttonOptions, NULL, choice);
string += F("<TR><TD>Send Boot state:<TD>");
if (Settings.TaskDevicePluginConfig[event->TaskIndex][3])
string += F("<input type=checkbox name=plugin_001_boot checked>");
else
string += F("<input type=checkbox name=plugin_001_boot>");
addFormCheckBox(string, F("Send Boot state"),F("plugin_001_boot"),
Settings.TaskDevicePluginConfig[event->TaskIndex][3]);
success = true;
break;
@@ -111,18 +78,15 @@ boolean Plugin_001(byte function, struct EventStruct *event, String& string)
case PLUGIN_WEBFORM_SAVE:
{
String plugin1 = WebServer.arg(F("plugin_001_type"));
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = plugin1.toInt();
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = getFormItemInt(F("plugin_001_type"));
if (Settings.TaskDevicePluginConfig[event->TaskIndex][0] == 2)
{
String plugin2 = WebServer.arg(F("plugin_001_dimvalue"));
Settings.TaskDevicePluginConfig[event->TaskIndex][1] = plugin2.toInt();
Settings.TaskDevicePluginConfig[event->TaskIndex][1] = getFormItemInt(F("plugin_001_dimvalue"));
}
String plugin3 = WebServer.arg(F("plugin_001_button"));
Settings.TaskDevicePluginConfig[event->TaskIndex][2] = plugin3.toInt();
String plugin4 = WebServer.arg(F("plugin_001_boot"));
Settings.TaskDevicePluginConfig[event->TaskIndex][3] = (plugin4 == "on");
Settings.TaskDevicePluginConfig[event->TaskIndex][2] = getFormItemInt(F("plugin_001_button"));
Settings.TaskDevicePluginConfig[event->TaskIndex][3] = isFormItemChecked(F("plugin_001_boot"));
success = true;
break;
+86 -5
View File
@@ -6,13 +6,17 @@
#define PLUGIN_ID_002 2
#define PLUGIN_NAME_002 "Analog input"
#define PLUGIN_VALUENAME1_002 "Analog"
uint32_t Plugin_002_OversamplingValue = 0;
uint16_t Plugin_002_OversamplingCount = 0;
boolean Plugin_002(byte function, struct EventStruct *event, String& string)
{
boolean success = false;
switch (function)
{
case PLUGIN_DEVICE_ADD:
{
Device[++deviceCount].Number = PLUGIN_ID_002;
@@ -40,13 +44,90 @@ boolean Plugin_002(byte function, struct EventStruct *event, String& string)
strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[0], PSTR(PLUGIN_VALUENAME1_002));
break;
}
case PLUGIN_WEBFORM_LOAD:
{
addFormCheckBox(string, F("Oversampling"), F("plugin_002_oversampling"), Settings.TaskDevicePluginConfig[event->TaskIndex][0]);
addFormSubHeader(string, F("Two Point Calibration"));
addFormCheckBox(string, F("Calibration Enabled"), F("plugin_002_cal"), Settings.TaskDevicePluginConfig[event->TaskIndex][3]);
addFormNumericBox(string, F("Point 1"), F("plugin_002_adc1"), Settings.TaskDevicePluginConfigLong[event->TaskIndex][0], 0, 1023);
string += F(" &#8793; ");
addTextBox(string, F("plugin_002_out1"), String(Settings.TaskDevicePluginConfigFloat[event->TaskIndex][0], 3), 10);
addFormNumericBox(string, F("Point 2"), F("plugin_002_adc2"), Settings.TaskDevicePluginConfigLong[event->TaskIndex][1], 0, 1023);
string += F(" &#8793; ");
addTextBox(string, F("plugin_002_out2"), String(Settings.TaskDevicePluginConfigFloat[event->TaskIndex][1], 3), 10);
success = true;
break;
}
case PLUGIN_WEBFORM_SAVE:
{
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = isFormItemChecked(F("plugin_002_oversampling"));
Settings.TaskDevicePluginConfig[event->TaskIndex][3] = isFormItemChecked(F("plugin_002_cal"));
Settings.TaskDevicePluginConfigLong[event->TaskIndex][0] = getFormItemInt(F("plugin_002_adc1"));
Settings.TaskDevicePluginConfigFloat[event->TaskIndex][0] = getFormItemFloat(F("plugin_002_out1"));
Settings.TaskDevicePluginConfigLong[event->TaskIndex][1] = getFormItemInt(F("plugin_002_adc2"));
Settings.TaskDevicePluginConfigFloat[event->TaskIndex][1] = getFormItemFloat(F("plugin_002_out2"));
success = true;
break;
}
case PLUGIN_TEN_PER_SECOND:
{
if (Settings.TaskDevicePluginConfig[event->TaskIndex][0]) //Oversampling?
{
Plugin_002_OversamplingValue += analogRead(A0);
Plugin_002_OversamplingCount ++;
}
success = true;
break;
}
case PLUGIN_READ:
{
int value = analogRead(A0);
UserVar[event->BaseVarIndex] = (float)value;
String log = F("ADC : Analog value: ");
log += value;
if (Plugin_002_OversamplingCount > 0)
{
UserVar[event->BaseVarIndex] = (float)Plugin_002_OversamplingValue / Plugin_002_OversamplingCount;
Plugin_002_OversamplingValue = 0;
Plugin_002_OversamplingCount = 0;
log += String(UserVar[event->BaseVarIndex], 3);
}
else
{
int16_t value = analogRead(A0);
UserVar[event->BaseVarIndex] = (float)value;
log += value;
}
if (Settings.TaskDevicePluginConfig[event->TaskIndex][3]) //Calibration?
{
int adc1 = Settings.TaskDevicePluginConfigLong[event->TaskIndex][0];
int adc2 = Settings.TaskDevicePluginConfigLong[event->TaskIndex][1];
float out1 = Settings.TaskDevicePluginConfigFloat[event->TaskIndex][0];
float out2 = Settings.TaskDevicePluginConfigFloat[event->TaskIndex][1];
if (adc1 != adc2)
{
float normalized = (float)(UserVar[event->BaseVarIndex] - adc1) / (float)(adc2 - adc1);
UserVar[event->BaseVarIndex] = normalized * (out2 - out1) + out1;
log += F(" = ");
log += String(UserVar[event->BaseVarIndex], 3);
}
}
addLog(LOG_LEVEL_INFO,log);
success = true;
break;
+12 -49
View File
@@ -64,22 +64,17 @@ boolean Plugin_003(byte function, struct EventStruct *event, String& string)
case PLUGIN_WEBFORM_LOAD:
{
char tmpString[128];
sprintf_P(tmpString, PSTR("<TR><TD>Debounce Time (mSec):<TD><input type='text' name='plugin_003' value='%u'>"), Settings.TaskDevicePluginConfig[event->TaskIndex][0]);
string += tmpString;
addFormNumericBox(string, F("Debounce Time (mSec)"), F("plugin_003")
, Settings.TaskDevicePluginConfig[event->TaskIndex][0]);
byte choice = Settings.TaskDevicePluginConfig[event->TaskIndex][1];
byte choice2 = Settings.TaskDevicePluginConfig[event->TaskIndex][2];
String options[4];
options[0] = F("Delta");
options[1] = F("Delta/Total/Time");
options[2] = F("Total");
options[3] = F("Delta/Total");
int optionValues[4];
optionValues[0] = 0;
optionValues[1] = 1;
optionValues[2] = 2;
optionValues[3] = 3;
String options[4] = { F("Delta"), F("Delta/Total/Time"), F("Total"), F("Delta/Total") };
addFormSelector(string, F("Counter Type"), F("plugin_003_countertype"), 4, options, NULL, choice );
if (choice !=0)
string += F("<span style=\"color:red\">Total count is not persistent!</span>");
String modeRaise[4];
modeRaise[0] = F("LOW");
modeRaise[1] = F("CHANGE");
@@ -91,36 +86,7 @@ boolean Plugin_003(byte function, struct EventStruct *event, String& string)
modeValues[2] = RISING;
modeValues[3] = FALLING;
string += F("<TR><TD>Counter Type:<TD><select name='plugin_003_countertype'>");
for (byte x = 0; x < 4; x++)
{
string += F("<option value='");
string += optionValues[x];
string += "'";
if (choice == optionValues[x])
string += F(" selected");
string += ">";
string += options[x];
string += F("</option>");
}
string += F("</select>");
if (choice !=0)
string += F("<span style=\"color:red\">Total count is not persistent!</span>");
string += F("<TR><TD>Counter Type:<TD><select name='plugin_003_raisetype'>");
for (byte x = 0; x < 4; x++)
{
string += F("<option value='");
string += modeValues[x];
string += "'";
if (choice2 == modeValues[x])
string += F(" selected");
string += ">";
string += modeRaise[x];
string += F("</option>");
}
string += F("</select>");
addFormSelector(string, F("Mode Type"), F("plugin_003_raisetype"), 4, modeRaise, modeValues, choice2 );
success = true;
break;
@@ -128,12 +94,9 @@ boolean Plugin_003(byte function, struct EventStruct *event, String& string)
case PLUGIN_WEBFORM_SAVE:
{
String plugin1 = WebServer.arg("plugin_003");
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = plugin1.toInt();
String plugin2 = WebServer.arg("plugin_003_countertype");
Settings.TaskDevicePluginConfig[event->TaskIndex][1] = plugin2.toInt();
String plugin3 = WebServer.arg("plugin_003_raisetype");
Settings.TaskDevicePluginConfig[event->TaskIndex][2] = plugin3.toInt();
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = getFormItemInt(F("plugin_003"));
Settings.TaskDevicePluginConfig[event->TaskIndex][1] = getFormItemInt(F("plugin_003_countertype"));
Settings.TaskDevicePluginConfig[event->TaskIndex][2] = getFormItemInt(F("plugin_003_raisetype"));
success = true;
break;
}
+484 -477
View File
File diff suppressed because it is too large Load Diff
+7 -26
View File
@@ -47,28 +47,10 @@ boolean Plugin_005(byte function, struct EventStruct *event, String& string)
case PLUGIN_WEBFORM_LOAD:
{
byte choice = Settings.TaskDevicePluginConfig[event->TaskIndex][0];
String options[3];
options[0] = F("DHT 11");
options[1] = F("DHT 22");
options[2] = F("DHT 12");
int optionValues[3];
optionValues[0] = 11;
optionValues[1] = 22;
optionValues[2] = 12;
string += F("<TR><TD>DHT Type:<TD><select name='plugin_005_dhttype'>");
for (byte x = 0; x < 3; x++)
{
string += F("<option value='");
string += optionValues[x];
string += "'";
if (choice == optionValues[x])
string += F(" selected");
string += ">";
string += options[x];
string += F("</option>");
}
string += F("</select>");
const String options[] = { F("DHT 11"), F("DHT 22"), F("DHT 12") };
int indices[] = { 11, 22, 12 };
addFormSelector(string, F("DHT Type"), F("plugin_005_dhttype"), 3, options, indices, Settings.TaskDevicePluginConfig[event->TaskIndex][0] );
success = true;
break;
@@ -76,8 +58,8 @@ boolean Plugin_005(byte function, struct EventStruct *event, String& string)
case PLUGIN_WEBFORM_SAVE:
{
String plugin1 = WebServer.arg(F("plugin_005_dhttype"));
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = plugin1.toInt();
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = getFormItemInt(F("plugin_005_dhttype"));
success = true;
break;
}
@@ -132,7 +114,7 @@ boolean Plugin_005(byte function, struct EventStruct *event, String& string)
{
float temperature = NAN;
float humidity = NAN;
if (Par3 == 11)
{
temperature = float(dht_dat[2]); // Temperature
@@ -221,4 +203,3 @@ int Plugin_005_read_dht_dat(void)
//interrupts();
return result;
}
+4 -6
View File
@@ -8,6 +8,8 @@
#define PLUGIN_VALUENAME1_006 "Temperature"
#define PLUGIN_VALUENAME2_006 "Pressure"
// TODO this will not work if we have more than one of this task!
boolean Plugin_006_init = false;
boolean Plugin_006(byte function, struct EventStruct *event, String& string)
@@ -47,18 +49,14 @@ boolean Plugin_006(byte function, struct EventStruct *event, String& string)
case PLUGIN_WEBFORM_LOAD:
{
string += F("<TR><TD>Altitude [m]:<TD><input type='text' title='Set Altitude to 0 to get measurement without altitude adjustment' name='");
string += F("_p006_bmp085_elev' value='");
string += Settings.TaskDevicePluginConfig[event->TaskIndex][1];
string += F("'>");
addFormNumericBox(string, F("Altitude [m]"), F("_p006_bmp085_elev"), Settings.TaskDevicePluginConfig[event->TaskIndex][1]);
success = true;
break;
}
case PLUGIN_WEBFORM_SAVE:
{
String elev = WebServer.arg(F("_p006_bmp085_elev"));
Settings.TaskDevicePluginConfig[event->TaskIndex][1] = elev.toInt();
Settings.TaskDevicePluginConfig[event->TaskIndex][1] = getFormItemInt(F("_p006_bmp085_elev"));
success = true;
break;
}
+2 -8
View File
@@ -46,11 +46,7 @@ boolean Plugin_009(byte function, struct EventStruct *event, String& string)
case PLUGIN_WEBFORM_LOAD:
{
string += F("<TR><TD>Send Boot state:<TD>");
if (Settings.TaskDevicePluginConfig[event->TaskIndex][0])
string += F("<input type=checkbox name=plugin_009_boot checked>");
else
string += F("<input type=checkbox name=plugin_009_boot>");
addFormCheckBox(string, F("Send Boot state") ,F("plugin_009_boot"), Settings.TaskDevicePluginConfig[event->TaskIndex][0]);
success = true;
break;
@@ -58,9 +54,7 @@ boolean Plugin_009(byte function, struct EventStruct *event, String& string)
case PLUGIN_WEBFORM_SAVE:
{
String plugin1 = WebServer.arg(F("plugin_009_boot"));
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = (plugin1 == "on");
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = isFormItemChecked(F("plugin_009_boot"));
success = true;
break;
+9 -38
View File
@@ -48,25 +48,16 @@ boolean Plugin_010(byte function, struct EventStruct *event, String& string)
case PLUGIN_WEBFORM_LOAD:
{
byte choice = Settings.TaskDevicePluginConfig[event->TaskIndex][0];
/*
String options[2];
options[0] = F("0x23 - default settings (ADDR Low)");
options[1] = F("0x5c - alternate settings (ADDR High)");
*/
int optionValues[2];
optionValues[0] = BH1750_DEFAULT_I2CADDR;
optionValues[1] = BH1750_SECOND_I2CADDR;
string += F("<TR><TD>I2C Address:<TD><select name='plugin_010'>");
for (byte x = 0; x < 2; x++)
{
string += F("<option value='");
string += optionValues[x];
string += "'";
if (choice == optionValues[x])
string += F(" selected");
string += ">";
string += options[x];
string += F("</option>");
}
string += F("</select>");
addFormSelectorI2C(string, F("plugin_010"), 2, optionValues, choice);
addFormNote(string, F("ADDR Low=0x23, High=0x5c"));
byte choiceMode = Settings.TaskDevicePluginConfig[event->TaskIndex][1];
String optionsMode[4];
@@ -79,25 +70,9 @@ boolean Plugin_010(byte function, struct EventStruct *event, String& string)
optionValuesMode[1] = RESOLUTION_NORMAL;
optionValuesMode[2] = RESOLUTION_HIGH;
optionValuesMode[3] = RESOLUTION_AUTO_HIGH;
string += F("<TR><TD>measurment mode:<TD><select name='plugin_010_mode'>");
for (byte x = 0; x < 4; x++)
{
string += F("<option value='");
string += optionValuesMode[x];
string += "'";
if (choiceMode == optionValuesMode[x])
string += F(" selected");
string += ">";
string += optionsMode[x];
string += F("</option>");
}
string += F("</select>");
addFormSelector(string, F("Measurment mode"), F("plugin_010_mode"), 4, optionsMode, optionValuesMode, choiceMode);
string += F("<TR><TD>Send sensor to sleep:<TD>");
if (Settings.TaskDevicePluginConfig[event->TaskIndex][2])
string += F("<input type=checkbox name=plugin_010_sleep checked>");
else
string += F("<input type=checkbox name=plugin_010_sleep>");
addFormCheckBox(string, F("Send sensor to sleep"), F("plugin_010_sleep"), Settings.TaskDevicePluginConfig[event->TaskIndex][2]);
success = true;
break;
@@ -105,12 +80,9 @@ boolean Plugin_010(byte function, struct EventStruct *event, String& string)
case PLUGIN_WEBFORM_SAVE:
{
String plugin1 = WebServer.arg(F("plugin_010"));
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = plugin1.toInt();
String plugin2 = WebServer.arg(F("plugin_010_mode"));
Settings.TaskDevicePluginConfig[event->TaskIndex][1] = plugin2.toInt();
String plugin3 = WebServer.arg(F("plugin_010_sleep"));
Settings.TaskDevicePluginConfig[event->TaskIndex][2] = (plugin3 == "on");
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = getFormItemInt(F("plugin_010"));
Settings.TaskDevicePluginConfig[event->TaskIndex][1] = getFormItemInt(F("plugin_010_mode"));
Settings.TaskDevicePluginConfig[event->TaskIndex][2] = isFormItemChecked(F("plugin_010_sleep"));
success = true;
break;
}
@@ -150,4 +122,3 @@ boolean Plugin_010(byte function, struct EventStruct *event, String& string)
}
return success;
}
+3 -22
View File
@@ -46,25 +46,8 @@ boolean Plugin_011(byte function, struct EventStruct *event, String& string)
case PLUGIN_WEBFORM_LOAD:
{
byte choice = Settings.TaskDevicePluginConfig[event->TaskIndex][0];
String options[2];
options[0] = F("Digital");
options[1] = F("Analog");
int optionValues[2];
optionValues[0] = 0;
optionValues[1] = 1;
string += F("<TR><TD>Port Type:<TD><select name='plugin_011'>");
for (byte x = 0; x < 2; x++)
{
string += F("<option value='");
string += optionValues[x];
string += "'";
if (choice == optionValues[x])
string += F(" selected");
string += ">";
string += options[x];
string += F("</option>");
}
string += F("</select>");
String options[2] = { F("Digital"), F("Analog") };
addFormSelector(string, F("Port Type"), F("plugin_011"), 2, options, NULL, choice);
success = true;
break;
@@ -72,8 +55,7 @@ boolean Plugin_011(byte function, struct EventStruct *event, String& string)
case PLUGIN_WEBFORM_SAVE:
{
String plugin1 = WebServer.arg(F("plugin_011"));
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = plugin1.toInt();
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = getFormItemInt(F("plugin_011"));
success = true;
break;
}
@@ -229,4 +211,3 @@ boolean Plugin_011_Write(byte Par1, byte Par2)
Wire.write((Par2 >> 8));
Wire.endTransmission();
}
+11 -36
View File
@@ -55,47 +55,25 @@ boolean Plugin_012(byte function, struct EventStruct *event, String& string)
case PLUGIN_WEBFORM_LOAD:
{
byte choice = Settings.TaskDevicePluginConfig[event->TaskIndex][0];
//String options[16];
int optionValues[16];
for (byte x = 0; x < 17; x++)
for (byte x = 0; x < 16; x++)
{
if (x < 8)
optionValues[x] = 0x20 + x;
else
optionValues[x] = 0x30 + x;
string += F("<TR><TD>I2C Address:<TD><select name='plugin_012_adr'>");
for (byte x = 0; x < 16; x++)
{
string += F("<option value='");
string += optionValues[x];
string += "'";
if (choice == optionValues[x])
string += F(" selected");
string += ">";
string += String(optionValues[x], HEX);
string += F("</option>");
//options[x] = F("0x");
//options[x] += String(optionValues[x], HEX);
}
string += F("</select>");
addFormSelectorI2C(string, F("plugin_012_adr"), 16, optionValues, choice);
byte choice2 = Settings.TaskDevicePluginConfig[event->TaskIndex][1];
String options2[2];
options2[0] = F("2 x 16");
options2[1] = F("4 x 20");
int optionValues2[2];
optionValues2[0] = 1;
optionValues2[1] = 2;
string += F("<TR><TD>Display Size:<TD><select name='plugin_012_size'>");
for (byte x = 0; x < 2; x++)
{
string += F("<option value='");
string += optionValues2[x];
string += "'";
if (choice2 == optionValues2[x])
string += F(" selected");
string += ">";
string += options2[x];
string += F("</option>");
}
string += F("</select>");
int optionValues2[2] = { 1, 2 };
addFormSelector(string, F("Display Size"), F("plugin_012_size"), 2, options2, optionValues2, choice2);
char deviceTemplate[4][80];
LoadCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate));
@@ -124,12 +102,9 @@ boolean Plugin_012(byte function, struct EventStruct *event, String& string)
case PLUGIN_WEBFORM_SAVE:
{
String plugin1 = WebServer.arg(F("plugin_012_adr"));
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = plugin1.toInt();
String plugin2 = WebServer.arg(F("plugin_012_size"));
Settings.TaskDevicePluginConfig[event->TaskIndex][1] = plugin2.toInt();
String plugin3 = WebServer.arg(F("plugin_12_timer"));
Settings.TaskDevicePluginConfig[event->TaskIndex][2] = plugin3.toInt();
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = getFormItemInt(F("plugin_012_adr"));
Settings.TaskDevicePluginConfig[event->TaskIndex][1] = getFormItemInt(F("plugin_012_size"));
Settings.TaskDevicePluginConfig[event->TaskIndex][2] = getFormItemInt(F("plugin_12_timer"));
char deviceTemplate[4][80];
for (byte varNr = 0; varNr < 4; varNr++)
+6 -25
View File
@@ -49,7 +49,7 @@ boolean Plugin_013(byte function, struct EventStruct *event, String& string)
strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[0], PSTR(PLUGIN_VALUENAME1_013));
break;
}
case PLUGIN_WEBFORM_LOAD:
{
@@ -57,28 +57,12 @@ boolean Plugin_013(byte function, struct EventStruct *event, String& string)
String options[2];
options[0] = F("Value");
options[1] = F("State");
int optionValues[2];
optionValues[0] = 1;
optionValues[1] = 2;
string += F("<TR><TD>Mode:<TD><select name='plugin_013_mode'>");
for (byte x = 0; x < 2; x++)
{
string += F("<option value='");
string += optionValues[x];
string += "'";
if (choice == optionValues[x])
string += F(" selected");
string += ">";
string += options[x];
string += F("</option>");
}
string += F("</select>");
int optionValues[2] = { 1, 2 };
addFormSelector(string, F("Mode"), F("plugin_013_mode"), 2, options, optionValues, choice);
if (Settings.TaskDevicePluginConfig[event->TaskIndex][0] == 2)
{
char tmpString[128];
sprintf_P(tmpString, PSTR("<TR><TD>Threshold:<TD><input type='text' name='plugin_013_threshold' value='%u'>"), Settings.TaskDevicePluginConfig[event->TaskIndex][1]);
string += tmpString;
addFormNumericBox(string, F("Threshold"), F("plugin_013_threshold"), Settings.TaskDevicePluginConfig[event->TaskIndex][1]);
}
success = true;
break;
@@ -86,12 +70,10 @@ boolean Plugin_013(byte function, struct EventStruct *event, String& string)
case PLUGIN_WEBFORM_SAVE:
{
String plugin1 = WebServer.arg(F("plugin_013_mode"));
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = plugin1.toInt();
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = getFormItemInt(F("plugin_013_mode"));
if (Settings.TaskDevicePluginConfig[event->TaskIndex][0] == 2)
{
String plugin2 = WebServer.arg(F("plugin_013_threshold"));
Settings.TaskDevicePluginConfig[event->TaskIndex][1] = plugin2.toInt();
Settings.TaskDevicePluginConfig[event->TaskIndex][1] = getFormItemInt(F("plugin_013_threshold"));
}
success = true;
break;
@@ -198,4 +180,3 @@ void Plugin_013_interrupt()
Plugin_013_timer = micros() - Plugin_013_timer;
}
}
+32 -45
View File
@@ -12,7 +12,7 @@
boolean Plugin_014_init = false;
// ======================================
// SI7021 sensor
// SI7021 sensor
// ======================================
#define SI7021_I2C_ADDRESS 0x40 // I2C address for the sensor
#define SI7021_MEASURE_TEMP_HUM 0xE0 // Measure Temp only after a RH conversion done
@@ -85,20 +85,8 @@ boolean Plugin_014(byte function, struct EventStruct *event, String& string)
options[2] = F("Temp 12 bits / RH 8 bits");
optionValues[3] = SI7021_RESOLUTION_11T_11RH;
options[3] = F("Temp 11 bits / RH 11 bits");
string += F("<TR><TD>Resolution (bits):<TD><select name='plugin_014_res'>");
for (byte x = 0; x < SI7021_RESOLUTION_OPTION; x++)
{
string += F("<option value='");
string += optionValues[x];
string += "'";
if (choice == optionValues[x])
string += F(" selected");
string += ">";
string += options[x];
string += F("</option>");
}
string += F("</select>");
addFormSelector(string, F("Resolution"), F("plugin_014_res"), SI7021_RESOLUTION_OPTION, options, optionValues, choice);
//addUnit(string, F("bits"));
success = true;
break;
@@ -106,8 +94,7 @@ boolean Plugin_014(byte function, struct EventStruct *event, String& string)
case PLUGIN_WEBFORM_SAVE:
{
String plugin1 = WebServer.arg(F("plugin_014_res"));
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = plugin1.toInt();
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = getFormItemInt(F("plugin_014_res"));
Plugin_014_init = false; // Force device setup next time
success = true;
break;
@@ -170,7 +157,7 @@ boolean Plugin_014_si7021_begin(uint8_t resolution)
ret = false;
}
return ret;
return ret;
}
/* ======================================================================
@@ -185,7 +172,7 @@ uint8_t Plugin_014_si7021_checkCRC(uint16_t data, uint8_t check)
uint32_t remainder, divisor;
//Pad with 8 bits because we have to add in the check value
remainder = (uint32_t)data << 8;
remainder = (uint32_t)data << 8;
// From: http://www.nongnu.org/avr-libc/user-manual/group__util__crc.html
// POLYNOMIAL = 0x0131 = x^8 + x^5 + x^4 + 1 : http://en.wikipedia.org/wiki/Computation_of_cyclic_redundancy_checks
@@ -193,17 +180,17 @@ uint8_t Plugin_014_si7021_checkCRC(uint16_t data, uint8_t check)
divisor = (uint32_t) 0x988000;
// Add the check value
remainder |= check;
remainder |= check;
// Operate on only 16 positions of max 24.
// Operate on only 16 positions of max 24.
// The remaining 8 are our remainder and should be zero when we're done.
for (uint8_t i = 0 ; i < 16 ; i++) {
//Check if there is a one in the left position
if( remainder & (uint32_t)1<<(23 - i) )
if( remainder & (uint32_t)1<<(23 - i) )
remainder ^= divisor;
//Rotate the divisor max 16 times so that we have 8 bits left of a remainder
divisor >>= 1;
divisor >>= 1;
}
return ((uint8_t) remainder);
}
@@ -220,22 +207,22 @@ int8_t Plugin_014_si7021_readRegister(uint8_t * value)
// Request user register
Wire.beginTransmission(SI7021_I2C_ADDRESS);
Wire.write(SI7021_READ_REG);
Wire.write(SI7021_READ_REG);
Wire.endTransmission();
// request 1 byte result
// request 1 byte result
Wire.requestFrom(SI7021_I2C_ADDRESS, 1);
if (Wire.available()>=1) {
*value = Wire.read();
return 0;
}
return 1;
return 1;
}
/* ======================================================================
Function: Plugin_014_si7021_startConv
Purpose : return temperature or humidity measured
Purpose : return temperature or humidity measured
Input : data type SI7021_READ_HUM or SI7021_READ_TEMP
current config resolution
Output : 0 if okay
@@ -247,7 +234,7 @@ int8_t Plugin_014_si7021_startConv(uint8_t datatype, uint8_t resolution)
uint16_t raw ;
uint8_t checksum,tmp;
//Request a reading
//Request a reading
Wire.beginTransmission(SI7021_I2C_ADDRESS);
Wire.write(datatype);
Wire.endTransmission();
@@ -264,19 +251,19 @@ int8_t Plugin_014_si7021_startConv(uint8_t datatype, uint8_t resolution)
// So to be more safe, we add 5 ms to each and use 8,10,13,21 ms
// But for ESP Easy, I think it does not matter at all...
// Martinus is correct there was a bug Mesasure HUM need
// Martinus is correct there was a bug Mesasure HUM need
// hum+temp delay because it also measure temp
if (resolution == SI7021_RESOLUTION_11T_11RH)
tmp = 7;
else if (resolution == SI7021_RESOLUTION_12T_08RH)
tmp = 13;
else if (resolution == SI7021_RESOLUTION_13T_10RH)
tmp = 25;
else
else
tmp = 50;
// Humidity fire also temp measurment so delay
// Humidity fire also temp measurment so delay
// need to be increased by 2 if no Hold Master
if (datatype == SI7021_MEASURE_HUM)
tmp *=2;
@@ -286,14 +273,14 @@ int8_t Plugin_014_si7021_startConv(uint8_t datatype, uint8_t resolution)
/*
// Wait for data to become available, device will NACK during conversion
tmp = 0;
do
do
{
// Request device
Wire.beginTransmission(SI7021_I2C_ADDRESS);
//Wire.write(SI7021_READ_REG);
//Wire.write(SI7021_READ_REG);
error = Wire.endTransmission(true);
delay(1);
}
}
// always use time out in loop to avoid potential lockup (here 12ms max)
// https://www.silabs.com/Support%20Documents/TechnicalDocs/Si7021-A20.pdf page 5
while(error!=0 && tmp++<=12 );
@@ -310,12 +297,12 @@ int8_t Plugin_014_si7021_startConv(uint8_t datatype, uint8_t resolution)
// Check CRC of data received
if(Plugin_014_si7021_checkCRC(raw, checksum) != 0) {
addLog(LOG_LEVEL_INFO,F("SI7021 : checksum error!"));
return -1;
return -1;
}
// Humidity
// Humidity
if (datatype == SI7021_MEASURE_HUM || datatype == SI7021_MEASURE_HUM_HM) {
// Convert value to Himidity percent
// Convert value to Himidity percent
// pm-cz: it is possible to enable decimal places for humidity as well by multiplying the value in formula by 100
data = ((1250 * (long)raw) >> 16) - 60;
@@ -379,7 +366,7 @@ int8_t Plugin_014_si7021_readValues(uint8_t resolution)
/* ======================================================================
Function: Plugin_014_si7021_setResolution
Purpose : Sets the sensor resolution to one of four levels
Purpose : Sets the sensor resolution to one of four levels
Input : see #define default is SI7021_RESOLUTION_14T_12RH
Output : 0 if okay
Comments: -
@@ -393,16 +380,16 @@ int8_t Plugin_014_si7021_setResolution(uint8_t res)
error = Plugin_014_si7021_readRegister(&reg);
if ( error == 0) {
// remove resolution bits
reg &= SI7021_RESOLUTION_MASK ;
reg &= SI7021_RESOLUTION_MASK ;
// Prepare to write to the register value
Wire.beginTransmission(SI7021_I2C_ADDRESS);
Wire.write(SI7021_WRITE_REG);
Wire.write(SI7021_WRITE_REG);
// Write the new resolution bits but clear unused before
Wire.write(reg | ( res &= ~SI7021_RESOLUTION_MASK) );
Wire.write(reg | ( res &= ~SI7021_RESOLUTION_MASK) );
return (int8_t) Wire.endTransmission();
}
}
return error;
}
+13 -51
View File
@@ -327,28 +327,17 @@ boolean Plugin_015(byte function, struct EventStruct *event, String& string)
case PLUGIN_WEBFORM_LOAD:
{
byte choice1 = Settings.TaskDevicePluginConfig[event->TaskIndex][0];
/*
String options1[3];
options1[0] = F("0x39 - (default)");
options1[1] = F("0x49");
options1[2] = F("0x29");
*/
int optionValues1[3];
optionValues1[0] = TSL2561_ADDR;
optionValues1[1] = TSL2561_ADDR_1;
optionValues1[2] = TSL2561_ADDR_0;
string += F("<TR><TD>I2C Address:<TD><select name='plugin_015_tsl2561_i2c'>");
for (byte x = 0; x < 3; x++)
{
string += F("<option value='");
string += optionValues1[x];
string += "'";
if (choice1 == optionValues1[x])
string += F(" selected");
string += ">";
string += options1[x];
string += F("</option>");
}
string += F("</select>");
addFormSelectorI2C(string, F("plugin_015_tsl2561_i2c"), 3, optionValues1, choice1);
#define TSL2561_INTEGRATION_OPTION 3
@@ -361,32 +350,13 @@ boolean Plugin_015(byte function, struct EventStruct *event, String& string)
options2[1] = F("101 ms");
optionValues2[2] = 0x02;
options2[2] = F("402 ms");
addFormSelector(string, F("Integration time"), F("plugin_015_integration"), TSL2561_INTEGRATION_OPTION, options2, optionValues2, choice2);
string += F("<TR><TD>Integration time:<TD><select name='plugin_015_integration'>");
for (byte x = 0; x < TSL2561_INTEGRATION_OPTION; x++)
{
string += F("<option value='");
string += optionValues2[x];
string += "'";
if (choice2 == optionValues2[x])
string += F(" selected");
string += ">";
string += options2[x];
string += F("</option>");
}
string += F("</select>");
addFormCheckBox(string, F("Send sensor to sleep:"), F("plugin_015_sleep"),
Settings.TaskDevicePluginConfig[event->TaskIndex][2]);
string += F("<TR><TD>Send sensor to sleep:<TD>");
if (Settings.TaskDevicePluginConfig[event->TaskIndex][2])
string += F("<input type=checkbox name=plugin_015_sleep checked>");
else
string += F("<input type=checkbox name=plugin_015_sleep>");
string += F("<TR><TD>Enable 16x Gain:<TD>");
if (Settings.TaskDevicePluginConfig[event->TaskIndex][3])
string += F("<input type=checkbox name=plugin_015_gain checked>");
else
string += F("<input type=checkbox name=plugin_015_gain>");
addFormCheckBox(string, F("Enable 16x Gain:"), F("plugin_015_gain"),
Settings.TaskDevicePluginConfig[event->TaskIndex][3]);
success = true;
break;
@@ -394,17 +364,13 @@ boolean Plugin_015(byte function, struct EventStruct *event, String& string)
case PLUGIN_WEBFORM_SAVE:
{
String plugin1 = WebServer.arg(F("plugin_015_tsl2561_i2c"));
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = plugin1.toInt();
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = getFormItemInt(F("plugin_015_tsl2561_i2c"));
String plugin2 = WebServer.arg(F("plugin_015_integration"));
Settings.TaskDevicePluginConfig[event->TaskIndex][1] = plugin2.toInt();
Settings.TaskDevicePluginConfig[event->TaskIndex][1] = getFormItemInt(F("plugin_015_integration"));
String plugin3 = WebServer.arg(F("plugin_015_sleep"));
Settings.TaskDevicePluginConfig[event->TaskIndex][2] = (plugin3 == "on");
Settings.TaskDevicePluginConfig[event->TaskIndex][2] = isFormItemChecked(F("plugin_015_sleep"));
String plugin4 = WebServer.arg(F("plugin_015_gain"));
Settings.TaskDevicePluginConfig[event->TaskIndex][3] = (plugin4 == "on");
Settings.TaskDevicePluginConfig[event->TaskIndex][3] = isFormItemChecked(F("plugin_015_gain"));
success = true;
break;
@@ -429,7 +395,7 @@ boolean Plugin_015(byte function, struct EventStruct *event, String& string)
unsigned char time = Settings.TaskDevicePluginConfig[event->TaskIndex][1];
plugin_015_setTiming(gain,time,ms);
plugin_015_setPowerUp();
delayMillis(ms);
delayBackground(ms);
unsigned int data0, data1;
if (plugin_015_getData(data0,data1))
@@ -475,7 +441,3 @@ boolean Plugin_015(byte function, struct EventStruct *event, String& string)
}
return success;
}
+1 -2
View File
@@ -66,8 +66,7 @@ boolean Plugin_017(byte function, struct EventStruct *event, String& string)
case PLUGIN_WEBFORM_LOAD:
{
string += F("<TR><TD>Reset Pin:<TD>");
addPinSelect(false, string, "taskdevicepin3", Settings.TaskDevicePin3[event->TaskIndex]);
addFormPinSelect(string, F("Reset Pin"), F("taskdevicepin3"), Settings.TaskDevicePin3[event->TaskIndex]);
success = true;
break;
}
+2 -8
View File
@@ -46,11 +46,7 @@ boolean Plugin_019(byte function, struct EventStruct *event, String& string)
case PLUGIN_WEBFORM_LOAD:
{
string += F("<TR><TD>Send Boot state:<TD>");
if (Settings.TaskDevicePluginConfig[event->TaskIndex][0])
string += F("<input type=checkbox name=plugin_019_boot checked>");
else
string += F("<input type=checkbox name=plugin_019_boot>");
addFormCheckBox(string, F("Send Boot state"), F("plugin_019_boot"), Settings.TaskDevicePluginConfig[event->TaskIndex][0]);
success = true;
break;
@@ -58,9 +54,7 @@ boolean Plugin_019(byte function, struct EventStruct *event, String& string)
case PLUGIN_WEBFORM_SAVE:
{
String plugin1 = WebServer.arg(F("plugin_019_boot"));
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = (plugin1 == "on");
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = isFormItemChecked(F("plugin_019_boot"));
success = true;
break;
+16 -57
View File
@@ -45,13 +45,9 @@ boolean Plugin_020(byte function, struct EventStruct *event, String& string)
case PLUGIN_WEBFORM_LOAD:
{
char tmpString[128];
sprintf_P(tmpString, PSTR("<TR><TD>TCP Port:<TD><input type='text' name='plugin_020_port' value='%u'>"), ExtraTaskSettings.TaskDevicePluginConfigLong[0]);
string += tmpString;
sprintf_P(tmpString, PSTR("<TR><TD>Baud Rate:<TD><input type='text' name='plugin_020_baud' value='%u'>"), ExtraTaskSettings.TaskDevicePluginConfigLong[1]);
string += tmpString;
sprintf_P(tmpString, PSTR("<TR><TD>Data bits:<TD><input type='text' name='plugin_020_data' value='%u'>"), ExtraTaskSettings.TaskDevicePluginConfigLong[2]);
string += tmpString;
addFormNumericBox(string, F("TCP Port"), F("plugin_020_port"), ExtraTaskSettings.TaskDevicePluginConfigLong[0]);
addFormNumericBox(string, F("Baud Rate"), F("plugin_020_baud"), ExtraTaskSettings.TaskDevicePluginConfigLong[1]);
addFormNumericBox(string, F("Data bits"), F("plugin_020_data"), ExtraTaskSettings.TaskDevicePluginConfigLong[2]);
byte choice = ExtraTaskSettings.TaskDevicePluginConfigLong[3];
String options[3];
@@ -62,51 +58,21 @@ boolean Plugin_020(byte function, struct EventStruct *event, String& string)
optionValues[0] = 0;
optionValues[1] = 2;
optionValues[2] = 3;
string += F("<TR><TD>Parity:<TD><select name='plugin_020_parity'>");
for (byte x = 0; x < 3; x++)
{
string += F("<option value='");
string += optionValues[x];
string += "'";
if (choice == optionValues[x])
string += F(" selected");
string += ">";
string += options[x];
string += F("</option>");
}
string += F("</select>");
addFormSelector(string, F("Parity"), F("plugin_020_parity"), 3, options, optionValues, choice);
sprintf_P(tmpString, PSTR("<TR><TD>Stop bits:<TD><input type='text' name='plugin_020_stop' value='%u'>"), ExtraTaskSettings.TaskDevicePluginConfigLong[4]);
string += tmpString;
addFormNumericBox(string, F("Stop bits"), F("plugin_020_stop"), ExtraTaskSettings.TaskDevicePluginConfigLong[4]);
string += F("<TR><TD>Reset target after boot:<TD>");
addPinSelect(false, string, "taskdevicepin1", Settings.TaskDevicePin1[event->TaskIndex]);
addFormPinSelect(string, F("Reset target after boot"), F("taskdevicepin1"), Settings.TaskDevicePin1[event->TaskIndex]);
addFormNumericBox(string, F("RX Receive Timeout (mSec)"), F("plugin_020_rxwait"), Settings.TaskDevicePluginConfig[event->TaskIndex][0]);
sprintf_P(tmpString, PSTR("<TR><TD>RX Receive Timeout (mSec):<TD><input type='text' name='plugin_020_rxwait' value='%u'>"), Settings.TaskDevicePluginConfig[event->TaskIndex][0]);
string += tmpString;
byte choice2 = Settings.TaskDevicePluginConfig[event->TaskIndex][1];
String options2[3];
options2[0] = F("None");
options2[1] = F("Generic");
options2[2] = F("RFLink");
int optionValues2[3];
optionValues2[0] = 0;
optionValues2[1] = 1;
optionValues2[2] = 2;
string += F("<TR><TD>Event processing:<TD><select name='plugin_020_events'>");
for (byte x = 0; x < 3; x++)
{
string += F("<option value='");
string += optionValues2[x];
string += "'";
if (choice2 == optionValues2[x])
string += F(" selected");
string += ">";
string += options2[x];
string += F("</option>");
}
string += F("</select>");
addFormSelector(string, F("Event processing"), F("plugin_020_events"), 3, options2, NULL, choice2);
success = true;
break;
@@ -114,20 +80,13 @@ boolean Plugin_020(byte function, struct EventStruct *event, String& string)
case PLUGIN_WEBFORM_SAVE:
{
String plugin1 = WebServer.arg(F("plugin_020_port"));
ExtraTaskSettings.TaskDevicePluginConfigLong[0] = plugin1.toInt();
String plugin2 = WebServer.arg(F("plugin_020_baud"));
ExtraTaskSettings.TaskDevicePluginConfigLong[1] = plugin2.toInt();
String plugin3 = WebServer.arg(F("plugin_020_data"));
ExtraTaskSettings.TaskDevicePluginConfigLong[2] = plugin3.toInt();
String plugin4 = WebServer.arg(F("plugin_020_parity"));
ExtraTaskSettings.TaskDevicePluginConfigLong[3] = plugin4.toInt();
String plugin5 = WebServer.arg(F("plugin_020_stop"));
ExtraTaskSettings.TaskDevicePluginConfigLong[4] = plugin5.toInt();
String plugin6 = WebServer.arg(F("plugin_020_rxwait"));
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = plugin6.toInt();
String plugin7 = WebServer.arg(F("plugin_020_events"));
Settings.TaskDevicePluginConfig[event->TaskIndex][1] = plugin7.toInt();
ExtraTaskSettings.TaskDevicePluginConfigLong[0] = getFormItemInt(F("plugin_020_port"));
ExtraTaskSettings.TaskDevicePluginConfigLong[1] = getFormItemInt(F("plugin_020_baud"));
ExtraTaskSettings.TaskDevicePluginConfigLong[2] = getFormItemInt(F("plugin_020_data"));
ExtraTaskSettings.TaskDevicePluginConfigLong[3] = getFormItemInt(F("plugin_020_parity"));
ExtraTaskSettings.TaskDevicePluginConfigLong[4] = getFormItemInt(F("plugin_020_stop"));
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = getFormItemInt(F("plugin_020_rxwait"));
Settings.TaskDevicePluginConfig[event->TaskIndex][1] = getFormItemInt(F("plugin_020_events"));
success = true;
break;
}
+7 -14
View File
@@ -53,12 +53,9 @@ boolean Plugin_021(byte function, struct EventStruct *event, String& string)
string += F("<TR><TD>Check Value:<TD>");
addTaskValueSelect(string, "plugin_021_value", Settings.TaskDevicePluginConfig[event->TaskIndex][1], Settings.TaskDevicePluginConfig[event->TaskIndex][0]);
string += F("<TR><TD>Set Value:<TD><input type='text' name='plugin_021_setvalue' value='");
string += Settings.TaskDevicePluginConfigFloat[event->TaskIndex][0];
string += F("'>");
string += F("<TR><TD>Hysteresis:<TD><input type='text' name='plugin_021_hyst' value='");
string += Settings.TaskDevicePluginConfigFloat[event->TaskIndex][1];
string += F("'>");
addFormTextBox(string, F("Set Value"), F("plugin_021_setvalue"), String(Settings.TaskDevicePluginConfigFloat[event->TaskIndex][0]), 8);
addFormTextBox(string, F("Hysteresis"), F("plugin_021_hyst"), String(Settings.TaskDevicePluginConfigFloat[event->TaskIndex][1]), 8);
LoadTaskSettings(event->TaskIndex); // we need to restore our original taskvalues!
success = true;
@@ -67,14 +64,10 @@ boolean Plugin_021(byte function, struct EventStruct *event, String& string)
case PLUGIN_WEBFORM_SAVE:
{
String plugin1 = WebServer.arg(F("plugin_021_task"));
String plugin2 = WebServer.arg(F("plugin_021_value"));
String plugin3 = WebServer.arg(F("plugin_021_setvalue"));
String plugin4 = WebServer.arg(F("plugin_021_hyst"));
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = plugin1.toInt();
Settings.TaskDevicePluginConfig[event->TaskIndex][1] = plugin2.toInt();
Settings.TaskDevicePluginConfigFloat[event->TaskIndex][0] = plugin3.toFloat();
Settings.TaskDevicePluginConfigFloat[event->TaskIndex][1] = plugin4.toFloat();
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = getFormItemInt(F("plugin_021_task"));
Settings.TaskDevicePluginConfig[event->TaskIndex][1] = getFormItemInt(F("plugin_021_value"));
Settings.TaskDevicePluginConfigFloat[event->TaskIndex][0] = getFormItemFloat(F("plugin_021_setvalue"));
Settings.TaskDevicePluginConfigFloat[event->TaskIndex][1] = getFormItemFloat(F("plugin_021_hyst"));
success = true;
break;
}
+18 -80
View File
@@ -60,88 +60,30 @@ boolean Plugin_023(byte function, struct EventStruct *event, String& string)
case PLUGIN_WEBFORM_LOAD:
{
byte choice = Settings.TaskDevicePluginConfig[event->TaskIndex][0];
String options[2];
options[0] = F("3C");
options[1] = F("3D");
int optionValues[2];
optionValues[0] = 0x3C;
optionValues[1] = 0x3D;
string += F("<TR><TD>I2C Address:<TD><select name='plugin_023_adr'>");
for (byte x = 0; x < 2; x++)
{
string += F("<option value='");
string += optionValues[x];
string += "'";
if (choice == optionValues[x])
string += F(" selected");
string += ">";
string += options[x];
string += F("</option>");
}
string += F("</select>");
/*String options[2] = { F("3C"), F("3D") };*/
int optionValues[2] = { 0x3C, 0x3D };
addFormSelectorI2C(string, F("plugin_023_adr"), 2, optionValues, choice);
byte choice2 = Settings.TaskDevicePluginConfig[event->TaskIndex][1];
String options2[2];
options2[0] = F("Normal");
options2[1] = F("Rotated");
int optionValues2[2];
optionValues2[0] = 1;
optionValues2[1] = 2;
string += F("<TR><TD>Rotation:<TD><select name='plugin_023_rotate'>");
for (byte x = 0; x < 2; x++)
{
string += F("<option value='");
string += optionValues2[x];
string += "'";
if (choice2 == optionValues2[x])
string += F(" selected");
string += ">";
string += options2[x];
string += F("</option>");
}
string += F("</select>");
String options2[2] = { F("Normal"), F("Rotated") };
int optionValues2[2] = { 1, 2 };
addFormSelector(string, F("Rotation"), F("plugin_023_rotate"), 2, options2, optionValues2, choice2);
byte choice3 = Settings.TaskDevicePluginConfig[event->TaskIndex][3];
String options3[2];
options3[0] = F("128x64");
options3[1] = F("64x48");
int optionValues3[2];
optionValues3[0] = 1;
optionValues3[1] = 2;
string += F("<TR><TD>Display Size:<TD><select name='plugin_023_size'>");
for (byte x = 0; x < 2; x++)
{
string += F("<option value='");
string += optionValues3[x];
string += "'";
if (choice3 == optionValues3[x])
string += F(" selected");
string += ">";
string += options3[x];
string += F("</option>");
}
string += F("</select>");
String options3[2] = { F("128x64"), F("64x48") };
int optionValues3[2] = { 1, 2 };
addFormSelector(string, F("Display Size"), F("plugin_023_size"), 2, options3, optionValues3, choice3);
char deviceTemplate[8][64];
LoadCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate));
for (byte varNr = 0; varNr < 8; varNr++)
{
string += F("<TR><TD>Line ");
string += varNr + 1;
string += F(":<TD><input type='text' size='64' maxlength='64' name='Plugin_023_template");
string += varNr + 1;
string += F("' value='");
string += deviceTemplate[varNr];
string += F("'>");
addFormTextBox(string, String(F("Line ")) + (varNr + 1), String(F("Plugin_023_template")) + (varNr + 1), deviceTemplate[varNr], 64);
}
string += F("<TR><TD>Display button:<TD>");
addPinSelect(false, string, "taskdevicepin3", Settings.TaskDevicePin3[event->TaskIndex]);
addFormPinSelect(string, F("Display button"), F("taskdevicepin3"), Settings.TaskDevicePin3[event->TaskIndex]);
char tmpString[128];
sprintf_P(tmpString, PSTR("<TR><TD>Display Timeout:<TD><input type='text' name='plugin_23_timer' value='%u'>"), Settings.TaskDevicePluginConfig[event->TaskIndex][2]);
string += tmpString;
addFormNumericBox(string, F("Display Timeout"), F("plugin_23_timer"), Settings.TaskDevicePluginConfig[event->TaskIndex][2]);
success = true;
break;
@@ -149,14 +91,10 @@ boolean Plugin_023(byte function, struct EventStruct *event, String& string)
case PLUGIN_WEBFORM_SAVE:
{
String plugin1 = WebServer.arg(F("plugin_023_adr"));
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = plugin1.toInt();
String plugin2 = WebServer.arg(F("plugin_023_rotate"));
Settings.TaskDevicePluginConfig[event->TaskIndex][1] = plugin2.toInt();
String plugin3 = WebServer.arg(F("plugin_23_timer"));
Settings.TaskDevicePluginConfig[event->TaskIndex][2] = plugin3.toInt();
String plugin4 = WebServer.arg(F("plugin_023_size"));
Settings.TaskDevicePluginConfig[event->TaskIndex][3] = plugin4.toInt();
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = getFormItemInt(F("plugin_023_adr"));
Settings.TaskDevicePluginConfig[event->TaskIndex][1] = getFormItemInt(F("plugin_023_rotate"));
Settings.TaskDevicePluginConfig[event->TaskIndex][2] = getFormItemInt(F("plugin_23_timer"));
Settings.TaskDevicePluginConfig[event->TaskIndex][3] = getFormItemInt(F("plugin_023_size"));
char deviceTemplate[8][64];
for (byte varNr = 0; varNr < 8; varNr++)
@@ -482,7 +420,7 @@ static void Plugin_023_sendStr(unsigned char *string)
{
Plugin_023_SendChar(pgm_read_byte(Plugin_023_myFont[*string - 0x20] + i));
}
*string++;
string++;
}
}
@@ -499,7 +437,7 @@ static void Plugin_023_sendStrXY(const char *string, int X, int Y)
{
Plugin_023_SendChar(pgm_read_byte(Plugin_023_myFont[*string - 0x20] + i));
}
*string++;
string++;
}
}
+4 -17
View File
@@ -20,7 +20,7 @@ uint16_t readRegister024(uint8_t i2cAddress, uint8_t reg) {
ret = Wire.read(); // receive DATA
ret |= Wire.read() << 8; // receive DATA
uint8_t pec = Wire.read();
return ret;
return ret;
}
float readTemp024(uint8_t i2c_addr, uint8_t i2c_reg)
@@ -72,24 +72,12 @@ boolean Plugin_024(byte function, struct EventStruct *event, String& string)
byte choice = Settings.TaskDevicePluginConfig[event->TaskIndex][0];
String options[MLX90614_OPTION];
uint optionValues[MLX90614_OPTION];
int optionValues[MLX90614_OPTION];
optionValues[0] = (0x07);
options[0] = F("IR object temperature");
optionValues[1] = (0x06);
options[1] = F("Ambient temperature");
string += F("<TR><TD>Option:<TD><select name='plugin_024_option'>");
for (byte x = 0; x < MLX90614_OPTION; x++)
{
string += F("<option value='");
string += optionValues[x];
string += "'";
if (choice == optionValues[x])
string += F(" selected");
string += ">";
string += options[x];
string += F("</option>");
}
string += F("</select>");
addFormSelector(string, F("Option"), F("plugin_024_option"), MLX90614_OPTION, options, optionValues, choice);
success = true;
break;
@@ -97,8 +85,7 @@ boolean Plugin_024(byte function, struct EventStruct *event, String& string)
case PLUGIN_WEBFORM_SAVE:
{
String plugin1 = WebServer.arg(F("plugin_024_option"));
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = plugin1.toInt();
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = getFormItemInt(F("plugin_024_option"));
Plugin_024_init = false; // Force device setup next time
success = true;
break;
+116 -97
View File
@@ -13,8 +13,9 @@ static uint16_t readRegister025(uint8_t i2cAddress, uint8_t reg) {
Wire.beginTransmission(i2cAddress);
Wire.write((0x00));
Wire.endTransmission();
Wire.requestFrom(i2cAddress, (uint8_t)2);
return ((Wire.read() << 8) | Wire.read());
if (Wire.requestFrom(i2cAddress, (uint8_t)2) != 2)
return 0x8000;
return ((Wire.read() << 8) | Wire.read());
}
boolean Plugin_025(byte function, struct EventStruct *event, String& string)
@@ -28,7 +29,7 @@ boolean Plugin_025(byte function, struct EventStruct *event, String& string)
Device[++deviceCount].Number = PLUGIN_ID_025;
Device[deviceCount].Type = DEVICE_TYPE_I2C;
Device[deviceCount].VType = SENSOR_TYPE_SINGLE;
Device[deviceCount].Ports = 4;
Device[deviceCount].Ports = 0;
Device[deviceCount].PullUpOption = false;
Device[deviceCount].InverseLogicOption = false;
Device[deviceCount].FormulaOption = true;
@@ -53,37 +54,59 @@ boolean Plugin_025(byte function, struct EventStruct *event, String& string)
case PLUGIN_WEBFORM_LOAD:
{
#define ADS1115_GAIN_OPTION 6
byte choice = Settings.TaskDevicePluginConfig[event->TaskIndex][0];
String options[ADS1115_GAIN_OPTION];
uint optionValues[ADS1115_GAIN_OPTION];
optionValues[0] = (0x00);
options[0] = F("2/3x gain 6.144V 0.1875mV");
optionValues[1] = (0x02);
options[1] = F("1x gain 4.096V 0.125mV");
optionValues[2] = (0x04);
options[2] = F("2x gain 2.048V 0.0625mV");
optionValues[3] = (0x06);
options[3] = F("4x gain 1.024V 0.03125mV");
optionValues[4] = (0x08);
options[4] = F("8x gain 0.512V 0.015625mV");
optionValues[5] = (0x0A);
options[5] = F("16x gain 0.256V 0.0078125mV");
string += F("<TR><TD>Gain:<TD><select name='plugin_025_gain'>");
for (byte x = 0; x < ADS1115_GAIN_OPTION; x++)
byte port = Settings.TaskDevicePort[event->TaskIndex];
if (port > 0) //map old port logic to new gain and mode settings
{
string += F("<option value='");
string += optionValues[x];
string += "'";
if (choice == optionValues[x])
string += F(" selected");
string += ">";
string += options[x];
string += F("</option>");
Settings.TaskDevicePluginConfig[event->TaskIndex][1] = Settings.TaskDevicePluginConfig[event->TaskIndex][0] / 2;
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = 0x48 + ((port-1)/4);
Settings.TaskDevicePluginConfig[event->TaskIndex][2] = ((port-1) & 3) | 4;
Settings.TaskDevicePort[event->TaskIndex] = 0;
}
string += F("</select>");
#define ADS1115_I2C_OPTION 4
byte addr = Settings.TaskDevicePluginConfig[event->TaskIndex][0];
int optionValues[ADS1115_I2C_OPTION] = { 0x48, 0x49, 0x4A, 0x4B };
addFormSelectorI2C(string, F("plugin_025_i2c"), ADS1115_I2C_OPTION, optionValues, addr);
addFormSubHeader(string, F("Input"));
#define ADS1115_PGA_OPTION 6
byte pga = Settings.TaskDevicePluginConfig[event->TaskIndex][1];
String pgaOptions[ADS1115_PGA_OPTION] = {
F("2/3x gain (FS=6.144V)"),
F("1x gain (FS=4.096V)"),
F("2x gain (FS=2.048V)"),
F("4x gain (FS=1.024V)"),
F("8x gain (FS=0.512V)"),
F("16x gain (FS=0.256V)")
};
addFormSelector(string, F("Gain"), F("plugin_025_gain"), ADS1115_PGA_OPTION, pgaOptions, NULL, pga);
#define ADS1115_MUX_OPTION 8
byte mux = Settings.TaskDevicePluginConfig[event->TaskIndex][2];
String muxOptions[ADS1115_MUX_OPTION] = {
F("AIN0 - AIN1 (Differential)"),
F("AIN0 - AIN3 (Differential)"),
F("AIN1 - AIN3 (Differential)"),
F("AIN2 - AIN3 (Differential)"),
F("AIN0 - GND (Single-Ended)"),
F("AIN1 - GND (Single-Ended)"),
F("AIN2 - GND (Single-Ended)"),
F("AIN3 - GND (Single-Ended)"),
};
addFormSelector(string, F("Input Multiplexer"), F("plugin_025_mode"), ADS1115_MUX_OPTION, muxOptions, NULL, mux);
addFormSubHeader(string, F("Two Point Calibration"));
addFormCheckBox(string, F("Calibration Enabled"), F("plugin_025_cal"), Settings.TaskDevicePluginConfig[event->TaskIndex][3]);
addFormNumericBox(string, F("Point 1"), F("plugin_025_adc1"), Settings.TaskDevicePluginConfigLong[event->TaskIndex][0], -32768, 32767);
string += F(" &#8793; ");
addTextBox(string, F("plugin_025_out1"), String(Settings.TaskDevicePluginConfigFloat[event->TaskIndex][0], 3), 10);
addFormNumericBox(string, F("Point 2"), F("plugin_025_adc2"), Settings.TaskDevicePluginConfigLong[event->TaskIndex][1], -32768, 32767);
string += F(" &#8793; ");
addTextBox(string, F("plugin_025_out2"), String(Settings.TaskDevicePluginConfigFloat[event->TaskIndex][1], 3), 10);
success = true;
break;
@@ -91,8 +114,20 @@ boolean Plugin_025(byte function, struct EventStruct *event, String& string)
case PLUGIN_WEBFORM_SAVE:
{
String plugin1 = WebServer.arg(F("plugin_025_gain"));
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = plugin1.toInt();
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = getFormItemInt(F("plugin_025_i2c"));
Settings.TaskDevicePluginConfig[event->TaskIndex][1] = getFormItemInt(F("plugin_025_gain"));
Settings.TaskDevicePluginConfig[event->TaskIndex][2] = getFormItemInt(F("plugin_025_mode"));
Settings.TaskDevicePluginConfig[event->TaskIndex][3] = isFormItemChecked(F("plugin_025_cal"));
Settings.TaskDevicePluginConfigLong[event->TaskIndex][0] = getFormItemInt(F("plugin_025_adc1"));
Settings.TaskDevicePluginConfigFloat[event->TaskIndex][0] = getFormItemFloat(F("plugin_025_out1"));
Settings.TaskDevicePluginConfigLong[event->TaskIndex][1] = getFormItemInt(F("plugin_025_adc2"));
Settings.TaskDevicePluginConfigFloat[event->TaskIndex][1] = getFormItemFloat(F("plugin_025_out2"));
Plugin_025_init = false; // Force device setup next time
success = true;
break;
@@ -107,76 +142,60 @@ boolean Plugin_025(byte function, struct EventStruct *event, String& string)
case PLUGIN_READ:
{
uint8_t m_gain = Settings.TaskDevicePluginConfig[event->TaskIndex][0];
int value;
value = 0;
byte unit = (Settings.TaskDevicePort[event->TaskIndex] - 1) / 4;
byte port = Settings.TaskDevicePort[event->TaskIndex] - (unit * 4);
uint8_t address = 0x48 + unit;
// get the current pin value
//int value = 0;
//byte unit = (Settings.TaskDevicePort[event->TaskIndex] - 1) / 4;
//byte port = Settings.TaskDevicePort[event->TaskIndex] - (unit * 4);
//uint8_t address = 0x48 + unit;
uint16_t config = (0x0003) | // Disable the comparator (default val)
(0x0000) | // Non-latching (default val)
(0x0000) | // Alert/Rdy active low (default val)
(0x0000) | // Traditional comparator (default val)
(0x0080) | // 1600 samples per second (default)
(0x0100) ; // Single-shot mode (default)
uint8_t address = Settings.TaskDevicePluginConfig[event->TaskIndex][0];
uint16_t config = (0x0003) | // Disable the comparator (default val)
(0x0000) | // Non-latching (default val)
(0x0000) | // Alert/Rdy active low (default val)
(0x0000) | // Traditional comparator (default val)
(0x0080) | // 128 samples per second (default)
(0x0100); // Single-shot mode (default)
uint16_t pga = Settings.TaskDevicePluginConfig[event->TaskIndex][1];
config |= pga << 9;
uint16_t mux = Settings.TaskDevicePluginConfig[event->TaskIndex][2];
config |= mux << 12;
config |= (0x8000); // Start a single conversion
// m_Gain = (0x0000); // 2/3x gain +/- 6.144V 1 bit = 3mV 0.1875mV (default)
// m_Gain = (0x0200); // 1x gain +/- 4.096V 1 bit = 2mV 0.125mV
// m_Gain = (0x0400); // 2x gain +/- 2.048V 1 bit = 1mV 0.0625mV
// m_Gain = (0x0600); // 4x gain +/- 1.024V 1 bit = 0.5mV 0.03125mV
// m_Gain = (0x0800); // 8x gain +/- 0.512V 1 bit = 0.25mV 0.015625mV
// m_Gain = (0x0A00); // 16x gain +/- 0.256V 1 bit = 0.125mV 0.0078125mV
// config |= m_gain;
// config |= (0x0000);
switch (m_gain)
{
case (0x00):
config |= (0x0000);
break;
case (0x02):
config |= (0x0200);
break;
case (0x04):
config |= (0x0400);
break;
case (0x06):
config |= (0x0600);
break;
case (0x08):
config |= (0x0800);
break;
case (0x0A):
config |= (0x0A00);
break;
}
switch (port)
{
case (1):
config |= (0x4000);
break;
case (2):
config |= (0x5000);
break;
case (3):
config |= (0x6000);
break;
case (4):
config |= (0x7000);
break;
}
config |= (0x8000);
Wire.beginTransmission(address);
Wire.write((uint8_t)(0x01));
Wire.write((uint8_t)(config>>8));
Wire.write((uint8_t)(config >> 8));
Wire.write((uint8_t)(config & 0xFF));
Wire.endTransmission();
String log = F("ADS1115 : Analog value: ");
delay(8);
UserVar[event->BaseVarIndex] = (float) readRegister025((address), (0x00)) ;
String log = F("ADS1115 : Analog value: ");
log += UserVar[event->BaseVarIndex];
addLog(LOG_LEVEL_INFO,log);
int16_t value = readRegister025((address), (0x00));
UserVar[event->BaseVarIndex] = (float)value;
log += value;
if (Settings.TaskDevicePluginConfig[event->TaskIndex][3]) //Calibration?
{
int adc1 = Settings.TaskDevicePluginConfigLong[event->TaskIndex][0];
int adc2 = Settings.TaskDevicePluginConfigLong[event->TaskIndex][1];
float out1 = Settings.TaskDevicePluginConfigFloat[event->TaskIndex][0];
float out2 = Settings.TaskDevicePluginConfigFloat[event->TaskIndex][1];
if (adc1 != adc2)
{
float normalized = (float)(value - adc1) / (float)(adc2 - adc1);
UserVar[event->BaseVarIndex] = normalized * (out2 - out1) + out1;
log += F(" ");
log += UserVar[event->BaseVarIndex];
}
}
//TEST log += F(" @0x");
//TEST log += String(config, 16);
addLog(LOG_LEVEL_DEBUG,log);
success = true;
break;
}
+4 -23
View File
@@ -46,25 +46,7 @@ boolean Plugin_026(byte function, struct EventStruct *event, String& string)
options[2] = F("Wifi RSSI");
options[3] = F("Input VCC");
options[4] = F("System load");
int optionValues[5];
optionValues[0] = 0;
optionValues[1] = 1;
optionValues[2] = 2;
optionValues[3] = 3;
optionValues[4] = 4;
string += F("<TR><TD>Indicator:<TD><select name='plugin_026'>");
for (byte x = 0; x < 5; x++)
{
string += F("<option value='");
string += optionValues[x];
string += "'";
if (choice == optionValues[x])
string += F(" selected");
string += ">";
string += options[x];
string += F("</option>");
}
string += F("</select>");
addFormSelector(string, F("Indicator"), F("plugin_026"), 5, options, NULL, choice);
success = true;
break;
@@ -72,12 +54,11 @@ boolean Plugin_026(byte function, struct EventStruct *event, String& string)
case PLUGIN_WEBFORM_SAVE:
{
String plugin1 = WebServer.arg(F("plugin_026"));
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = plugin1.toInt();
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = getFormItemInt(F("plugin_026"));
success = true;
break;
}
case PLUGIN_READ:
{
float value = 0;
@@ -111,7 +92,7 @@ boolean Plugin_026(byte function, struct EventStruct *event, String& string)
{
value = (100 - (100 * loopCounterLast / loopCounterMax));
break;
}
}
}
UserVar[event->BaseVarIndex] = value;
String log = F("SYS : ");
+7 -40
View File
@@ -108,52 +108,22 @@ boolean Plugin_027(byte function, struct EventStruct *event, String& string)
options[0] = F("Voltage");
options[1] = F("Current");
options[2] = F("Power");
int optionValues[3];
optionValues[0] = 0;
optionValues[1] = 1;
optionValues[2] = 2;
string += F("<TR><TD>Report:<TD><select name='plugin_027_value'>");
for (byte x = 0; x < 3; x++)
{
string += F("<option value='");
string += optionValues[x];
string += "'";
if (choice == optionValues[x])
string += F(" selected");
string += ">";
string += options[x];
string += F("</option>");
}
string += F("</select>");
addFormSelector(string, F("Report"), F("plugin_027_value"), 3, options, NULL, choice);
byte choice2 = Settings.TaskDevicePluginConfig[event->TaskIndex][1];
/*
String options2[4];
options2[0] = F("0x40 - (default)");
options2[1] = F("0x41");
options2[2] = F("0x44");
options2[3] = F("0x45");
int optionValues2[3];
*/
int optionValues2[4];
optionValues2[0] = INA219_ADDRESS;
optionValues2[1] = INA219_ADDRESS2;
optionValues2[2] = INA219_ADDRESS3;
optionValues2[3] = INA219_ADDRESS4;
string += F("<TR><TD>I2C Address:<TD><select name='plugin_027_i2c'>");
for (byte x = 0; x < 4; x++)
{
string += F("<option value='");
string += optionValues2[x];
string += "'";
if (choice2 == optionValues2[x])
string += F(" selected");
string += ">";
string += options2[x];
string += F("</option>");
}
string += F("</select>");
addFormSelectorI2C(string, F("plugin_027_i2c"), 4, optionValues2, choice2);
success = true;
break;
@@ -161,11 +131,9 @@ boolean Plugin_027(byte function, struct EventStruct *event, String& string)
case PLUGIN_WEBFORM_SAVE:
{
String plugin1 = WebServer.arg(F("plugin_027_value"));
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = plugin1.toInt();
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = getFormItemInt(F("plugin_027_value"));
String plugin2 = WebServer.arg(F("plugin_027_i2c"));
Settings.TaskDevicePluginConfig[event->TaskIndex][1] = plugin2.toInt();
Settings.TaskDevicePluginConfig[event->TaskIndex][1] = getFormItemInt(F("plugin_027_i2c"));
success = true;
break;
}
@@ -386,4 +354,3 @@ float Plugin_027_getCurrent_mA() {
valueDec /= ina219_currentDivider_mA;
return valueDec;
}
+12 -27
View File
@@ -124,29 +124,17 @@ boolean Plugin_028(byte function, struct EventStruct *event, String& string)
case PLUGIN_WEBFORM_LOAD:
{
byte choice = Settings.TaskDevicePluginConfig[event->TaskIndex][0];
/*
String options[2];
options[0] = F("0x76 - default settings (SDO Low)");
options[1] = F("0x77 - alternate settings (SDO HIGH)");
int optionValues[2];
optionValues[0] = 0x76;
optionValues[1] = 0x77;
string += F("<TR><TD>I2C Address:<TD><select name='plugin_028_bme280_i2c'>");
for (byte x = 0; x < 2; x++)
{
string += F("<option value='");
string += optionValues[x];
string += "'";
if (choice == optionValues[x])
string += F(" selected");
string += ">";
string += options[x];
string += F("</option>");
}
string += F("</select>");
string += F("<TR><TD>Altitude [m]:<TD><input type='text' title='Set Altitude to 0 to get measurement without altitude adjustment' name='");
string += F("plugin_028_bme280_elev' value='");
string += Settings.TaskDevicePluginConfig[event->TaskIndex][1];
string += F("'>");
*/
int optionValues[2] = { 0x76, 0x77 };
addFormSelectorI2C(string, F("plugin_028_bme280_i2c"), 2, optionValues, choice);
addFormNote(string, F("SDO Low=0x76, High=0x77"));
addFormNumericBox(string, F("Altitude"), F("plugin_028_bme280_elev"), Settings.TaskDevicePluginConfig[event->TaskIndex][1]);
addUnit(string, F("m"));
success = true;
break;
@@ -154,10 +142,8 @@ boolean Plugin_028(byte function, struct EventStruct *event, String& string)
case PLUGIN_WEBFORM_SAVE:
{
String plugin1 = WebServer.arg(F("plugin_028_bme280_i2c"));
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = plugin1.toInt();
String elev = WebServer.arg(F("plugin_028_bme280_elev"));
Settings.TaskDevicePluginConfig[event->TaskIndex][1] = elev.toInt();
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = getFormItemInt(F("plugin_028_bme280_i2c"));
Settings.TaskDevicePluginConfig[event->TaskIndex][1] = getFormItemInt(F("plugin_028_bme280_elev"));
success = true;
break;
}
@@ -228,14 +214,14 @@ bool Plugin_028_begin(uint8_t a) {
return false;
Plugin_028_readCoefficients(_i2caddr & 0x01);
// Set the Sensor in sleep to be make sure that the following configs will be stored
Plugin_028_write8(BME280_REGISTER_CONTROL, 0x00);
Plugin_028_write8(BME280_REGISTER_CONFIG, BME280_CONFIG_SETTING);
Plugin_028_write8(BME280_REGISTER_CONTROLHUMID, BME280_CONTROL_SETTING_HUMIDITY);
Plugin_028_write8(BME280_REGISTER_CONTROL, BME280_CONTROL_SETTING);
return true;
}
@@ -462,4 +448,3 @@ float Plugin_028_readAltitude(float seaLevel)
float Plugin_028_pressureElevation(float atmospheric, int altitude) {
return atmospheric / pow(1.0 - (altitude/44330.0), 5.255);
}
+9 -28
View File
@@ -103,29 +103,13 @@ boolean Plugin_030(byte function, struct EventStruct *event, String& string)
case PLUGIN_WEBFORM_LOAD:
{
byte choice = Settings.TaskDevicePluginConfig[event->TaskIndex][0];
String options[2];
options[0] = F("0x76 - default settings (SDO Low)");
options[1] = F("0x77 - alternate settings (SDO HIGH)");
int optionValues[2];
optionValues[0] = 0x76;
optionValues[1] = 0x77;
string += F("<TR><TD>I2C Address:<TD><select name='plugin_030_bmp280_i2c'>");
for (byte x = 0; x < 2; x++)
{
string += F("<option value='");
string += optionValues[x];
string += "'";
if (choice == optionValues[x])
string += F(" selected");
string += ">";
string += options[x];
string += F("</option>");
}
string += F("</select>");
string += F("<TR><TD>Altitude [m]:<TD><input type='text' title='Set Altitude to 0 to get measurement without altitude adjustment' name='");
string += F("plugin_030_bmp280_elev' value='");
string += Settings.TaskDevicePluginConfig[event->TaskIndex][1];
string += F("'>");
/*String options[2] = { F("0x76 - default settings (SDO Low)"), F("0x77 - alternate settings (SDO HIGH)") };*/
int optionValues[2] = { 0x76, 0x77 };
addFormSelectorI2C(string, F("plugin_030_bmp280_i2c"), 2, optionValues, choice);
addFormNote(string, F("SDO Low=0x76, High=0x77"));
addFormNumericBox(string, F("Altitude"), F("plugin_030_bmp280_elev"), Settings.TaskDevicePluginConfig[event->TaskIndex][1]);
addUnit(string, F("m"));
success = true;
break;
@@ -133,10 +117,8 @@ boolean Plugin_030(byte function, struct EventStruct *event, String& string)
case PLUGIN_WEBFORM_SAVE:
{
String plugin1 = WebServer.arg(F("plugin_030_bmp280_i2c"));
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = plugin1.toInt();
String elev = WebServer.arg(F("plugin_030_bmp280_elev"));
Settings.TaskDevicePluginConfig[event->TaskIndex][1] = elev.toInt();
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = getFormItemInt(F("plugin_030_bmp280_i2c"));
Settings.TaskDevicePluginConfig[event->TaskIndex][1] = getFormItemInt(F("plugin_030_bmp280_elev"));
success = true;
break;
}
@@ -412,4 +394,3 @@ float Plugin_030_readAltitude(float seaLevel)
float Plugin_030_pressureElevation(float atmospheric, int altitude) {
return atmospheric / pow(1.0 - (altitude/44330.0), 5.255);
}
+20 -41
View File
@@ -70,29 +70,11 @@ boolean Plugin_032(byte function, struct EventStruct *event, String& string)
case PLUGIN_WEBFORM_LOAD:
{
byte choice = Settings.TaskDevicePluginConfig[event->TaskIndex][0];
String options[2];
options[0] = F("0x77 - default I2C address");
options[1] = F("0x76 - alternate I2C address");
int optionValues[2];
optionValues[0] = 0x77;
optionValues[1] = 0x76;
string += F("<TR><TD>I2C Address:<TD><select name='plugin_032_ms5611_i2c'>");
for (byte x = 0; x < 2; x++)
{
string += F("<option value='");
string += optionValues[x];
string += "'";
if (choice == optionValues[x])
string += F(" selected");
string += ">";
string += options[x];
string += F("</option>");
}
string += F("</select>");
string += F("<TR><TD>Altitude [m]:<TD><input type='text' title='Set Altitude to 0 to get measurement without altitude adjustment' name='");
string += F("plugin_032_ms5611_elev' value='");
string += Settings.TaskDevicePluginConfig[event->TaskIndex][1];
string += F("'>");
/*String options[2] = { F("0x77 - default I2C address"), F("0x76 - alternate I2C address") };*/
int optionValues[2] = { 0x77, 0x76 };
addFormSelectorI2C(string, F("plugin_032_ms5611_i2c"), 2, optionValues, choice);
addFormNumericBox(string, F("Altitude [m]"), F("plugin_032_ms5611_elev"), Settings.TaskDevicePluginConfig[event->TaskIndex][1]);
success = true;
break;
@@ -100,10 +82,8 @@ boolean Plugin_032(byte function, struct EventStruct *event, String& string)
case PLUGIN_WEBFORM_SAVE:
{
String plugin1 = WebServer.arg(F("plugin_032_ms5611_i2c"));
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = plugin1.toInt();
String elev = WebServer.arg(F("plugin_032_ms5611_elev"));
Settings.TaskDevicePluginConfig[event->TaskIndex][1] = elev.toInt();
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = getFormItemInt(F("plugin_032_ms5611_i2c"));
Settings.TaskDevicePluginConfig[event->TaskIndex][1] = getFormItemInt(F("plugin_032_ms5611_elev"));
success = true;
break;
}
@@ -112,13 +92,13 @@ boolean Plugin_032(byte function, struct EventStruct *event, String& string)
{
if (!Plugin_032_init)
{
Plugin_032_init = Plugin_032_begin(Settings.TaskDevicePluginConfig[event->TaskIndex][0]);
Plugin_032_init = Plugin_032_begin(Settings.TaskDevicePluginConfig[event->TaskIndex][0]);
}
if (Plugin_032_init) {
Plugin_032_read_prom();
Plugin_032_readout();
UserVar[event->BaseVarIndex] = ms5611_temperature / 100;
int elev = Settings.TaskDevicePluginConfig[event->TaskIndex][1];
if (elev)
@@ -167,9 +147,9 @@ byte Plugin_032_send_cmd(byte aCMD)
//**************************************************************************/
// Reads the PROM of MS5611
// There are in total 8 addresses resulting in a total memory of 128 bit.
// Address 0 contains factory data and the setup, addresses 1-6 calibration
// coefficients and address 7 contains the serial code and CRC.
// There are in total 8 addresses resulting in a total memory of 128 bit.
// Address 0 contains factory data and the setup, addresses 1-6 calibration
// coefficients and address 7 contains the serial code and CRC.
// The command sequence is 8 bits long with a 16 bit result which is
// clocked with the MSB first.
//**************************************************************************/
@@ -177,7 +157,7 @@ void Plugin_032_read_prom() {
Plugin_032_send_cmd(MS5xxx_CMD_RESET);
delay(3);
for(uint8_t i=0;i<8;i++)
for(uint8_t i=0;i<8;i++)
{
ms5611_prom[i]=0x0000;
Plugin_032_send_cmd(MS5xxx_CMD_PROM_RD+2*i);
@@ -188,7 +168,7 @@ void Plugin_032_read_prom() {
c = Wire.read();
ms5611_prom[i] += c;
Wire.endTransmission(true);
}
}
}
//**************************************************************************/
@@ -198,7 +178,7 @@ unsigned long Plugin_032_read_adc(unsigned char aCMD)
{
unsigned long value=0;
unsigned long c=0;
Plugin_032_send_cmd(MS5xxx_CMD_ADC_CONV+aCMD); // start DAQ and conversion of ADC data
switch (aCMD & 0x0f)
{
@@ -222,7 +202,7 @@ unsigned long Plugin_032_read_adc(unsigned char aCMD)
c = Wire.read();
value += c;
Wire.endTransmission(true);
return value;
}
@@ -233,7 +213,7 @@ unsigned long Plugin_032_read_adc(unsigned char aCMD)
void Plugin_032_readout() {
unsigned long D1=0, D2=0;
double dT;
double OFF;
double SENS;
@@ -247,7 +227,7 @@ void Plugin_032_readout() {
SENS=ms5611_prom[1]*pow(2,15)+dT*ms5611_prom[3]/pow(2,8);
ms5611_temperature=(2000+(dT*ms5611_prom[6])/pow(2,23));
ms5611_pressure=(((D1*SENS)/pow(2,21)-OFF)/pow(2,15));
// perform higher order corrections
double T2=0., OFF2=0., SENS2=0.;
if(ms5611_temperature<2000) {
@@ -259,11 +239,11 @@ void Plugin_032_readout() {
SENS2+=11*(ms5611_temperature+1500)*(ms5611_temperature+1500)/pow(2,1);
}
}
ms5611_temperature-=T2;
OFF-=OFF2;
SENS-=SENS2;
ms5611_pressure=(((D1*SENS)/pow(2,21)-OFF)/pow(2,15));
ms5611_pressure=(((D1*SENS)/pow(2,21)-OFF)/pow(2,15));
}
//**************************************************************************/
@@ -272,4 +252,3 @@ void Plugin_032_readout() {
double Plugin_032_pressureElevation(double atmospheric, int altitude) {
return atmospheric / pow(1.0 - (altitude/44330.0), 5.255);
}
+4 -17
View File
@@ -69,19 +69,8 @@ boolean Plugin_033(byte function, struct EventStruct *event, String& string)
optionValues[8] = SENSOR_TYPE_DIMMER;
optionValues[9] = SENSOR_TYPE_LONG;
optionValues[10] = SENSOR_TYPE_WIND;
string += F("<TR><TD>Simulate Data Type:<TD><select name='plugin_033_sensortype'>");
for (byte x = 0; x < 11; x++)
{
string += F("<option value='");
string += optionValues[x];
string += "'";
if (choice == optionValues[x])
string += F(" selected");
string += ">";
string += options[x];
string += F("</option>");
}
string += F("</select>");
addFormSelector(string, F("Simulate Data Type"), F("plugin_033_sensortype"), 11, options, optionValues, choice );
success = true;
break;
@@ -89,12 +78,11 @@ boolean Plugin_033(byte function, struct EventStruct *event, String& string)
case PLUGIN_WEBFORM_SAVE:
{
String plugin1 = WebServer.arg(F("plugin_033_sensortype"));
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = plugin1.toInt();
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = getFormItemInt(F("plugin_033_sensortype"));
success = true;
break;
}
case PLUGIN_READ:
{
event->sensorType = Settings.TaskDevicePluginConfig[event->TaskIndex][0];
@@ -112,4 +100,3 @@ boolean Plugin_033(byte function, struct EventStruct *event, String& string)
}
return success;
}
+3 -3
View File
@@ -82,9 +82,9 @@ boolean Plugin_035(byte function, struct EventStruct *event, String& string)
if (IrType.equalsIgnoreCase("RAW")) {
String IrRaw;
unsigned int IrHz;
unsigned int IrPLen;
unsigned int IrBLen;
unsigned int IrHz=0;
unsigned int IrPLen=0;
unsigned int IrBLen=0;
if (GetArgv(command, TmpStr1, 3)) IrRaw = TmpStr1;
if (GetArgv(command, TmpStr1, 4)) IrHz = str2int(TmpStr1);
+16 -91
View File
@@ -69,48 +69,22 @@ boolean Plugin_036(byte function, struct EventStruct *event, String& string)
case PLUGIN_WEBFORM_LOAD:
{
byte choice0 = Settings.TaskDevicePluginConfig[event->TaskIndex][0];
/*
String options0[2];
options0[0] = F("3C");
options0[1] = F("3D");
*/
int optionValues0[2];
optionValues0[0] = 0x3C;
optionValues0[1] = 0x3D;
string += F("<TR><TD>I2C Address:<TD><select name='plugin_036_adr'>");
for (byte x = 0; x < 2; x++)
{
string += F("<option value='");
string += optionValues0[x];
string += "'";
if (choice0 == optionValues0[x])
string += F(" selected");
string += ">";
string += options0[x];
string += F("</option>");
}
string += F("</select>");
//
addFormSelectorI2C(string, F("plugin_036_adr"), 2, optionValues0, choice0);
byte choice1 = Settings.TaskDevicePluginConfig[event->TaskIndex][1];
String options1[2];
options1[0] = F("Normal");
options1[1] = F("Rotated");
int optionValues1[2];
optionValues1[0] = 1;
optionValues1[1] = 2;
string += F("<TR><TD>Rotation:<TD><select name='plugin_036_rotate'>");
for (byte x = 0; x < 2; x++)
{
string += F("<option value='");
string += optionValues1[x];
string += "'";
if (choice1 == optionValues1[x])
string += F(" selected");
string += ">";
string += options1[x];
string += F("</option>");
}
string += F("</select>");
int optionValues1[2] = { 1, 2 };
addFormSelector(string, F("Rotation"), F("plugin_036_rotate"), 2, options1, optionValues1, choice1);
byte choice2 = Settings.TaskDevicePluginConfig[event->TaskIndex][2];
String options2[4];
@@ -118,24 +92,8 @@ boolean Plugin_036(byte function, struct EventStruct *event, String& string)
options2[1] = F("2");
options2[2] = F("3");
options2[3] = F("4");
int optionValues2[4];
optionValues2[0] = 1;
optionValues2[1] = 2;
optionValues2[2] = 3;
optionValues2[3] = 4;
string += F("<TR><TD>Lines per Frame:<TD><select name='plugin_036_nlines'>");
for (byte x = 0; x < 4; x++)
{
string += F("<option value='");
string += optionValues2[x];
string += "'";
if (choice2 == optionValues2[x])
string += F(" selected");
string += ">";
string += options2[x];
string += F("</option>");
}
string += F("</select>");
int optionValues2[4] = { 1, 2, 3, 4 };
addFormSelector(string, F("Lines per Frame"), F("plugin_036_nlines"), 4, options2, optionValues2, choice2);
byte choice3 = Settings.TaskDevicePluginConfig[event->TaskIndex][3];
String options3[5];
@@ -150,42 +108,19 @@ boolean Plugin_036(byte function, struct EventStruct *event, String& string)
optionValues3[2] = 4;
optionValues3[3] = 8;
optionValues3[4] = 32;
string += F("<TR><TD>Scroll:<TD><select name='plugin_036_scroll'>");
for (byte x = 0; x < 5; x++)
{
string += F("<option value='");
string += optionValues3[x];
string += F("'");
if (choice3 == optionValues3[x])
string += F(" selected");
string += F(">");
string += options3[x];
string += F("</option>");
}
string += F("</select>");
addFormSelector(string, F("Scroll"), F("plugin_036_scroll"), 5, options3, optionValues3, choice3);
char deviceTemplate[Nlines][32];
LoadCustomTaskSettings(event->TaskIndex, (byte*)&deviceTemplate, sizeof(deviceTemplate));
for (byte varNr = 0; varNr < Nlines; varNr++)
{
string += F("<TR><TD>Line ");
string += varNr + 1;
string += F(":<TD><input type='text' size='32' maxlength='32' name='Plugin_036_template");
string += varNr + 1;
string += F("' value='");
string += deviceTemplate[varNr];
string += F("'>");
addFormTextBox(string, String(F("Line ")) + (varNr + 1), String(F("Plugin_036_template")) + (varNr + 1), deviceTemplate[varNr], 32);
}
string += F("<TR><TD>Display button:<TD>");
addPinSelect(false, string, "taskdevicepin3", Settings.TaskDevicePin3[event->TaskIndex]);
addFormPinSelect(string, F("Display button"), F("taskdevicepin3"), Settings.TaskDevicePin3[event->TaskIndex]);
char tmpString[128];
sprintf_P(tmpString, PSTR("<TR><TD>Display Timeout:<TD><input type='text' name='plugin_036_timer' value='%u'>"), Settings.TaskDevicePluginConfig[event->TaskIndex][4]);
string += tmpString;
addFormNumericBox(string, F("Display Timeout"), F("plugin_036_timer"), Settings.TaskDevicePluginConfig[event->TaskIndex][4]);
success = true;
break;
@@ -193,21 +128,11 @@ boolean Plugin_036(byte function, struct EventStruct *event, String& string)
case PLUGIN_WEBFORM_SAVE:
{
String plugin0 = WebServer.arg(F("plugin_036_adr"));
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = plugin0.toInt();
String plugin1 = WebServer.arg(F("plugin_036_rotate"));
Settings.TaskDevicePluginConfig[event->TaskIndex][1] = plugin1.toInt();
String plugin2 = WebServer.arg(F("plugin_036_nlines"));
Settings.TaskDevicePluginConfig[event->TaskIndex][2] = plugin2.toInt();
String plugin3 = WebServer.arg(F("plugin_036_scroll"));
Settings.TaskDevicePluginConfig[event->TaskIndex][3] = plugin3.toInt();
String plugin4 = WebServer.arg(F("plugin_036_timer"));
Settings.TaskDevicePluginConfig[event->TaskIndex][4] = plugin4.toInt();
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = getFormItemInt(F("plugin_036_adr"));
Settings.TaskDevicePluginConfig[event->TaskIndex][1] = getFormItemInt(F("plugin_036_rotate"));
Settings.TaskDevicePluginConfig[event->TaskIndex][2] = getFormItemInt(F("plugin_036_nlines"));
Settings.TaskDevicePluginConfig[event->TaskIndex][3] = getFormItemInt(F("plugin_036_scroll"));
Settings.TaskDevicePluginConfig[event->TaskIndex][4] = getFormItemInt(F("plugin_036_timer"));
String argName;
+2 -8
View File
@@ -73,13 +73,8 @@ boolean Plugin_037(byte function, struct EventStruct *event, String& string)
for (byte varNr = 0; varNr < 4; varNr++)
{
string += F("<TR><TD>MQTT Topic ");
string += varNr + 1;
string += F(":<TD><input type='text' size='40' maxlength='40' name='Plugin_037_template");
string += varNr + 1;
string += F("' value='");
string += deviceTemplate[varNr];
string += F("'>");
addFormTextBox(string, String(F("MQTT Topic ")) + (varNr + 1), String(F("Plugin_037_template")) +
(varNr + 1), deviceTemplate[varNr], 40);
}
success = true;
break;
@@ -469,7 +464,6 @@ float string2float(String myString) {
if (myString.substring(0, 1) == "-") {
start = 1; //allow a minus in front of string
tmp[i] = '-';
}
for (i = start; i < len; i++)
+4 -8
View File
@@ -50,21 +50,17 @@ boolean Plugin_038(byte function, struct EventStruct *event, String& string)
case PLUGIN_WEBFORM_LOAD:
{
char tmpString[128];
sprintf_P(tmpString, PSTR("<TR><TD>Led Count:<TD><input type='text' name='plugin_038_leds' size='3' value='%u'>"), Settings.TaskDevicePluginConfig[event->TaskIndex][0]);
string += tmpString;
addFormNumericBox(string, F("Led Count"), F("plugin_038_leds"), Settings.TaskDevicePluginConfig[event->TaskIndex][0],1 ,999);
string += F("<TR><TD>GPIO:<TD>");
addPinSelect(false, string, "taskdevicepin1", Settings.TaskDevicePin1[event->TaskIndex]);
addFormPinSelect(string, F("GPIO"), F("taskdevicepin1"), Settings.TaskDevicePin1[event->TaskIndex]);
success = true;
success = true;
break;
}
case PLUGIN_WEBFORM_SAVE:
{
String plugin1 = WebServer.arg(F("plugin_038_leds"));
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = plugin1.toInt();
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = getFormItemInt(F("plugin_038_leds"));
success = true;
break;
}
+9 -24
View File
@@ -102,30 +102,16 @@ boolean Plugin_039(byte function, struct EventStruct *event, String& string)
case PLUGIN_WEBFORM_LOAD:
{
string += F("<TR><TD>Info GPIO:<TD><b>1st GPIO</b> = CS (Usable GPIOs : 0, 2, 4, 5, 15)");
addFormNote(string, F("<b>1st GPIO</b> = CS (Usable GPIOs : 0, 2, 4, 5, 15)"));
//string += F("<TR><TD>Info GPIO:<TD><b>1st GPIO</b> = CS (Usable GPIOs : 0, 2, 4, 5, 15)");
byte choice = Settings.TaskDevicePluginConfig[event->TaskIndex][0];
String options[2];
options[0] = F("MAX 6675");
options[1] = F("MAX 31855");
//options[2] = F("MAX 31865");
int optionValues[2];
optionValues[0] = 1;
optionValues[1] = 2;
//optionValues[2] = 3;
string += F("<TR><TD>Adapter IC:<TD><select name='plugin_039_maxtype'>");
for (byte x = 0; x < 2; x++)
{
string += F("<option value='");
string += optionValues[x];
string += "'";
if (choice == optionValues[x])
string += F(" selected");
string += ">";
string += options[x];
string += F("</option>");
}
string += F("</select>");
int optionValues[2] = { 1, 2 };
addFormSelector(string, F("Adapter IC"), F("plugin_039_maxtype"), 2, options, optionValues, choice);
success = true;
break;
@@ -133,8 +119,7 @@ boolean Plugin_039(byte function, struct EventStruct *event, String& string)
case PLUGIN_WEBFORM_SAVE:
{
String plugin1 = WebServer.arg("plugin_039_maxtype");
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = plugin1.toInt();
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = getFormItemInt(F("plugin_039_maxtype"));
success = true;
break;
}
@@ -256,7 +241,7 @@ double readMax31855()
rawvalue >>= 18;
// Check for negative Values
// +25.00 0000 0001 1001 00
// +25.00 0000 0001 1001 00
// 0.00 0000 0000 0000 00
// -0.25 1111 1111 1111 11
// -1.00 1111 1111 1111 00
@@ -264,11 +249,11 @@ double readMax31855()
if (rawvalue & 0x2000) // Bit 31=1 -> neg Values
{
// Negate all Bits
rawvalue = ~rawvalue;
// Add 1 and make negative
rawvalue = ~rawvalue;
// Add 1 and make negative
rawvalue = (rawvalue + 1) * -1;
}
// Calculate Celsius
return rawvalue * 0.25;
}
+6 -13
View File
@@ -50,25 +50,18 @@ boolean Plugin_041(byte function, struct EventStruct *event, String& string)
case PLUGIN_WEBFORM_LOAD:
{
char tmpString[128];
sprintf_P(tmpString, PSTR("<TR><TD>Red:<TD><input type='text' name='plugin_041_red' size='3' value='%u'>"), Settings.TaskDevicePluginConfig[event->TaskIndex][0]);
string += tmpString;
sprintf_P(tmpString, PSTR("<TR><TD>Green:<TD><input type='text' name='plugin_041_green' size='3' value='%u'>"), Settings.TaskDevicePluginConfig[event->TaskIndex][1]);
string += tmpString;
sprintf_P(tmpString, PSTR("<TR><TD>Blue:<TD><input type='text' name='plugin_041_blue' size='3' value='%u'>"), Settings.TaskDevicePluginConfig[event->TaskIndex][2]);
string += tmpString;
addFormNumericBox(string, F("Red"), F("plugin_041_red"), Settings.TaskDevicePluginConfig[event->TaskIndex][0], 0, 255);
addFormNumericBox(string, F("Green"), F("plugin_041_green"), Settings.TaskDevicePluginConfig[event->TaskIndex][1], 0, 255);
addFormNumericBox(string, F("Blue"), F("plugin_041_blue"), Settings.TaskDevicePluginConfig[event->TaskIndex][2], 0, 255);
success = true;
break;
}
case PLUGIN_WEBFORM_SAVE:
{
String plugin1 = WebServer.arg(F("plugin_041_red"));
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = plugin1.toInt();
String plugin2 = WebServer.arg(F("plugin_041_green"));
Settings.TaskDevicePluginConfig[event->TaskIndex][1] = plugin2.toInt();
String plugin3 = WebServer.arg(F("plugin_041_blue"));
Settings.TaskDevicePluginConfig[event->TaskIndex][2] = plugin3.toInt();
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = getFormItemInt(F("plugin_041_red"));
Settings.TaskDevicePluginConfig[event->TaskIndex][1] = getFormItemInt(F("plugin_041_green"));
Settings.TaskDevicePluginConfig[event->TaskIndex][2] = getFormItemInt(F("plugin_041_blue"));
Plugin_041_red = Settings.TaskDevicePluginConfig[event->TaskIndex][0];
Plugin_041_green = Settings.TaskDevicePluginConfig[event->TaskIndex][1];
Plugin_041_blue = Settings.TaskDevicePluginConfig[event->TaskIndex][2];
+53 -79
View File
@@ -9,32 +9,32 @@
// INCLUDE jscolor (http://jscolor.com/)
// * Download the lib from here: http://jscolor.com/release/latest.zip
// * Extract jscolor.min.js
// * Now open the Web UI of your ESPEasy with this URL:
// * Now open the Web UI of your ESPEasy with this URL:
// http://<IP-ESPEasy>/upload
// * Select Browse ... and choose the extracted jscolor.min.js File (ensure the ...min... verion !!)
// * Press Upload und you are done.
// * Press Upload und you are done.
// Add the Adafruit Neopixel Library to your library path. You will find it here:
// Add the Adafruit Neopixel Library to your library path. You will find it here:
// https://github.com/adafruit/Adafruit_NeoPixel
// That´s all :-) Now ESPEasy has a new 25ms "Timer loop" and Neopixel Support.
// That´s all :-) Now ESPEasy has a new 25ms "Timer loop" and Neopixel Support.
// NOTES
// Please keep in mind that you can add tasks which produce a very large delay while reading the sensor.
// For example the DS18B20 is very slow in reading the values. This can slow down the simulation and you
// will notice that the candle did not run smooth. So keep an eye on your tasks and donßt add to much other tasks.
// Please keep in mind that you can add tasks which produce a very large delay while reading the sensor.
// For example the DS18B20 is very slow in reading the values. This can slow down the simulation and you
// will notice that the candle did not run smooth. So keep an eye on your tasks and donßt add to much other tasks.
// HARDWARE
// The Wifi Candle uses 20 WS2812 RGB pixels. They are all connected in one row.
// The Wifi Candle uses 20 WS2812 RGB pixels. They are all connected in one row.
// I build a wooden wick with 5 pixels on each side. (A picture is here : http://www.esp8266.nu/forum/viewtopic.php?f=2&t=2147)
// The pixels are connected to 5V and the data pin I use is GPIO13 (but you can choose another one).
// Please ensure that you use a strong power supply because the pixels consume a lot of power when they
// The pixels are connected to 5V and the data pin I use is GPIO13 (but you can choose another one).
// Please ensure that you use a strong power supply because the pixels consume a lot of power when they
// shine in white with high brigthness!
// I also placed a 100µF capacitor at the end of the WS2812 chain on +5/GND just to ensure a good power stability.
// btw ... My Testboard was a NodeMCU V3.
// I also placed a 100µF capacitor at the end of the WS2812 chain on +5/GND just to ensure a good power stability.
// btw ... My Testboard was a NodeMCU V3.
// QUESTIONS
// Send me an email at dominik@logview.info
// or place a comment in the Forum:
// QUESTIONS
// Send me an email at dominik@logview.info
// or place a comment in the Forum:
// http://www.esp8266.nu/forum/viewtopic.php?f=2&t=2147
// Candle Infos
@@ -149,11 +149,6 @@ boolean Plugin_042(byte function, struct EventStruct *event, String& string)
options[6] = F("Strobe");
options[7] = F("Color Fader");
for (byte x = 0; x < 8; x++)
{
optionValues[x] = x;
}
byte choice = Settings.TaskDevicePluginConfig[event->TaskIndex][4];
if (choice > sizeof(options) - 1)
{
@@ -161,19 +156,7 @@ boolean Plugin_042(byte function, struct EventStruct *event, String& string)
}
// Candle Type Selection
string += F("<TR><TD>Flame Type:<TD><select name='web_Candle_Type'>");
for (byte x = 0; x < 8; x++)
{
string += F("<option value='");
string += optionValues[x];
string += "'";
if (choice == optionValues[x])
string += F(" selected");
string += ">";
string += options[x];
string += F("</option>");
}
string += F("</select>");
addFormSelector(string, F("Flame Type"), F("web_Candle_Type"), 8, options, NULL, choice);
// Advanced Color options
Candle_color = (ColorType)Settings.TaskDevicePluginConfig[event->TaskIndex][5];
@@ -194,7 +177,7 @@ boolean Plugin_042(byte function, struct EventStruct *event, String& string)
string += F("<label for='web_Color_Selected'> Use selected color</label><br>");
// Color Selection
char hexvalue[6] = {0};
char hexvalue[7] = {0};
sprintf(hexvalue, "%02X%02X%02X", // Create Hex value for color
Settings.TaskDevicePluginConfig[event->TaskIndex][0],
Settings.TaskDevicePluginConfig[event->TaskIndex][1],
@@ -204,12 +187,9 @@ boolean Plugin_042(byte function, struct EventStruct *event, String& string)
string += F("<TR><TD>Color:<TD><input class=\"jscolor {onFineChange:'update(this)'}\" value='");
string += hexvalue;
string += F("'>");
sprintf_P(tmpString, PSTR("<TR><TD>RGB Color:<TD><input type='text' name='web_RGB_Red' id='web_RGB_Red' size='3' value='%u'>"), Settings.TaskDevicePluginConfig[event->TaskIndex][0]);
string += tmpString;
sprintf_P(tmpString, PSTR("&nbsp;&nbsp;<input type='text' name='web_RGB_Green' id='web_RGB_Green' size='3' value='%u'>"), Settings.TaskDevicePluginConfig[event->TaskIndex][1]);
string += tmpString;
sprintf_P(tmpString, PSTR("&nbsp;&nbsp;<input type='text' name='web_RGB_Blue' id='web_RGB_Blue' size='3' value='%u'>"), Settings.TaskDevicePluginConfig[event->TaskIndex][2]);
string += tmpString;
addFormNumericBox(string, F("RGB Color"), F("web_RGB_Red"), Settings.TaskDevicePluginConfig[event->TaskIndex][0], 0, 255);
addNumericBox(string, F("web_RGB_Green"), Settings.TaskDevicePluginConfig[event->TaskIndex][1], 0, 255);
addNumericBox(string, F("web_RGB_Blue"), Settings.TaskDevicePluginConfig[event->TaskIndex][2], 0, 255);
// Brightness Selection
string += F("<TR><TD>Brightness:<TD>min<input type='range' id='web_Bright_Slide' min='0' max='255' value='");
@@ -241,18 +221,12 @@ boolean Plugin_042(byte function, struct EventStruct *event, String& string)
case PLUGIN_WEBFORM_SAVE:
{
String plugin1 = WebServer.arg(F("web_RGB_Red"));
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = plugin1.toInt();
String plugin2 = WebServer.arg(F("web_RGB_Green"));
Settings.TaskDevicePluginConfig[event->TaskIndex][1] = plugin2.toInt();
String plugin3 = WebServer.arg(F("web_RGB_Blue"));
Settings.TaskDevicePluginConfig[event->TaskIndex][2] = plugin3.toInt();
String plugin4 = WebServer.arg(F("web_Bright_Text"));
Settings.TaskDevicePluginConfig[event->TaskIndex][3] = plugin4.toInt();
String plugin5 = WebServer.arg(F("web_Candle_Type"));
Settings.TaskDevicePluginConfig[event->TaskIndex][4] = plugin5.toInt();
String plugin6 = WebServer.arg(F("web_Color_Type"));
Settings.TaskDevicePluginConfig[event->TaskIndex][5] = plugin6.toInt();
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = getFormItemInt(F("web_RGB_Red"));
Settings.TaskDevicePluginConfig[event->TaskIndex][1] = getFormItemInt(F("web_RGB_Green"));
Settings.TaskDevicePluginConfig[event->TaskIndex][2] = getFormItemInt(F("web_RGB_Blue"));
Settings.TaskDevicePluginConfig[event->TaskIndex][3] = getFormItemInt(F("web_Bright_Text"));
Settings.TaskDevicePluginConfig[event->TaskIndex][4] = getFormItemInt(F("web_Candle_Type"));
Settings.TaskDevicePluginConfig[event->TaskIndex][5] = getFormItemInt(F("web_Color_Type"));
Candle_red = Settings.TaskDevicePluginConfig[event->TaskIndex][0];
Candle_green = Settings.TaskDevicePluginConfig[event->TaskIndex][1];
@@ -389,8 +363,8 @@ boolean Plugin_042(byte function, struct EventStruct *event, String& string)
case PLUGIN_WRITE:
{
String tmpString = string;
// Test
// Test
// MQTT : mosquitto_pub -d -t sensors/espeasy/ESP_Candle/cmd -m "CANDLE_OFF"
// HTTP : http://192.168.30.183/tools?cmd=CANDLE%3A5%3AFF0000%3A200
// http://192.168.30.183/tools?cmd=CANDLE:4:FF0000:200
@@ -401,19 +375,19 @@ boolean Plugin_042(byte function, struct EventStruct *event, String& string)
// <FlameType> : 1 Static Light, 2 Simple Candle, 3 Advanced Candle, 4 Police, 5 Blink, 6 Strobe, 7 Color Fader
// <Color> : n.def. Use the default color
// RRGGBB Use color in RRGGBB style (red, green blue) as HEX
// <Brightness> : 0-255
// <Brightness> : 0-255
// Samples: CANDLE:2::100 Simple Candle with Default color and Brigthness at 100
// CANDLE:5:FF0000:200 Blink with RED Color and Brigthness at 200
// CANDLE:0:: Candle OFF
// CANDLE:1::255 Candle ON - White and full brigthness
if (tmpString.startsWith("CANDLE:")){
int idx1 = tmpString.indexOf(':');
int idx2 = tmpString.indexOf(':', idx1+1);
int idx3 = tmpString.indexOf(':', idx2+1);
int idx4 = tmpString.indexOf(':', idx3+1);
String val_Type = tmpString.substring(idx1+1, idx2);
String val_Color = tmpString.substring(idx2+1, idx3);
String val_Color = tmpString.substring(idx2+1, idx3);
String val_Bright = tmpString.substring(idx3+1, idx4);
if (val_Type != "") {
@@ -467,7 +441,7 @@ boolean Plugin_042(byte function, struct EventStruct *event, String& string)
//SaveTaskSettings(event->TaskIndex);
//SaveSettings();
success = true;
}
@@ -530,18 +504,18 @@ void type_Advanced_Candle() {
Candle_Temp[1] = random(1, 4) + Candle_Temp[0]; // 1..3 LEDs in Yellow / Orange
Candle_Temp[2] = random(0, 2); // 0..1 Choose Yellow = 0 / Orange = 1
int colorbase[3];
int color1[3];
int color2[3];
int color3[3];
int colorbase[3];
int color1[3];
int color2[3];
int color3[3];
if (Candle_color == ColorDefault) {
colorbase[0] = 255; colorbase[1] = 120; colorbase[2] = 0; // Light Orange #FF7800
colorbase[0] = 255; colorbase[1] = 120; colorbase[2] = 0; // Light Orange #FF7800
color1[0] = 115; color1[1] = 50; color1[2] = 0; // Brown #733200
color2[0] = 180; color2[1] = 80; color2[2] = 0; // Orange #B45000
color2[0] = 180; color2[1] = 80; color2[2] = 0; // Orange #B45000
color3[0] = 70; color3[1] = 30; color3[2] = 0; // Dark brown #4A2000
} else {
colorbase[0] = Candle_red; colorbase[1] = Candle_green; colorbase[2] = Candle_blue;
colorbase[0] = Candle_red; colorbase[1] = Candle_green; colorbase[2] = Candle_blue;
double hsv[3];
// Calc HSV
RGBtoHSV(Candle_red, Candle_green, Candle_blue, hsv);
@@ -551,20 +525,20 @@ void type_Advanced_Candle() {
double newV2 = hsv[2] / 4;
// Calc new RGBs
HSVtoRGB(newH, hsv[1], hsv[2], color1);
HSVtoRGB(hsv[0], hsv[1], newV, color2);
HSVtoRGB(newH, hsv[1], newV2, color3);
HSVtoRGB(hsv[0], hsv[1], newV, color2);
HSVtoRGB(newH, hsv[1], newV2, color3);
}
for (int j = 0; j < 4; j++) {
for (int i = 1; i < 6; i++){
if (i <= Candle_Temp[0]) {
Candle_pixels->setPixelColor(j * 5 + i - 1, colorbase[0], colorbase[1], colorbase[2]);
Candle_pixels->setPixelColor(j * 5 + i - 1, colorbase[0], colorbase[1], colorbase[2]);
}
if (i > Candle_Temp[0] && i <= Candle_Temp[1]) {
if (Candle_Temp[2] == 0){
Candle_pixels->setPixelColor(j * 5 + i - 1, color1[0], color1[1], color1[2]);
Candle_pixels->setPixelColor(j * 5 + i - 1, color1[0], color1[1], color1[2]);
} else {
Candle_pixels->setPixelColor(j * 5 + i - 1, color2[0], color2[1], color2[2]);
Candle_pixels->setPixelColor(j * 5 + i - 1, color2[0], color2[1], color2[2]);
}
}
if (i > Candle_Temp[1]) {
@@ -635,14 +609,14 @@ void type_ColorFader() {
}
// Calc HSV
// void RGBtoHSV(byte r, byte g, byte b, double hsv[3])
// void RGBtoHSV(byte r, byte g, byte b, double hsv[3])
RGBtoHSV(Candle_red, Candle_green, Candle_blue, hsv);
// Calc RGB with new V
// HSVtoRGB(int hue, int sat, int val, int colors[3])
// Calc RGB with new V
// HSVtoRGB(int hue, int sat, int val, int colors[3])
// hue: 0-359, sat: 0-255, val (lightness): 0-255
HSVtoRGB(hsv[0], hsv[1], Candle_Temp[0], colors);
for (int i = 0; i < NUM_PIXEL; i++) {
Candle_pixels->setPixelColor(i, colors[0], colors[1], colors[2]);
}
@@ -651,10 +625,10 @@ void type_ColorFader() {
if (Candle_Temp[0] > 359) {
Candle_Temp[0] = 0;
}
// hue: 0-359, sat: 0-255, val (lightness): 0-255
HSVtoRGB(Candle_Temp[0], 255, 255, colors);
for (int i = 0; i < NUM_PIXEL; i++) {
Candle_pixels->setPixelColor(i, colors[0], colors[1], colors[2]);
}
@@ -670,7 +644,7 @@ void HSVtoRGB(int hue, int sat, int val, int colors[3]) {
colors[0]=val;
colors[1]=val;
colors[2]=val;
}
}
else {
base = ((255 - sat) * val)>>8;
switch(hue/60) {
@@ -722,12 +696,12 @@ void RGBtoHSV(byte r, byte g, byte b, double hsv[3]) {
double minval = rd;
if (gd < minval) { minval = gd; }
if (bd < minval) { minval = bd; }
double h, s, v = maxval;
double h = 0, s, v = maxval;
double d = maxval - minval;
s = maxval == 0 ? 0 : d / maxval;
if (maxval == minval) {
if (maxval == minval) {
h = 0; // achromatic
} else {
if (maxval == rd) {
+15 -31
View File
@@ -42,40 +42,25 @@ boolean Plugin_043(byte function, struct EventStruct *event, String& string)
case PLUGIN_WEBFORM_LOAD:
{
String options[3];
options[0] = F("");
options[1] = F("Off");
options[2] = F("On");
for (byte x = 0; x < PLUGIN_043_MAX_SETTINGS; x++)
{
string += F("<TR><TD>Day,Time ");
string += x+1;
string += F(":<TD><input type='text' name='plugin_043_clock");
string += x;
string += F("' value='");
string += timeLong2String(ExtraTaskSettings.TaskDevicePluginConfigLong[x]);
string += F("'>");
addFormTextBox(string, String(F("Day,Time ")) + (x + 1), String(F("plugin_043_clock")) + (x), timeLong2String(ExtraTaskSettings.TaskDevicePluginConfigLong[x]), 32);
// string += F("<TR><TD>Day,Time ");
// string += x+1;
// string += F(":<TD><input type='text' name='plugin_043_clock");
// string += x;
// string += F("' value='");
// string += timeLong2String(ExtraTaskSettings.TaskDevicePluginConfigLong[x]);
// string += F("'>");
string += F(" ");
byte choice = ExtraTaskSettings.TaskDevicePluginConfig[x];
String options[3];
options[0] = F("");
options[1] = F("Off");
options[2] = F("On");
int optionValues[3];
optionValues[0] = 0;
optionValues[1] = 1;
optionValues[2] = 2;
string += F("<select name='plugin_043_state");
string += x;
string += F("'>");
for (byte x = 0; x < 3; x++)
{
string += F("<option value='");
string += optionValues[x];
string += "'";
if (choice == optionValues[x])
string += F(" selected");
string += ">";
string += options[x];
string += F("</option>");
}
string += F("</select>");
addSelector(string, String(F("plugin_043_state")) + (x), 3, options, NULL, NULL, choice, false);
}
success = true;
break;
@@ -134,4 +119,3 @@ boolean Plugin_043(byte function, struct EventStruct *event, String& string)
}
return success;
}
+15 -42
View File
@@ -65,45 +65,23 @@ boolean Plugin_044(byte function, struct EventStruct *event, String& string)
case PLUGIN_WEBFORM_LOAD:
{
char tmpString[128];
sprintf_P(tmpString, PSTR("<TR><TD>TCP Port:<TD><input type='text' name='plugin_044_port' value='%u'>"), ExtraTaskSettings.TaskDevicePluginConfigLong[0]);
string += tmpString;
sprintf_P(tmpString, PSTR("<TR><TD>Baud Rate:<TD><input type='text' name='plugin_044_baud' value='%u'>"), ExtraTaskSettings.TaskDevicePluginConfigLong[1]);
string += tmpString;
sprintf_P(tmpString, PSTR("<TR><TD>Data bits:<TD><input type='text' name='plugin_044_data' value='%u'>"), ExtraTaskSettings.TaskDevicePluginConfigLong[2]);
string += tmpString;
addFormNumericBox(string, F("TCP Port"), F("plugin_044_port"), ExtraTaskSettings.TaskDevicePluginConfigLong[0]);
addFormNumericBox(string, F("Baud Rate"), F("plugin_044_baud"), ExtraTaskSettings.TaskDevicePluginConfigLong[1]);
addFormNumericBox(string, F("Data bits"), F("plugin_044_data"), ExtraTaskSettings.TaskDevicePluginConfigLong[2]);
byte choice = ExtraTaskSettings.TaskDevicePluginConfigLong[3];
String options[3];
options[0] = F("No parity");
options[1] = F("Even");
options[2] = F("Odd");
int optionValues[3];
optionValues[0] = 0;
optionValues[1] = 2;
optionValues[2] = 3;
string += F("<TR><TD>Parity:<TD><select name='plugin_044_parity'>");
for (byte x = 0; x < 3; x++)
{
string += F("<option value='");
string += optionValues[x];
string += "'";
if (choice == optionValues[x])
string += F(" selected");
string += ">";
string += options[x];
string += F("</option>");
}
string += F("</select>");
int optionValues[3] = { 0, 2, 3 };
addFormSelector(string, F("Parity"), F("plugin_044_parity"), 3, options, optionValues, choice);
sprintf_P(tmpString, PSTR("<TR><TD>Stop bits:<TD><input type='text' name='plugin_044_stop' value='%u'>"), ExtraTaskSettings.TaskDevicePluginConfigLong[4]);
string += tmpString;
addFormNumericBox(string, F("Stop bits"), F("plugin_044_stop"), ExtraTaskSettings.TaskDevicePluginConfigLong[4]);
string += F("<TR><TD>Reset target after boot:<TD>");
addPinSelect(false, string, "taskdevicepin1", Settings.TaskDevicePin1[event->TaskIndex]);
addFormPinSelect(string, F("Reset target after boot"), F("taskdevicepin1"), Settings.TaskDevicePin1[event->TaskIndex]);
sprintf_P(tmpString, PSTR("<TR><TD>RX Receive Timeout (mSec):<TD><input type='text' name='plugin_044_rxwait' value='%u'>"), Settings.TaskDevicePluginConfig[event->TaskIndex][0]);
string += tmpString;
addFormNumericBox(string, F("RX Receive Timeout (mSec)"), F("plugin_044_rxwait"), Settings.TaskDevicePluginConfig[event->TaskIndex][0]);
success = true;
break;
@@ -111,18 +89,13 @@ boolean Plugin_044(byte function, struct EventStruct *event, String& string)
case PLUGIN_WEBFORM_SAVE:
{
String plugin1 = WebServer.arg(F("plugin_044_port"));
ExtraTaskSettings.TaskDevicePluginConfigLong[0] = plugin1.toInt();
String plugin2 = WebServer.arg(F("plugin_044_baud"));
ExtraTaskSettings.TaskDevicePluginConfigLong[1] = plugin2.toInt();
String plugin3 = WebServer.arg(F("plugin_044_data"));
ExtraTaskSettings.TaskDevicePluginConfigLong[2] = plugin3.toInt();
String plugin4 = WebServer.arg(F("plugin_044_parity"));
ExtraTaskSettings.TaskDevicePluginConfigLong[3] = plugin4.toInt();
String plugin5 = WebServer.arg(F("plugin_044_stop"));
ExtraTaskSettings.TaskDevicePluginConfigLong[4] = plugin5.toInt();
String plugin6 = WebServer.arg(F("plugin_044_rxwait"));
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = plugin6.toInt();
ExtraTaskSettings.TaskDevicePluginConfigLong[0] = getFormItemInt(F("plugin_044_port"));
ExtraTaskSettings.TaskDevicePluginConfigLong[1] = getFormItemInt(F("plugin_044_baud"));
ExtraTaskSettings.TaskDevicePluginConfigLong[2] = getFormItemInt(F("plugin_044_data"));
ExtraTaskSettings.TaskDevicePluginConfigLong[3] = getFormItemInt(F("plugin_044_parity"));
ExtraTaskSettings.TaskDevicePluginConfigLong[4] = getFormItemInt(F("plugin_044_stop"));
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = getFormItemInt(F("plugin_044_rxwait"));
success = true;
break;
}
+24 -56
View File
@@ -114,28 +114,19 @@ boolean Plugin_045(byte function, struct EventStruct *event, String& string)
{
// Setup webform for address selection
byte choice = Settings.TaskDevicePluginConfig[event->TaskIndex][0];
/*
String options[10];
options[0] = F("0x68 - default settings (ADDR Low)");
options[1] = F("0x69 - alternate settings (ADDR High)");
*/
int optionValues[2];
optionValues[0] = 0x68;
optionValues[1] = 0x69;
string += F("<TR><TD>I2C Address:<TD><select name='plugin_045_address'>");
for (byte x = 0; x < 2; x++)
{
string += F("<option value='");
string += optionValues[x];
string += "'";
if (choice == optionValues[x])
string += F(" selected");
string += ">";
string += options[x];
string += F("</option>");
}
string += F("</select>");
// Setup webform for instance function
addFormSelectorI2C(string, F("plugin_045_address"), 2, optionValues, choice);
addFormNote(string, F("ADDR Low=0x68, High=0x69"));
choice = Settings.TaskDevicePluginConfig[event->TaskIndex][1];
string += F("<TR><TD>Function:<TD><select name='plugin_045_function'>");
String options[10];
options[0] = F("Movement detection");
options[1] = F("Range acceleration X");
options[2] = F("Range acceleration Y");
@@ -146,45 +137,29 @@ boolean Plugin_045(byte function, struct EventStruct *event, String& string)
options[7] = F("G-force X");
options[8] = F("G-force Y");
options[9] = F("G-force Z");
for (byte x = 0; x < 10; x++)
{
string += F("<option value='");
string += x;
string += "'";
if (choice == x)
string += F(" selected");
string += ">";
string += options[x];
string += F("</option>");
}
string += F("</select>");
addFormSelector(string, F("Function"), F("plugin_045_function"), 10, options, NULL, choice);
if (choice == 0) {
// If this is instance function 0, setup webform for additional vars
// Show some user information about the webform and what the vars mean.
string += F("<TR><TD><TD>The thresholdvalues (0-65535) can be used to set a threshold for one or more<br>");
string += F("axis. The axis will trigger when the range for that axis exceeds the threshold<br>");
string += F("value. A value of 0 disables movement detection for that axis.");
string += F("<TR><TD>Detection threshold X:<TD><input type='text' size='6' maxlength='6' name='plugin_045_threshold_x' value='");
string += Settings.TaskDevicePluginConfig[event->TaskIndex][2];
string += F("'>");
string += F("<TR><TD>Detection threshold Y:<TD><input type='text' size='6' maxlength='6' name='plugin_045_threshold_y' value='");
string += Settings.TaskDevicePluginConfig[event->TaskIndex][3];
string += F("'>");
string += F("<TR><TD>Detection threshold Z:<TD><input type='text' size='6' maxlength='6' name='plugin_045_threshold_z' value='");
string += Settings.TaskDevicePluginConfig[event->TaskIndex][4];
string += F("'>");
addFormNumericBox(string, F("Detection threshold X"), F("plugin_045_threshold_x"), Settings.TaskDevicePluginConfig[event->TaskIndex][2], 0, 65535);
addFormNumericBox(string, F("Detection threshold Y"), F("plugin_045_threshold_y"), Settings.TaskDevicePluginConfig[event->TaskIndex][3], 0, 65535);
addFormNumericBox(string, F("Detection threshold Z"), F("plugin_045_threshold_z"), Settings.TaskDevicePluginConfig[event->TaskIndex][4], 0, 65535);
string += F("<TR><TD><TD>Each 30 seconds a counter for the detection window is increased plus all axis<br>");
string += F("are checked and if they *all* exceeded the threshold values, a counter is increased.<br>");
string += F("Each period, defined by the [detection window], the counter is checked against<br>");
string += F("the [min. detection count] and if found equal or larger, movement is detected.<br>");
string += F("If in the next window the [min. detection count] value is not met, movement has stopped.");
string += F("The [detection window] cannot be smaller than the [min. detection count].");
string += F("<TR><TD>Min. detection count:<TD><input type='text' size='6' maxlength='6' name='plugin_045_threshold_counter' value='");
string += Settings.TaskDevicePluginConfig[event->TaskIndex][5];
string += F("'>");
string += F("<TR><TD>Detection window:<TD><input type='text' size='6' maxlength='6' name='plugin_045_threshold_window' value='");
string += Settings.TaskDevicePluginConfig[event->TaskIndex][6];
string += F("'>");
addFormNumericBox(string, F("Min. detection count"), F("plugin_045_threshold_counter"), Settings.TaskDevicePluginConfig[event->TaskIndex][5], 0, 999999);
addFormNumericBox(string, F("Detection window"), F("plugin_045_threshold_window"), Settings.TaskDevicePluginConfig[event->TaskIndex][6], 0, 999999);
}
success = true;
break;
@@ -193,20 +168,13 @@ boolean Plugin_045(byte function, struct EventStruct *event, String& string)
case PLUGIN_WEBFORM_SAVE:
{
// Save the vars
String plugin1 = WebServer.arg("plugin_045_address");
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = plugin1.toInt();
plugin1 = WebServer.arg("plugin_045_function");
Settings.TaskDevicePluginConfig[event->TaskIndex][1] = plugin1.toInt();
plugin1 = WebServer.arg("plugin_045_threshold_x");
Settings.TaskDevicePluginConfig[event->TaskIndex][2] = plugin1.toInt();
plugin1 = WebServer.arg("plugin_045_threshold_y");
Settings.TaskDevicePluginConfig[event->TaskIndex][3] = plugin1.toInt();
plugin1 = WebServer.arg("plugin_045_threshold_z");
Settings.TaskDevicePluginConfig[event->TaskIndex][4] = plugin1.toInt();
plugin1 = WebServer.arg("plugin_045_threshold_counter");
Settings.TaskDevicePluginConfig[event->TaskIndex][5] = plugin1.toInt();
plugin1 = WebServer.arg("plugin_045_threshold_window");
Settings.TaskDevicePluginConfig[event->TaskIndex][6] = plugin1.toInt();
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = getFormItemInt(F("plugin_045_address"));
Settings.TaskDevicePluginConfig[event->TaskIndex][1] = getFormItemInt(F("plugin_045_function"));
Settings.TaskDevicePluginConfig[event->TaskIndex][2] = getFormItemInt(F("plugin_045_threshold_x"));
Settings.TaskDevicePluginConfig[event->TaskIndex][3] = getFormItemInt(F("plugin_045_threshold_y"));
Settings.TaskDevicePluginConfig[event->TaskIndex][4] = getFormItemInt(F("plugin_045_threshold_z"));
Settings.TaskDevicePluginConfig[event->TaskIndex][5] = getFormItemInt(F("plugin_045_threshold_counter"));
Settings.TaskDevicePluginConfig[event->TaskIndex][6] = getFormItemInt(F("plugin_045_threshold_window"));
if (Settings.TaskDevicePluginConfig[event->TaskIndex][6] < Settings.TaskDevicePluginConfig[event->TaskIndex][5]) {
Settings.TaskDevicePluginConfig[event->TaskIndex][6] = Settings.TaskDevicePluginConfig[event->TaskIndex][5];
}
+13 -38
View File
@@ -152,22 +152,8 @@ boolean Plugin_046(byte function, struct EventStruct *event, String& string)
options[7] = F("Unknown 2, byte 16");
options[8] = F("Unknown 3, byte 19");
int optionValues[nrchoices];
for (byte x = 0; x < nrchoices; x++) {
optionValues[x] = x;
}
string += F("<TR><TD>Plugin function:<TD><select name='plugin_046'>");
for (byte x = 0; x < nrchoices; x++) {
string += F("<option value='");
string += optionValues[x];
string += "'";
if (choice == optionValues[x])
string += F(" selected");
string += ">";
string += options[x];
string += F("</option>");
}
string += F("</select>");
addFormSelector(string, F("Plugin function"), F("plugin_046"), nrchoices, options, NULL, choice);
if (choice==0) {
string += F("<TR><TD>1st GPIO (5-MOSI):<TD>");
addPinSelect(false, string, "taskdevicepin1", Settings.TaskDevicePluginConfig[event->TaskIndex][1]);
@@ -244,17 +230,12 @@ boolean Plugin_046(byte function, struct EventStruct *event, String& string)
case PLUGIN_WEBFORM_SAVE:
{
String plugin1 = WebServer.arg("plugin_046");
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = plugin1.toInt();
if (plugin1.toInt()==0) {
String plugin2 = WebServer.arg("taskdevicepin1");
Settings.TaskDevicePluginConfig[event->TaskIndex][1] = plugin2.toInt();
String plugin3 = WebServer.arg("taskdevicepin2");
Settings.TaskDevicePluginConfig[event->TaskIndex][2] = plugin3.toInt();
String plugin4 = WebServer.arg("taskdevicepin3");
Settings.TaskDevicePluginConfig[event->TaskIndex][3] = plugin4.toInt();
String plugin5 = WebServer.arg("taskdeviceport");
Settings.TaskDevicePluginConfig[event->TaskIndex][4] = plugin5.toInt();
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = getFormItemInt(F("plugin_046"));
if (Settings.TaskDevicePluginConfig[event->TaskIndex][0] == 0) {
Settings.TaskDevicePluginConfig[event->TaskIndex][1] = getFormItemInt(F("taskdevicepin1"));
Settings.TaskDevicePluginConfig[event->TaskIndex][2] = getFormItemInt(F("taskdevicepin2"));
Settings.TaskDevicePluginConfig[event->TaskIndex][3] = getFormItemInt(F("taskdevicepin3"));
Settings.TaskDevicePluginConfig[event->TaskIndex][4] = getFormItemInt(F("taskdeviceport"));
}
success = true;
break;
@@ -327,18 +308,12 @@ boolean Plugin_046(byte function, struct EventStruct *event, String& string)
Plugin_046_MasterSlave = false;
Plugin_046_newData = false;
if (PLUGIN_046_DEBUG) {
String log = "Ventus W266 Rcvd(";
log += hour();
log += ":";
if (minute() < 10) { log += "0"; }
log += minute();
log += ":";
if (tm.Second < 10) { log += "0"; }
log += tm.Second;
log += ") ";
String log = F("Ventus W266 Rcvd(");
log += getTimeString(':');
log += F(") ");
for (int i = 0; i < Plugin_046_Payload; i++) {
if ((i==2)||(i==3)||(i==4)||(i==9)||(i==10)||(i==14)||(i==17)||(i==18)||(i==20)) {
log += ":";
log += F(":");
}
char myHex = (Plugin_046_databuffer[i] >> 4) + 0x30;
if (myHex > 0x39) { myHex += 7; }
@@ -347,7 +322,7 @@ boolean Plugin_046(byte function, struct EventStruct *event, String& string)
if (myHex > 0x39) { myHex += 7; }
log += myHex;
}
log += " > ";
log += F(" > ");
char myHex = (crc >> 4) + 0x30;
if (myHex > 0x39) { myHex += 7; }
log += myHex;
+15 -30
View File
@@ -75,32 +75,20 @@ boolean Plugin_047(byte function, struct EventStruct *event, String& string)
case PLUGIN_WEBFORM_LOAD:
{
string += F("<TR><TD>I2C Address (Hex): <TD><input type='text' title='Set i2c Address of sensor' name='");
string += F("plugin_047_i2cSoilMoisture_i2cAddress' value='0x");
string += String(Settings.TaskDevicePluginConfig[event->TaskIndex][0],HEX);
string += F("'>");
addFormTextBox(string, F("I2C Address (Hex)"), F("plugin_047_i2cSoilMoisture_i2cAddress"), String(F("0x")) +
String(Settings.TaskDevicePluginConfig[event->TaskIndex][0],HEX), 4);
string += F("<TR><TD>Send sensor to sleep:<TD>");
if (Settings.TaskDevicePluginConfig[event->TaskIndex][1])
string += F("<input type=checkbox name=plugin_047_sleep checked>");
else
string += F("<input type=checkbox name=plugin_047_sleep>");
addFormCheckBox(string, F("Send sensor to sleep"), F("plugin_047_sleep"), Settings.TaskDevicePluginConfig[event->TaskIndex][1]);
string += F("<TR><TD>Check sensor version:<TD>");
if (Settings.TaskDevicePluginConfig[event->TaskIndex][2])
string += F("<input type=checkbox name=plugin_047_version checked>");
else
string += F("<input type=checkbox name=plugin_047_version>");
addFormCheckBox(string, F("Check sensor version") ,F("plugin_047_version"), Settings.TaskDevicePluginConfig[event->TaskIndex][2]);
string += F("<TR><TD>Change Sensor address:<TD>");
string += F("<input type=checkbox name=plugin_047_changeAddr>");
addFormSeparator(string);
addFormCheckBox(string, F("Change Sensor address"),F("plugin_047_changeAddr"), false);
addFormTextBox(string, F("Change I2C Addr. to (Hex)"), F("plugin_047_i2cSoilMoisture_changeAddr"), String(F("0x")) +
String(Settings.TaskDevicePluginConfig[event->TaskIndex][0],HEX), 4);
string += F("<TR><TD>Change I2C Addr. to (Hex): <TD><input type='text' title='Set new i2c Address of sensor' name='");
string += F("plugin_047_i2cSoilMoisture_changeAddr' value='0x");
string += String(Settings.TaskDevicePluginConfig[event->TaskIndex][0],HEX);
string += F("'>");
addFormSeparator(string);
success = true;
break;
@@ -111,17 +99,14 @@ boolean Plugin_047(byte function, struct EventStruct *event, String& string)
String plugin1 = WebServer.arg(F("plugin_047_i2cSoilMoisture_i2cAddress"));
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = (int) strtol(plugin1.c_str(), 0, 16);
String plugin2 = WebServer.arg(F("plugin_047_sleep"));
Settings.TaskDevicePluginConfig[event->TaskIndex][1] = (plugin2 == F("on"));
Settings.TaskDevicePluginConfig[event->TaskIndex][1] = isFormItemChecked(F("plugin_047_sleep"));
String plugin3 = WebServer.arg(F("plugin_047_version"));
Settings.TaskDevicePluginConfig[event->TaskIndex][2] = (plugin3 == F("on"));
Settings.TaskDevicePluginConfig[event->TaskIndex][2] = isFormItemChecked(F("plugin_047_version"));
String plugin4 = WebServer.arg(F("plugin_047_i2cSoilMoisture_changeAddr"));
Settings.TaskDevicePluginConfig[event->TaskIndex][3] = (int) strtol(plugin4.c_str(), 0, 16);
String plugin5 = WebServer.arg(F("plugin_047_changeAddr"));
Settings.TaskDevicePluginConfig[event->TaskIndex][4] = (plugin5 == F("on"));
Settings.TaskDevicePluginConfig[event->TaskIndex][4] = isFormItemChecked(F("plugin_047_changeAddr"));
success = true;
break;
}
@@ -133,7 +118,7 @@ boolean Plugin_047(byte function, struct EventStruct *event, String& string)
if (Settings.TaskDevicePluginConfig[event->TaskIndex][1]) {
// wake sensor
Plugin_047_getVersion();
delayMillis(20);
delayBackground(20);
addLog(LOG_LEVEL_DEBUG, F("SoilMoisture->wake"));
}
@@ -165,7 +150,7 @@ boolean Plugin_047(byte function, struct EventStruct *event, String& string)
Plugin_047_write8(SOILMOISTURESENSOR_MEASURE_LIGHT);
// 2 s delay ...we need this delay, otherwise we get only the last reading...
delayMillis(2000);
delayBackground(2000);
float temperature = ((float)Plugin_047_readTemperature()) / 10;
float moisture = ((float)Plugin_047_readMoisture());
@@ -310,7 +295,7 @@ uint8_t Plugin_047_getVersion() {
bool Plugin_047_setAddress(int addr) {
Plugin_047_write8(SOILMOISTURESENSOR_SET_ADDRESS, addr);
Plugin_047_write8(SOILMOISTURESENSOR_RESET);
delayMillis(1000);
delayBackground(1000);
_i2caddrP47=addr;
return (Plugin_047_read8(SOILMOISTURESENSOR_GET_ADDRESS) == addr);
}
+14 -24
View File
@@ -5,15 +5,16 @@
// Adafruit Motorshield v2
// like this one: https://www.adafruit.com/products/1438
// based on this library: https://github.com/adafruit/Adafruit_Motor_Shield_V2_Library
// Currently DC Motors and Steppers are implemented, Servos are missing!!!
// written by https://github.com/krikk
// Currently DC Motors and Steppers are implemented, Servos are in default firmware!!!
#ifdef PLUGIN_BUILD_DEV
#ifdef PLUGIN_BUILD_TESTING
#include <Adafruit_MotorShield.h>
#define PLUGIN_048
#define PLUGIN_ID_048 48
#define PLUGIN_NAME_048 "Motor - Adafruit Motorshield v2 [DEVELOPMENT]"
#define PLUGIN_NAME_048 "Motor - Adafruit Motorshield v2 [TEST]"
#define PLUGIN_VALUENAME1_048 "MotorShield v2"
uint8_t Plugin_048_MotorShield_address = 0x60;
@@ -57,25 +58,14 @@ boolean Plugin_048(byte function, struct EventStruct *event, String& string) {
case PLUGIN_WEBFORM_LOAD: {
string +=
F("<TR><TD>I2C Address (Hex): <TD><input type='text' title='Set i2c Address of sensor' name='");
string += F("plugin_048_adr' value='0x");
string += String(Settings.TaskDevicePluginConfig[event->TaskIndex][0],HEX);
string += F("'>");
string +=
F("<TR><TD>Stepper: steps per revolution: <TD><input type='text' title='Set steps per revolution for steppers' name='");
string += F("plugin_048_MotorStepsPerRevolution' value='");
string += String(Settings.TaskDevicePluginConfig[event->TaskIndex][1]);
string += F("'>");
string +=
F("<TR><TD>Stepper speed (rpm): <TD><input type='text' title='Set speed of the stepper motor rotation in RPM' name='");
string += F("plugin_048_StepperSpeed' value='");
string += String(Settings.TaskDevicePluginConfig[event->TaskIndex][2]);
string += F("'>");
addFormTextBox(string, F("I2C Address (Hex)"), F("plugin_048_adr"), String(F("0x")) +
String(Settings.TaskDevicePluginConfig[event->TaskIndex][0],HEX), 4);
addFormNumericBox(string, F("Stepper: steps per revolution"), F("plugin_048_MotorStepsPerRevolution")
, Settings.TaskDevicePluginConfig[event->TaskIndex][1]);
addFormNumericBox(string, F("Stepper speed (rpm)"), F("plugin_048_StepperSpeed")
, Settings.TaskDevicePluginConfig[event->TaskIndex][2]);
success = true;
break;
@@ -84,10 +74,10 @@ boolean Plugin_048(byte function, struct EventStruct *event, String& string) {
case PLUGIN_WEBFORM_SAVE: {
String plugin1 = WebServer.arg(F("plugin_048_adr"));
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = (int) strtol(plugin1.c_str(), 0, 16);
String plugin2 = WebServer.arg(F("plugin_048_MotorStepsPerRevolution"));
Settings.TaskDevicePluginConfig[event->TaskIndex][1] = plugin2.toInt();
String plugin3 = WebServer.arg(F("plugin_048_StepperSpeed"));
Settings.TaskDevicePluginConfig[event->TaskIndex][2] = plugin3.toInt();
Settings.TaskDevicePluginConfig[event->TaskIndex][1] = getFormItemInt(F("plugin_048_MotorStepsPerRevolution"));
Settings.TaskDevicePluginConfig[event->TaskIndex][2] = getFormItemInt(F("plugin_048_StepperSpeed"));
success = true;
break;
}
+2 -26
View File
@@ -78,19 +78,7 @@ boolean Plugin_050(byte function, struct EventStruct *event, String& string)
optionValuesMode[3] = TCS34725_INTEGRATIONTIME_101MS;
optionValuesMode[4] = TCS34725_INTEGRATIONTIME_154MS;
optionValuesMode[5] = TCS34725_INTEGRATIONTIME_700MS;
string += F("<TR><TD>Integration Time:<TD><select name='plugin_050_integrationTime'>");
for (byte x = 0; x < 6; x++)
{
string += F("<option value='");
string += optionValuesMode[x];
string += "'";
if (choiceMode == optionValuesMode[x])
string += F(" selected");
string += ">";
string += optionsMode[x];
string += F("</option>");
}
string += F("</select>");
addFormSelector(string, F("Integration Time"), F("plugin_050_integrationTime"), 6, optionsMode, optionValuesMode, choiceMode);
byte choiceMode2 = Settings.TaskDevicePluginConfig[event->TaskIndex][1];
String optionsMode2[4];
@@ -103,19 +91,7 @@ boolean Plugin_050(byte function, struct EventStruct *event, String& string)
optionValuesMode2[1] = TCS34725_GAIN_4X;
optionValuesMode2[2] = TCS34725_GAIN_16X;
optionValuesMode2[3] = TCS34725_GAIN_60X;
string += F("<TR><TD>Gain:<TD><select name='plugin_050_gain'>");
for (byte x = 0; x < 4; x++)
{
string += F("<option value='");
string += optionValuesMode2[x];
string += "'";
if (choiceMode2 == optionValuesMode2[x])
string += F(" selected");
string += ">";
string += optionsMode2[x];
string += F("</option>");
}
string += F("</select>");
addFormSelector(string, F("Gain"), F("plugin_050_gain"), 4, optionsMode2, optionValuesMode2, choiceMode2);
success = true;
break;
+104
View File
@@ -0,0 +1,104 @@
//#######################################################################################################
//#################### Plugin 051 Temperature and Humidity Sensor AM2320 ##############
//#######################################################################################################
//
// Temperature and Humidity Sensor AM2320
// written by https://github.com/krikk
// based on this library: https://github.com/thakshak/AM2320
// this code is based on git-version https://github.com/thakshak/AM2320/commit/ddaabaf37952d4c74f3ea70af20e5a95cfdfcadb
// of the above library
//
#ifdef PLUGIN_BUILD_TESTING
#include <AM2320.h>
#define PLUGIN_051
#define PLUGIN_ID_051 51
#define PLUGIN_NAME_051 "Environment - AM2320 [TEST]"
#define PLUGIN_VALUENAME1_051 "Temperature"
#define PLUGIN_VALUENAME2_051 "Humidity"
boolean Plugin_051(byte function, struct EventStruct *event, String& string)
{
boolean success = false;
switch (function)
{
case PLUGIN_DEVICE_ADD:
{
Device[++deviceCount].Number = PLUGIN_ID_051;
Device[deviceCount].Type = DEVICE_TYPE_I2C;
Device[deviceCount].VType = SENSOR_TYPE_TEMP_HUM;
Device[deviceCount].Ports = 0;
Device[deviceCount].PullUpOption = false;
Device[deviceCount].InverseLogicOption = false;
Device[deviceCount].FormulaOption = true;
Device[deviceCount].ValueCount = 2;
Device[deviceCount].SendDataOption = true;
Device[deviceCount].TimerOption = true;
Device[deviceCount].GlobalSyncOption = true;
break;
}
case PLUGIN_GET_DEVICENAME:
{
string = F(PLUGIN_NAME_051);
break;
}
case PLUGIN_GET_DEVICEVALUENAMES:
{
strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[0], PSTR(PLUGIN_VALUENAME1_051));
strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[1], PSTR(PLUGIN_VALUENAME2_051));
break;
}
case PLUGIN_WEBFORM_LOAD:
{
success = true;
break;
}
case PLUGIN_WEBFORM_SAVE:
{
success = true;
break;
}
case PLUGIN_READ:
{
AM2320 th;
switch(th.Read()) {
case 2:
addLog(LOG_LEVEL_ERROR, F("AM2320: CRC failed"));
break;
case 1:
addLog(LOG_LEVEL_ERROR, F("AM2320: Sensor offline"));
break;
case 0:
UserVar[event->BaseVarIndex] = th.t;
UserVar[event->BaseVarIndex + 1] = th.h;
String log = F("AM2320: Temperature: ");
log += UserVar[event->BaseVarIndex];
addLog(LOG_LEVEL_INFO, log);
log = F("AM2320: Humidity: ");
log += UserVar[event->BaseVarIndex + 1];
addLog(LOG_LEVEL_INFO, log);
success = true;
break;
}
}
}
return success;
}
#endif
+250
View File
@@ -0,0 +1,250 @@
//#######################################################################################################
//############################# Plugin 052: SenseAir CO2 Sensors ########################################
//#######################################################################################################
/*
Plugin originally written by: Daniel Tedenljung info__AT__tedenljungconsulting.com
Rewritten by: Mikael Trieb mikael__AT__triebconsulting.se
This plugin reads availble values of SenseAir Co2 Sensors.
Datasheet can be found here:
S8: http://www.senseair.com/products/oem-modules/senseair-s8/
K30: http://www.senseair.com/products/oem-modules/k30/
K70/tSENSE: http://www.senseair.com/products/wall-mount/tsense/
Circuit wiring
GPIO Setting 1 -> RX
GPIO Setting 2 -> TX
Use 1kOhm in serie on datapins!
*/
#ifdef PLUGIN_BUILD_TESTING
#define PLUGIN_052
#define PLUGIN_ID_052 52
#define PLUGIN_NAME_052 "SenseAir"
#define PLUGIN_VALUENAME1_052 ""
boolean Plugin_052_init = false;
#include <SoftwareSerial.h>
SoftwareSerial *Plugin_052_SoftSerial;
boolean Plugin_052(byte function, struct EventStruct *event, String& string)
{
boolean success = false;
switch (function)
{
case PLUGIN_DEVICE_ADD:
{
Device[++deviceCount].Number = PLUGIN_ID_052;
Device[deviceCount].Type = DEVICE_TYPE_DUAL;
Device[deviceCount].VType = SENSOR_TYPE_SINGLE;
Device[deviceCount].Ports = 0;
Device[deviceCount].PullUpOption = false;
Device[deviceCount].InverseLogicOption = false;
Device[deviceCount].FormulaOption = true;
Device[deviceCount].ValueCount = 1;
Device[deviceCount].SendDataOption = true;
Device[deviceCount].TimerOption = true;
Device[deviceCount].GlobalSyncOption = true;
break;
}
case PLUGIN_GET_DEVICENAME:
{
string = F(PLUGIN_NAME_052);
break;
}
case PLUGIN_GET_DEVICEVALUENAMES:
{
strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[0], PSTR(PLUGIN_VALUENAME1_052));
break;
}
case PLUGIN_WEBFORM_LOAD:
{
byte choice = Settings.TaskDevicePluginConfig[event->TaskIndex][0];
String options[4] = { F("Status"), F("Carbon Dioxide"), F("Temperature"), F("Humidity") };
addFormSelector(string, F("Sensor"), F("plugin_052"), 4, options, NULL, choice);
success = true;
break;
}
case PLUGIN_WEBFORM_SAVE:
{
String plugin1 = WebServer.arg(F("plugin_052"));
Settings.TaskDevicePluginConfig[event->TaskIndex][0] = plugin1.toInt();
success = true;
break;
}
case PLUGIN_INIT:
{
Plugin_052_init = true;
Plugin_052_SoftSerial = new SoftwareSerial(Settings.TaskDevicePin1[event->TaskIndex],
Settings.TaskDevicePin2[event->TaskIndex]);
success = true;
break;
}
case PLUGIN_READ:
{
if (Plugin_052_init)
{
String log = F("SenseAir ");
switch(Settings.TaskDevicePluginConfig[event->TaskIndex][0])
{
case 0:
{
int sensor_status = Plugin_052_readStatus();
UserVar[event->BaseVarIndex] = sensor_status;
log += F("status: ");
log += sensor_status;
break;
}
case 1:
{
int co2 = Plugin_052_readCo2();
UserVar[event->BaseVarIndex] = co2;
log += F("co2: ");
log += co2;
break;
}
case 2:
{
float temperature = Plugin_052_readTemperature();
UserVar[event->BaseVarIndex] = (float)temperature;
log += F("temperature: ");
log += (float)temperature;
break;
}
case 3:
{
float relativeHumidity = Plugin_052_readRelativeHumidity();
UserVar[event->BaseVarIndex] = (float)relativeHumidity;
log += F("humidity: ");
log += (float)relativeHumidity;
break;
}
}
addLog(LOG_LEVEL_INFO, log);
success = true;
break;
}
break;
}
}
return success;
}
void Plugin_052_buildFrame(byte slaveAddress,
byte functionCode,
short startAddress,
short numberOfRegisters,
byte frame[8])
{
frame[0] = slaveAddress;
frame[1] = functionCode;
frame[2] = (byte)(startAddress >> 8);
frame[3] = (byte)(startAddress);
frame[4] = (byte)(numberOfRegisters >> 8);
frame[5] = (byte)(numberOfRegisters);
// CRC-calculation
byte checkSum[2] = {0};
unsigned int crc = Plugin_052_ModRTU_CRC(frame, 6, checkSum);
frame[6] = checkSum[0];
frame[7] = checkSum[1];
}
int Plugin_052_sendCommand(byte command[])
{
byte recv_buf[7] = {0xff};
byte data_buf[2] = {0xff};
long value = -1;
Plugin_052_SoftSerial->write(command, 8); //Send the byte array
delay(50);
// Read answer from sensor
int ByteCounter = 0;
while(Plugin_052_SoftSerial->available()) {
recv_buf[ByteCounter] = Plugin_052_SoftSerial->read();
ByteCounter++;
}
data_buf[0] = recv_buf[3];
data_buf[1] = recv_buf[4];
value = (data_buf[0] << 8) | (data_buf[1]);
return value;
}
int Plugin_052_readStatus(void)
{
int sensor_status = -1;
byte frame[8] = {0};
Plugin_052_buildFrame(0xFE, 0x04, 0x00, 1, frame);
sensor_status = Plugin_052_sendCommand(frame);
return sensor_status;
}
int Plugin_052_readCo2(void)
{
int co2 = 0;
byte frame[8] = {0};
Plugin_052_buildFrame(0xFE, 0x04, 0x03, 1, frame);
co2 = Plugin_052_sendCommand(frame);
return co2;
}
float Plugin_052_readTemperature(void)
{
int temperatureX100 = 0;
float temperature = 0.0;
byte frame[8] = {0};
Plugin_052_buildFrame(0xFE, 0x04, 0x04, 1, frame);
temperatureX100 = Plugin_052_sendCommand(frame);
temperature = temperatureX100/100;
return temperature;
}
float Plugin_052_readRelativeHumidity(void)
{
int rhX100 = 0;
float rh = 0.0;
byte frame[8] = {0};
Plugin_052_buildFrame(0xFE, 0x04, 0x05, 1, frame);
rhX100 = Plugin_052_sendCommand(frame);
rh = rhX100/100;
return rh;
}
// Compute the MODBUS RTU CRC
unsigned int Plugin_052_ModRTU_CRC(byte buf[], int len, byte checkSum[2])
{
unsigned int crc = 0xFFFF;
for (int pos = 0; pos < len; pos++) {
crc ^= (unsigned int)buf[pos]; // XOR byte into least sig. byte of crc
for (int i = 8; i != 0; i--) { // Loop over each bit
if ((crc & 0x0001) != 0) { // If the LSB is set
crc >>= 1; // Shift right and XOR 0xA001
crc ^= 0xA001;
}
else // Else LSB is not set
crc >>= 1; // Just shift right
}
}
// Note, this number has low and high bytes swapped, so use it accordingly (or swap bytes)
checkSum[1] = (byte)((crc >> 8) & 0xFF);
checkSum[0] = (byte)(crc & 0xFF);
return crc;
}
#endif
+208
View File
@@ -0,0 +1,208 @@
//#######################################################################################################
//#################################### Plugin 053: Plantower PMSx003 ####################################
//#######################################################################################################
//
// http://www.aqmd.gov/docs/default-source/aq-spec/resources-page/plantower-pms5003-manual_v2-3.pdf?sfvrsn=2
//
// The PMSx005 are particle sensors. Particles are measured by blowing air though the enclosue and,
// togther with a laser, count the amount of particles. These sensors have an integrated microcontroller
// that counts particles and transmits measurement data over the serial connection.
#ifdef PLUGIN_BUILD_TESTING
#define PLUGIN_053
#define PLUGIN_ID_053 53
#define PLUGIN_NAME_053 "Particle Sensor - PMSx003"
#define PLUGIN_VALUENAME1_053 "pm1.0"
#define PLUGIN_VALUENAME2_053 "pm2.5"
#define PLUGIN_VALUENAME3_053 "pm10"
boolean Plugin_053_init = false;
byte Plugin_PMSx003_UART = 0;
byte timer = 0;
boolean values_received = false;
void SerialRead16(uint16_t* value, uint16_t* checksum)
{
uint8_t data_high, data_low;
while(Serial.available() == 0) {};
data_high = Serial.read();
while(Serial.available() == 0) {};
data_low = Serial.read();
*value = data_low;
*value |= (data_high << 8);
if (checksum != NULL)
{
*checksum += data_high;
*checksum += data_low;
}
// Low-level logging to see data from sensor
#if 0
String log = F("PMSx003 : byte high=0x");
log += String(data_high,HEX);
log += F(" byte low=0x");
log += String(data_low,HEX);
log += F(" result=0x");
log += String(*value,HEX);
addLog(LOG_LEVEL_INFO, log);
#endif
}
boolean Plugin_053(byte function, struct EventStruct *event, String& string)
{
boolean success = false;
switch (function)
{
case PLUGIN_DEVICE_ADD:
{
Device[++deviceCount].Number = PLUGIN_ID_053;
Device[deviceCount].Type = DEVICE_TYPE_DUAL;
Device[deviceCount].VType = SENSOR_TYPE_TRIPLE;
Device[deviceCount].Ports = 0;
Device[deviceCount].PullUpOption = false;
Device[deviceCount].InverseLogicOption = false;
Device[deviceCount].FormulaOption = false;
Device[deviceCount].ValueCount = 3;
Device[deviceCount].SendDataOption = true;
Device[deviceCount].TimerOption = true;
Device[deviceCount].GlobalSyncOption = true;
success = true;
break;
}
case PLUGIN_GET_DEVICENAME:
{
string = F(PLUGIN_NAME_053);
success = true;
break;
}
case PLUGIN_GET_DEVICEVALUENAMES:
{
strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[0], PSTR(PLUGIN_VALUENAME1_053));
strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[1], PSTR(PLUGIN_VALUENAME2_053));
strcpy_P(ExtraTaskSettings.TaskDeviceValueNames[2], PSTR(PLUGIN_VALUENAME3_053));
success = true;
break;
}
case PLUGIN_INIT:
{
Serial.begin(9600);
// Toggle 'reset' to assure we start reading header
pinMode(Settings.TaskDevicePin1[event->TaskIndex], OUTPUT);
digitalWrite(Settings.TaskDevicePin1[event->TaskIndex], LOW);
delay(250);
digitalWrite(Settings.TaskDevicePin1[event->TaskIndex], HIGH);
pinMode(Settings.TaskDevicePin1[event->TaskIndex], INPUT_PULLUP);
// Put device in suspend by driving 'set'low
pinMode(Settings.TaskDevicePin2[event->TaskIndex], OUTPUT);
digitalWrite(Settings.TaskDevicePin2[event->TaskIndex], HIGH);
Plugin_053_init = true;
success = true;
break;
}
case PLUGIN_ONCE_A_SECOND:
{
// Do measurements only every 30 seconds
#if 0
if ((timer++) % 30 == 0)
if (digitalRead(Settings.TaskDevicePin2[event->TaskIndex]))
digitalWrite(Settings.TaskDevicePin2[event->TaskIndex], LOW);
else
digitalWrite(Settings.TaskDevicePin2[event->TaskIndex], HIGH);
#endif
success = true;
}
case PLUGIN_SERIAL_IN:
{
if (Plugin_053_init)
{
uint16_t checksum = 0, checksum2 = 0;
uint16_t framelength = 0;
uint16_t data[13];
byte data_low, data_high;
int i = 0;
String log;
// Check for 2-byte header. A total of 32 bytes is to be received.
if (Serial.read() == 0x42 && Serial.read() == 0x4d)
{
checksum += 0x42 + 0x4d;
SerialRead16(&framelength, &checksum);
if (framelength != 28)
{
log = F("PMSx003 : invalid framelength - ");
log+=framelength;
addLog(LOG_LEVEL_INFO, log);
break;
}
for (i = 0; i < 13; i++)
{
SerialRead16(&data[i], &checksum);
}
log = F("PMSx003 : pm1.0=");
log += data[0];
log += F(", pm2.5=");
log += data[1];
log += F(", pm10=");
log += data[2];
log += F(", pm1.0a=");
log += data[3];
log += F(", pm2.5a=");
log += data[4];
log += F(", pm10a=");
log += data[5];
addLog(LOG_LEVEL_INFO, log);
log = F("PMSx003 : count/0.1L : 0.3um=");
log += data[6];
log += F(", 0.5um=");
log += data[7];
log += F(", 1.0um=");
log += data[8];
log += F(", 2.5um=");
log += data[9];
log += F(", 5.0um=");
log += data[10];
log += F(", 10um=");
log += data[11];
addLog(LOG_LEVEL_INFO, log);
// Compare checksums
SerialRead16(&checksum2, NULL);
if (checksum == checksum2)
{
/* Data is checked and good, fill in output */
UserVar[event->BaseVarIndex] = data[3];
UserVar[event->BaseVarIndex + 1] = data[4];
UserVar[event->BaseVarIndex + 2] = data[5];
values_received = true;
}
}
}
success = true;
break;
}
case PLUGIN_READ:
{
// Prevent sending data to controller when nothing received yet
if (values_received)
success = true;
break;
}
}
return success;
}
#endif // PLUGIN_BUILD_TESTING