Compare commits

...
1015 Commits
Author SHA1 Message Date
ESPEasy release bot a151e60755 automaticly updated release notes for mega-20180414 2018-04-14 04:00:08 +02:00
Gijs NoorlanderandGitHub ce11c84e74 Merge pull request #1186 from linuxnico/mega
add ds1822 definition to ds_read_temp function
2018-04-14 00:13:39 +02:00
Gijs NoorlanderandGitHub 9808bf86c4 Merge pull request #1078 from GHolli/mega
Sensor MH-Z19: Fixing offsets for the detection range setting command
2018-04-14 00:13:04 +02:00
Gijs NoorlanderandGitHub cfae636e55 Merge pull request #1240 from TD-er/feature/bssid_channel_variables
[issue #1239] %bssid% and %wi_ch% added as variables
2018-04-14 00:09:23 +02:00
Gijs NoorlanderandGitHub ebaaf50df6 Merge pull request #1230 from Grovkillen/Fix-nomenclature-for-delay/interval
Renamed delay to interval/time for better understanding
2018-04-14 00:09:09 +02:00
Gijs NoorlanderandGitHub 5c0be9e89f Merge pull request #1193 from clumsy-stefan/patch-1
_P015_TSL2561 added Broadband and IR Values
2018-04-14 00:07:32 +02:00
Gijs NoorlanderandGitHub 36468663f7 Merge pull request #1210 from giig1967g/mega
Fixes for #1208 and partial #1196
2018-04-14 00:05:36 +02:00
TD-er fba32608ee [issue #1239] %bssid% and %wi_ch% added as variables
See #1239
2018-04-13 23:47:08 +02:00
GrovkillenandGitHub 06848e50c3 Fixed main page!
Table was messed up... also update other tables
2018-04-13 23:46:45 +02:00
GrovkillenandGitHub 879d0d4916 Added better(?) format for tables
Fixed "normal" and "multirow" table css and made some column widths fixed.
2018-04-13 15:47:13 +02:00
ESPEasy release bot d083a58cd7 automaticly updated release notes for mega-20180413 2018-04-13 04:00:09 +02:00
Gijs NoorlanderandGitHub b1e9ff9fdc Merge pull request #1234 from TD-er/bugfix/Wifi_connection_issues
[wifi] Event based wifi, fix set AP and crash on start
2018-04-13 01:51:45 +02:00
TD-er 304280f415 [wifi] Event based wifi, fix set AP and crash on start
The settings had 2 new values which would be overwriten by the checksum and there was still some issue about when to save the settings.

Also added a check to only save changed settings.

Known issue: 
Sometimes after initial setup of wifi credentials, it is best to perform a reset.
2018-04-13 01:48:22 +02:00
GrovkillenandGitHub 2c8ca1421f Removed the serial print "done." 2018-04-12 09:55:11 +02:00
GrovkillenandGitHub 3ce0fb9f75 Merge branch 'mega' into Fix-nomenclature-for-delay/interval 2018-04-12 09:28:48 +02:00
ESPEasy release bot 8a71d2abd6 automaticly updated release notes for mega-20180412 2018-04-12 04:00:14 +02:00
Gijs NoorlanderandGitHub 1b174f4eac Merge pull request #1224 from flexiti/mega
ESP32 cpu speed and Id
2018-04-12 01:25:45 +02:00
Gijs NoorlanderandGitHub f1d18c7b41 Merge pull request #1220 from TD-er/bugfix/SoftAP_event_based_wifi
[issue #1215] Cannot login to accesspoint on new install
2018-04-12 01:22:46 +02:00
TD-er 204d4607ba Merge remote-tracking branch 'upstream/mega' into bugfix/SoftAP_event_based_wifi 2018-04-12 01:12:28 +02:00
TD-er 51f7ce0cb6 [wifi] Event based wifi, improve scan information. 2018-04-12 01:07:39 +02:00
Gijs NoorlanderandGitHub 1d4147309c [MQTT] Process MQTT loop on publish
As [discussed here](https://github.com/letscontrolit/ESPEasy/issues/1228#issuecomment-380420609).
2018-04-11 15:29:49 +02:00
mvdbro a68e4c1456 Merge branch 'mega' of https://github.com/letscontrolit/ESPEasy into mega 2018-04-11 14:57:22 +02:00
mvdbro 2ee51363dd Reboot/Reset pin, build 20101 patch 2018-04-11 14:57:12 +02:00
TD-er 172eb37b5b [wifi] Fix wifi AP setup mode for ESP32. 2018-04-11 01:24:34 +02:00
GrovkillenandGitHub 68e1d8ea69 Added RSSI, BSSID, Channel to WifiScan/Setup
And also delay is now renamed interval.
2018-04-10 15:47:59 +02:00
GrovkillenandGitHub ac8e8db0e7 Merge pull request #1 from letscontrolit/mega
Update
2018-04-10 14:24:17 +02:00
ESPEasy release bot d72bf9b76c automaticly updated release notes for mega-20180410 2018-04-10 04:00:21 +02:00
GeraldandGitHub 6d3f535d16 Merge pull request #3 from letscontrolit/mega
Downstream updates from head fork.
2018-04-09 21:39:15 +02:00
GrovkillenandGitHub 0709763f3a Update issue_template.md
`YOUR TEXT GOES HERE` added
2018-04-09 13:09:59 +02:00
GrovkillenandGitHub 538d843643 Update issue_template.md
Rearranged the topics...
2018-04-09 13:07:56 +02:00
GrovkillenandGitHub 2339ee928c Update issue_template.md
Added code format
2018-04-09 13:05:55 +02:00
GrovkillenandGitHub 9550b951d5 Update issue_template.md
Added a "Summarize" topic
2018-04-09 12:55:43 +02:00
GrovkillenandGitHub 0491af8a2f Added comments that will not show up on issues
Many users forget to "clean" the template from unnecessary text... these are now automatically hidden.
2018-04-09 12:53:05 +02:00
ESPEasy release bot 806a2757b2 automaticly updated release notes for mega-20180409 2018-04-09 04:00:13 +02:00
TD-er 3931b71d00 Merge branch 'mega' into bugfix/SoftAP_event_based_wifi 2018-04-09 00:17:48 +02:00
TD-er af0c3d5f62 [wifi] Make it work for ESP32 again 2018-04-08 23:50:07 +02:00
mvdbro c7a6ca4555 Both reset/factoryreset option 2018-04-08 17:05:59 +02:00
mvdbro 4a01e2eb49 Factory Reset (not enabled yet) 2018-04-08 08:27:25 +02:00
TD-er d6ff20b35d [WiFi] Event based wifi, now AP mode works
It appeared to be related to the core 2.3.0 version. The 2.4.0 does just work. Also changed a number of other things to improve stability.
2018-04-08 00:34:34 +02:00
ESPEasy release bot 0ada9aa105 automaticly updated release notes for mega-20180407 2018-04-07 04:00:12 +02:00
Holli 6b04539571 Disable detection range commands by default. 2018-04-06 18:40:08 +02:00
Plebs 9380ec13dc Added #I
#I: IN/OUT
2018-04-06 12:41:00 +02:00
GrovkillenandGitHub ae946c27c0 Fixed clickable link www.letscontrolit.com (#1192) 2018-04-06 10:02:36 +02:00
Plebs 86cf00759f added more formats
#X
#y
#Z
2018-04-06 08:38:26 +02:00
Plebs 0eb5f55d63 new #formats
Hi, here the new formats:
#O: ON/OFF
#C: Open/Close
#U: UP/Down
#Y: YES/NO
#D: converto to nearest integer
#F: convert to floor
#E: convert to ceiling
2018-04-05 23:39:54 +02:00
flexitiandGitHub f27d2aa7eb ESP CPU speed and ID 2018-04-05 15:09:24 +02:00
flexitiandGitHub 2d3285aaaf Merge pull request #1 from letscontrolit/mega
update
2018-04-05 15:05:25 +02:00
ESPEasy release bot 5bd2532853 automaticly updated release notes for mega-20180405 2018-04-05 04:00:10 +02:00
Plebs 765c56ccef modified float() call 2018-04-05 00:20:38 +02:00
mvdbro 4c755d83a6 ESP32 RTOS 10 per second
Run 10 per seconds call independent from main loop
2018-04-04 21:55:50 +02:00
mvdbro 1b9e1b92aa ESP32 RTOS config setting 2018-04-04 12:32:17 +02:00
Gijs NoorlanderandGitHub a4c73cc91e Merge pull request #1175 from Grovkillen/Fix-parsing-structure-for-JSON-+-upload-file-filter
Updated JSON path for sensor values and names
2018-04-04 10:06:17 +02:00
Gijs NoorlanderandGitHub 736fe2111a Merge pull request #1218 from soif/Fix/PioConfTypo
Unwanted lib_ignore now properly commented
2018-04-04 10:05:22 +02:00
Gijs NoorlanderandGitHub 767b0af733 Merge pull request #1217 from soif/Feat/JsonLoad
Shows CPU Load in JSON page
2018-04-04 10:04:59 +02:00
TD-er 02255180e9 [Wifi] Use statemachine to move between Wifi states
Still existing problems:
- Credentials are not being saved from web interface and thus connection doesn't work from setup page.
- First time connect to SoftAP takes a lot of attempts, when the wifi was searching for an existing accesspoint. This searching does prevent the SoftAP to form a stable connection to the client.

Maybe the entire wifi stack has to be reset before switching to SoftAP. Now it is near to impossible to recover from incorrect settings or a changes accesspoint.
Still under investigation.

It looks to be a problem with the
2018-04-04 03:19:03 +02:00
ESPEasy release bot c3bde94f7a automaticly updated release notes for mega-20180403 2018-04-03 04:00:14 +02:00
TD-er 886958d479 Merge remote-tracking branch 'origin/bugfix/SoftAP_event_based_wifi' into bugfix/SoftAP_event_based_wifi 2018-04-03 01:04:22 +02:00
TD-er 84cbc19f38 [issue #1215] Cannot login to accesspoint on new install
Since event based wifi, it became more apparent the ESP8266 has some issues with running AP and STA mode simultaneous.
It appears this can only work when the channel remains constant. But when trying to connect to an accesspoint that channel will change.
This means Soft AP and STA cannot be active at the same time when searching for an accesspoint to connect to. For example login to the Soft AP to correct some settings or replace an accesspoint would not be possible.

This fix deals with all of these issues and keeps the fast try/fail connection attempts offered by the event based wifi.
In short:
- 3x attempt to connect to AP1 (each attempt takes about 2.5 seconds when failing)
- 3x attempt to connect to AP2
- Enable accesspoint

When accesspoint is active, the connect attempts will be done at a slower pace and STA mode is disabled. STA mode is also disabled as soon as someone connects to the Soft AP.
When the settings are saved, a retry to connect like normal is started almost immediately. N.B. This will result in a disconnect of the connected users to the Soft AP.

So the connection time is:
- AP1 is valid: 4 - 10 seconds
- AP1 is not valid, AP2 is: 12 - 20 seconds
- AP1 and AP2 are not valid: +/- 18 seconds before activating Soft AP
2018-04-03 01:03:27 +02:00
TD-er 178ec9dfa9 [issue #1215] Cannot login to accesspoint on new install
Since event based wifi, it became more apparent the ESP8266 has some issues with running AP and STA mode simultaneous.
It appears this can only work when the channel remains constant. But when trying to connect to an accesspoint that channel will change.
This means Soft AP and STA cannot be active at the same time when searching for an accesspoint to connect to. For example login to the Soft AP to correct some settings or replace an accesspoint would not be possible.

This fix deals with all of these issues and keeps the fast try/fail connection attempts offered by the event based wifi.
In short:
- 3x attempt to connect to AP1 (each attempt takes about 2.5 seconds when failing)
- 3x attempt to connect to AP2
- Enable accesspoint

When accesspoint is active, the connect attempts will be done at a slower pace and STA mode is disabled. STA mode is also disabled as soon as someone connects to the Soft AP.
When the settings are saved, a retry to connect like normal is started almost immediately. N.B. This will result in a disconnect of the connected users to the Soft AP.

So the connection time is:
- AP1 is valid: 4 - 10 seconds
- AP1 is not valid, AP2 is: 12 - 20 seconds
- AP1 and AP2 are not valid: +/- 18 seconds before activating Soft AP
2018-04-03 00:47:06 +02:00
GrovkillenandGitHub 080be1ad0a Update _P029_Output.ino 2018-04-02 20:41:22 +02:00
GrovkillenandGitHub 232ca4f215 Update _P038_NeoPixel.ino 2018-04-02 20:40:08 +02:00
mvdbro bfa6eac538 ESP32 prep for RTOS multitasking 2018-04-02 15:59:01 +02:00
moi 0ca06782b9 unwanted lib_ignore now properly commented 2018-04-02 13:27:02 +02:00
moi 2079b0f28b Adds CPU Load LC in JSON page 2018-04-02 12:39:14 +02:00
moi 32bf45e817 Show CPU Load in JSON page 2018-04-02 12:38:30 +02:00
ESPEasy release bot 5d41bf9e73 automaticly updated release notes for mega-20180402 2018-04-02 04:00:10 +02:00
Gijs Noorlander dc5a2fd956 Revert "Merge pull request #1205 from s0170071/SerialSwap"
This reverts commit 46586e5355.
2018-04-01 10:47:50 +02:00
ESPEasy release bot b20f05305b automaticly updated release notes for mega-20180401 2018-04-01 04:00:08 +02:00
Gijs NoorlanderandGitHub 46586e5355 Merge pull request #1205 from s0170071/SerialSwap
Serial Swap function
2018-04-01 01:17:51 +02:00
Gijs NoorlanderandGitHub 7e8a751657 Merge pull request #1203 from TD-er/feature/mqtt_disconnect_event
[issue #1201] MQTT#Disconnected event and MQTT stability improvements
2018-04-01 01:14:55 +02:00
TD-er 7d61e55d34 [deepsleep] Allow for some minimum wifi connect time
In Deepsleep mode the wifi connect time is now minimum of 6 seconds.
Also the first loop after connect, the 'awake' timer will reset and start over. Without WiFi connection the set 'awake' timer starts at the moment the node boots.
2018-03-31 23:53:15 +02:00
GrovkillenandGitHub 2f663429a3 P0059 (rotary encoder) and P0063 (ttp229, keypad)
These two plugins are not in test but in normal.
2018-03-31 19:52:25 +02:00
ESPEasy release bot 492791a4ac automaticly updated release notes for mega-20180331 2018-03-31 04:00:09 +02:00
TD-er 52e75ade78 Merge remote-tracking branch 'origin/feature/mqtt_disconnect_event' into feature/mqtt_disconnect_event 2018-03-31 01:42:19 +02:00
TD-er 525a0ba0a1 [issue #1201] MQTT#Disconnected event and MQTT stability improvements
While looking for issues regarding DeepSleep + MQTT and issue #1195, I came across a number of other issues related to high CPU load and WiFi disconnects when a MQTT controller cannot reach the MQTT broker or is set to be no longer enabled.

These fixes improve CPU load and WiFi stability and also send the following events:
- `MQTT#Connected` 
- `MQTT#Disconnected`
- `MQTTimport#Connected` 
- `MQTTimport#Disconnected`

The MQTTimport plugin still has some major issues which have to be taken care of, so #1195 is not fixed yet.
2018-03-31 01:34:50 +02:00
Gijs NoorlanderandGitHub 52c7e5012e Merge pull request #1212 from TD-er/bugfix/build_issues_ESP32_ESP8266
[Build ESP32] Fix for build issues between ESP32 and ESP8266
2018-03-31 01:32:13 +02:00
TD-er 4dd733eb63 [ESP32] Build errors/warnings 2018-03-31 00:53:25 +02:00
TD-er 02a065d623 [Build ESP32] Fix for build issues between ESP32 and ESP8266
There is a problem with the PlatformIO builder since the last update of @mvdbro
It's an issue with the parsing of `#ifdef ESP32`.

It is very well explained here: [platformio/platformio-core#801 (comment)](https://github.com/platformio/platformio-core/issues/801#issuecomment-252447178)

In short, the event handling functions for the wifi have been moved to a separate .h file, since those files will be parsed properly by the Library Dependency Finder (LDF) in PlatformIO 3.x
2018-03-31 00:22:12 +02:00
Plebs e774ef5751 Fixes for #1208 and partial #1196
Fixed #1208
Added dìformat commands:
#C: 1/0 = Open/Close
#U: 1/0 = Up/Down
2018-03-30 21:05:33 +02:00
mvdbro 0afee4fafb ESP32: Fix Wifi Disconnect reason 2018-03-30 16:21:47 +02:00
s0170071 eba1fb3388 Serial Swap function
swaps Serial Pins *and* keeps track of it.
2018-03-30 08:47:55 +02:00
ESPEasy release bot b2c866edeb automaticly updated release notes for mega-20180330 2018-03-30 04:00:10 +02:00
TD-er 3583db3e22 [issue #1201] MQTT#Disconnected event and MQTT stability improvements
While looking for issues regarding DeepSleep + MQTT and issue #1195, I came across a number of other issues related to high CPU load and WiFi disconnects when a MQTT controller cannot reach the MQTT broker or is set to be no longer enabled.

These fixes improve CPU load and WiFi stability and also send the following events:
- `MQTT#Connected` 
- `MQTT#Disconnected`
- `MQTTimport#Connected` 
- `MQTTimport#Disconnected`

The MQTTimport plugin still has some major issues which have to be taken care of, so #1195 is not fixed yet.
2018-03-30 02:48:23 +02:00
GeraldandGitHub 5d3f8bf073 Update _P049_MHZ19.ino
Clarification of pin connections.
2018-03-29 21:28:25 +02:00
Gijs NoorlanderandGitHub 1a72444b0a Build issue with Arduino IDE
See https://github.com/letscontrolit/ESPEasy/issues/1188#issuecomment-377020065
2018-03-29 21:27:09 +02:00
GHolliandGitHub dd88db1913 Merge pull request #2 from letscontrolit/mega
Downstream updates
2018-03-29 20:10:05 +02:00
GHolliandGitHub aab00567fc Downstream updates (#1)
* Initial re-organisation of plugin sets (#1019)

* 12bit ADC values acceted up to 4095

MCP3221 is a 12bit ADC so accepted values should be up to 40195 not 1024

* automaticly updated release notes for v2.0-20180313

* - move all structs from ESPEasy.ino into header file
- add some fix for headers
- add const to rtttl notes array

* [issue #1066] Fix Webserver handle_control

There wasn't a proper start/end for the streaming webserver.
See discussion on issue #1066

* automaticly updated release notes for mega-20180314

* Custom controller GUI option

* Fixed #433

Not tested!

* #893, part 2 receiving

* Merge branch 'mega' of github.com:letscontrolit/ESPEasy into mega

# Conflicts:
#	src/ESPEasy.ino

* Rules fix

* #893 part1, send messages

* Custom controller GUI option

* #893, part 2 receiving

* Rules fix

* automaticly updated release notes for mega-20180315

* - move all structs from ESPEasy.ino into header file

- add some fix for headers
- add const to rtttl notes array

* Merge branch 'mega' of github.com:letscontrolit/ESPEasy into mega

# Conflicts:
#	src/ESPEasy.ino

* [v2.0 split globals] Base split on v2.0 version of ESPEasy.ino

*  MCP3221 allow values for calibration (#1073)

MCP3221 allow values for calibration

* [issue #1066] Fix Webserver handle_control (#1079)

[issue #1066] Fix Webserver handle_control

* Fixed multi instance problem on SHT3x #433 (#1081)

Fixed multi instance problem on SHT3x #433

* [issue #1057] AM PM display issue

X:XX PM (for hours 1...9)
X:XX AM (for hours 1...9)
XX:XX PM (for hours 10...12)
XX:XX AM (for hours 10...12)

Added for H:MM (without seconds) notations:
- `%systm_hm%`
-`%systm_hm_am%`

* [issue #993] variable in MQTT subscribe topic

As [noted](https://github.com/letscontrolit/ESPEasy/issues/993#issuecomment-373140135) by @kluszcyn

* [issue #951] Changed System#Initialized  => System#Wake

Changed System#Initialized  => System#Wake
New event name makes more sense and Initialized may be used later to indicate all needed connections, etc. are ready.

* [issue #1057] AM PM display issue

X:XX PM (for hours 1...9)
X:XX AM (for hours 1...9)
XX:XX PM (for hours 10...12)
XX:XX AM (for hours 10...12)

Added for H:MM (without seconds) notations:
- `%systm_hm%`
-`%systm_hm_am%`

* [issue #993] variable in MQTT subscribe topic

As [noted](https://github.com/letscontrolit/ESPEasy/issues/993#issuecomment-373140135) by @kluszcyn

* [issue #951] Changed System#Initialized  => System#Wake

Changed System#Initialized  => System#Wake
New event name makes more sense and Initialized may be used later to indicate all needed connections, etc. are ready.

* automaticly updated release notes for mega-20180316

* automaticly updated release notes for v2.0-20180316

* Add download button for current rule set

* - add encoder write #1086

* changed memory tracker to uint64_t for the ESP32

* Changed so that running all tasks immediately with deep sleep enabled only happens on first iteration after wake up

* Keep uint. Just change the init value.

* [WiFi] Try to minimize effect of WiFi interruptions

And send event when connected to a different accesspoint.
Currently the impact on WiFi reconnects is enorm. The ESP stalls, won't react on events, etc.

* - fix success setting

* - fix P073 success setting in PLUGIN_WRITE callback

* - initialize pointer in P073

* [Relaxed WiFi] Perform WiFi initialization in steps

Doing WiFi initialization in multiple steps, will reduce boot time a lot.
For deepsleep the Setup is waiting for wifi initialization to complete, but for normal use the wifi connection is initiated during setup and checked on regular intervals to see if it is available.
The same for WiFi reconnect, which will hopefully not affect the performance of the ESP module during reconnects.

Also added a check + event when connected to another accesspoint with different BSSID (MAC address of accesspoint). Also the last used BSSID is used to reconnect to try to connect to the same device over and over, which may be useful with WiFi repeaters.

* [Travis error] Some #include test that wasn't meant to be included

... in the commit.

* [JSON] Add uint name (#1099) and WiFi information (PR #1113)

As suggested by @Grovkillen on PR #1113.

* [issue #1007] Allow user specific data in separate file

File will be ignored by git and can be simply included using `-D USE_OWN_DEFAULTS` in the build

* #ifndef instead of #ifdef

* [issue #1007] Add other defines as suggested by @uzi18

* [Memory] parseTemplate did not check if markers were found

"Free Mem" reported this function to be using quite a lot of memory.
Maybe that was related to parsing texts without matching ']' or '#'
Just added some checks to see if they were found.

* [issue #1097] MQTT publish after deep sleep

The MQTTConnect was only called after a while. This is a problem for deepsleep.
So now the MQTT connect is done at the first loop when deep sleep is enabled.

* Add download button for current rule set (#1102)

Add download button for current rule set

* - add encoder write command #1086 (#1103)

- add encoder write command #1086

* Changed so that running all tasks immediately with deep sleep enabled… (#1110)

Changed so that running all tasks immediately with deep sleep enabled only happens on first iteration after wake up

* Merge pull request #1112 from uzi18/fix-p073

Fix p073 - #1111

* Merge pull request #1114 from TD-er/feature/wifi_details_json

[JSON] Add uint name (#1099) and WiFi information (PR #1113)

* Merge pull request #1113 from TD-er/feature/reduce_impact_wifi_disconnect

[Relaxed WiFi] Perform WiFi initialization in steps

* Merge pull request #1116 from TD-er/feature/allow_own_defaults

[issue #1007] Allow user specific data in separate file

* Merge pull request #1118 from TD-er/bugfix/mqtt_publish_after_deep_sleep

[issue #1097] MQTT publish after deep sleep

* [merge] MIssing #endif due to merging.

* automaticly updated release notes for mega-20180319

* automaticly updated release notes for v2.0-20180319

* Fix wiring description for SN75176 transceiver

* Revert "Merge pull request #1116 from TD-er/feature/allow_own_defaults"

This reverts commit 8ccbdcadf0.

* Fix wiring description for SN75176 transceiver

* Revert "Merge pull request #1116 from TD-er/feature/allow_own_defaults"

This reverts commit 8ccbdcadf0.

* [issue #1097] WiFi connect with deepsleep enabled trigger watchdog reset

Did not allow for enough time to do background tasks while waiting for wifi connect with DeepSleep enabled.

* [issue #1097] WiFi connect with deepsleep enabled trigger watchdog reset

Did not allow for enough time to do background tasks while waiting for wifi connect with DeepSleep enabled.

* automaticly updated release notes for mega-20180320

* automaticly updated release notes for v2.0-20180320

* [wifi] Setup with factory settings could not complete

* [wifi] Setup with factory settings could not complete

* [merge issue] Forgotten #endif in merge

* - P012 fix command interpretation

* - P023 fix command interpretation

* - P035 move strings to flash

* - P048 fetch params only when needed

* automaticly updated release notes for mega-20180321

* automaticly updated release notes for v2.0-20180321

* Serial WD crash

* [wifi] Make more robust checks and increase timeout

See #1145

* - P012 fix command interpretation

* - P023 fix command interpretation

* - P035 move strings to flash

* - P048 fetch params only when needed

* Serial WD crash

* [wifi] Make more robust checks and increase timeout

See #1145

* [Memory] parseTemplate did not check if markers were found

"Free Mem" reported this function to be using quite a lot of memory.
Maybe that was related to parsing texts without matching ']' or '#'
Just added some checks to see if they were found.

* [WiFi] Take much more time for initial WiFi connect during setup

Accesspoint is still active, so it may take a lot more time to make the initial connection

* [WiFi] Take much more time for initial WiFi connect during setup

Accesspoint is still active, so it may take a lot more time to make the initial connection

* automaticly updated release notes for mega-20180322

* ESP32 fix

* [Command] Parsing improvement for commands

Use more intelligent parsing of commands and switch statement to improve speed

* automaticly updated release notes for mega-20180323

* [WiFi] Reverted those temp String uses for ssid/pass

Was introduced due to misunderstanding of reported issues with WiFi.

* [issue #1131] Add %unixtime%

Show the current time as [Unix time](https://en.wikipedia.org/wiki/Unix_time) (numbers of seconds that have elapsed since midnight 1970-01-01, UTC)

* [issue #1097] Call MQTTclient.loop() during deepsleep

The `MQTTclient.loop()` function should be called quite often.
This does the actual MQTT handling.
In normal operations, this is called quite frequently, but it should also be called when deepsleep is active and right before deepsleep is activated again.

* [P1] Support for latest standard

* [wifi] Event based connect/reconnect

Now using the core WiFiEvents to act on:

- connect
- disconnect
- gotIP

This will make polling for a status no longer needed.
It also allows to get a better understanding in why diconnects happen, since the disconnect reason is given in the events.
This extra information is also present on the information panel on the webinterface and also in the JSON output.

The entire connect/disconnect/reconnect is now done completely asynchronous and thus takes much less resources from the ESP.
A disconnect will now also send an event: "WiFi#Disconnected"

For deepsleep this means there has to be a minimum awake time set and perhaps use rules to set the ESP into sleep again when done.
Typical connection times to an accesspoint are about 3 seconds + about 1 second for DHCP.

This also resolves the issues where services my try to connect while there is a WiFi connection, but not yet an IP address set.

I already noticed a lot of NTP servers from pool.ntp.org are non responsive the last few weeks, so that may still take some time, but that's another issue.

* automaticly updated release notes for mega-20180324

* [NTP] Speedup NTP again with async WiFi

Previously it would only start calling "now" when the WiFi was already setup.
And in calling `now()`, a call to an NTP server is being made. When this fails, retry again in a minute.
But now the WiFi initialization is asynchronous, so the first NTP query was already failing and thus the retry is already set to a minute.

This is fixed now and also the pool.ntp.org will pick a random one from 0...3 (.pool.ntp.org).
The DNS queries from this pool change about every minute, so if you want to retry because one of the servers is offline, you should try one from the other `N.pool.ntp.org` or else you have to wait for another minute.

* - fix for #1170 - uservar not setted on encwrite

* automaticly updated release notes for mega-20180326

* [issue #1174] Show degree sign via external writes to LCD

Fix suggested by [elmicha](https://github.com/letscontrolit/ESPEasy/issues/1174#issuecomment-376244766)

* [ESP32] Event driven WiFi for ESP32

Not tested, just got some inspiration by these files:

- https://github.com/espressif/arduino-esp32/blob/master/libraries/WiFi/examples/WiFiClientEvents/WiFiClientEvents.ino
- https://github.com/espressif/arduino-esp32/blob/master/libraries/WiFi/src/WiFiGeneric.cpp
- https://github.com/espressif/arduino-esp32/blob/master/tools/sdk/include/esp32/esp_event.h

* automaticly updated release notes for mega-20180327

* Fix nesting level check

* [Build] Cleanup/split builds using defines

See PR #1034 and #1040 made by @soif

* [build] Disabled a few PlatformIO profiles for now.

There were way too many.
Just placed them in comments and Travis had already built them all to test first.

* automaticly updated release notes for mega-20180328

* [Arduino IDE] Revert changes in include paths

Were changed to be able to test the PlatformIO feature to compile only files that are actually used.
Apparently the Arduino IDE cannot find the files anymore because that IDE needs the parent directory to be named as the main project file, not "src"

* automaticly updated release notes for mega-20180329
2018-03-29 19:53:54 +02:00
clumsy-stefanandGitHub 21cb6135dd _P015_TSL2561 added Broadband and IR Values
Extended Plugin to also read Broadband and IR values from device.
2018-03-29 09:27:53 +02:00
ESPEasy release bot f613bb4572 automaticly updated release notes for mega-20180329 2018-03-29 04:00:11 +02:00
Gijs NoorlanderandGitHub 51059f0c18 Merge pull request #1189 from TD-er/bugfix/include_paths_ArduinoIDE
[issue #1188] Revert changes in include paths
2018-03-28 21:58:07 +02:00
TD-er dec6598f49 [Arduino IDE] Revert changes in include paths
Were changed to be able to test the PlatformIO feature to compile only files that are actually used.
Apparently the Arduino IDE cannot find the files anymore because that IDE needs the parent directory to be named as the main project file, not "src"
2018-03-28 21:40:09 +02:00
mvdbroandGitHub f8f6767bec Merge pull request #1180 from TD-er/bugfix/esp32_eventbased_wifi
[ESP32] Event driven WiFi for ESP32
2018-03-28 19:42:54 +02:00
linuxnico 07948c87aa add ds1822 definition to ds_read_temp function 2018-03-28 14:30:05 +02:00
ESPEasy release bot 5c475b98db automaticly updated release notes for mega-20180328 2018-03-28 04:00:09 +02:00
Gijs NoorlanderandGitHub 58fb8dc42b Merge pull request #1182 from TD-er/feature/pluginsets
[Build] Cleanup/split builds using defines
2018-03-27 22:37:45 +02:00
TD-er cb2b11a41a [build] Disabled a few PlatformIO profiles for now.
There were way too many.
Just placed them in comments and Travis had already built them all to test first.
2018-03-27 22:27:31 +02:00
TD-er ac4f3c4cd4 [Build] Cleanup/split builds using defines
See PR #1034 and #1040 made by @soif
2018-03-27 21:24:08 +02:00
mvdbro c651e29d2a Merge branch 'mega' of https://github.com/letscontrolit/ESPEasy into mega 2018-03-27 17:24:45 +02:00
mvdbro d7e886a841 Fix nesting level check 2018-03-27 17:23:56 +02:00
Gijs NoorlanderandGitHub eec7647782 Merge pull request #1025 from soif/Feat/PlugSets
Initial re-organisation of plugin sets (#1019)
2018-03-27 10:12:56 +02:00
ESPEasy release bot 6f9d120ff0 automaticly updated release notes for mega-20180327 2018-03-27 04:00:09 +02:00
TD-er 28ddc2d9c0 [ESP32] Event driven WiFi for ESP32
Not tested, just got some inspiration by these files:

- https://github.com/espressif/arduino-esp32/blob/master/libraries/WiFi/examples/WiFiClientEvents/WiFiClientEvents.ino
- https://github.com/espressif/arduino-esp32/blob/master/libraries/WiFi/src/WiFiGeneric.cpp
- https://github.com/espressif/arduino-esp32/blob/master/tools/sdk/include/esp32/esp_event.h
2018-03-26 22:44:58 +02:00
Gijs NoorlanderandGitHub cc54354ac3 Merge pull request #1178 from TD-er/bugfix/degree_parse_LCD
[issue #1174] Show degree sign via external writes to LCD
2018-03-26 19:48:56 +02:00
TD-er 3929390629 [issue #1174] Show degree sign via external writes to LCD
Fix suggested by [elmicha](https://github.com/letscontrolit/ESPEasy/issues/1174#issuecomment-376244766)
2018-03-26 19:48:12 +02:00
GrovkillenandGitHub 5f4685337e Added value number as discussed. 2018-03-26 14:59:47 +02:00
GrovkillenandGitHub 08c158aa9c Moved to correct folder 2018-03-26 10:33:22 +02:00
GrovkillenandGitHub e9d71a8f35 Delete WebServer.ino
Same mistake as before, wrong folder upload
2018-03-26 10:32:58 +02:00
GrovkillenandGitHub 3e3173cbb0 Updated JSON path for sensor values and names
+file type filter on upload (not OTA since that is not part of ESP Easy core)
2018-03-26 10:31:27 +02:00
ESPEasy release bot 3a26ebf7b1 automaticly updated release notes for mega-20180326 2018-03-26 04:00:15 +02:00
Gijs NoorlanderandGitHub 1685bead52 Merge pull request #1173 from TD-er/merge/command_parsing
Merge "improve command parsing" & fix for #1170 - uservar not set on encwrite
2018-03-25 21:54:19 +02:00
Bartlomiej ZimonandTD-er 3a2fe35e5c - fix for #1170 - uservar not setted on encwrite 2018-03-25 21:04:34 +02:00
TD-er 29ce7f774f Merge branch 'bugfix/improve_command_parsing' into mega 2018-03-25 20:51:23 +02:00
Gijs NoorlanderandGitHub cc85327356 Merge pull request #1164 from BrianSetz/bugfix/plugin044
[P1 Wifi Gateway] Support for ESMR 5.0
2018-03-25 20:33:01 +02:00
Gijs NoorlanderandGitHub 0851bb655e Merge pull request #1165 from TD-er/feature/event_driven_wifi
[wifi] Event based connect/reconnect
2018-03-25 20:30:49 +02:00
TD-er d4bc10d8f1 [NTP] Speedup NTP again with async WiFi
Previously it would only start calling "now" when the WiFi was already setup.
And in calling `now()`, a call to an NTP server is being made. When this fails, retry again in a minute.
But now the WiFi initialization is asynchronous, so the first NTP query was already failing and thus the retry is already set to a minute.

This is fixed now and also the pool.ntp.org will pick a random one from 0...3 (.pool.ntp.org).
The DNS queries from this pool change about every minute, so if you want to retry because one of the servers is offline, you should try one from the other `N.pool.ntp.org` or else you have to wait for another minute.
2018-03-25 12:32:06 +02:00
ESPEasy release bot 0672f32f4b automaticly updated release notes for mega-20180324 2018-03-24 04:00:10 +01:00
TD-er a17f7b679c [wifi] Event based connect/reconnect
Now using the core WiFiEvents to act on:

- connect
- disconnect
- gotIP

This will make polling for a status no longer needed.
It also allows to get a better understanding in why diconnects happen, since the disconnect reason is given in the events.
This extra information is also present on the information panel on the webinterface and also in the JSON output.

The entire connect/disconnect/reconnect is now done completely asynchronous and thus takes much less resources from the ESP.
A disconnect will now also send an event: "WiFi#Disconnected"

For deepsleep this means there has to be a minimum awake time set and perhaps use rules to set the ESP into sleep again when done.
Typical connection times to an accesspoint are about 3 seconds + about 1 second for DHCP.

This also resolves the issues where services my try to connect while there is a WiFi connection, but not yet an IP address set.

I already noticed a lot of NTP servers from pool.ntp.org are non responsive the last few weeks, so that may still take some time, but that's another issue.
2018-03-24 01:19:32 +01:00
Brian Setz 425bd85c83 [P1] Support for latest standard 2018-03-23 22:13:03 +01:00
Gijs NoorlanderandGitHub 3be005e1ee Merge pull request #1161 from TD-er/bugfix/mqtt_deepsleep
[issue #1097] Call MQTTclient.loop() during deepsleep
2018-03-23 15:52:48 +01:00
TD-er 174f9e6e03 [issue #1097] Call MQTTclient.loop() during deepsleep
The `MQTTclient.loop()` function should be called quite often.
This does the actual MQTT handling.
In normal operations, this is called quite frequently, but it should also be called when deepsleep is active and right before deepsleep is activated again.
2018-03-23 15:19:10 +01:00
Gijs NoorlanderandGitHub 51a14a174f Merge pull request #1160 from TD-er/feature/epoch_time
[issue #1131] Add %unixtime%
2018-03-23 14:44:55 +01:00
Gijs NoorlanderandGitHub 7cb1f453d3 Merge pull request #1159 from TD-er/bugfix/wifi_issues
[WiFi] Reverted those temp String uses for ssid/pass
2018-03-23 14:44:41 +01:00
TD-er 23a6caab89 [issue #1131] Add %unixtime%
Show the current time as [Unix time](https://en.wikipedia.org/wiki/Unix_time) (numbers of seconds that have elapsed since midnight 1970-01-01, UTC)
2018-03-23 14:23:27 +01:00
TD-er 6b4300bd46 [WiFi] Reverted those temp String uses for ssid/pass
Was introduced due to misunderstanding of reported issues with WiFi.
2018-03-23 12:34:27 +01:00
ESPEasy release bot 04a9069db0 automaticly updated release notes for mega-20180323 2018-03-23 04:00:06 +01:00
TD-er dd636903c8 [Command] Parsing improvement for commands
Use more intelligent parsing of commands and switch statement to improve speed
2018-03-22 22:33:41 +01:00
GHolliandGitHub 4543a10739 Change comma to semicolon
Same functionality, but more common.
2018-03-22 20:12:28 +01:00
mvdbro 940b65e86a ESP32 fix 2018-03-22 14:08:47 +01:00
ESPEasy release bot 6344de0649 automaticly updated release notes for mega-20180322 2018-03-22 04:00:11 +01:00
TD-er 8ccd7c3e8d Merge branch 'v2.0' into mega 2018-03-22 01:06:27 +01:00
TD-er 22371649a4 [WiFi] Take much more time for initial WiFi connect during setup
Accesspoint is still active, so it may take a lot more time to make the initial connection
2018-03-22 01:05:56 +01:00
Gijs NoorlanderandGitHub 2a48d5033e Merge pull request #1149 from TD-er/bugfix/initialWiFiconnect
[WiFi] Take much more time for initial WiFi connect during setup
2018-03-22 01:04:48 +01:00
TD-er f064da797d [WiFi] Take much more time for initial WiFi connect during setup
Accesspoint is still active, so it may take a lot more time to make the initial connection
2018-03-22 01:04:19 +01:00
TD-er b0b8edf935 Merge branch 'v2.0' into mega 2018-03-22 00:27:38 +01:00
Gijs NoorlanderandGitHub 8cbd9a0822 Merge pull request #1148 from TD-er/merge/mega_to_v2.0_0321
Merge/mega to v2.0 0321
2018-03-22 00:24:59 +01:00
TD-er 93f9d11738 [Memory] parseTemplate did not check if markers were found
"Free Mem" reported this function to be using quite a lot of memory.
Maybe that was related to parsing texts without matching ']' or '#'
Just added some checks to see if they were found.
2018-03-22 00:24:17 +01:00
TD-er cf3e0a3f0a [wifi] Make more robust checks and increase timeout
See #1145
2018-03-22 00:12:04 +01:00
s0170071andTD-er ccfd14dbd3 Serial WD crash 2018-03-22 00:11:48 +01:00
Bartlomiej ZimonandTD-er 3034738ad4 - P048 fetch params only when needed 2018-03-22 00:11:30 +01:00
TD-er 178d1c46a2 - P035 move strings to flash 2018-03-22 00:11:21 +01:00
Bartlomiej ZimonandTD-er cdfd1d986e - P023 fix command interpretation 2018-03-22 00:10:55 +01:00
Bartlomiej ZimonandTD-er 4b7aa53692 - P012 fix command interpretation 2018-03-22 00:10:50 +01:00
Gijs NoorlanderandGitHub 7959a5133f Merge pull request #1117 from TD-er/bugfix/memoryusage_parsetemplate
[Memory] parseTemplate did not check if markers were found
2018-03-21 23:33:47 +01:00
Gijs NoorlanderandGitHub 941fb5c29c Merge pull request #1147 from TD-er/bugfix/check_wifi_cred
[wifi] Make more robust checks and increase timeout
2018-03-21 23:32:37 +01:00
TD-er c43c9ea2b3 [wifi] Make more robust checks and increase timeout
See #1145
2018-03-21 23:19:05 +01:00
Gijs NoorlanderandGitHub 967103bcad Merge pull request #1141 from uzi18/mega-plugins_check
some small fixes found during check for propper success setting
2018-03-21 21:36:52 +01:00
Gijs NoorlanderandGitHub efe637ec70 Merge pull request #1146 from s0170071/SerialWDCrash
Wifi connect fails if serial bytes are incoming
2018-03-21 21:24:43 +01:00
s0170071 00450eb260 Serial WD crash 2018-03-21 19:48:04 +01:00
ESPEasy release bot cc02fa4481 automaticly updated release notes for v2.0-20180321 2018-03-21 04:00:21 +01:00
ESPEasy release bot 1c5f8af083 automaticly updated release notes for mega-20180321 2018-03-21 04:00:08 +01:00
Bartlomiej Zimon fccc31a7c6 - P048 fetch params only when needed 2018-03-21 02:43:04 +01:00
Bartlomiej Zimon b84d905a0b - P035 move strings to flash 2018-03-21 02:42:13 +01:00
Bartlomiej Zimon 94aa951cba - P023 fix command interpretation 2018-03-21 02:41:35 +01:00
Bartlomiej Zimon 2a23dcd011 - P012 fix command interpretation 2018-03-21 02:41:08 +01:00
Gijs NoorlanderandGitHub ab3a406706 [merge issue] Forgotten #endif in merge 2018-03-20 23:46:43 +01:00
TD-er e7a9ee7eee Merge branch 'v2.0' into mega 2018-03-20 23:28:59 +01:00
Unknown 3edfdbf5f7 [wifi] Setup with factory settings could not complete 2018-03-20 23:27:39 +01:00
Gijs NoorlanderandGitHub 27bac2ca00 Merge pull request #1140 from TD-er/bugfix/connect_to_wifi_during_setup
[wifi] Setup with factory settings could not complete
2018-03-20 23:25:57 +01:00
Unknown 373f74e9f8 [wifi] Setup with factory settings could not complete 2018-03-20 23:25:23 +01:00
ESPEasy release bot 1220c565c8 automaticly updated release notes for v2.0-20180320 2018-03-20 04:00:23 +01:00
ESPEasy release bot 1931fe9e53 automaticly updated release notes for mega-20180320 2018-03-20 04:00:10 +01:00
Unknown 0eab6293dc Merge branch 'v2.0' into mega 2018-03-20 00:30:02 +01:00
Unknown f0987dab41 [issue #1097] WiFi connect with deepsleep enabled trigger watchdog reset
Did not allow for enough time to do background tasks while waiting for wifi connect with DeepSleep enabled.
2018-03-20 00:29:24 +01:00
Gijs NoorlanderandGitHub 51bd52603f Merge pull request #1134 from TD-er/bugfix/deepsleep_mqtt
[issue #1097] WiFi connect with deepsleep enabled trigger watchdog reset
2018-03-20 00:27:58 +01:00
Unknown 47f1fa145a [issue #1097] WiFi connect with deepsleep enabled trigger watchdog reset
Did not allow for enough time to do background tasks while waiting for wifi connect with DeepSleep enabled.
2018-03-20 00:26:48 +01:00
Unknown 605055d95a Merge branch 'v2.0' into mega 2018-03-19 22:52:36 +01:00
Unknown af3e353181 Revert "Merge pull request #1116 from TD-er/feature/allow_own_defaults"
This reverts commit 8ccbdcadf0.
2018-03-19 22:51:23 +01:00
es-kaandUnknown c711d6ea51 Fix wiring description for SN75176 transceiver 2018-03-19 22:50:31 +01:00
Gijs NoorlanderandGitHub 20c23a2935 Merge pull request #1133 from TD-er/bugfix/undo_espeasy_globals.h
Revert "Merge pull request #1116 from TD-er/feature/allow_own_defaults"
2018-03-19 22:48:51 +01:00
Gijs Noorlander bbfe254232 Revert "Merge pull request #1116 from TD-er/feature/allow_own_defaults"
This reverts commit 8ccbdcadf0.
2018-03-19 22:47:42 +01:00
Gijs NoorlanderandGitHub 882c888f6d Merge pull request #1132 from es-ka/mega
Fix wiring description for SN75176 transceiver
2018-03-19 22:37:04 +01:00
es-kaandGitHub 0a754f072c Fix wiring description for SN75176 transceiver 2018-03-19 20:00:41 +01:00
ESPEasy release bot 1f084c51cc automaticly updated release notes for v2.0-20180319 2018-03-19 04:00:24 +01:00
ESPEasy release bot 89df0932c5 automaticly updated release notes for mega-20180319 2018-03-19 04:00:11 +01:00
Unknown 429fd3e4d0 Merge branch 'v2.0' into mega 2018-03-19 01:06:32 +01:00
Gijs NoorlanderandGitHub 85e8d98da8 Merge pull request #1121 from TD-er/merge/fixes_20180318_to_v2.0
Merge/fixes 20180318 to v2.0
2018-03-19 01:01:42 +01:00
Unknown 6d52a7e03a [merge] MIssing #endif due to merging. 2018-03-19 00:51:05 +01:00
Gijs Noorlander fa513b52f9 Merge pull request #1118 from TD-er/bugfix/mqtt_publish_after_deep_sleep
[issue #1097] MQTT publish after deep sleep
2018-03-19 00:46:03 +01:00
Unknown f98401524f Merge pull request #1116 from TD-er/feature/allow_own_defaults
[issue #1007] Allow user specific data in separate file
2018-03-19 00:45:52 +01:00
Unknown 4090b4f23c Merge pull request #1113 from TD-er/feature/reduce_impact_wifi_disconnect
[Relaxed WiFi] Perform WiFi initialization in steps
2018-03-19 00:42:58 +01:00
Gijs Noorlander b89c00008d Merge pull request #1114 from TD-er/feature/wifi_details_json
[JSON] Add uint name (#1099) and WiFi information (PR #1113)
2018-03-19 00:39:43 +01:00
Gijs Noorlander d57a617138 Merge pull request #1112 from uzi18/fix-p073
Fix p073 - #1111
2018-03-19 00:39:32 +01:00
Gijs Noorlander cefe6b4b7c Changed so that running all tasks immediately with deep sleep enabled… (#1110)
Changed so that running all tasks immediately with deep sleep enabled only happens on first iteration after wake up
2018-03-19 00:38:30 +01:00
Gijs Noorlander 2432740b41 - add encoder write command #1086 (#1103)
- add encoder write command #1086
2018-03-19 00:35:09 +01:00
Gijs Noorlander 44a934651c Add download button for current rule set (#1102)
Add download button for current rule set
2018-03-19 00:34:52 +01:00
Gijs NoorlanderandGitHub 95fb0d6e6c Merge pull request #1118 from TD-er/bugfix/mqtt_publish_after_deep_sleep
[issue #1097] MQTT publish after deep sleep
2018-03-19 00:29:37 +01:00
Gijs NoorlanderandGitHub 8ccbdcadf0 Merge pull request #1116 from TD-er/feature/allow_own_defaults
[issue #1007] Allow user specific data in separate file
2018-03-19 00:29:08 +01:00
Unknown 433aa6910a [issue #1097] MQTT publish after deep sleep
The MQTTConnect was only called after a while. This is a problem for deepsleep.
So now the MQTT connect is done at the first loop when deep sleep is enabled.
2018-03-19 00:18:29 +01:00
Unknown f135c63d84 [Memory] parseTemplate did not check if markers were found
"Free Mem" reported this function to be using quite a lot of memory.
Maybe that was related to parsing texts without matching ']' or '#'
Just added some checks to see if they were found.
2018-03-18 23:57:42 +01:00
Unknown 2ebc733b63 [issue #1007] Add other defines as suggested by @uzi18 2018-03-18 23:17:57 +01:00
Unknown 21bc1a7814 #ifndef instead of #ifdef 2018-03-18 22:55:30 +01:00
Unknown 53b8009df6 [issue #1007] Allow user specific data in separate file
File will be ignored by git and can be simply included using `-D USE_OWN_DEFAULTS` in the build
2018-03-18 22:46:15 +01:00
Gijs NoorlanderandGitHub 68a8e5982e Merge pull request #1113 from TD-er/feature/reduce_impact_wifi_disconnect
[Relaxed WiFi] Perform WiFi initialization in steps
2018-03-18 21:53:33 +01:00
Gijs NoorlanderandGitHub 08acfeac97 Merge pull request #1114 from TD-er/feature/wifi_details_json
[JSON] Add uint name (#1099) and WiFi information (PR #1113)
2018-03-18 21:52:24 +01:00
Unknown 999a561515 [JSON] Add uint name (#1099) and WiFi information (PR #1113)
As suggested by @Grovkillen on PR #1113.
2018-03-18 21:51:46 +01:00
Gijs NoorlanderandGitHub 3ee1a4ed2e Merge pull request #1112 from uzi18/fix-p073
Fix p073 - #1111
2018-03-18 21:23:11 +01:00
Gijs NoorlanderandGitHub 05801db47c Changed so that running all tasks immediately with deep sleep enabled… (#1110)
Changed so that running all tasks immediately with deep sleep enabled only happens on first iteration after wake up
2018-03-18 21:22:43 +01:00
Gijs NoorlanderandGitHub 7bec632f15 Merge pull request #1109 from s0170071/memtracker
changed memory tracker to uint64_t for the ESP32
2018-03-18 21:21:18 +01:00
Gijs NoorlanderandGitHub 3f8fe11b47 - add encoder write command #1086 (#1103)
- add encoder write command #1086
2018-03-18 21:17:13 +01:00
Gijs NoorlanderandGitHub 4b8f1e4c1b Add download button for current rule set (#1102)
Add download button for current rule set
2018-03-18 21:13:26 +01:00
Unknown 573fd0f320 [Travis error] Some #include test that wasn't meant to be included
... in the commit.
2018-03-18 21:08:22 +01:00
Unknown 4fa5203c5b [Relaxed WiFi] Perform WiFi initialization in steps
Doing WiFi initialization in multiple steps, will reduce boot time a lot.
For deepsleep the Setup is waiting for wifi initialization to complete, but for normal use the wifi connection is initiated during setup and checked on regular intervals to see if it is available.
The same for WiFi reconnect, which will hopefully not affect the performance of the ESP module during reconnects.

Also added a check + event when connected to another accesspoint with different BSSID (MAC address of accesspoint). Also the last used BSSID is used to reconnect to try to connect to the same device over and over, which may be useful with WiFi repeaters.
2018-03-18 20:54:27 +01:00
Bartlomiej Zimon 9c9617f6ed - initialize pointer in P073 2018-03-18 20:30:47 +01:00
Bartlomiej Zimon bbbf6c483f - fix P073 success setting in PLUGIN_WRITE callback 2018-03-18 20:30:18 +01:00
Bartlomiej Zimon 668909e7b3 - fix success setting 2018-03-18 20:16:37 +01:00
Unknown c642848ef2 [WiFi] Try to minimize effect of WiFi interruptions
And send event when connected to a different accesspoint.
Currently the impact on WiFi reconnects is enorm. The ESP stalls, won't react on events, etc.
2018-03-18 02:51:59 +01:00
s0170071 6eea35aa81 Keep uint. Just change the init value. 2018-03-17 22:58:09 +01:00
Panayotis Kouvarakis 738a48213c Changed so that running all tasks immediately with deep sleep enabled only happens on first iteration after wake up 2018-03-17 23:33:21 +02:00
s0170071 d1c093d109 changed memory tracker to uint64_t for the ESP32 2018-03-17 20:15:48 +01:00
Bartlomiej Zimon 00166a1aad - add encoder write #1086 2018-03-16 19:54:24 +01:00
Bartlomiej Zimon 589238324b Add download button for current rule set 2018-03-16 18:15:52 +01:00
ESPEasy release bot 6787bc8c0e automaticly updated release notes for v2.0-20180316 2018-03-16 04:00:23 +01:00
ESPEasy release bot 6845a03741 automaticly updated release notes for mega-20180316 2018-03-16 04:00:11 +01:00
Unknown 6a4284f189 Merge branch 'v2.0' into mega 2018-03-16 00:44:54 +01:00
Gijs NoorlanderandGitHub cf644b45b1 Merge pull request #1095 from TD-er/merge/PR_1092_1093_1094
Merge/pr 1092 1093 1094
2018-03-16 00:43:16 +01:00
Unknown e6fe1c63a9 [issue #951] Changed System#Initialized => System#Wake
Changed System#Initialized  => System#Wake
New event name makes more sense and Initialized may be used later to indicate all needed connections, etc. are ready.
2018-03-16 00:38:00 +01:00
Unknown df978036f0 [issue #993] variable in MQTT subscribe topic
As [noted](https://github.com/letscontrolit/ESPEasy/issues/993#issuecomment-373140135) by @kluszcyn
2018-03-16 00:37:54 +01:00
Unknown 7cb375833d [issue #1057] AM PM display issue
X:XX PM (for hours 1...9)
X:XX AM (for hours 1...9)
XX:XX PM (for hours 10...12)
XX:XX AM (for hours 10...12)

Added for H:MM (without seconds) notations:
- `%systm_hm%`
-`%systm_hm_am%`
2018-03-16 00:37:45 +01:00
Gijs NoorlanderandGitHub 41c57f1ef9 Merge pull request #1094 from TD-er/bugfix/System_Wake_event
[issue #951] Changed System#Initialized  => System#Wake
2018-03-16 00:35:24 +01:00
Unknown 808b40bdba [issue #951] Changed System#Initialized => System#Wake
Changed System#Initialized  => System#Wake
New event name makes more sense and Initialized may be used later to indicate all needed connections, etc. are ready.
2018-03-16 00:34:32 +01:00
Gijs NoorlanderandGitHub 58b20615da Merge pull request #1093 from TD-er/bugfix/993_parse_sysvars
[issue #993] variable in MQTT subscribe topic
2018-03-15 23:57:01 +01:00
Unknown 13026b1cc4 [issue #993] variable in MQTT subscribe topic
As [noted](https://github.com/letscontrolit/ESPEasy/issues/993#issuecomment-373140135) by @kluszcyn
2018-03-15 23:56:01 +01:00
Gijs NoorlanderandGitHub 7f3460e492 Merge pull request #1092 from TD-er/bugfix/am_pm_time
[issue #1057] AM PM display issue
2018-03-15 23:44:18 +01:00
Unknown a222391f81 [issue #1057] AM PM display issue
X:XX PM (for hours 1...9)
X:XX AM (for hours 1...9)
XX:XX PM (for hours 10...12)
XX:XX AM (for hours 10...12)

Added for H:MM (without seconds) notations:
- `%systm_hm%`
-`%systm_hm_am%`
2018-03-15 23:43:14 +01:00
Unknown a8165531d5 Merge branch 'v2.0' into mega 2018-03-15 23:06:07 +01:00
Gijs NoorlanderandGitHub 3218ea9839 Merge pull request #1091 from TD-er/merge/fixes_1073_1079_1081 into v2.0
Merge/fixes 1073 1079 1081 into v2.0
2018-03-15 23:05:06 +01:00
Gijs Noorlander eca8901fca Fixed multi instance problem on SHT3x #433 (#1081)
Fixed multi instance problem on SHT3x #433
2018-03-15 23:02:04 +01:00
Gijs Noorlander 6635eafe91 [issue #1066] Fix Webserver handle_control (#1079)
[issue #1066] Fix Webserver handle_control
2018-03-15 23:01:52 +01:00
Gijs Noorlander fe4d1f952f MCP3221 allow values for calibration (#1073)
MCP3221 allow values for calibration
2018-03-15 23:01:39 +01:00
Gijs NoorlanderandGitHub 1abd31b421 Fixed multi instance problem on SHT3x #433 (#1081)
Fixed multi instance problem on SHT3x #433
2018-03-15 23:00:05 +01:00
Gijs NoorlanderandGitHub 72fe49d905 [issue #1066] Fix Webserver handle_control (#1079)
[issue #1066] Fix Webserver handle_control
2018-03-15 22:58:38 +01:00
Gijs NoorlanderandGitHub 9dd9f3befa MCP3221 allow values for calibration (#1073)
MCP3221 allow values for calibration
2018-03-15 22:57:14 +01:00
Unknown 471d76dbe6 Merge branch 'v2.0' into mega 2018-03-15 22:55:31 +01:00
Gijs NoorlanderandGitHub 4475a225cc Merge pull request #1090 from TD-er/merge/split_globals_v2.0
Merge/split globals v2.0
2018-03-15 22:46:46 +01:00
Gijs NoorlanderandGitHub 8b047490c4 Merge pull request #1089 from TD-er/merge/split_globals_Mega
Merge/split globals mega
2018-03-15 22:46:28 +01:00
Unknown 455f77d0ed Merge branch 'v2.0' into mega 2018-03-15 22:42:50 +01:00
Unknown 836fc4a875 Merge remote-tracking branch 'uzi18/mega' into merge/split_globals 2018-03-15 22:29:30 +01:00
Unknown 2aece1c143 [v2.0 split globals] Base split on v2.0 version of ESPEasy.ino 2018-03-15 22:23:59 +01:00
Bartlomiej ZimonandUnknown 70df225e7e Merge branch 'mega' of github.com:letscontrolit/ESPEasy into mega
# Conflicts:
#	src/ESPEasy.ino
2018-03-15 22:05:36 +01:00
Unknown 19af52a3ef - move all structs from ESPEasy.ino into header file
- add some fix for headers
- add const to rtttl notes array
2018-03-15 22:05:22 +01:00
Gijs NoorlanderandGitHub 3d396575ff Merge pull request #1088 from TD-er/merge/rules_fix__and_globalsync_toV2.0
Merge/rules fix  and globalsync to v2.0
2018-03-15 21:52:41 +01:00
ESPEasy release bot 873f8474b5 automaticly updated release notes for mega-20180315 2018-03-15 04:00:08 +01:00
mvdbroandUnknown 826deaac89 Rules fix 2018-03-14 21:28:24 +01:00
mvdbroandUnknown cce621cff8 #893, part 2 receiving 2018-03-14 21:28:15 +01:00
mvdbroandUnknown 57eb38dbd0 Custom controller GUI option 2018-03-14 21:28:08 +01:00
mvdbroandUnknown fd2451bb07 #893 part1, send messages 2018-03-14 21:27:50 +01:00
mvdbro c94e5cb903 Rules fix 2018-03-14 19:26:29 +01:00
Bartlomiej Zimon 27699f7192 Merge branch 'mega' of github.com:letscontrolit/ESPEasy into mega
# Conflicts:
#	src/ESPEasy.ino
2018-03-14 19:09:46 +01:00
Bartlomiej Zimon 2eff001b14 Merge branch 'mega' of github.com:letscontrolit/ESPEasy into mega 2018-03-14 18:54:24 +01:00
mvdbro bd499c7a94 #893, part 2 receiving 2018-03-14 13:11:16 +01:00
JK 4da1e4fbdd Fixed #433
Not tested!
2018-03-14 12:19:57 +01:00
mvdbro 1d14770ea7 Custom controller GUI option 2018-03-14 10:45:15 +01:00
ESPEasy release bot 8b7574d298 automaticly updated release notes for mega-20180314 2018-03-14 04:00:11 +01:00
Unknown 14d87d95f6 [issue #1066] Fix Webserver handle_control
There wasn't a proper start/end for the streaming webserver.
See discussion on issue #1066
2018-03-14 01:30:49 +01:00
GHolliandGitHub daecf2017e Update _P049_MHZ19.ino 2018-03-13 21:41:17 +01:00
Holli 37122bc619 It seems the offsets [3]..[4] for the detection range setting (command byte 0x99) are wrong in the latest online data sheet: http://www.winsen-sensor.com/d/files/infrared-gas-sensor/mh-z19b-co2-ver1_0.pdf
According to the MH-Z19B data sheet version 1.2, valid from: 2017.03.22 (received 2018-03-07), the offset should be [6]..[7] instead.
Fixing the implementation accordingly.
2018-03-13 20:22:45 +01:00
mvdbro 5a15288d80 #893 part1, send messages 2018-03-13 16:36:58 +01:00
Bartlomiej Zimon 869dff12ce - move all structs from ESPEasy.ino into header file
- add some fix for headers
- add const to rtttl notes array
2018-03-13 15:53:42 +01:00
ESPEasy release bot cc0b3dac26 automaticly updated release notes for v2.0-20180313 2018-03-13 04:00:23 +01:00
ESPEasy release bot 4208048fc1 automaticly updated release notes for mega-20180313 2018-03-13 04:00:11 +01:00
Unknown 06a2f47812 Merge branch 'v2.0' into mega 2018-03-12 23:20:59 +01:00
Gijs NoorlanderandGitHub d3434eb4d2 Merge/fix rules trailing spaces (#1065) #1074
Merge/fix rules trailing spaces (#1065)
2018-03-12 23:18:22 +01:00
Bartlomiej ZimonandUnknown bd2665041f - remove double trimm() 2018-03-12 23:15:48 +01:00
Bartlomiej ZimonandUnknown 1fd429a029 - fix for #1065 2018-03-12 23:15:40 +01:00
sassod 7b3a71bcc9 12bit ADC values acceted up to 4095
MCP3221 is a 12bit ADC so accepted values should be up to 40195 not 1024
2018-03-12 19:56:42 +01:00
mvdbroandGitHub 18e612dea2 Merge pull request #1067 from uzi18/mega
- fix for #1065
2018-03-12 19:35:51 +01:00
mvdbro f99593ed62 ESP32 C010 fix 2018-03-12 19:34:40 +01:00
sassod 2f7e96fa5b Merge remote-tracking branch 'refs/remotes/origin/mega' into letscontrolit/mega 2018-03-12 18:51:00 +01:00
Bartlomiej Zimon 25b4392dd5 - remove double trimm() 2018-03-12 12:09:07 +01:00
Bartlomiej Zimon ad4130a547 - fix for #1065 2018-03-12 11:42:00 +01:00
ESPEasy release bot e4d4463eab automaticly updated release notes for v2.0-20180312 2018-03-12 04:00:19 +01:00
ESPEasy release bot 991384822f automaticly updated release notes for mega-20180312 2018-03-12 04:00:07 +01:00
Gijs NoorlanderandGitHub b29f56c6f4 Merge pull request #1063 from TD-er/merge/rule_engine_fix
Rule Engine minor fix and added dev debugging
2018-03-12 00:55:49 +01:00
Unknown 779514481d Rule Engine minor fix and added dev debugging 2018-03-12 00:52:30 +01:00
Unknown 82ed319e59 Merge branch 'v2.0' into mega 2018-03-12 00:46:31 +01:00
Gijs NoorlanderandGitHub 0a752dd26f Merge pull request #1062 from TD-er/merge/issue_1039
Merge/issue 1039
2018-03-12 00:44:02 +01:00
Gijs NoorlanderandGitHub 2e4af86a99 Merge pull request #1061 from TD-er/bugfix/chunking_webserver
[webserver] Improve chunked transfer
2018-03-12 00:42:30 +01:00
Unknown 8112e0e67a [webserver] Improve chunked transfer
Do chunked transfer using full buffer on all data sent to the streaming webserver.
2018-03-12 00:42:08 +01:00
Unknown 89a9f842fd [issue #1039 ] Change CSS to show topmost SSID on large screens
For screens with > 960 pixels width.
To show all accesspoints on AP selection.
2018-03-12 00:41:44 +01:00
Gijs NoorlanderandGitHub b4791d3421 Merge pull request #1060 from TD-er/bugfix/selection_accesspoints
[issue #1039 ] Change CSS to show topmost SSID on large screens
2018-03-12 00:40:13 +01:00
Unknown 885c5394a3 [webserver] Improve chunked transfer
Do chunked transfer using full buffer on all data sent to the streaming webserver.
2018-03-12 00:34:51 +01:00
Unknown e35304e4e7 [issue #1039 ] Change CSS to show topmost SSID on large screens
For screens with > 960 pixels width.
To show all accesspoints on AP selection.
2018-03-12 00:32:46 +01:00
mvdbro 6561d577d4 Rule Engine minor fix and added dev debugging 2018-03-11 10:40:54 +01:00
ESPEasy release bot 92932fddb2 automaticly updated release notes for v2.0-20180311 2018-03-11 04:00:19 +01:00
ESPEasy release bot 02d8834763 automaticly updated release notes for mega-20180311 2018-03-11 04:00:06 +01:00
Gijs NoorlanderandGitHub e82080dc52 Merge pull request #1053 from letscontrolit/v2.0
V2.0
2018-03-11 02:07:27 +01:00
Unknown 89581fd0fb [issue #1039] Topmost SSID are covered on mobile Browser
Added <span> tags with a class around the error, which allow the CSS to position the content below the header.
2018-03-11 01:59:51 +01:00
Gijs NoorlanderandGitHub cfbf972c1b [issue #1039] Topmost SSID are covered on mobile Browser (#1052)
[issue #1039] Topmost SSID are covered on mobile Browser
2018-03-11 01:58:13 +01:00
Unknown e25ea52edc [issue #1039] Topmost SSID are covered on mobile Browser
Added <span> tags with a class around the error, which allow the CSS to position the content below the header.
2018-03-11 01:57:24 +01:00
Unknown 3f84a961ad [DNS lookup] Controllers sometimes try to connect to 0.0.0.0
See issue #824
2018-03-11 01:38:50 +01:00
Gijs NoorlanderandGitHub 7d8e5e5175 [DNS lookup] Controllers sometimes try to connect to 0.0.0.0 (#1051)
[DNS lookup] Controllers sometimes try to connect to 0.0.0.0
2018-03-11 01:37:38 +01:00
Unknown 3d39dec686 [DNS lookup] Controllers sometimes try to connect to 0.0.0.0
See issue #824
2018-03-11 01:36:29 +01:00
Unknown ff656593ec Merge branch 'v2.0' into mega 2018-03-10 23:07:53 +01:00
Unknown 96bfaa27f5 [OLED] fix drawProgressBar
See this PR: https://github.com/ThingPulse/esp8266-oled-ssd1306/pull/178
2018-03-10 23:04:03 +01:00
Unknown bcca0514dd [deepsleep] Make sure the 'shortcut' of running all services when sleep enabled
As pointed out on [the forum by arion_p](https://www.letscontrolit.com/forum/viewtopic.php?p=25771#p25771)
2018-03-10 23:03:55 +01:00
Gijs NoorlanderandGitHub 90b4e3438d [OLED] fix drawProgressBar (#1048)
[OLED] fix drawProgressBar
2018-03-10 22:58:25 +01:00
Gijs NoorlanderandGitHub 139f8905d0 [deepsleep] Use the 'shortcut' of running all when sleep enabled (#1047)
[deepsleep] Use the 'shortcut' of running all when sleep enabled
2018-03-10 22:55:59 +01:00
Unknown 6c1806fae6 [OLED] fix drawProgressBar
See this PR: https://github.com/ThingPulse/esp8266-oled-ssd1306/pull/178
2018-03-10 22:53:18 +01:00
Unknown e6b581e7ff [deepsleep] Make sure the 'shortcut' of running all services when sleep enabled
As pointed out on [the forum by arion_p](https://www.letscontrolit.com/forum/viewtopic.php?p=25771#p25771)
2018-03-10 22:42:04 +01:00
Gijs NoorlanderandGitHub bb9f8fc809 Merge pull request #1046 from TD-er/merge/mega_to_v2.0
Merge/mega to v2.0
2018-03-10 22:03:14 +01:00
Unknown 4d9504bce0 [P073] Remove tm1637_bitDelay()
Not used anymore
2018-03-10 22:01:27 +01:00
Unknown ff3a769033 Update P07 Plugin
added suppor for other version of TM1637 modules (4dgt+colon, 4dgt+dots,6dgt+dots)
2018-03-10 22:01:20 +01:00
Unknown e3de56a7a8 [AM/PM] Am/Pm notation doesn't have '0' hours
11.59 a.m. => 12.00 p.m.
12.59 p.m. => 1.00 p.m.
11.59 p.m. => 12.00 a.m.
2018-03-10 22:01:04 +01:00
Gijs NoorlanderandGitHub 873d639461 Update P073 Plugin - support extra versions of TM1637 modules (@Papperone) (#1043)
Update P073 Plugin - support extra versions of TM1637 modules  (@Papperone)
2018-03-10 21:58:14 +01:00
Gijs NoorlanderandGitHub edb2a6d3f6 [AM/PM] Am/Pm notation doesn't have '0' hours (#1044)
[AM/PM] Am/Pm notation doesn't have '0' hours
2018-03-10 21:56:42 +01:00
Gijs NoorlanderandGitHub 2682b0bd2f [v2.0] Merge/rules process speed improvements (#1045)
[v2.0] Merge/rules process speed improvements
2018-03-10 21:55:25 +01:00
Unknown 5097157a09 Final ruleset speed-up
It's now down from 100 mSec to 19 mSec for 1 fully loaded non matching ruleset.
2018-03-10 21:41:13 +01:00
Unknown 02ea957894 Add read buffer to rule processing to speedup parsing
On a full ruleset (2k), a non matching event takes 100 mSec instead of 170 mSec.
2018-03-10 21:39:51 +01:00
mvdbroandUnknown c2b0d76595 Rule Engine, stop waisting time on non matching rules 2018-03-10 21:38:01 +01:00
Unknown 91b7cbe075 Improve flash read performance 2018-03-10 21:37:47 +01:00
Unknown bff60a2e27 [P073] Remove tm1637_bitDelay()
Not used anymore
2018-03-10 21:28:09 +01:00
Unknown 61831e5962 [AM/PM] Am/Pm notation doesn't have '0' hours
11.59 a.m. => 12.00 p.m.
12.59 p.m. => 1.00 p.m.
11.59 p.m. => 12.00 a.m.
2018-03-10 21:19:35 +01:00
Unknown d105b47d44 Update P07 Plugin
added suppor for other version of TM1637 modules (4dgt+colon, 4dgt+dots,6dgt+dots)
2018-03-10 18:38:33 +01:00
mvdbro 449568bcc4 Final ruleset speed-up
It's now down from 100 mSec to 19 mSec for 1 fully loaded non matching ruleset.
2018-03-10 16:53:02 +01:00
mvdbro 3144077103 Add read buffer to rule processing to speedup parsing
On a full ruleset (2k), a non matching event takes 100 mSec instead of 170 mSec.
2018-03-10 15:48:56 +01:00
mvdbro 8f056be0a8 Rule Engine, stop waisting time on non matching rules 2018-03-10 10:48:03 +01:00
mvdbro e9cdc5693d Improve flash read performance 2018-03-10 08:51:35 +01:00
ESPEasy release bot 64b38df187 automaticly updated release notes for v2.0-20180310 2018-03-10 04:00:20 +01:00
ESPEasy release bot 377c50ec36 automaticly updated release notes for mega-20180310 2018-03-10 04:00:07 +01:00
Gijs NoorlanderandGitHub 76f6dfdc59 Merge Mega -> v2.0: conversions & delay wifi init (#1037)
Merge Mega -> v2.0: conversions  & delay wifi init
2018-03-09 23:20:47 +01:00
Unknown 3a6f7acd15 [Conversions] Use more decimals in conversions and add AM/PM for time.
See comments on #1015
2018-03-09 23:19:19 +01:00
Unknown d65b126f84 Move plugin init before WiFi init
As suggested at PR #1032 by @M0ebiu5
2018-03-09 23:18:10 +01:00
Gijs NoorlanderandGitHub 90a2a799da [Conversions] Use more decimals in conversions and add AM/PM for time. (#1036)
[Conversions] Use more decimals in conversions and add AM/PM for time.
2018-03-09 23:15:48 +01:00
Unknown feb419b6ae [Conversions] Use more decimals in conversions and add AM/PM for time.
See comments on #1015
2018-03-09 23:13:03 +01:00
Gijs NoorlanderandGitHub e83d8468b0 Move plugin init before WiFi init (#1035)
Move plugin init before WiFi init
2018-03-09 22:18:35 +01:00
Unknown 6eabaaa62d Move plugin init before WiFi init
As suggested at PR #1032 by @M0ebiu5
2018-03-09 22:10:25 +01:00
ESPEasy release bot 8299e38b24 automaticly updated release notes for v2.0-20180309 2018-03-09 04:00:22 +01:00
ESPEasy release bot b0169b4aa7 automaticly updated release notes for mega-20180309 2018-03-09 04:00:11 +01:00
Unknown 786ec4714a Merge branch 'v2.0' into mega 2018-03-09 00:37:47 +01:00
Gijs NoorlanderandGitHub 67a28a7f97 Add other simple conversions like Celsius to Fahrenheit (#1033)
[issue #1015] Add other simple conversions like Celsius to Fahrenheit…
2018-03-09 00:35:06 +01:00
Unknown 18b8e61d32 [issue #1015] Add other simple conversions like Celsius to Fahrenheit, etc.
- %c_w_dir%   -  getBearing 
- %c_c2f%   -    String(CelsiusToFahrenheit) 
- %c_ms2Bft%   - String(m_secToBeaufort) 
- %c_cm2imp%   - centimeterToImperialLength 
- %c_mm2imp%   - millimeterToImperialLength 
- %c_m2day%   -  String(minutesToDay) 
- %c_m2dh%   -   minutesToDayHour 
- %c_m2dhm%   -  minutesToDayHourMinute 
- %c_s2dhms%   - secondsToDayHourMinuteSecond
2018-03-09 00:31:27 +01:00
Unknown 5821b0709c [issue #1015] Add other simple conversions like Celsius to Fahrenheit, etc.
- %c_w_dir%   -  getBearing 
- %c_c2f%   -    String(CelsiusToFahrenheit) 
- %c_ms2Bft%   - String(m_secToBeaufort) 
- %c_cm2imp%   - centimeterToImperialLength 
- %c_mm2imp%   - millimeterToImperialLength 
- %c_m2day%   -  String(minutesToDay) 
- %c_m2dh%   -   minutesToDayHour 
- %c_m2dhm%   -  minutesToDayHourMinute 
- %c_s2dhms%   - secondsToDayHourMinuteSecond
2018-03-09 00:29:52 +01:00
Unknown ec783fe03b [Rule Events] Add a number of events to handle in rules and awake timer
Changed the sleep checkbox to allow a number of seconds awake from deep sleep.

Also added the following events:

- MQTT#Connected
- WiFi#Connected
- System#Initialized
- Time#Set    Time set by an update from NTP.
- Time#Initialized  Time set for the first time since boot.
- Login#Failed

See #951
2018-03-08 23:00:33 +01:00
Gijs NoorlanderandGitHub 4d749b19fd [Rule Events] Add a number of events to handle in rules and awake timer (#1032)
[Rule Events] Add a number of events to handle in rules and awake timer
2018-03-08 22:55:19 +01:00
Unknown 6a66440a5f [Rule Events] Add a number of events to handle in rules and awake timer
Changed the sleep checkbox to allow a number of seconds awake from deep sleep.

Also added the following events:

- MQTT#Connected
- WiFi#Connected
- System#Initialized 
- Time#Set    Time set by an update from NTP.
- Time#Initialized  Time set for the first time since boot.
- Login#Failed

See #951
2018-03-08 21:43:52 +01:00
ESPEasy release bot 1b23efe48c automaticly updated release notes for mega-20180308 2018-03-08 04:00:08 +01:00
mvdbro 9a9d39763f Second step towards port monitoring without tasks 2018-03-07 16:17:40 +01:00
mvdbro 9f94ef073c First step towards port monitoring without tasks 2018-03-07 14:13:12 +01:00
ESPEasy release bot 9122565431 automaticly updated release notes for v2.0-20180307 2018-03-07 04:00:21 +01:00
ESPEasy release bot 000d2d7c77 automaticly updated release notes for mega-20180307 2018-03-07 04:00:09 +01:00
Unknown 64a0f79e02 [issue #1012] Removed Content-Length header + improved webserver speed
See: Web interface doesn't work on iOS #1012

The operatore+= String function now chunks long strings
2018-03-07 00:56:23 +01:00
Gijs NoorlanderandGitHub c1b945e6c1 [issue #1012] Removed Content-Length header + improved webserver speed (#1027)
[issue #1012] Removed Content-Length header + improved webserver speed
2018-03-07 00:55:48 +01:00
Unknown dbbe6b65dd [issue #1012] Removed Content-Length header + improved webserver speed
See: Web interface doesn't work on iOS #1012

The operatore+= String function now chunks long strings
2018-03-07 00:54:23 +01:00
Gijs Noorlander 92e4a8da9b [CSS] Quick fix for smaller displays (#1026)
[CSS] Quick fix for smaller displays by @doxikus
2018-03-06 21:53:54 +01:00
Gijs NoorlanderandGitHub 4611ef5d87 [CSS] Quick fix for smaller displays (#1026)
[CSS] Quick fix for smaller displays by @doxikus
2018-03-06 21:52:15 +01:00
Unknown 807cc1796d [CSS] Quick fix for smaller displays
Quick fix, created by @doxikus
2018-03-06 21:50:54 +01:00
soif 4bca2c6361 Initial re-organisation of plugin sets (#1019) 2018-03-06 09:53:17 +01:00
ESPEasy release bot 40e2d7ec8e automaticly updated release notes for v2.0-20180306 2018-03-06 04:00:17 +01:00
Gijs NoorlanderandDatuX 7318e87965 Fixes P073 plugin for latest TM1637 based 7 segments displays modules (#996) (#1022)
Fixes P073 plugin for latest TM1637 based 7 segments displays modules
2018-03-05 20:17:51 +01:00
ESPEasy release bot 9c3a28439f automaticly updated release notes for v2.0-20180305 2018-03-05 04:00:20 +01:00
ESPEasy release bot 82933ae170 automaticly updated release notes for mega-20180305 2018-03-05 04:00:08 +01:00
Unknown 503fd3555e Merge branch 'v2.0' into mega 2018-03-05 00:40:22 +01:00
Gijs NoorlanderandGitHub 127627a22c [issue #1003 ] Add conversion of wind direction to string (#1014)
[issue #1003 ] Add conversion of wind direction to string
2018-03-05 00:37:44 +01:00
Gijs NoorlanderandGitHub e59401e24f [issue #528] Set DOUT flash mode for all 1M builds (#1013)
[issue #528] Set DOUT flash mode for all 1M builds
2018-03-05 00:36:39 +01:00
Unknown 769f76d3dc [issue #1003 ] Add conversion of wind direction to string
Also made some clean-up of calls to string replacements.
Improved the lookup function to determine the wind direction (was 11.25 degree off)
Now it is also possible to add simple standard conversions like Celcius-Fahrenheit, m/s - Beaufort, etc.
2018-03-05 00:28:32 +01:00
Unknown 4eb7cf0859 [issue #528] Set DOUT flash mode for all 1M builds
See [this elaborate post on the different flash modes](https://www.esp32.com/viewtopic.php?t=1250)
2018-03-04 22:30:13 +01:00
Edwin Eefting a464f638ad automaticly updated release notes for v2.0-20180304b 2018-03-04 18:20:49 +01:00
Edwin Eefting f31cce4182 Merge branch 'v2.0' into mega 2018-03-04 18:14:58 +01:00
Edwin Eefting a5cfe1beec dont build in silent mode to prevent travis timeouts 2018-03-04 18:14:27 +01:00
Edwin Eefting f36fada375 Merge branch 'v2.0' into mega 2018-03-04 18:12:07 +01:00
soifandDatuX d51bce97f5 fixes typos in the issue template (#1006) 2018-03-04 18:09:34 +01:00
soifandDatuX 0368aa4d43 Add OS specific hidden files (#1005) 2018-03-04 18:09:08 +01:00
mvdbro 3c4aa7564f ESP32 - 32 Tasks -redo commit 2018-03-04 17:34:08 +01:00
mvdbro f46b89f1bd Merge branch 'mega' of https://github.com/letscontrolit/ESPEasy into mega 2018-03-04 17:15:43 +01:00
mvdbro 4e2b78056a ESP32 - 32 Tasks
Full reset needed!
2018-03-04 17:14:35 +01:00
Gijs NoorlanderandGitHub d94ce17fd4 Merge pull request #1009 from TD-er/bugfix/factory_reset_twice
[Webserver] Factory Reset was present twice
2018-03-04 16:27:16 +01:00
Unknown cd2c59ba5b [Webserver] Factory Reset was present twice
See issue #1008
2018-03-04 16:26:07 +01:00
mvdbro b6a6943668 ESP32 fix-2 for P020/P044
This time it actually works.
2018-03-04 12:27:38 +01:00
ESPEasy release bot a8fcb420e7 automaticly updated release notes for v2.0-20180304 2018-03-04 04:00:19 +01:00
ESPEasy release bot e1e894d540 automaticly updated release notes for mega-20180304 2018-03-04 04:00:08 +01:00
Unknown d15311e70a Merge branch 'v2.0' into mega 2018-03-04 00:50:43 +01:00
Gijs NoorlanderandGitHub 3ed6564063 [issue #892 ] Only use sensor type when really needed (#1004)
[issue #892 ] Only use sensor type when really needed
2018-03-04 00:45:52 +01:00
Unknown 5f575c0224 [issue #892 ] Only use sensor type when really needed
Only the Domoticz controllers need the sensor type. The rest just needs the number of sensor values.
2018-03-04 00:37:18 +01:00
Gijs NoorlanderandGitHub 34c1ba158f [issue #993] Add %unit% variable in MQTT subscribe topic (PR #1002)
[issue #993] Add %unit% variable in MQTT subscribe topic
2018-03-03 22:40:18 +01:00
Unknown 04ca424085 [issue #993] Add %unit% variable in MQTT subscribe topic 2018-03-03 22:39:09 +01:00
Gijs Noorlander 7a8f476e05 _P072_HDC1080 allow to send values to the controllers (#999)
_P072_HDC1080 add success and break statement.
it seems that without the break statement and success set to true, the values aren't sent back to the controller(s).
2018-03-03 21:30:22 +01:00
Gijs NoorlanderandGitHub eef8391ffc _P072_HDC1080 allow to send values to the controllers (#999)
_P072_HDC1080 add success and break statement.
it seems that without the break statement and success set to true, the values aren't sent back to the controller(s).
2018-03-03 21:29:12 +01:00
Gijs NoorlanderandGitHub d47751c31f Fixes P073 plugin for latest TM1637 based 7 segments displays modules (#996)
Fixes P073 plugin for latest TM1637 based 7 segments displays modules
2018-03-03 20:40:11 +01:00
Gijs Noorlander e42ab85f4b Merge pull request #1000 from uzi18/test3 (more comparisions in IF condition)
support for more comparisions in IF condition: >=,<=,!=,<>,<,>,= also fix extended conditions when first check is not '>'
2018-03-03 20:38:13 +01:00
Gijs NoorlanderandGitHub b048d3f1f8 Merge pull request #1000 from uzi18/test3 (more comparisions in IF condition)
support for more comparisions in IF condition: >=,<=,!=,<>,<,>,= also fix extended conditions when first check is not '>'
2018-03-03 20:37:07 +01:00
Bartlomiej Zimon f94ab3a04a - support for more comparisions in IF conditions: >=,<=,!=,<>,<,>,=
also fix extended conditions when first check is not >
2018-03-03 16:04:44 +01:00
mvdbro 1b9375f83b ESP32 Dallas DS18B20 fix
This is a quick fix for this sensor only. It seems that ESP32 RTOS needs more or differtent interrupt handling for time critical sensor code.
2018-03-03 14:08:20 +01:00
clumsy-stefanandGitHub a77798d18f add success and break statement
it seems that without the break statement and success set to true, the values aren ot sent back to the controller(s).
2018-03-03 13:05:25 +01:00
ESPEasy release bot 3094cb5260 automaticly updated release notes for v2.0-20180303 2018-03-03 04:00:19 +01:00
ESPEasy release bot ec4dd09968 automaticly updated release notes for mega-20180303 2018-03-03 04:00:08 +01:00
Unknown d68a5fb9d4 Merge branch 'v2.0' into mega 2018-03-03 02:23:03 +01:00
Gijs NoorlanderandGitHub 0e67480f46 Merge pull request #995 from TD-er/bugfix/mqtt_proper_case
Bugfix/mqtt proper case
2018-03-03 02:19:49 +01:00
Unknown c32f2cc89d Add AND/OR to rules & prevent unwanted case changes in strings (#994) 2018-03-03 02:09:41 +01:00
Unknown ad489f0db2 [Issue #827] MQTT not using proper case for %sysname% variable.
Some functions and plugins could change strings to lowercase.
Added some check also to help debugging.
2018-03-03 02:03:20 +01:00
Gijs NoorlanderandGitHub d9267fa9c2 Add Task device type to json by @s0170071 (#991)
Add Task device type to json by @s0170071
2018-03-02 22:40:20 +01:00
Unknown e82fb37870 Add Task device type to json by @s0170071
Taken from his branch, he forgot to PR.
2018-03-02 22:30:55 +01:00
Unknown 635c149f12 Merge branch 'v2.0' into mega 2018-03-02 22:16:37 +01:00
Gijs NoorlanderandGitHub 26f00dcdec [issue #293] json output nan values not double quoted (#990)
[issue #293] json output nan values not double quoted
2018-03-02 22:03:07 +01:00
Unknown b2bb1d039b [issue #293] json output nan values not double quoted
Generate valid JSON output
2018-03-02 21:49:06 +01:00
soif 57e256a5fa Fixes P073 plugin for latest TM1637 based 7 segments displays modules 2018-03-02 21:06:45 +01:00
Unknown c58e975b7e revert json to non-chunking #988 from s0170071/mega
revert json to non-chunking
2018-03-02 20:40:13 +01:00
Gijs NoorlanderandGitHub 7d16ffa4a4 revert json to non-chunking #988 from s0170071/mega
revert json to non-chunking
2018-03-02 20:36:42 +01:00
s0170071 856e370ba0 make handle_json return void 2018-03-02 15:00:48 +01:00
s0170071 4df9e7d065 Add git build and local time 2018-03-02 13:58:05 +01:00
s0170071 edb3857e04 revert json to non-chunking 2018-03-02 13:17:20 +01:00
ESPEasy release bot 08312cbcb7 automaticly updated release notes for v2.0-20180302 2018-03-02 04:00:21 +01:00
ESPEasy release bot fb1cc219ee automaticly updated release notes for mega-20180302 2018-03-02 04:00:10 +01:00
Unknown da7329891d Merge branch 'v2.0' into mega 2018-03-02 02:08:55 +01:00
Gijs NoorlanderandGitHub 953a53bb9a Merge pull request #985 from TD-er/bugfix/json_content-length
backport of "rule wildcard" + improve formatting of Webserver's StreamingBuffer
2018-03-02 01:58:53 +01:00
Unknown e9fac7926f [webserver] Layout of code to improve readability
Indentation was completely off, which made it hard to read.
Also added member json_format, which is set at start of stream.
2018-03-02 01:53:40 +01:00
mvdbroandUnknown 810a0b2aa9 Rule wildcard option on literal events
Added wildcard rule filter on literal string events
Changed "sendcontent free"content logging level to 'DEV'
2018-03-01 23:41:42 +01:00
Unknown 7f897bc856 Merge branch 'v2.0' into mega
Merge initiated from GitKraken directly on Letscontrol_it/ESPEasy
2018-03-01 23:31:00 +01:00
Gijs NoorlanderandGitHub 5d9137d1d2 Merge pull request #976 from TD-er/bugfix/P053_PMSx003DustPlugin
[issue #914] _P053_PMSx003 Dust Sensor looses sync
2018-03-01 23:07:38 +01:00
Gijs Noorlander 8de49cd38e Merge pull request #983 from kahvm/mega
Added support for degree sign on LCD1602/2004
2018-03-01 22:42:58 +01:00
Gijs NoorlanderandGitHub 0092ba92b5 Merge pull request #983 from kahvm/mega
Added support for degree sign on LCD1602/2004
2018-03-01 22:41:54 +01:00
Gijs NoorlanderandGitHub fe1c44f6b3 Merge pull request #980 from uzi18/formatout
Format output marge from mega to v2.0
2018-03-01 22:34:08 +01:00
Gijs NoorlanderandGitHub e39d588530 Merge pull request #975 from TD-er/merge/important_fixes_from_mega
Merge/important fixes from mega
2018-03-01 22:31:36 +01:00
kahvmandGitHub 7a4e3d954d Merge pull request #1 from kahvm/support-degree-sign-lcd1602
Support for degree sign on LCD1602
2018-03-01 22:00:41 +01:00
kahvmandGitHub 9dc4fefa0b Support for degree sign on LCD1602
More: https://www.letscontrolit.com/forum/viewtopic.php?p=11875#p11875
2018-03-01 20:09:50 +01:00
Unknown 4ca318f5a6 [Build error fix] Must-keep-focus-when-pressing-buttons...
Quickly commit + merge is never a good idea when some visitors arrive...
Fixed now.
2018-03-01 20:08:51 +01:00
mvdbro 695bb58d64 Rule wildcard option on literal events
Added wildcard rule filter on literal string events
Changed "sendcontent free"content logging level to 'DEV'
2018-03-01 14:29:10 +01:00
Bartlomiej Zimon 608a7212eb Merge branch 'mega' of github.com:letscontrolit/ESPEasy into test3 2018-03-01 03:02:23 +01:00
Bartłomiej ZimońandBartlomiej Zimon 37a24933f5 add format #O to templates to show OFF/ON instead 0/1 (#949)
* - pcfgpio,port,2 sets pin as input
- fix for #222,#702 - we can mix inputs and outputs now

* - extend conditions with AND/OR, now it is possible to simplify rules

test rules:
on test do
  if [test#a]=0 or [test#b]=0 or [test#c]=0
    event ok
  else
    event nok
  endif
endon

on test2 do
  if [test#a]=1 and [test#b]=1 and [test#c]=1
    event ok
  else
    event nok
  endif
endon

on test3 do
  if [test#a]=1 and [test#b]=1 or [test#c]=0
    event ok
  else
    event nok
  endif
endon

on test4 do
  if [test#a]=0
    event ok
  else
    event nok
  endif
endon

* - remove Serial print

* - add format #O to templates to show OFF/ON instead 0/1 - eg.: Pump:[Outputs#pump#O]

* - add formating for active low outputs eg.: #O!
2018-02-28 23:06:01 +01:00
Bartlomiej Zimon a6b447600f Merge branch 'v2.0' of github.com:letscontrolit/ESPEasy into v2.0 2018-02-28 22:43:52 +01:00
Unknown 5fbb900e5b [issue #914] Check first 2 bytes of packet 2018-02-28 22:39:34 +01:00
ESPEasy release bot aa5dee01fb automaticly updated release notes for v2.0-20180228 2018-02-28 04:00:20 +01:00
ESPEasy release bot 4e2a5d3b3d automaticly updated release notes for mega-20180228 2018-02-28 04:00:09 +01:00
Unknown 1a44ed6578 [issue #914] _P053_PMSx003 Dust Sensor looses sync
- Use peek instead of read, to make sure a complete packet is in the buffer.
- Flush buffer after processing a packet.
- Increased software serial buffer to the size of 3 packets.
- Peek (+ read garbage) 10 times per second to get the buffer in sync to start with start byte of packet.
- Decent delete + clean up of software serial allocation when changing settings (prevent memory leak)
- Move log String allocation to inside scope of function, not permanent allocated.
- Split into separate functions to make it better readable.
2018-02-28 02:11:33 +01:00
Bartłomiej ZimońandUnknown e86667e37e fix #964, add timeStringToSeconds and use it to compare time conditions (#965)
* - pcfgpio,port,2 sets pin as input
- fix for #222,#702 - we can mix inputs and outputs now

* - extend conditions with AND/OR, now it is possible to simplify rules

test rules:
on test do
  if [test#a]=0 or [test#b]=0 or [test#c]=0
    event ok
  else
    event nok
  endif
endon

on test2 do
  if [test#a]=1 and [test#b]=1 and [test#c]=1
    event ok
  else
    event nok
  endif
endon

on test3 do
  if [test#a]=1 and [test#b]=1 or [test#c]=0
    event ok
  else
    event nok
  endif
endon

on test4 do
  if [test#a]=0
    event ok
  else
    event nok
  endif
endon

* - remove Serial print

* - add format #O to templates to show OFF/ON instead 0/1 - eg.: Pump:[Outputs#pump#O]

* - add formating for active low outputs eg.: #O!

* - fix #964, add timeStringToSeconds and use it to compare time conditions

* - fix number of pages available to browse
2018-02-28 00:00:37 +01:00
s0170071andUnknown 0db1f78421 Add Factory Reset button to web interface (#954) 2018-02-27 23:59:31 +01:00
Bartłomiej ZimońandUnknown 780c34846e add format #O to templates to show OFF/ON instead 0/1 (#949)
* - pcfgpio,port,2 sets pin as input
- fix for #222,#702 - we can mix inputs and outputs now

* - extend conditions with AND/OR, now it is possible to simplify rules

test rules:
on test do
  if [test#a]=0 or [test#b]=0 or [test#c]=0
    event ok
  else
    event nok
  endif
endon

on test2 do
  if [test#a]=1 and [test#b]=1 and [test#c]=1
    event ok
  else
    event nok
  endif
endon

on test3 do
  if [test#a]=1 and [test#b]=1 or [test#c]=0
    event ok
  else
    event nok
  endif
endon

on test4 do
  if [test#a]=0
    event ok
  else
    event nok
  endif
endon

* - remove Serial print

* - add format #O to templates to show OFF/ON instead 0/1 - eg.: Pump:[Outputs#pump#O]

* - add formating for active low outputs eg.: #O!
2018-02-27 23:58:50 +01:00
Edwin Eefting a4dcc304a9 Merge branch 'v2.0' into mega 2018-02-27 23:43:36 +01:00
Gijs NoorlanderandDatuX a938bc78c1 [issue #968] Use template parser for OLED commands (#974)
N.B. Now even task values can be used in commands, next to special characters.
2018-02-27 23:43:18 +01:00
Gijs NoorlanderandDatuX d2c7743197 [issue #966] Add %sysweekday% and %sysweekday_s% (#973)
- %sysweekday%  number of the day (Sunday = 1)
- %sysweekday_s%  3 letter String of the weekday (Sun, Mon, Tue, ...)
2018-02-27 23:43:01 +01:00
Bartłomiej ZimońandDatuX f0fc20de57 fix #964, add timeStringToSeconds and use it to compare time conditions (#965)
* - pcfgpio,port,2 sets pin as input
- fix for #222,#702 - we can mix inputs and outputs now

* - extend conditions with AND/OR, now it is possible to simplify rules

test rules:
on test do
  if [test#a]=0 or [test#b]=0 or [test#c]=0
    event ok
  else
    event nok
  endif
endon

on test2 do
  if [test#a]=1 and [test#b]=1 and [test#c]=1
    event ok
  else
    event nok
  endif
endon

on test3 do
  if [test#a]=1 and [test#b]=1 or [test#c]=0
    event ok
  else
    event nok
  endif
endon

on test4 do
  if [test#a]=0
    event ok
  else
    event nok
  endif
endon

* - remove Serial print

* - add format #O to templates to show OFF/ON instead 0/1 - eg.: Pump:[Outputs#pump#O]

* - add formating for active low outputs eg.: #O!

* - fix #964, add timeStringToSeconds and use it to compare time conditions

* - fix number of pages available to browse
2018-02-27 23:42:20 +01:00
ESPEasy release bot d35a50be17 automaticly updated release notes for v2.0-20180227 2018-02-27 04:00:22 +01:00
ESPEasy release bot 537d4cd1e9 automaticly updated release notes for mega-20180227 2018-02-27 04:00:11 +01:00
Edwin Eefting 62422f4924 Merge branch 'v2.0' into mega 2018-02-27 00:42:15 +01:00
Edwin Eefting 04de145dbb [test suite] changes from mega to 2.0 2018-02-27 00:41:27 +01:00
Edwin Eefting 21840d0b26 [test suite] changes from mega to 2.0 2018-02-27 00:41:21 +01:00
Gijs NoorlanderandDatuX 076ce0127b [build conflict] Renamed ESP32 version of ping (#963)
Had a conflict with the ESP8266 version of ping.
Let's hope I did not break anything with the ESP32 builds @mvdbro does.
2018-02-27 00:10:17 +01:00
Edwin Eefting 226c0a6f83 Merge branch 'v2.0' into mega 2018-02-26 23:03:48 +01:00
s0170071andDatuX 6ffa8d92a6 Add Factory Reset button to web interface (#954) 2018-02-26 22:54:24 +01:00
Bartłomiej ZimońandDatuX dae2cc2f4a add format #O to templates to show OFF/ON instead 0/1 (#949)
* - pcfgpio,port,2 sets pin as input
- fix for #222,#702 - we can mix inputs and outputs now

* - extend conditions with AND/OR, now it is possible to simplify rules

test rules:
on test do
  if [test#a]=0 or [test#b]=0 or [test#c]=0
    event ok
  else
    event nok
  endif
endon

on test2 do
  if [test#a]=1 and [test#b]=1 and [test#c]=1
    event ok
  else
    event nok
  endif
endon

on test3 do
  if [test#a]=1 and [test#b]=1 or [test#c]=0
    event ok
  else
    event nok
  endif
endon

on test4 do
  if [test#a]=0
    event ok
  else
    event nok
  endif
endon

* - remove Serial print

* - add format #O to templates to show OFF/ON instead 0/1 - eg.: Pump:[Outputs#pump#O]

* - add formating for active low outputs eg.: #O!
2018-02-26 22:53:15 +01:00
Gijs NoorlanderandDatuX 555ccbe229 [BuildError] StreamingBuffer code cleanup + fix order member initialize (#961)
The order in which the members are defined should also be the order in which they will be initialized.

Also applied #958
2018-02-26 22:52:27 +01:00
mvdbro d277d22914 Fix ESP32 compile errors 2018-02-26 14:26:17 +01:00
ESPEasy release bot b5e4994392 automaticly updated release notes for v2.0-20180226 2018-02-26 04:00:21 +01:00
ESPEasy release bot cbdddf8c06 automaticly updated release notes for mega-20180226 2018-02-26 04:00:08 +01:00
Gijs NoorlanderandGitHub 8b5d22a081 Merge pull request #948 from TD-er/build/remove_duplicate_library
[softwareSerial] Remove duplicate with only capilization as difference
2018-02-25 21:29:09 +01:00
Unknown 88fc0a8445 [softwareSerial] Remove duplicate with only capilization as difference 2018-02-25 21:27:57 +01:00
Gijs NoorlanderandGitHub ec9187d038 Merge pull request #947 from letscontrolit/v2.0
V2.0 => Mega: Ping library and Webserver@LowMemory
2018-02-25 21:20:37 +01:00
s0170071andUnknown 51ede17d2a Update WebServer.ino 2018-02-25 21:15:33 +01:00
s0170071andUnknown 97ee69b371 V20 Webserver@LowMemory 2018-02-25 21:15:24 +01:00
Unknown f77ce9c8f7 [ping lib] Added ping library
It was linked as a dependency in PlatformIO.ini, but apparently will add complexity to Arduino IDE users.
2018-02-25 21:14:07 +01:00
Edwin Eefting 99cc6f72af Merge branch 'v2.0' into mega 2018-02-25 17:18:59 +01:00
Gijs NoorlanderandDatuX 848f43b704 [2k Webserver] Proper initialisation of StreamingBuffer members. (#941)
Was reported in Travis as build error.
2018-02-25 17:17:47 +01:00
Edwin Eefting 3a5ef5da81 device page doesnt need next/previous page buttons anymore 2018-02-25 17:12:45 +01:00
Edwin Eefting 3527b69718 Merge branch 'v2.0' into mega 2018-02-25 16:57:03 +01:00
Gijs NoorlanderandDatuX 54628bfca9 [timeouts] Improve response when hosts are not reachable (#939)
See #922 and #847

Problem with DNS resolve is that it is quite slow when resulting in a failure and it tends to keep the ESP occupied and make it unresponsive.

Changed the way it is connecting to a controller.
Not sure if http requests are still OK, maybe we should make an exception for those when selected to use DNS.
2018-02-25 14:15:56 +01:00
Gijs NoorlanderandDatuX 72ff745eff [Mega] rename SoftwareSerial lib #930 (#937)
Just a rename of the library directory + some notes in the library description to indicate the differences.
2018-02-25 14:12:59 +01:00
Gijs NoorlanderandDatuX aed566b6db [v2.0] Use ESPeasySoftwareSerial (#936)
This one has virtual destructor and will use less memory.
See issue #930.
2018-02-25 14:12:33 +01:00
Gijs NoorlanderandDatuX 504ea0c813 [v2.0 merge] 2kwebserver_merge_to_mega #929 (#934)
The v2.0 branch merge of the 2k webserver PR.
As test build, please try [these builds](https://www.dropbox.com/s/ky6ldixh6wgzd8k/2k_webserver_build_v2.0_20180221.rar?dl=0)
2018-02-25 14:12:11 +01:00
Gijs NoorlanderandDatuX 4ca5ef3f72 [v2.0] Added Vcc-binaries to deploy process #933 (#935)
PR for the V2.0 branch to add the VCC binaries to the deploy process.
2018-02-25 14:11:34 +01:00
Michael SchröderandDatuX dd9db3b557 Added Vcc-binaries to deploy process (#933) 2018-02-25 14:11:25 +01:00
Bartłomiej ZimońandDatuX 9c531b30bc - extend conditions with AND/OR, now it is possible to simplify rules (#932)
* - pcfgpio,port,2 sets pin as input
- fix for #222,#702 - we can mix inputs and outputs now

* - extend conditions with AND/OR, now it is possible to simplify rules

test rules:
on test do
  if [test#a]=0 or [test#b]=0 or [test#c]=0
    event ok
  else
    event nok
  endif
endon

on test2 do
  if [test#a]=1 and [test#b]=1 and [test#c]=1
    event ok
  else
    event nok
  endif
endon

on test3 do
  if [test#a]=1 and [test#b]=1 or [test#c]=0
    event ok
  else
    event nok
  endif
endon

on test4 do
  if [test#a]=0
    event ok
  else
    event nok
  endif
endon

* - remove Serial print
2018-02-25 14:04:55 +01:00
Bartłomiej ZimońandDatuX 67c8477a61 provide System@Sleep event (#875) (#931)
- provide System@Sleep event
- fixes #870 (mqtt not sent before sleep)
- call deepsleep at the end of loop - so we know all is done
2018-02-25 14:01:40 +01:00
Edwin Eefting cd30b81202 Merge branch '2kwebservermergetomega' of https://github.com/s0170071/ESPEasy into mega 2018-02-25 13:55:28 +01:00
s0170071andDatuX 550881faa5 Memtracker (#927)
* preparations for lwip2

* Add CRC32 to settings

* Add CRC to progmem

* Add crc of program memory to stettings and security settings

.. so that there is a warning if the settings are used by another binary than they were written with.

* Moved to md5

* Flash included, moved to MD5 now

* Broken comment

* Stability improvements

free memory went as low as 3000 bytes which made the webserver unresponsive.

* Add binary filename to crc2.py and sysinfo

* Update WebServer.ino

* Memory tracker

displays debug memory trace

WD   : Uptime 3 ConnectFailures 0 FreeMem 15304
Memtrace
0: lowest: 4456  PluginCall_s (35)-> 15328 PluginCall_s (35)-> 15328 PluginCall_s (35)-> 15328 PluginCall_s (35)-> 15328 PluginCall_s (35)-> 15328 PluginCall_s (35)-> 15328 PluginCall_s (35)-> 15328 PluginCall_s (35)-> 15328 PluginCall_s (35)-> 15328 handle_hardware-> 15192 sendWebPage-> 9672 sendWebPageChunkedData-> 5816 sendWebPageChunkedData-> 5128 sendWebPageChunkedData-> 4456 sendWebPageChunkedData-> 4456 
1: lowest: 4456  PluginCall_s (35)-> 15328 PluginCall_s (35)-> 15328 PluginCall_s (35)-> 15328 PluginCall_s (35)-> 15328 PluginCall_s (35)-> 15328 PluginCall_s (35)-> 15328 PluginCall_s (35)-> 15328 PluginCall_s (35)-> 15328 PluginCall_s (35)-> 15328 PluginCall_s (35)-> 15328 handle_hardware-> 15192 sendWebPage-> 9672 sendWebPageChunkedData-> 5816 sendWebPageChunkedData-> 5128 sendWebPageChunkedData-> 4456 
2: lowest: 3768  PluginCall_s (35)-> 15328 PluginCall_s (35)-> 15328 PluginCall_s (35)-> 15328 PluginCall_s (35)-> 15328 PluginCall_s (35)-> 15328 PluginCall_s (35)-> 15328 PluginCall_s (35)-> 15328 PluginCall_s (35)-> 15328 handle_hardware-> 15192 sendWebPage-> 9672 sendWebPageChunkedData-> 5816 sendWebPageChunkedData-> 5128 sendWebPageChunkedData-> 4456 sendWebPageChunkedData-> 4456 sendWebPageChunkedData-> 3768 
WD   : Uptime 4 ConnectFailures 0 FreeMem 15304

* Update Misc.ino
2018-02-25 13:14:57 +01:00
Gijs NoorlanderandDatuX 3d07466904 [MQTT] LWT "Connected" message doesn't have the retained flag (#925)
See comments of [Superpiffer](https://github.com/letscontrolit/ESPEasy/commit/a93a078c0b8ae4090c22717eacc8bc8ba92ad780#commitcomment-27718045)
2018-02-25 13:10:58 +01:00
s0170071 ed45945f21 Fix compile error when SD card is enabled 2018-02-24 18:03:38 +01:00
s0170071 f13abe8922 Removed double entry on info page 2018-02-24 17:32:44 +01:00
s0170071 34b0a683a9 fix travis 2018-02-24 17:10:52 +01:00
s0170071 9ab10437b5 Merge remote-tracking branch 's0170071/2kwebservermergetomega' into 2kwebservermergetomega 2018-02-24 16:59:54 +01:00
s0170071 b0b7408522 variable timeout 2018-02-24 16:59:46 +01:00
s0170071 b104942db9 Merge remote-tracking branch 's0170071/2kwebservermergetomega' into 2kwebservermergetomega 2018-02-24 16:57:17 +01:00
s0170071 a694b658b1 Merge remote-tracking branch 's0170071/2kwebservermergetomega' into 2kwebservermergetomega 2018-02-24 16:57:07 +01:00
s0170071 cb07a0d342 Merge remote-tracking branch 's0170071/2kwebservermergetomega' into 2kwebservermergetomega 2018-02-24 16:54:06 +01:00
s0170071 1ceaad04ec Merge branch '2kws_dynpayload' into 2kwebservermergetomega 2018-02-24 16:53:56 +01:00
s0170071 5cbf0c1e38 Merge branch '2kws_dynpayload' into 2kwebservermergetomega 2018-02-24 16:48:14 +01:00
Bartlomiej Zimon 4951f294b9 - remove Serial print 2018-02-24 16:34:30 +01:00
s0170071 ef0ef092f0 Merge remote-tracking branch 's0170071/2kws_dynpayload' into 2kws_dynpayload 2018-02-24 16:24:44 +01:00
s0170071ands0170071 46d3ae6a2b Merge branch 'mega' into 2kwebservermergetomega 2018-02-24 16:24:32 +01:00
Bartlomiej Zimon ef1bf646ab Merge branch 'mega' of github.com:letscontrolit/ESPEasy into mega 2018-02-24 10:32:09 +01:00
Bartlomiej Zimon f72a48ffc2 - extend conditions with AND/OR, now it is possible to simplify rules
test rules:
on test do
  if [test#a]=0 or [test#b]=0 or [test#c]=0
    event ok
  else
    event nok
  endif
endon

on test2 do
  if [test#a]=1 and [test#b]=1 and [test#c]=1
    event ok
  else
    event nok
  endif
endon

on test3 do
  if [test#a]=1 and [test#b]=1 or [test#c]=0
    event ok
  else
    event nok
  endif
endon

on test4 do
  if [test#a]=0
    event ok
  else
    event nok
  endif
endon
2018-02-24 10:19:12 +01:00
ESPEasy release bot da54ddda78 automaticly updated release notes for mega-20180224 2018-02-24 04:00:06 +01:00
Bartłomiej ZimońandBartlomiej Zimon 03ee569510 provide System@Sleep event (#875)
- provide System@Sleep event
- fixes #870 (mqtt not sent before sleep)
- call deepsleep at the end of loop - so we know all is done
2018-02-23 19:57:01 +01:00
mvdbro c24205713d ESP32 fixed P020 and P044 2018-02-23 15:21:48 +01:00
s0170071andGitHub 52d4cb804e Merge branch 'mega' into 2kwebservermergetomega 2018-02-23 15:07:18 +01:00
mvdbro ae077de72b Fix ESP32 compile errors 2018-02-23 14:38:14 +01:00
s0170071 86fa5ec6ae Merge into mega
... and removed obsolete function
2018-02-23 14:07:46 +01:00
s0170071 41c9d68422 Merge remote-tracking branch 'origin/mega' into 2kwebservermergetomega 2018-02-23 14:00:19 +01:00
ESPEasy release bot e713da5d79 automaticly updated release notes for mega-20180223 2018-02-23 04:00:07 +01:00
GHolliandDatuX edc261ca2b * BugFix: According to the data sheet, the offset for the detection range values (command byte 0x99) is 3..4 instead of 6..7 (#921)
Reference: http://www.winsen-sensor.com/d/files/infrared-gas-sensor/mh-z19b-co2-ver1_0.pdf
* Optimisation of the code
  - Using an enumeration for the commands to send
  - Removing redundancy of the commands stored in flash
  - Creating a function for the checksum calculation
2018-02-22 19:11:35 +01:00
s0170071andDatuX 8f4a52a6f1 Include name of binary file in crc2.py and sysinfo (#918)
* preparations for lwip2

* Add CRC32 to settings

* Add CRC to progmem

* Add crc of program memory to stettings and security settings

.. so that there is a warning if the settings are used by another binary than they were written with.

* Moved to md5

* Flash included, moved to MD5 now

* Broken comment

* Stability improvements

free memory went as low as 3000 bytes which made the webserver unresponsive.

* Add binary filename to crc2.py and sysinfo

* Update WebServer.ino
2018-02-22 18:55:45 +01:00
ESPEasy release bot af519748a6 automaticly updated release notes for v2.0-20180221 2018-02-21 04:00:20 +01:00
ESPEasy release bot c04b80b2f1 automaticly updated release notes for mega-20180221 2018-02-21 04:00:09 +01:00
Edwin Eefting cdbc2498c1 [test suite] corrected PUYA test. added erase/build/flash for all chips. preparations for full automatic hardware regression testing 2018-02-21 02:44:57 +01:00
Edwin Eefting 78997b4329 Merge branch 'v2.0' into mega 2018-02-21 02:11:18 +01:00
Edwin Eefting 2bece45712 apply PUYA patch to all available frameworks 2018-02-21 02:08:06 +01:00
Gijs NoorlanderandDatuX 10c73a001a [issue #899 ] Backport of DHT22 implementation on Mega (#913)
It has quite some changes, but according to [litrinhos](https://github.com/letscontrolit/ESPEasy/issues/899#issuecomment-366940174) it works, instead of the v2.0 implementation.
2018-02-21 01:26:08 +01:00
GHolliandDatuX 790a946cf6 Optimisation: Save RAM (freeing RAM by moving static data from RAM to program memory). (#910) 2018-02-21 00:02:59 +01:00
Stanislav MihicandDatuX 69c5be6489 Frontend (#906)
* Updating template structure, adding viewport meta name for mobile devices, feature ready for responsive layout

* Adding meta viewport, feature ready nad support for mobile devices, responsive layout, update template structure, adding article html5 tag, easier to style interface, find/replace uppercase to lowercase, matter of elegance and preference code readability :-)

* revert to default state and change only template related lines

* final check, revert uppercase

* Last template changes, lost in undo process :-)

* h6 footer TR
2018-02-20 23:54:46 +01:00
ESPEasy release bot 233ca2bf43 automaticly updated release notes for v2.0-20180220 2018-02-20 04:00:19 +01:00
ESPEasy release bot 3de400fc91 automaticly updated release notes for mega-20180220 2018-02-20 04:00:08 +01:00
Edwin Eefting edeea02f71 SENSOR_TYPE_TEMP_BARO changed, was probably implemented incorrectly before 2018-02-20 01:56:40 +01:00
Edwin Eefting 6fae1f79d8 function was moved to StringConverter.inp 2018-02-20 01:20:57 +01:00
Edwin Eefting 1222e04caf Merge branch 'v2.0' into mega 2018-02-20 01:08:29 +01:00
Bartłomiej ZimońandDatuX f38973aad6 - pcfgpio,port,2 sets pin as input (#897)
- fix for #222,#702 - we can mix inputs and outputs now
2018-02-20 00:57:55 +01:00
Gijs NoorlanderandDatuX b31b1d913f [issue #893] Fix globalSync not working when no controllers active (#896)
* [issue #893] Fix globalSync not working when no controllers active

See #893 and [this topic on the forum](https://www.letscontrolit.com/forum/viewtopic.php?p=24851#p24851)

* [issue #893] Global Sync call when no other controllers active
2018-02-20 00:52:43 +01:00
Gijs NoorlanderandDatuX fa3d4af8cb [Cleanup] Move String manipulating functions to single file (#895)
Makes it easier to re-use functions and improve them.
2018-02-20 00:52:18 +01:00
Gijs NoorlanderandDatuX 29320aab90 [isue #877] Add VCC enable firmware file to release list (#894)
* [isue #877] Add VCC enable firmware file to release list

Added one for the testing build.
Not sure if we should add one for every build, since these flags will lead to an explosion of release versions. 
But at least we will test builds with FEATURE_ADC_VCC define enabled more often.

* Add define FEATURE_ADC_VCC to the PUYA build

Since it is so hard to make a puya version on your own.
2018-02-20 00:50:56 +01:00
Gijs NoorlanderandGitHub 3bc8609611 Merge pull request #905 from TD-er/bugfix/DHTinit_sequence_wrong
[issue #899] DHT22 readings not received
2018-02-20 00:16:51 +01:00
Gijs NoorlanderandGitHub c43d6b3769 Merge pull request #904 from TD-er/feature/log_event_name
[Event Log] Add event name to event processing time log
2018-02-20 00:16:19 +01:00
Gijs NoorlanderandGitHub e9e2ea32ed Merge pull request #903 from TD-er/bugfix/OpenHAB_MQTT_topic_parser_fix
[issue #847] Fix last letter of command is cut in OpenHAB MQTT
2018-02-20 00:15:51 +01:00
Unknown 24b7d1f438 [issue #899] DHT22 readings not received
Applied fix as suggested here: https://github.com/adafruit/DHT-sensor-library/issues/48
2018-02-20 00:04:13 +01:00
Unknown 4febf08501 [Event Log] Add event name to event processing time log
As suggested on the forum by [Methusalem](https://www.letscontrolit.com/forum/viewtopic.php?p=24887#p24887)
2018-02-19 23:31:19 +01:00
Unknown 7f4eae19f4 [issue #847] Fix last letter of command is cut in OpenHAB MQTT
Thanks [jivkopavlovski](https://github.com/letscontrolit/ESPEasy/commit/f23d9fa3d3def506e1401c2208c8a19a1d5d1da2#commitcomment-27660279) for pointing this out (and testing ofcourse)
2018-02-19 22:57:57 +01:00
ESPEasy release bot c13952d04c automaticly updated release notes for v2.0-20180219 2018-02-19 04:00:19 +01:00
ESPEasy release bot 3032463917 automaticly updated release notes for mega-20180219 2018-02-19 04:00:09 +01:00
Bartlomiej Zimon f5e84a155e - pcfgpio,port,2 sets pin as input
- fix for #222,#702 - we can mix inputs and outputs now
2018-02-19 01:38:52 +01:00
Edwin Eefting bbb97bfc7e Merge branch 'v2.0' into mega 2018-02-18 19:23:09 +01:00
Gijs NoorlanderandDatuX e51f7683a5 [issue #890] Split overlap for both Domoticz controllers to helper (#891)
* [issue #890] Split overlap for both Domoticz controllers to helper

Both Domoticz controllers had quite some overlap in code.
And where they differ, one of them was faulty and/or already fixed.

Now this overlap is split into a Domoticz helper file to keep code duplication to a minimum.

* [issue #890] Fix some wierd data corruption

Do not store references in a Json object, but just the string :)

* [Domoticz] Add WiFi strength and battery info
2018-02-18 13:18:23 +01:00
Gijs NoorlanderandDatuX e747756dd2 [Build Mega] Fix for Build Mega 20180217 (#889) 2018-02-18 13:17:02 +01:00
Gijs NoorlanderandDatuX 1ad6fd6ea0 [issue #885] MAC address as system variable (#887)
%mac% will be replaced by the MAC-address of the ESP board.
%mac_int% will show the integer representation of the last 24 bits (MAC address without the OUI part) for use in rules.
2018-02-18 13:16:42 +01:00
ESPEasy release bot d2ec15a4bf automaticly updated release notes for v2.0-20180218 2018-02-18 04:00:11 +01:00
Gijs NoorlanderandDatuX f23d9fa3d3 [issue #847 ] OpenHAB MQTT rewrite topic parser (#886)
* [issue #847 ] OpenHAB MQTT rewrite topic parser

When OpenHAB MQTT controller was selected, the web interface becomes unresponsive when the controller tab was selected.
Also the ESP almost freezes when MQTT messages were sent.

This is an attempt to make them work faster.
Also a lot of string manipulation, copies and resizes are now no longer needed and the received values are checked to be valid int or float before used.

* signed unsigned warning
2018-02-17 13:18:52 +01:00
s0170071 6df5840db9 Fixed String redeclaration 2018-02-17 09:45:40 +01:00
s0170071 5f79e4b922 Merge Webserver 2018-02-17 09:43:46 +01:00
s0170071 e058507b9a Merge remote-tracking branch 'origin/mega' into 2kRamWebserver 2018-02-17 09:26:32 +01:00
ESPEasy release bot 3cea522ec4 automaticly updated release notes for v2.0-20180217 2018-02-17 04:00:18 +01:00
ESPEasy release bot 5c4defdf6e automaticly updated release notes for mega-20180217 2018-02-17 04:00:07 +01:00
Edwin Eefting e58ea2a3fe Merge branch 'v2.0' into mega 2018-02-16 21:43:23 +01:00
Gijs NoorlanderandDatuX a93a078c0b [issue #869] Added 'LWT' to last will topic and improved CPU load (#883)
* [issue #869] Added 'LWT' to last will topic and improved CPU load

See #869 for discussion on Last Will Topic.
Also changed the way it tried to reconnect to make it return a lot faster when connection is not (yet) possible and call the PubSubClient::loop() at a much slower pace to reduce CPU usage. (See #847)
This higher CPU load was probably introduced when fixing #683.

* [MQTT] Fix error reporting success status with longer payloads

Applied PR https://github.com/knolleary/pubsubclient/pull/360/files

* made MQTT_CALLBACK_SIGNATURE for esp32 functional

Applied PR https://github.com/knolleary/pubsubclient/pull/336
2018-02-16 21:32:53 +01:00
Gijs NoorlanderandDatuX 0e0e7be95a [OLED Framed] ESP Easy logo (#876) 2018-02-16 21:29:44 +01:00
Bartłomiej ZimońandDatuX 2b7a61469f provide System@Sleep event (#875)
- provide System@Sleep event
- fixes #870 (mqtt not sent before sleep)
- call deepsleep at the end of loop - so we know all is done
2018-02-16 21:28:52 +01:00
Gijs NoorlanderandDatuX ce02c9e039 [issue #853] Favicon.ico (#874)
* [issue #853] Favicon.ico

Added a very small favicon.ico of the ESPeasy logo. (1150 Bytes, 16x16)

* [Favicon] Added instructions to change icon.

In the comments. Just use 'xxd' from the (Linux) commandline.
2018-02-16 21:27:58 +01:00
Gijs NoorlanderandDatuX 1e9dc1d14c [issue 866] Try to stop logging to serial when serial is not read. (#868)
First attempt, not clear yet how to detect it.
See #866

Also preparation for future improvement on logging. (to detect whether there is some logging active so Strings may not have to be prepared.
2018-02-16 21:26:18 +01:00
s0170071andGitHub 75f1c6c140 Update .gitignore 2018-02-14 20:56:44 +01:00
ESPEasy release bot 9a6f7360da automaticly updated release notes for v2.0-20180214 2018-02-14 04:00:21 +01:00
ESPEasy release bot e3cd057ad8 automaticly updated release notes for mega-20180214 2018-02-14 04:00:10 +01:00
Edwin Eefting fec069ba00 Merge branch 'v2.0' into mega 2018-02-14 03:27:15 +01:00
Edwin Eefting d835ef679c updated deploy script for PUYA 2018-02-14 03:23:50 +01:00
Edwin Eefting 9144e7901b travis build fix for PUYA 2018-02-14 03:10:30 +01:00
Edwin Eefting 858ce397c3 workaround for PUYA flash chips with write issues #650 2018-02-14 03:01:42 +01:00
Gijs NoorlanderandDatuX 78c9ff70be [v2.0] Blynk controller (#865)
* update Blynk controller

- use of real controller index
- we use idx
- check if password not empty
- use real password

* fix for Blynk Controller

- use of real controller index
- we use idx
- check if password not empty
- use real password
- use proper port

* Update _C012.ino

add SENSOR_TYPE_SWITCH support

* [v2.0] Blynk controller
2018-02-14 00:23:59 +01:00
Bartłomiej ZimońandDatuX b2db97e808 fix for Blynk Controller (#863)
* fix for Blynk Controller

- use of real controller index
- we use idx
- check if password not empty
- use real password
- use proper port

* Update _C012.ino

add SENSOR_TYPE_SWITCH support
2018-02-14 00:23:38 +01:00
s0170071 4e537461f2 Fix travis
unsigned int -> int comparison
2018-02-13 21:59:18 +01:00
s0170071 dc7bb12581 4->12 Devices per page
that was easy :-)
2018-02-13 21:53:04 +01:00
s0170071andGitHub 0c80cdc119 Merge branch 'mega' into 2kRamWebserver 2018-02-13 21:36:05 +01:00
s0170071 37210031b7 Cleanup and +1k Ram
- on 2.4.0 git /low mem LWIP ram goes never below 20k, during TX core dives down to 18,7k (each main menu clicked once, plain new config.)
- Fixed json output
- cleanup of send function#
- un-split css, transfer to buffer byte by byte (prevents 1.7k temporary string)
- removed commented-out function
2018-02-13 21:28:10 +01:00
ESPEasy release bot 40eb3e7ceb automaticly updated release notes for v2.0-20180213 2018-02-13 04:00:20 +01:00
ESPEasy release bot d7134e6b87 automaticly updated release notes for mega-20180213 2018-02-13 04:00:09 +01:00
Edwin Eefting 8dc1924059 Merge branch 'v2.0' into mega 2018-02-13 03:16:06 +01:00
Edwin Eefting a7b77b6008 make blynk stuff compile again 2018-02-13 03:11:09 +01:00
Gijs NoorlanderandDatuX 88320d25fc [MQTT] Allow for background tests while waiting for wifi (#860)
Recent changes in 'early exit' when not connected, triggered lots of retry events.
Added some function to allow to wait for WiFi and in the meantime do some background tasks.
2018-02-13 03:01:15 +01:00
Edwin Eefting 649305a2dd Merge branch 'v2.0' into mega 2018-02-13 01:43:11 +01:00
Gijs NoorlanderandDatuX d49197a621 [issue #825] Change labels and password form for Thingspeak controller (#849)
See #825

Added option for controllers to change their display string on some controller fields in the web interface.
When password field label is non-default it also implies to use a visible textfield instead of a password field.
2018-02-13 01:17:04 +01:00
Henri de JongandDatuX 2371b0f315 Added support for pioneer ir signals (#844) 2018-02-13 01:14:44 +01:00
Gijs NoorlanderandDatuX 9abdd097c9 Formatting user vars (re-do of PR#482) + enabled check OpenHabMQTT (#851)
Re-implementation of PR #482 which was done on Mega branch.
Just to keep merges simple between branches. (and improve readabilit)

Also added a simple check to C005 (OpenHAB MQTT) on receiving messages. (see #847 )
2018-02-13 01:07:24 +01:00
Gijs NoorlanderandDatuX f8849cb601 Bugfix/oled framed less memory (#859)
* [OLED] Move font to oled lib dir

It is specific for use wth that library.

* [OLED framed] Stop reading from flash constantly and live update WiFi

See #857
The OLED Framed plugin was reading from spiffs all of the time (on every display update)
Now the data is only read from SPIFFS when needed.
Also made the WiFi strength indicator update every second (only when changed) to be able to see changes in WiFi status much easier.
2018-02-13 01:05:36 +01:00
soifandDatuX b293e8fee0 P012 - Fix/handle lines exceeding LCD width + allow to clear line b4 print (#852)
* Update Library LiquidCrystal_I2C to the latest version

* Fix LCD command (when message is longer than columns) that get split into the wrong lines - issue #603

* Added a "LCD command mode" parameter to handle how exceeding message would be treated, and if the line should be first padded with space.
2018-02-13 01:03:24 +01:00
Gijs NoorlanderandDatuX 11b1c8505a [v2.0] Fix compile errors on ESP32 (#848)
Cherry pick from Mega branch to avoid future merge conflicts.
2018-02-13 00:39:12 +01:00
Gijs NoorlanderandDatuX 9cb3ceed83 [P001 Switch] Fix a mixup in previous fix for switch (#845)
It was causing issues when people upgraded from previous builds.
Leaving it would cause high CPU loads, instable wifi, and incorrect set switch type when upgrading from older builds.

Only thing is when people were using it as a dimmer and used one of the builds in the last few weeks.
Then it will be used as a 'switch', not a dimmer. Change and set and all is fine again.
2018-02-13 00:38:51 +01:00
Gijs NoorlanderandDatuX 2ac1df9482 [issue #839] Add command support for setting contrast for OLED Framed (#841)
* [issue #839] Add command support for setting contrast for OLED Framed

See #839

* [issue #839] Should not use 0 as off value, since that is default

With 0 as "off", the display would be off when not set.
Changed it to 1, which is not a value that can be set other than with the commands
2018-02-13 00:38:01 +01:00
Gijs NoorlanderandDatuX 59b7768722 Blynk controler (re-implementation of PR#92) (#837)
* Blynk controler (re-implementation of PR#92)

See #92
This plugin is just ported from the old implementation, which was not merged into the Mega branch.
It now is using a lot of the newly created functions and optimizations.
But not yet tested.

* Update _C012.ino
2018-02-13 00:32:02 +01:00
Gijs NoorlanderandDatuX d4e5742b1c [#804] Degree symbol for non-framed OLED display (#835) 2018-02-13 00:24:32 +01:00
s0170071 baa1df620f Travis... 2018-02-12 16:55:24 +01:00
s0170071 a310811919 fix Travis
uninitialized variable.
2018-02-12 13:46:36 +01:00
s0170071 e9dd5da690 Add Ram usage debug message
usually shows: 
Ram usage: Webserver only: 1048 including Core: 3120
2018-02-12 11:48:01 +01:00
s0170071 f9c25489d1 fix download page
don't stream this one.
2018-02-12 09:26:00 +01:00
s0170071 46ee928b07 navMenuIndex
fixed order. Needs to be set before stream starts.
2018-02-12 08:11:15 +01:00
s0170071 3af102f2ad Unused variable 2018-02-12 07:07:12 +01:00
s0170071 ca53ec0263 fix travis
unused variable
2018-02-12 06:48:46 +01:00
s0170071 5ca7c073f1 fix travis 2018-02-12 06:34:19 +01:00
ESPEasy release bot f815564dc7 automaticly updated release notes for v2.0-20180212 2018-02-12 04:00:22 +01:00
ESPEasy release bot b320c2a1e2 automaticly updated release notes for mega-20180212 2018-02-12 04:00:09 +01:00
Gijs NoorlanderandDatuX 2b51a4d7c4 [Issue #831] Use DOUT flash mode (#834)
Set DOUT flash mode in the firmware image.
2018-02-12 02:24:16 +01:00
soifandDatuX 01d0723424 Add Device Name in /json page (#815)
* Add Name in /json page

* Json dev friendly (updatable) syntax

* Reorder Json field
2018-02-12 02:11:01 +01:00
s0170071 3f68154819 Merge branch 'webserverminmem' into mega 2018-02-11 22:24:17 +01:00
s0170071 7b1c4483bb Merge remote-tracking branch 's0170071/webserverminmem' into webserverminmem 2018-02-11 22:23:50 +01:00
s0170071 572d9c0714 2k Webserver 2018-02-11 22:23:38 +01:00
mvdbro b85010006b Fix compile errors on ESP32 2018-02-11 14:46:08 +01:00
s0170071 48643cf87e Merge remote-tracking branch 's0170071/webserverminmem' into webserverminmem 2018-02-09 12:28:17 +01:00
s0170071 9ea594afeb Optimized memory usage
memory never goes below 10k now. 
Added wait for memory return on header send, 
Added wait for memory return on chunk end send,
removed duplicate of data stashing with  getWebPageTemplateVar
2018-02-09 12:27:45 +01:00
ESPEasy release bot aec539be43 automaticly updated release notes for v2.0-20180209 2018-02-09 04:00:26 +01:00
ESPEasy release bot 749c8cd931 automaticly updated release notes for mega-20180209 2018-02-09 04:00:15 +01:00
s0170071 49a783c381 "Content-Type","text/html" 2018-02-08 20:11:07 +01:00
s0170071 c9b81f7ab9 Wait for memory be like before send chunked
goes not below 9680 bytes now
2018-02-08 19:57:16 +01:00
AndreyandDatuX eb2dbb5b90 Added HIGH-Z state options for GPIO command (#833)
Add command like 'GPIO,12,2' for set pin to HIGH-Z (INPUT) state.
2018-02-08 19:37:52 +01:00
wdonkerandDatuX e49f31121c Add trigger for rulesprocessing (#826)
* Update _C002.ino

Trigger rulesprocessing om MQTT receive message

* Replace direct call by createRuleEvents

Change to createRuleEvents
2018-02-08 19:33:32 +01:00
s0170071 91c6e3af61 Does Travis like extern "C" ? 2018-02-08 17:31:26 +01:00
s0170071 faeb921bcf Merge remote-tracking branch 's0170071/webserverminmem' into webserverminmem 2018-02-08 17:13:01 +01:00
s0170071 9928f56ad3 try fix travis 2018-02-08 17:12:53 +01:00
s0170071andGitHub 61d27084c1 trigger travis re-compile
trigger travis re-compile to see if the compile failure was due to a quick re-submission.
2018-02-08 10:04:07 +01:00
s0170071 e5393a9fa4 Adapted timeout 2018-02-07 22:08:43 +01:00
s0170071 1cbc49021a tcp_cleanup for LWIP1 & 2 2018-02-07 22:04:39 +01:00
s0170071 84f389b44e Timeout 100ms 2018-02-07 17:29:16 +01:00
s0170071 765775e22f Adjusted to min 7k free 2018-02-07 17:21:28 +01:00
s0170071 02c97c4513 Webserver min memory
memory went as low as 3k, so wait for it to return ...
2018-02-07 17:15:23 +01:00
ESPEasy release bot bd874c4a13 automaticly updated release notes for v2.0-20180206 2018-02-06 05:00:21 +01:00
ESPEasy release bot d87cd7eafe automaticly updated release notes for mega-20180206 2018-02-06 05:00:10 +01:00
Edwin Eefting 58bb62cc1a Merge branch 'v2.0' into mega 2018-02-06 01:08:36 +01:00
Gijs NoorlanderandDatuX 6b8ea6c15b [issue #727] Proper user interface to set DST rules (#823)
See #727
And it only took 4 bytes extra storage :)

When initialized with an invalid setting for DST, (like fresh after flashing), it will use the CEST/CET setting.
2018-02-06 00:42:45 +01:00
Gijs NoorlanderandDatuX a62dd5ce8f [issue #817] Added mail header to SMTP (#820)
* [issue #817] Added mail header to SMTP

N.B. use only mail address (no name, no '<>' etc) as sender.

* [SMTP] Add user/pass to send email.

* [issue #817] Added user + passwd authentication to SMTP notifications

Tested with smtp2go.com (non TLS mail proxy)
It is now possible to add username + passwd when sending mail.
If both left empty, authentication will not be used.
2018-02-05 23:59:24 +01:00
Gijs NoorlanderandDatuX 92889b6cf1 Backport OLED framed from mega + support special characters (#818)
* [OLED framed] Backport of OLED lib upgrade from Mega to v2.0

Lots of issues with older lib and the newer version in the Mega branch appeared to be very stable.

* [OLED framed] Use less string allocations

And a first attempt to display the Euro sign. (does not yet work)

* [Special Char] Allow to use special characters

For some special characters, it is often hard to find them and/or use them in URL or JSON streams.
For a subset of supported special characters, a short notation and HTML equivalent is added.
These can be used anywhere.

* [OLED lib] Fixed memory leak

Man library did some allocs without free.
Also unneeded allocs.

* Applied pull requests from esp8266-oled-ssd1306:
https://github.com/squix78/esp8266-oled-ssd1306/pull/169
https://github.com/squix78/esp8266-oled-ssd1306/pull/157
https://github.com/squix78/esp8266-oled-ssd1306/pull/144

And applied the suggestions from issues:
https://github.com/squix78/esp8266-oled-ssd1306/issues/170
https://github.com/squix78/esp8266-oled-ssd1306/issues/161

* [OLED] Support multiple display resolutions

Applied PR from esp8266-oled-ssd1306:
https://github.com/squix78/esp8266-oled-ssd1306/pull/133

* [OLED] Better Brightness / Contrast control

Suggestions taken from this issue:
https://github.com/squix78/esp8266-oled-ssd1306/issues/134

* [OLED] Set contrast to High by default, when no choice was made

Sounds like a valid choice, based on the findings in issue #821

* Compiler error on comments

As suggested here: https://github.com/TD-er/ESPEasy/pull/3/files
2018-02-05 23:56:17 +01:00
soifandDatuX b5479575eb All Advanced Settings as 'DEFAULT_' Defines (#813)
* Implements all Advanced Settings as "DEFAULT_" defines

* Organise and comment "DEFAULT_" defines
2018-02-05 23:50:48 +01:00
s0170071andDatuX 201d013230 Add compile time (#811) 2018-02-05 23:49:26 +01:00
ESPEasy release bot 6fead68f34 automaticly updated release notes for v2.0-20180203 2018-02-03 05:00:20 +01:00
ESPEasy release bot 9a77b1727c automaticly updated release notes for mega-20180203 2018-02-03 05:00:11 +01:00
GrovkillenandGitHub 2f26cd13bc Update README.md 2018-02-02 12:52:12 +01:00
GrovkillenandGitHub f0d35527df Update README.md
Made the "warning" stand out a bit more.
2018-02-02 12:50:58 +01:00
ESPEasy release bot 3a9ef290e8 automaticly updated release notes for v2.0-20180202 2018-02-02 05:00:23 +01:00
ESPEasy release bot 9cbaa4d7e7 automaticly updated release notes for mega-20180202 2018-02-02 05:00:12 +01:00
Edwin Eefting af4ad9fbcb Merge branch 'v2.0' into mega 2018-02-02 03:17:01 +01:00
soifandDatuX 36a9bdae72 Json page also Shows Git Build (#808)
* remove un-needed spaces in JSON (save some memory?)

* Add the Git Build string in the /json page
2018-02-02 03:11:02 +01:00
soifandDatuX ebfa0a45a6 Custom define file (#807)
* Allows to use a Custom.h file to change defaults setting without changing the repo file

* Custom.h example
2018-02-02 02:40:56 +01:00
soifandDatuX c2e70360c4 Allows to define the IP address when in AP Mode (#806) 2018-02-02 02:39:47 +01:00
Edwin Eefting 8bdfa656de Add CRC checks to all binaries when building a release with travis. fixes #779 2018-02-02 02:27:23 +01:00
Edwin Eefting 952bf68b93 Merge branch 'v2.0' into mega 2018-02-02 01:37:35 +01:00
DatuXandGitHub 712a5e80d0 Update README.md 2018-02-02 01:23:42 +01:00
DatuXandGitHub a44069ae26 Update README.md 2018-02-02 01:17:06 +01:00
DatuXandGitHub 13f73c0156 Update README.md 2018-02-02 01:15:34 +01:00
soifandDatuX bb88225cab Fix Syslog : include Hosname instead of Unit Number - now RFC3164 compliant (#805) 2018-02-02 00:40:04 +01:00
Gijs NoorlanderandDatuX 3089b288b2 [issue #739] Reconnect MQTT when Unit Name has changed. (#803)
See #739
When %sysname% has changed, force a reconnect of the MQTT client.

Also made the client ID guaranteed unique by using the MAC address.
2018-02-02 00:38:28 +01:00
soifandDatuX 6abea46eb5 Fixes invalid '/json' page output format : DateTimeString is now correctly quoted (#802) 2018-02-02 00:37:01 +01:00
Gijs NoorlanderandDatuX ffa73aee59 [v2.0] Resource friendly string replacement (#798)
As part of #698 and also since these system variable replacement may grow.
Some replacement strings may need some work to create and such effort is wasted if the matching string does not occur.
To improve this and still remain readable, I added a simple macro to check first and then create the strings only when needed.
Some strings are already present, so these do not use the macro since searching first and then look again to replace will take more effort.
2018-02-02 00:34:02 +01:00
Gijs NoorlanderandDatuX f4b7e97997 [issue #794] Add longpulse_ms command (#796)
See #794
2018-02-02 00:30:49 +01:00
Gijs NoorlanderandDatuX b32212b061 [Mega] Fix pointer arithmetic on void pointers for CRC computations (#795)
It was a change I made last week to get it to compile for the 2.4.0 core lib, but made an error in the pointer arithmetic.
No it shoud be correct.
See https://github.com/letscontrolit/ESPEasy/issues/792#issuecomment-361714575
2018-02-02 00:28:58 +01:00
ESPEasy release bot 66d0de684a automaticly updated release notes for v2.0-20180130 2018-01-30 05:00:23 +01:00
ESPEasy release bot cae3baf71e automaticly updated release notes for mega-20180130 2018-01-30 05:00:12 +01:00
Edwin Eefting 27db33f1bd Merge branch 'v2.0' into mega 2018-01-30 01:54:10 +01:00
Gijs NoorlanderandDatuX 23d5709957 [Log] Clean up of log routines and more intuitive log level input (#788)
As part of #781, #747 and the general cleanup issue #698.
2018-01-30 01:50:24 +01:00
Edwin Eefting b96e12f217 Merge branch 'v2.0' into mega 2018-01-29 22:52:14 +01:00
Gijs NoorlanderandDatuX 16eb08afa0 [#784] Add %rssi% as system variable (#786)
* [#784] Add %rssi% as system variable

See #784

* [#787] Add %unit% and %ssid% system variable

See #787
Unit is the unit number of the ESP device.
SSID is the name of the WiFi accesspoint the ESP device is connected with.
2018-01-29 22:51:26 +01:00
Edwin Eefting ad8e229c06 Merge branch 'v2.0' into mega 2018-01-29 20:52:56 +01:00
Gijs NoorlanderandDatuX b9b7ceccb6 Bugfix/issue 740 allow mqtt as controller 2 3 (#785)
* [issue #740] Allow MQTT controller to be on any controller

See #740

Still there is an issue when >1 MQTT controller is selected and enabled.
Currently only one MQTT controller may be active.

* [issue #740] Add warning when >1 MQTT controller is active

Add a warning to the web interface when >1 MQTT controller is active.
See #740
2018-01-29 18:12:47 +01:00
Edwin Eefting 5c4bf52b66 forgot to commit last framed oled display fix 2018-01-29 17:30:01 +01:00
ESPEasy release bot 34369d268e automaticly updated release notes for v2.0-20180126 2018-01-26 05:00:22 +01:00
ESPEasy release bot 0ec7085022 automaticly updated release notes for mega-20180126 2018-01-26 05:00:12 +01:00
Edwin Eefting 913cd67eee Merge branch 'v2.0' into mega 2018-01-25 22:15:57 +01:00
Gijs NoorlanderandDatuX 3292051bae Update _C007.ino (#774) (#776)
This change allows to send the switch state to Emoncms, previously it was ignored
2018-01-25 22:07:07 +01:00
Gijs NoorlanderandDatuX 2586b94e28 [Mega] Force 2.3.0 for all builds and add an option for 2.4.0 core (#775)
* [Mega] Force 2.3.0 for all builds and add an option for 2.4.0 core

This way we can test issues easier and people are still using 2.3.0 core version.

* Update platformio.ini

Environment labels should not use dots. Then they will not show in the build selection box.
2018-01-25 22:06:45 +01:00
Gijs NoorlanderandDatuX d492347f31 [V2.0] Allow IRremoteESP8266 to be built with core 2.4.0 (#773)
* [V2.0] Allow IRremoteESP8266 to be build with core 2.4.0

A partial cherrypick of #772, to make merging easier.
Just some simple patches on the use of min() and max() in the library to allow it to compile using the 2.4.0 core lib. Actual use of this core lib is still prohibited by the check in ESPEasy.ino.

* [core 2.3.0] Force PlatformIO to use the 2.3.0 core libs

This update forces the PlatformIO environment to load the 1.5.0 version of espressif8266@1.5.0, which uses Core 2.3.0
2018-01-25 22:04:54 +01:00
josemariaaraujoandDatuX b811b13483 Update _C007.ino (#774)
This change allows to send the switch state to Emoncms, previously it was ignored
2018-01-25 15:49:31 +01:00
Gijs NoorlanderandDatuX 56f9bc9c3a [issue #759] Disable Senseair ABC due to firmware issues (#771)
See #759

Just commented the Set ABC functionality. People may compile it for themselves, but be aware of possible consequences.
2018-01-25 15:48:21 +01:00
Gijs NoorlanderandDatuX c149888bed [Mega] Allow compile with 2.4.0 core library (#772)
Last few days, lots of issues reported by users who installed the 2.4.0 core libraries.
e.g. #769 and #763
It appeared the default PlatformIO Espressif 8266 1.6.0 libs now include the 2.4.0 core libraries.
Now I have to find a way to get my own environment back to the 2.3.0 core libs and see how I can get PlatformIO Espressif 8266 library back to version 1.5.0
2018-01-25 15:47:58 +01:00
ESPEasy release bot 82cea3db2e automaticly updated release notes for v2.0-20180124 2018-01-24 05:00:20 +01:00
ESPEasy release bot 8aea298854 automaticly updated release notes for mega-20180124 2018-01-24 05:00:09 +01:00
Edwin Eefting 5617fbe0a0 Merge branch 'mega' of github.com:letscontrolit/ESPEasy into mega 2018-01-24 03:17:32 +01:00
Edwin Eefting 6a643da8ee Merge branch 'v2.0' into mega 2018-01-24 03:17:20 +01:00
Edwin Eefting 2f32799b67 fix #718. also update display on save and removed graphical boot logo to conserve space. also fixes #713. (web interface will be non repsonsive during scrolling now, but there is no easy fix for that) 2018-01-24 02:58:25 +01:00
s0170071andDatuX ee568a76c1 Space (#767)
* preparations for lwip2

* Add CRC32 to settings

* Add CRC to progmem

* Add crc of program memory to stettings and security settings

.. so that there is a warning if the settings are used by another binary than they were written with.

* Moved to md5

* Flash included, moved to MD5 now

* Broken comment
2018-01-23 23:55:55 +01:00
s0170071andDatuX beaf077b06 Broken comment (#766)
* preparations for lwip2

* Add CRC32 to settings

* Add CRC to progmem

* Add crc of program memory to stettings and security settings

.. so that there is a warning if the settings are used by another binary than they were written with.

* Moved to md5

* Flash included, moved to MD5 now

* Broken comment
2018-01-23 23:55:29 +01:00
Gijs NoorlanderandDatuX fd5da94f9c [issue #758] P029 MQTT helper does not log anymore (#764)
See #758
2018-01-23 23:54:34 +01:00
ESPEasy release bot 0694fcc5fb automaticly updated release notes for v2.0-20180123 2018-01-23 05:00:20 +01:00
ESPEasy release bot e36a9f163e automaticly updated release notes for mega-20180123 2018-01-23 05:00:10 +01:00
Edwin Eefting 17f0f6637a Merge branch 'v2.0' into mega 2018-01-23 04:58:52 +01:00
Edwin Eefting bc91939757 request mainpage when checking if reboot is complete 2018-01-23 04:57:20 +01:00
Edwin Eefting eb743f95cf added easy reboot warning and function to work around several issues 2018-01-23 04:49:16 +01:00
Edwin Eefting 0ec770fc51 Merge branch 'v2.0' into mega 2018-01-23 02:43:07 +01:00
Edwin Eefting ed4cdc3d90 clear custom task and controller settings when selecting a different device or protocol. replaces #762 . fixes #721 2018-01-23 02:37:02 +01:00
Edwin Eefting 9da5f465d1 Merge branch 'v2.0' into mega 2018-01-23 01:02:12 +01:00
Edwin Eefting 8e72ace3b5 test suite: espcli can now do stuff for all configured nodes 2018-01-23 00:50:00 +01:00
s0170071andDatuX 5230a4fe4f CRC on settings and security settings and progmem (#720)
* preparations for lwip2

* Add CRC32 to settings

* Add CRC to progmem

* Add crc of program memory to stettings and security settings

.. so that there is a warning if the settings are used by another binary than they were written with.

* Moved to md5

* Flash included, moved to MD5 now
2018-01-22 23:58:43 +01:00
Edwin Eefting b236887718 Merge branch 'v2.0' into mega 2018-01-22 23:54:55 +01:00
Gijs NoorlanderandDatuX 2527cbe097 Central function for system variable replacement (#757)
* Central function for system variable replacement

Related to:
- #698 => Not complete
- #709 => fixed
- #751 => fixed

Redesign of PR #485 (in mega branch)

One note: no sensor values can be used in controllers. Is this what we want, or should we call parseTemplate everywhere parseSystemVariables is being used?
Also not all controllers apparently allow system variables. Is this also correct?

* [issue 757] Add %lcltime% to display date + time

As requested by @PsychoAndi at PR #757

* [issue 757] Add local time to JSON output

As suggested by @PsychoAndi
2018-01-22 23:38:14 +01:00
Edwin Eefting cbca4c3efa Merge branch 'v2.0' into mega 2018-01-22 23:35:45 +01:00
Edwin Eefting 5b0e9d934c test suite: now possible to run all tests at once. fixes 2018-01-22 23:32:46 +01:00
ESPEasy release bot 19429e8507 automaticly updated release notes for v2.0-20180122 2018-01-22 05:00:19 +01:00
ESPEasy release bot a67f92176f automaticly updated release notes for mega-20180122 2018-01-22 05:00:08 +01:00
Edwin Eefting 3922827fad Merged v2.0 changes and fixed some regressions 2018-01-22 01:43:42 +01:00
Gijs NoorlanderandDatuX 0c637da19f [#732] Only process P029 MQTT helper when enabled (#743)
See #732
Also did some small optimizations for when no Domoticz MQTT controller enabled and/or task enabled.
2018-01-21 17:10:08 +01:00
Gijs NoorlanderandDatuX 48f168da9d [issue #745] Set IPaddress to 0.0.0.0 when read from empty string (#754)
Also str2ip now uses IPAddress.fromString()
2018-01-21 17:08:15 +01:00
ESPEasy release bot 3357eb287c automaticly updated release notes for v2.0-20180121 2018-01-21 05:00:13 +01:00
Edwin Eefting 5da1c54b70 test suite: fixes. testing boot gpio states 2018-01-21 04:28:12 +01:00
Edwin Eefting c5bbdb401a test suite: lots of refactoring and fixing 2018-01-21 03:23:22 +01:00
Edwin Eefting f69b84d24b test suite: fixed issues, started working on nodo 2018-01-21 01:53:22 +01:00
Edwin Eefting 1250e09fef cleaned up nodo logging. fixed domotics SENSOR_TYPE_WIND inconsistency 2018-01-21 01:52:36 +01:00
Edwin Eefting fbf22ba7af test suite: generelized controller testing in test005 2018-01-20 21:49:24 +01:00
ESPEasy release bot 5c26d50227 automaticly updated release notes for v2.0-20180120 2018-01-20 05:00:12 +01:00
Edwin Eefting 47be037be9 Merge branch 'v2.0' of github.com:letscontrolit/ESPEasy into v2.0 2018-01-19 05:45:10 +01:00
Edwin Eefting bc4f7d390c test suite: started on testcase to test all sensor types via the dummy plugin 2018-01-19 05:44:57 +01:00
Edwin Eefting 9fe64834f9 added QUAD to c002. fixed getBearing and SENSOR_TYPE_WIND. 2018-01-19 05:43:50 +01:00
ESPEasy release bot 4d943c2386 automaticly updated release notes for v2.0-20180119 2018-01-19 05:00:18 +01:00
ESPEasy release bot 4b298d6e31 automaticly updated release notes for mega-20180119 2018-01-19 05:00:07 +01:00
jctualandDatuX c0c65364e5 DHT plugin update (#736)
Modification of DHT plugin to use Sonoff am2301 and si7021 sensors.
Also correct some NAN readings.
2018-01-19 02:43:22 +01:00
Edwin Eefting 51b76682cf test suite: added dht22 2018-01-19 02:35:38 +01:00
Edwin Eefting 5f89698308 Merge branch 'v2.0' into mega 2018-01-19 01:30:40 +01:00
Edwin Eefting 400ee82686 test suite domoticz mqtt + found few fixmes 2018-01-19 01:28:14 +01:00
ESPEasy release bot 485f97bdc2 automaticly updated release notes for v2.0-20180118 2018-01-18 05:00:19 +01:00
ESPEasy release bot 5821377b6c automaticly updated release notes for mega-20180118 2018-01-18 05:00:08 +01:00
Edwin Eefting e6e3c1ddee refactoring test suite controller stuff 2018-01-18 03:37:25 +01:00
Edwin Eefting a6ea35ef9c Merge branch 'v2.0' into mega 2018-01-18 02:15:01 +01:00
Edwin Eefting fe9a579dc3 added fixme 2018-01-18 02:03:54 +01:00
Gijs NoorlanderandDatuX 017aad051e [issue 728] Proper reconnect for MQTT controllers (#737)
See #728
Also looked into the very strange configuration settings lookup for MQTT settings. The way it was, the settings for the first MQTT controller were used even when the actual MQTT controller was inactive or using different settings.

Now the controller selected in the the plugin is being used and when no plugin setting is available (and also for P037 MQTT import) the first active MQTT controller will be used.
2018-01-18 01:04:55 +01:00
Gijs NoorlanderandDatuX 8a30659015 [issue 733] Fix for negative values on MQTT import (#735)
See #733.
The '-' was parsed, but not copied to the tmp char array to be converted.
2018-01-18 00:44:08 +01:00
ESPEasy release bot ed7f597b3d automaticly updated release notes for mega-20180117 2018-01-17 05:00:08 +01:00
Edwin Eefting 6700030d7c Merge branch 'mega' of github.com:letscontrolit/ESPEasy into mega 2018-01-17 00:16:09 +01:00
Edwin Eefting f45c7650de fix #719 (initial ds18b20 value after power on 85 degrees) 2018-01-17 00:15:59 +01:00
papperoneandDatuX a36ee65865 merge with main branch (#648)
* removed note for 74HC595

74HC595 pin reminder not needed as this chip won't be supported anymore

* deleted GPIO notes referring to 75HC595 not supported
2018-01-16 20:20:52 +01:00
ESPEasy release bot b61c638f0a automaticly updated release notes for v2.0-20180116 2018-01-16 05:00:21 +01:00
ESPEasy release bot dfb5b8a4c5 automaticly updated release notes for mega-20180116 2018-01-16 05:00:11 +01:00
Edwin Eefting 09e5d6abcd now supports powercycle to test for bugs like #719 2018-01-16 04:15:48 +01:00
Edwin Eefting 2aafbb57a8 made test resumable and importable 2018-01-16 03:41:29 +01:00
Edwin Eefting 9d3dd49e9d Merge branch 'v2.0' into mega 2018-01-16 00:20:12 +01:00
Edwin Eefting 744f22112b Merge branch 'v2.0' of github.com:letscontrolit/ESPEasy into v2.0 2018-01-15 23:04:48 +01:00
Edwin Eefting b38edfb672 fixed custom build path 2018-01-15 23:04:40 +01:00
Gijs NoorlanderandDatuX a73875a2e2 [AutoDST] Added Auto DST (Bugfix/v2.0 issue569) (#726)
* [Time] Moved time related code to separate file

* [AutoDST] Added Auto DST

Preliminary support for Auto DST, as requested in #569
Also did a little refactorin of time related code, with #698 in mind.
All time related code is split into a few files based on its function.

The currently selected DST will start on Last Sunday March 2am and end on Last Sunday October 3am.
This is the most frequently used DST, according to https://en.wikipedia.org/wiki/Daylight_saving_time_by_country

To change it, currently the code has to be changed in the function applyTimeZone(). Several examples are given right below that function.
Problem is where to store the information of the timezone, how to use it in the web interface and how convenient it is to set by hand.
The UTC offset in minutes still has to be entered and whether or not DST should be enabled.
2018-01-15 21:51:15 +01:00
ESPEasy release bot 0833029c82 automaticly updated release notes for mega-20180114 2018-01-14 05:00:08 +01:00
s0170071andDatuX 71cf207bf7 preparations for lwip2 (#707) 2018-01-13 12:22:32 +01:00
ESPEasy release bot f7ea185f80 automaticly updated release notes for v2.0-20180113 2018-01-13 05:00:20 +01:00
ESPEasy release bot 3d3a035822 automaticly updated release notes for mega-20180113 2018-01-13 05:00:10 +01:00
Edwin Eefting 11a94aae25 testsuite: working on generic http/mqtt controller emulatior receiving 2018-01-13 03:21:09 +01:00
Edwin Eefting af3bf5217d fix version number 2018-01-13 03:07:38 +01:00
Edwin Eefting 11f47f26e6 Merge branch 'v2.0' into mega 2018-01-13 03:04:33 +01:00
Edwin Eefting 57c6fbbaab ESPEasy v2.0 only supports compiling under arduino core 2.3.0 to prevent issues like #705 when people use Arduino IDE to compile with arduino core 2.4.0 2018-01-13 02:53:15 +01:00
Edwin Eefting f7b37306aa automaticly updated release notes for mega-20180112 2018-01-12 02:05:49 +01:00
Edwin Eefting 8b3d8f6ad4 Merge branch 'v2.0' into mega 2018-01-12 02:03:58 +01:00
Edwin Eefting 7a9726063d dont make same release twice 2018-01-12 02:02:43 +01:00
Edwin Eefting d6680b604f dont make same release twice 2018-01-12 02:02:27 +01:00
Edwin Eefting 25ef1803e0 release bot fixes 2018-01-12 01:59:03 +01:00
Edwin Eefting 2bc72151bc automaticly updated release notes for v2.0-20180112 2018-01-12 01:56:54 +01:00
Edwin Eefting 93ceae3bef fixed releasebot issues with multiple branches 2018-01-12 01:56:34 +01:00
Edwin Eefting b5cad22afd Merge branch 'v2.0' into mega 2018-01-12 01:41:13 +01:00
Edwin Eefting 2bf31a1985 testsuite requirements 2018-01-12 01:40:20 +01:00
Gijs NoorlanderandDatuX 5796f50439 [v2.0 #470] Do not send invalid values to a controller (#701)
Prevent sending of invalid values (NaN, inf) to any controller.
Simple test is to output any plugin value with formula set to "%value%/0" and try to send it to any controller.
Is a fix for #470 and #693
2018-01-12 01:06:36 +01:00
Edwin Eefting 36415d424e first http domoticz test works 2018-01-12 01:04:47 +01:00
Edwin Eefting 76be5dd8d9 added http server emulation and domotics http to testsuite 2018-01-12 00:50:45 +01:00
Edwin Eefting 407dae03ca merged v2.0 changes 2018-01-11 23:00:15 +01:00
Gijs NoorlanderandDatuX 6e760cd25b [Issue 699] Incorrect shown device name (#700)
And some improvements in readability and performance of webserver.
2018-01-11 22:45:50 +01:00
ESPEasy release bot 69c03cafb9 automaticly updated release notes for v2.0-20180111 2018-01-11 05:00:18 +01:00
ESPEasy release bot c17e683834 automaticly updated release notes for mega-20180111 2018-01-11 05:00:08 +01:00
Edwin Eefting 311abeabd0 Merge branch 'v2.0' into mega 2018-01-11 03:27:25 +01:00
Edwin Eefting b20d4a10ba working on http mocker for test suite 2018-01-11 03:26:30 +01:00
Edwin Eefting 548bf8b867 added frame oled test 2018-01-11 01:49:57 +01:00
Edwin Eefting 0b68e16894 test suite fixes 2018-01-11 01:35:32 +01:00
Edwin Eefting 33e46addbb analysed some code and added comments 2018-01-11 00:54:19 +01:00
Edwin Eefting 04f27e0d03 Merge branch 'v2.0' into mega 2018-01-11 00:52:36 +01:00
Edwin Eefting 628ff925b7 Merge branch 'v2.0' of github.com:letscontrolit/ESPEasy into v2.0 2018-01-11 00:48:44 +01:00
Edwin Eefting 6fddf25a39 copied test-stuff from mega to v2.0 to do some testing 2018-01-11 00:48:24 +01:00
Gijs NoorlanderandDatuX 84e58285af [v2.0_kamstrup] Plugin configuration does not load (#697)
Could not change the device settings. The PLUGIN_WEBFORM_LOAD case was not handled.
2018-01-10 23:22:40 +01:00
Edwin Eefting fc5103de8d oops...somehow git did made some changes :( 2018-01-10 22:34:36 +01:00
Edwin Eefting 14b6345277 no changes, just merge the v2.0 branch 2018-01-10 22:22:29 +01:00
Gijs NoorlanderandDatuX 9a70037e32 Merge/v2.0 dev13 to mega (#695)
* [switch] Fixed switch behavior and default settings. (#675)

As described in #673 .
The problem was partly related to the default values stored in flash ("0"), which was not a valid value for the switch type.

When upgrading from an older version of ESPeasy, make sure to check the switch type (normal switch or dimmer) and save the settings for the switch device again, even when nothing was changed.
Default configuration and new added switches will now work like intended.

When a controller is enabled (e.g. Domoticz MQTT or -HTTP) and the button is pressed multiple times, the ESP may reboot. See issue #674.

* ABC calibration feature added (#606)

* [Flash info] Detailed flash information (#678)

Last few days a number of issues and forum topic was about the type of flash used on the ESP boards.

This is an extension of the detailed information page.

Perhaps also merge with the newer and more clear layout of pull request #624?
That pull request was only merged to the mega branch.
I kept the changes local, but perhaps they should be placed in the "Storage" section introduced with #624.
Maybe also that pull request should get merged into the v2.0 branch.

* Bugfix/v2.0 crash switch (#682)

* [crashes] Added constructors to initialize all members in structs

Numerous structs are defined, but none of them have default constructors and there is no guarantee the members will be set when used. 
With these default constructors, the parameters at least have an initialized value.

* [PubSubClient] Add bound checks on the internal buffer

Not sure if this was really causing an issue, but proper bound checks are always a good thing.

* [Crash Switch] Disabled delayBackground and added yield() calls

Something really fishy is going on with the delayBackground function, which will result in crashes when pressing the switch multiple times, with Domoticz MQTT enabled as first controller.
Disabled for now and delay(1) added to give background tasks a chance to do their work and make sure the watchdog doesn't perform a reset.

* [CI build errors] Commented out some unused variables

Travis considers them as error and fails the checks.

* [CI check] Out-of-bounds check fix

* actually ignore MQTT messages that are too big.

* moved mqtt stuff outside of backgroundtasks(). fixes #683 in my test scenario

* [Adafruit MPR121] Change deprecated name setThreshholds to setThresholds (#685)

See #684

* fixed plugin id of "Communication - Kamstrup Multical 401". (accidental octal notation)

* changed devicecombobox handling to save a lot of memory on device page. fixes #654 #676 and could be triggered by #683 in some cases.

* [CPPcheck] v2.0 ControllerSettingsStruct some variables not initialized (#692)

Fixing these cppcheck errors:
101.43s$ cppcheck --enable=warning src/*.ino -q --force -I src --include=src/ESPEasy.ino --error-exitcode=1
[src/ESPEasy.ino:500]: (warning) Member variable 'ControllerSettingsStruct::HostName' is not initialized in the constructor.
[src/ESPEasy.ino:500]: (warning) Member variable 'ControllerSettingsStruct::Publish' is not initialized in the constructor.
[src/ESPEasy.ino:500]: (warning) Member variable 'ControllerSettingsStruct::Subscribe' is not initialized in the constructor.
2018-01-10 21:51:42 +01:00
Edwin Eefting 3a8323faab Merge branch 'v2.0' of github.com:letscontrolit/ESPEasy into v2.0 2018-01-10 19:19:57 +01:00
Edwin Eefting fe1944922c changed devicecombobox handling to save a lot of memory on device page. fixes #654 #676 and could be triggered by #683 in some cases. 2018-01-10 19:19:48 +01:00
Gijs NoorlanderandDatuX 7ea0c767fa [CPPcheck] v2.0 ControllerSettingsStruct some variables not initialized (#692)
Fixing these cppcheck errors:
101.43s$ cppcheck --enable=warning src/*.ino -q --force -I src --include=src/ESPEasy.ino --error-exitcode=1
[src/ESPEasy.ino:500]: (warning) Member variable 'ControllerSettingsStruct::HostName' is not initialized in the constructor.
[src/ESPEasy.ino:500]: (warning) Member variable 'ControllerSettingsStruct::Publish' is not initialized in the constructor.
[src/ESPEasy.ino:500]: (warning) Member variable 'ControllerSettingsStruct::Subscribe' is not initialized in the constructor.
2018-01-10 19:15:35 +01:00
Edwin Eefting ec18e5c530 updates version numbering documentation 2018-01-10 16:34:58 +01:00
ESPEasy release bot 885781850b automaticly updated release notes for v2.0-20180110 2018-01-10 16:14:23 +01:00
ESPEasy release bot 443b46f383 added releasebot to v2.0 branch 2018-01-10 16:13:24 +01:00
GrovkillenandGitHub 8ce1aa0092 Update README.md
Re-arranged the date format to = the current code standard.
2018-01-10 16:01:27 +01:00
Edwin Eefting 801a591282 fixed plugin id of "Communication - Kamstrup Multical 401". (accidental octal notation) 2018-01-10 15:09:10 +01:00
Gijs NoorlanderandDatuX 740efcb763 [Adafruit MPR121] Change deprecated name setThreshholds to setThresholds (#685)
See #684
2018-01-10 02:45:50 +01:00
Edwin Eefting 67fa39f4ed moved mqtt stuff outside of backgroundtasks(). fixes #683 in my test scenario 2018-01-10 02:25:01 +01:00
Edwin Eefting 7a8bb7c0e0 actually ignore MQTT messages that are too big. 2018-01-10 01:56:05 +01:00
Gijs NoorlanderandDatuX 961b1106aa Bugfix/v2.0 crash switch (#682)
* [crashes] Added constructors to initialize all members in structs

Numerous structs are defined, but none of them have default constructors and there is no guarantee the members will be set when used. 
With these default constructors, the parameters at least have an initialized value.

* [PubSubClient] Add bound checks on the internal buffer

Not sure if this was really causing an issue, but proper bound checks are always a good thing.

* [Crash Switch] Disabled delayBackground and added yield() calls

Something really fishy is going on with the delayBackground function, which will result in crashes when pressing the switch multiple times, with Domoticz MQTT enabled as first controller.
Disabled for now and delay(1) added to give background tasks a chance to do their work and make sure the watchdog doesn't perform a reset.

* [CI build errors] Commented out some unused variables

Travis considers them as error and fails the checks.

* [CI check] Out-of-bounds check fix
2018-01-10 00:49:47 +01:00
Gijs NoorlanderandDatuX 9dc549e62d [Flash info] Detailed flash information (#678)
Last few days a number of issues and forum topic was about the type of flash used on the ESP boards.

This is an extension of the detailed information page.

Perhaps also merge with the newer and more clear layout of pull request #624?
That pull request was only merged to the mega branch.
I kept the changes local, but perhaps they should be placed in the "Storage" section introduced with #624.
Maybe also that pull request should get merged into the v2.0 branch.
2018-01-10 00:35:27 +01:00
chunter1andDatuX c1a11ff6e4 ABC calibration feature added (#606) 2018-01-05 17:11:29 +01:00
Gijs NoorlanderandDatuX 151bf18cc6 [switch] Fixed switch behavior and default settings. (#675)
As described in #673 .
The problem was partly related to the default values stored in flash ("0"), which was not a valid value for the switch type.

When upgrading from an older version of ESPeasy, make sure to check the switch type (normal switch or dimmer) and save the settings for the switch device again, even when nothing was changed.
Default configuration and new added switches will now work like intended.

When a controller is enabled (e.g. Domoticz MQTT or -HTTP) and the button is pressed multiple times, the ESP may reboot. See issue #674.
2018-01-05 17:03:44 +01:00
ESPEasy release bot d2e2522c07 automaticly updated release notes for mega-20180104 2018-01-04 03:13:01 +00:00
ESPEasy release bot 4a212302e0 changed date format of nightly builds 2018-01-03 14:51:40 +00:00
ESPEasy release bot 993dd7ade3 automaticly updated release notes for mega-01032018 2018-01-03 04:00:06 +00:00
Edwin Eefting e4d68b9d0e readme updates 2018-01-03 01:32:02 +01:00
Edwin Eefting b5e093bc80 changed readme title 2018-01-03 01:06:48 +01:00
Edwin Eefting d544fc84e8 changed readme to reflect mega branch and automated builds 2018-01-03 01:04:18 +01:00
Edwin Eefting e6dba4456c Merge branch 'v2.0' into mega 2018-01-03 00:52:03 +01:00
Edwin Eefting a0a0c31a49 updated travis link to reflect v2.0 2018-01-03 00:51:56 +01:00
Edwin Eefting d2777a9b15 updated travis link to reflect v2.0 2018-01-03 00:50:49 +01:00
Edwin Eefting c7d12bb798 Merge branch 'v2.0' into mega 2018-01-03 00:48:13 +01:00
Edwin Eefting 901d87ad1d updated readme to reflect new binary names 2018-01-03 00:47:35 +01:00
ESPEasy release bot ef912a4484 automaticly updated release notes for mega-01022018 2018-01-02 23:32:50 +00:00
ESPEasy release bot b4debd9559 created releasebot script 2018-01-02 23:30:53 +00:00
Edwin Eefting d7277649dd merged v2.0 branch. disabled memory checker (takes too long, perhaps enable it via a commit keyword?) 2018-01-03 00:28:22 +01:00
Edwin Eefting f177ff9e11 automaticly updated release notes for v2.0.0-dev13 2018-01-02 17:41:19 +01:00
Edwin Eefting 53a2008a0a still trying to fix travis release scripts.. 2018-01-02 17:41:06 +01:00
Edwin Eefting 2525b0e502 automaticly updated release notes for v2.0.0-dev13 2018-01-02 14:24:08 +01:00
Edwin Eefting b7e7c0bb0b release all binaries by doing the full compile step as last 2018-01-02 14:21:21 +01:00
Edwin Eefting a397796188 automaticly updated release notes for v2.0.0-dev13 2018-01-02 13:25:28 +01:00
Edwin Eefting 33ec7e5240 Merge branch 'v2.0' into mega 2018-01-02 12:49:55 +01:00
Gijs NoorlanderandDatuX d62b692b3b [SDS011] Allow the sensor to sleep to extend sensor lifetime (#668)
* [SDS011] Add send commands to sensor

In the library used to communicate to the SDS011 sensor was only support to receive data from the sensor and not query the sensor or set another mode.
This is needed for #499 , to let the sensor sleep.

N.B. code is not yet tested, only implemented while reading the datasheet "Laser Dust Sensor Control Protocol V1.3"

* [SDS011] Lessen load on ESP by polling less frequent and use SoftSerial

The default setting were to set the delay to 0 and use an own software serial implementation.
This caused frequent timeouts on the web interface, WiFi reconnects, etc.
Now the already present SoftSerial is being used. This will gather all the data from the serial port and thus there is no need to poll 50 times a second.
Now the ESP is much more responsive.

* [SDS011] Allow the sensor to sleep to extend sensor lifetime

The internal laser of the SDS011 only will last for about 1 year when ran continuously.
When the RX of the sensor is connected, it can be set to sleep for N minutes between measurements. This will extend the lifetime of the sensor and reduce power consumption.
This sleep time is stored inside the flash of the sensor, so it can be set once and then the RX on the sensor could be disconnected again to be used for other purposes.
2018-01-02 12:22:57 +01:00
paulv888andDatuX 493bfd56b9 usesID = true (#666)
fixes #646
2018-01-02 11:41:01 +01:00
Gijs NoorlanderandDatuX 0f0bc30052 [PubSubClient] Bug in handling domainname (#660)
As discussed in pull request #629 and the new issue #658 and also on https://github.com/knolleary/pubsubclient/issues/375
In short, the PubSubClient does not store the domainname used to connect to, but only a pointer to the string.
However, PubSubClient should not expect this pointer to remain valid, since it is outside its scope. So PubSubClient should keep the domainname stored in its own variables.

This fixes the problem where the MQTT broker is no longer reachable after a while when using DNS instead of IP.
2017-12-31 15:51:21 +01:00
krikkandDatuX abbfa24ca6 added support for the TSL2591 Sensor based on Adafruit Library (#661)
* initial support for TSL2591 sensor

* return lux, visible, ir and full light separately

* better plugin init

* check sensor initialization before reading it..

* incorporated a few pending fixes for the adafruit library

* minor typo
2017-12-31 15:35:44 +01:00
Gijs NoorlanderandDatuX fae1edc859 [Security] Add IP-based filtering to web interface and http-commands. (#653)
* [mega] Detect client IP for SysInfo page and some cleanup

Added formatIP functions for readability and add client IP to SystemInfo page as preparation to detect origin just to get an idea of possibilities for #647.
Also added some reserve() statements to Strings to prevent heap fragmentation.

* [mega] Cleanup formatIP calls

* [security] #647 Add IP filtering to web interface and commands

As discussed in #647:
In the Config tab, a "Client IP filtering" section is added.
This allows for 3 levels of IP filtering:
* "Allow All" - does not imply any filtering based on IP address of the client.
* "Allow Local Subnet" - Allow only clients from within the local subnet, based on IP and subnetmask of the ESP.
* "Allow IP range" - Allow only clients within a range of IP-addresses.

Settings like these are very likely to lock out the rightful owner, so there are also two commands added, which can be sent via the serial connection.
* accessinfo
* clearaccessblock

The first one just displays the current active IP filtering.
The "clearaccessblock" command will temporarily disable the access filtering. This allows the user to login and reset the access filtering.

"Allow Local Subnet" is set as factory default.
Only when first loading a new firmware with this feature and existing configuration, the "All Allowed" is active (the old default)
2017-12-31 15:31:20 +01:00
s0170071andDatuX a9a741f775 fix chunking (#649)
* change chunking 

so that manual chunking is only done with core 2.3.0. 2.4.0rc2 and later do chunking web transfer implicitly

* Update WebServer.ino
2017-12-28 20:16:03 +01:00
Edwin Eefting c0d482e4fc merged v2.0 fixes 2017-12-28 19:01:16 +01:00
Gijs NoorlanderandDatuX 2b256389dd [WiFi] Avoid timeouts when not connected to WiFi (#639)
* [DNS/IP] Obey UseDNS setting for all controllers

As described in #381 #261 and #521
A first attempt to let all controllers use the same logic to connect to external hosts.

* [WiFi] Avoid timeouts when not connected to WiFi

As discussed in #589
Stil needed to actively disconnect network services when network was disconnected.

* [WiFi] Actively ignore network services when disconnected

All controllers now stop sending when WiFi disconnected.
Also add NTP update directly after connection was made.

Delay with waiting for unavailable network is now about 30 seconds, then normal boot continues. Every 60 seconds the WiFi will be polled again.
2017-12-28 18:31:19 +01:00
Bartłomiej ZimońandDatuX b5cabdc775 Update _C002.ino (#645)
related to #636
2017-12-18 23:14:11 +01:00
Gijs NoorlanderandDatuX e103cc38f7 [>49.7 days uptime overflow] Use separate function to compute time differences (#621)
* [time overflow] Use separate function to compute time differences

As discussed in #594
The timeOut() function had already a remark that it was behaving fishy.

It is now split into a timeDiff function and two convenience functions:
- timeOutReached
- timePassedSince

The timeDiff function may be a bit more elaborate than strictly needed, but it is very important to do it right and the original notation was very hard to read and understand.

Almost all locations in the code where millis() was used to compute a time difference or check for timeouts now use these functions.
Potentially all of these locations could cause issues when the timer wraps.

* [time overflow] Fix for a one-off error

2^31-1 can be casted to a long value.
Thus changed "<" into "<="
2017-12-18 22:54:43 +01:00
Gijs NoorlanderandDatuX c71a43c3a6 Reduce iRAM usage for plugins using SoftwareSerial (#631)
* [addLib] Added SoftwareSerial library

Added latest version from: https://github.com/plerup/espsoftwareserial

* [renLib] Renamed files to avoid conflicts with existing code

* [renLib] Changed include according to rename

* [renLib] Renamed all occurences and includes and removed unused pins

Renamed to make sure all plugins use the 'new' ESPeasySoftwareSerial.
Also added pinToIndex function to reduce memory footprint with about 150 Bytes, as described in issue #630

* [unused pins] Adjust indices in object list

Forgot to change the indices in the object list of SoftwareSerial

* Simple patch for timeouts

As mentioned in this issue: https://github.com/plerup/espsoftwareserial/issues/54

* [SoftSerial] Set ObjList static

Set the object list static to share all SoftwareSerial iRAM used as described in #630

* [revertLib] Revert to old version lib, since new version uses more iram

Just to test with old version, originally available in 2.3.0 library, to see if memory usage improves.

* [test] Reduce number of ports to 1 and lower buffer size to 18 for MHZ19

Just as a test, to see what happens to the iRAM usage, lower the number of concurrent softserial ports to 1.
Also the default buffer size = 64 Bytes. The MH-Z19 sensor can do with less, since a response will be up to 9 bytes, a 18-byte buffer allows for 2 messages to be stored.

* Enable usage of up to 10 concurrent softserial and reduce variable sizes

Re-enable use of up to 10 concurrent software serials.
Also reduce the variable sizes to smaller ranges. (e.g. uint8 instead of int)

* [test] Limit number of concurrent software serial devices

Earlier tests show the amount of iRAM used is somewhat related to the maximum number of allowed software serial ports.
In this test it is set to 3 and they are assigned through first come first served a slot.
2017-12-18 22:02:53 +01:00
Edwin Eefting cd01283ac6 Merge branch 'v2.0' into mega 2017-12-18 21:26:06 +01:00
M0ebiu5andDatuX 7ce1077bd6 P022_PCA9685 added change frequency - P038_NeoPixel added RGBW strips (SK6812) (#638)
* added change frequency

* rgbw test

* PCA9685 change frequency

* Cleanup RGBW implementation

* Added instructions
2017-12-18 21:18:39 +01:00
DaMandDatuX f9701d1c7b [Domoticz HTTP] Compatibility fix for BMP280 (#636) 2017-12-18 21:13:34 +01:00
GrovkillenandDatuX e764830113 Updated "/pinstates" page: Made the plugin number column display "P001" instead of "1" and "P012" instead of "12". 2017-12-18 21:11:00 +01:00
Gijs NoorlanderandDatuX 28eceffedf [v2.0] Add more characters to the list not to escape in URLs (#635)
As discussed in #634.
2017-12-18 21:04:59 +01:00
Gijs NoorlanderandDatuX 57a1b0dd6f [DNS/IP] Obey UseDNS setting for all controllers (#629)
As described in #381 #261 and #521
A first attempt to let all controllers use the same logic to connect to external hosts.
2017-12-08 14:31:51 +01:00
GHolliandDatuX 9646457b50 Cosmetics: fixing typos. (#628)
* Optimisation: save RAM.

* Another RAM optimisation (freeing RAM by moving static data from RAM to program memory).

* Fixing user-visible typos.

* Fixing typos in variables and comments.

* Fixing typos in comments.

* Revert changes of other pull request.
2017-12-08 14:18:24 +01:00
GrovkillenandDatuX 7346e55e0d Updated ESPTOOLS.exe from 0.4.6 to 0.4.12 (#627)
* Add files via upload

* Add files via upload

* Updated ESPTOOLS.exe from 0.4.6 to 0.4.12

See releases here: https://github.com/igrr/esptool-ck/releases
2017-12-08 13:57:04 +01:00
fensoftandDatuX ae38a8cb4f added #define FEATURE_SD (permit a flash size reduction of ~10k) (#568) 2017-12-08 13:56:13 +01:00
Sen HaerensandDatuX df46a4a5fc Enhanced system info layout (#624)
* Enhance sysinfo page layout

* Added hex notation for chip IDs

* Fixed comment
2017-12-08 13:48:17 +01:00
Gijs NoorlanderandDatuX a0b546e416 Move CO2 MH-Z19 plugin from "testing" to "normal" (#618)
As discussed in #616
2017-12-04 22:08:37 +01:00
GrovkillenandDatuX 7c6797a141 Move "TTP229 keypad" and "Encoder" plugin from "testing" to "normal" (#619)
* Add files via upload

* Add files via upload
2017-12-04 21:58:25 +01:00
mvdbro 83abac8c5e Fix #599 2017-12-03 15:13:29 +01:00
s0170071andDatuX 5ba6b2f335 split IP addrress (#605)
The system variable %ip% truncates the last octet or so when printed on small displays. Now there are four new variables %ip1%, %ip2%... so that the octet printout can be distibuted across two lines.
2017-11-23 19:04:59 +01:00
Edwin Eefting 64caeac9ee fix #588. parseTemplate() now only checks enabled taskes for [] macros 2017-11-22 03:38:06 +01:00
Edwin Eefting 0d4ba7c6f1 testing for ds18b20 2017-11-22 03:35:29 +01:00
Edwin Eefting a1fc351183 fix #588. parseTemplate() now only checks enabled taskes for [] macros 2017-11-22 03:33:34 +01:00
GrovkillenandEdwin Eefting 3131a075f5 Changed bin file names to be more descriptive. (#597)
* Changed bin file names to be more descriptive.

* Fixed TRAVIS check
2017-11-21 23:42:10 +01:00
GrovkillenandDatuX 33a6c39fc4 Changed bin file names to be more descriptive. (#597)
* Changed bin file names to be more descriptive.

* Fixed TRAVIS check
2017-11-21 23:40:19 +01:00
papperoneandDatuX f853f6ef25 deleted GPIO notes referring to 75HC595 not supported (#591) 2017-11-20 22:52:01 +01:00
Edwin Eefting 7a2d114360 fix illegal string manipulations in PLUGIN_WRITE for some plugins. fixes #347 and #460 2017-11-16 03:01:14 +01:00
Edwin Eefting 0157f387ee Merge branch 'v2.0' into mega 2017-11-16 02:02:22 +01:00
Edwin Eefting 3418f2b708 set lcd to NULL by default. #584 2017-11-16 01:18:51 +01:00
Gijs NoorlanderandEdwin Eefting 5a0f588344 [LCD plugin] Added check of LCD object before dereferencing it (#584)
Possible fix for #581.
Just looking at the description of the problem, this may be causing the crashes,since the commands may be trying to dereference the LCD pointer while it still is NULL.
2017-11-16 01:18:16 +01:00
GrovkillenandEdwin Eefting d362446451 Added categories... (#552) 2017-11-16 01:16:39 +01:00
sakinitandDatuX c23be231e1 Fix p1 wifi gateway module (#587)
* Fix receiving illegal characters using Domoticz

* Update P1GatewayServer life-cycle
2017-11-16 00:24:34 +01:00
Gijs NoorlanderandDatuX 00f5c36919 [P039 Thermocouple] Handling negative values and proper error logging (#586)
Cppcheck warned for 'suspicious code':
[src\_P039_Thermocouple.ino:254]: (warning) Suspicious code: sign conversion of -1 in calculation because '-1' has a negative value

I agree with cppcheck that the code is at least suspicious and probably compiler dependent.
So in order to let cppcheck no longer output a warning and make it a bit more readable, I made this change.

Also added logs to indicate errors reported by the sensor.
2017-11-16 00:05:23 +01:00
Edwin Eefting c960175ec1 set lcd to NULL by default. #584 2017-11-15 23:57:01 +01:00
Gijs NoorlanderandDatuX e456604436 [LCD plugin] Added check of LCD object before dereferencing it (#584)
Possible fix for #581.
Just looking at the description of the problem, this may be causing the crashes,since the commands may be trying to dereference the LCD pointer while it still is NULL.
2017-11-15 23:55:29 +01:00
GrovkillenandDatuX ac4657e77f Added categories... (#552) 2017-11-14 21:28:53 +01:00
papperoneandDatuX 3817427e79 Update _P073_7DGT.ino (#553) 2017-11-13 00:49:28 +01:00
Edwin Eefting 0200b3c63e fix travis build errors. disable cpp checking for now 2017-11-13 00:26:21 +01:00
Edwin Eefting 972a1a5703 Merge branch 'mega' of github.com:letscontrolit/ESPEasy into mega 2017-11-12 23:10:27 +01:00
mvdbro 73c22176b8 ESP32 fixed chunked HTTP transfer 2017-11-05 09:19:26 +01:00
mvdbro 4db036f350 ESP32 fix UDP instability 2017-11-04 17:15:24 +01:00
mvdbro 52223f0a20 ESP32 Enabled OTA 2017-11-04 10:38:14 +01:00
mvdbro 907ad0faf6 ESP32 fix FreeRAM reporting 2017-10-29 14:34:46 +01:00
mvdbro 887e10c947 ESP32 Rules/ADC/PWM 2017-10-28 16:07:00 +02:00
mvdbro b4c463e452 ESP32 IRAM/Deepsleep 2017-10-27 17:04:45 +02:00
mvdbro 66ba9b1f46 First preparations for ESP32 2017-10-25 16:10:16 +02:00
Edwin Eefting 7db50811ba esptest stuff 2017-10-23 20:44:23 +02:00
Edwin Eefting 17d20705ff smooth out testing code 2017-10-23 00:44:00 +02:00
Edwin Eefting e3bd782a42 test fixes 2017-10-22 23:20:07 +02:00
Edwin Eefting b073379fff fixed bug in oled upstream lib 2017-10-16 17:29:26 +02:00
Edwin Eefting b89d8ff946 fix warnings 2017-10-16 17:19:48 +02:00
Gijs NoorlanderandDatuX 22ad971c8e Support both SSD1306 and SH1106 OLED in OLED_Framed plugin (#509)
* [SSD1306] Upgrade library to version 3.0

The library at https://github.com/squix78/esp8266-oled-ssd1306 has to be initialized differently in version 3.0

Known issue: The font for 3 lines is not working, so temporary used the same font as for 4 ilnes. The online font generator is currently unavailable at http://oleddisplay.squix.ch/

* OLED framed improve header footer

The header now has better visible WiFi bars indicator and alternates the device name and the connected WiFi SSID.

The bottom part now only shows dots for the pages with visible data instead of the maximum number of pages possible.

* [SSD1306] Upgrade library to version 3.2.7

Forgot to commit deletion of obsolete files in previous commit.

* [SSD1306] Added 12pt font for version 3.x of the library

The font generator is online again: http://oleddisplay.squix.ch/#/home 
Added Dialog Plain 12 font for the 3-line display mode.

* [OLED_Framed] Allow to use either SSD1306 or SH1106

The new OLED library  allows to use SH1106 and SSD1306 controler.
Added support for both with an selector to select the available controler.

* [OLED_Framed] Only destruct and construct display object when changed

* [OLED Framed] Add contrast setting to display

Both SSD1306 and SH1106 support setting the contrast.

* Update _P036_FrameOLED.ino
2017-10-16 16:55:22 +02:00
Edwin Eefting ab06cc3703 merged v2.0 fix for MHZ19 (was already fixed in a different way) 2017-10-16 01:54:37 +02:00
Edwin Eefting 8a5cc5f2bd fix plugin id (starting with a 0 makes it octal in c++ :( ) 2017-10-16 01:47:57 +02:00
papperoneandDatuX 6919baf23c Plugin 073 - 7-segment display plugin TM1637/MAX7219 2017-10-16 01:44:56 +02:00
Gijs NoorlanderandDatuX ddedb215c4 [MH-Z19] Allow for B-version and add filtering (#525)
* [MH-Z19] Allow for B-version and add filtering

The "B" version of the sensor does not output an S value, but does internally apply a dynamic response filter on the samples based on the amount of fluctiation in the data.
The implemented filter does something similar for the "A" version and for both adds the option for an extra delay filter to smooth the data.

Default filter setting ("off") is the old behavior, where only stable values are allowed.

* [MH-Z19] Improve label texts and logging

The first commit for the filtering had some confusing text labels.
Also it would be nice to see the effect of filtering in the logs.
2017-10-16 01:36:43 +02:00
Edwin Eefting 3dc5f1e160 Simple fix for MH-Z19 B version. #529 2017-10-16 01:33:34 +02:00
Tomasz TorczandDatuX 08d4d817f6 retain MQTT LWT messages (#516)
Retaining will messages allows monitoring agent to receive full info about clients state.
Without retaining, the monitoring agent will only be informed about events (connect/connection lost) happening during agent's connection to broker. Any reconnect would cause monitoring agent to lose state.
2017-10-16 01:18:45 +02:00
Edwin Eefting e8bdcfbaf2 keep TASKS_PER_PAGE at default value of 4 2017-10-16 01:16:55 +02:00
Edwin Eefting 743fb4494e improvement: Configurable number of tasks for "Devices" page #510
(by hexenmeister)
2017-10-16 01:15:34 +02:00
MichaelandDatuX 0a4bc7fad6 src/Hardware.ino: make it possible to use GPIO-0 (D3) as Pin_sd_cs (#508) 2017-10-16 01:04:12 +02:00
MichaelandDatuX 49d0b16324 WebServer.ino: enhance handle_SDfilelist() (#507) 2017-10-16 01:03:42 +02:00
Gijs NoorlanderandDatuX de479d6188 [SSD1306] Feature/oled 1306 library upgrade (#501)
* [SSD1306] Upgrade library to version 3.0

The library at https://github.com/squix78/esp8266-oled-ssd1306 has to be initialized differently in version 3.0

Known issue: The font for 3 lines is not working, so temporary used the same font as for 4 ilnes. The online font generator is currently unavailable at http://oleddisplay.squix.ch/

* OLED framed improve header footer

The header now has better visible WiFi bars indicator and alternates the device name and the connected WiFi SSID.

The bottom part now only shows dots for the pages with visible data instead of the maximum number of pages possible.

* [SSD1306] Upgrade library to version 3.2.7

Forgot to commit deletion of obsolete files in previous commit.

* [SSD1306] Added 12pt font for version 3.x of the library

The font generator is online again: http://oleddisplay.squix.ch/#/home 
Added Dialog Plain 12 font for the 3-line display mode.
2017-10-16 01:00:30 +02:00
Gijs NoorlanderandDatuX 3fd3e13dc7 OLED framed improve header footer (#495)
The header now has better visible WiFi bars indicator and alternates the device name and the connected WiFi SSID.

The bottom part now only shows dots for the pages with visible data instead of the maximum number of pages possible.
2017-10-16 00:55:25 +02:00
BadWolf42andDatuX d7d913d439 Dallas Plugin enhanced : no more "delay()" (#488)
* Enhanced Dallas pooling to avoid use of delay(800)

DS_readTemp has been split in 2: DS_convertTemp and DS_readonlyTemp.
DS_convertTemp is first called after DS_setResolution.
Then DS_convertTemp is called after temp has been read.
DS_readTemp has been kept for compatibility.
The only downside is that you read the temperature of previous query (value set by Timer/TDT option).

* typo

* Moved to Environment + code cleaning

- Moved Plugin from Temperature to Environment
- Modified Plugin_004_DS_crc8 to check CRC8, not return it
- Renamed Plugin_004_DS_convertTemp to Plugin_004_DS_startConvertion and removed useless vars in it
- Removed unneed braces and empty lines
- Added comments
2017-10-16 00:51:05 +02:00
SightofSilenceandDatuX 5c4ae3820b Add System Variable for day, month and year / Fix for "Calculate" function to recognize minus-sign (#485)
* Add files via upload

* Update Misc.ino

* Add files via upload
2017-10-16 00:47:58 +02:00
Gijs NoorlanderandDatuX 38774a20c6 Single function for format to user defined number decimals (#482)
* Single function for format to user defined number decimals

In a number of files the same long definition was cut and paste a lot to format  values to a user defined number of decimals.

Now a new simple function is added to Misc to perform this formatting, which results in more clean code, less prone to errors and a reduction in use of resources.

* Single function for format to user defined number decimals

In a number of files the same long definition was cut and paste a lot to format  values to a user defined number of decimals.

Now a new simple function is added to Misc to perform this formatting, which results in more clean code, less prone to errors and a reduction in use of resources.
2017-10-16 00:42:14 +02:00
Gijs NoorlanderandDatuX 9fc58bb4df P028 to support both BME280 and BMP280 to reduce resource usage (#481)
* P028 now supports both BME280 and BMP280

Both plugins P028 and P030 had a lot of code duplication. This takes up resources and is hard to maintain.
Now the P028 plugin can detect and use both sensors so P030 may be removed.

Only caveat is that the BMP280 does not measure humidity and thus actually is a 2-value sensor. The Domotics MQTT controller did not distinguish between them, but other controllers may do so.
When needed, the P030 plugin can still be a mere stub for the output and plugin definition and still share all code with P028.

* [BME280] Add temperature offset and improve read stability

The BME280/BMP280 may heat up internally if read too often and too long.
Also when built in a small container along with other sensors and the ESP, the sensor may read values which are too high.
To compensate for these higher readings, a constant offset may be applied in the device parameters.
This value is a signed integer value representing the offset in 1/10th degree Celsius.

Since the humidity is a relative value, depending on the temperature, this should be adjusted also.

Only this computed dew point temperature is also too high, due to the fact the sensor is warmer than the air and thus the perceived humidity is off.
To correct for this, half the offset temperature is being used to compute the dew point temperature.

The other improvement is the routine to read the sensor.

Using this routine, the sensor is only active for about 1.6 seconds each minute.
This prevents the sensor to heat up from its own readings and also allows stable readings using some filtering. (slamming a door does not affect the readings)

* [BMx280] Auto detect connected chip ID and show in Device config tab

Detect connected chip (BME280/BMP280) automatically and show detected device immediately in the Device config page next to the I2C address selection.

* [BME/BMP280] Perform reset at init

Just to make the reading a bit more stable when the sensor stops responding.
This is also done in the "official" Bosch github: https://github.com/BoschSensortec/BME280_driver

* [BMx280] Allow for more than one sensor 

As suggested in #491 for another sensor, its I2Caddress was handled incorrectly. The same applied to this plugin.
2017-10-16 00:27:04 +02:00
SloMustiandDatuX ca936ca42f implemewnted web activity timer tracker (#462) 2017-10-16 00:23:05 +02:00
Edwin Eefting 840fb6b647 Merge branch 'v2.0' into mega 2017-10-16 00:16:25 +02:00
Edwin Eefting 34f54c51e4 Merge branch 'v2.0' of github.com:letscontrolit/ESPEasy into v2.0 2017-10-16 00:16:10 +02:00
Edwin Eefting cda973a54f test library stuff 2017-10-16 00:15:43 +02:00
Edwin Eefting 8d77c29d75 update branching info 2017-10-16 00:15:28 +02:00
denisfrenchandDatuX c80b5d6d78 Set MQTT clientid to %sysname% +/- Settings.Unit (#431) (#436) 2017-10-16 00:12:09 +02:00
Gijs NoorlanderandDatuX 0454926d68 [INA219_v2.0] Improve logs for multiple devices (#546)
And added comments in the code about how to use multiple devices.
Also renamed the plugin to match existing "Energy" category as discussed in #542
2017-10-16 00:09:17 +02:00
hatzlhofferandDatuX 40067c514f added new display size 128x32 (#545)
added font size optimization
2017-10-16 00:06:59 +02:00
Edwin Eefting 77e5d8f00e working on test stuff 2017-10-15 23:09:14 +02:00
Edwin Eefting e33f9c1709 cleaner errors 2017-10-13 01:31:17 +02:00
Edwin Eefting 31ba3aad85 examples for the lone wanderer 2017-10-13 01:28:49 +02:00
Edwin Eefting 3c591f146e refactored and added automated test stuff 2017-10-13 01:19:35 +02:00
Edwin Eefting 35f82ea616 warnings are treated as errors now, by travis 2017-10-12 22:09:45 +02:00
Edwin Eefting 60f5bdb069 cleaned up notification stuff. fixed #502 2017-10-12 21:48:27 +02:00
Edwin Eefting 7be9f321a2 fixes 2017-10-12 21:34:04 +02:00
sassod eee55a92d9 Merge remote-tracking branch 'refs/remotes/letscontrolit/mega' into mega 2017-10-11 07:21:45 +02:00
Edwin Eefting 00998a8d3e worked around error caused by upstream libraries 2017-10-02 00:54:26 +02:00
Edwin Eefting 1f5d0f1968 travis fix 2017-10-02 00:38:30 +02:00
Edwin Eefting ec83cf39cd Merge branch 'mega' of github.com:letscontrolit/ESPEasy into mega 2017-10-02 00:36:11 +02:00
Edwin Eefting 7c8487632d now using PRAGMA to enable warnings, so that we dont get warnings from core libraries. also warnings will be treated as errors in Travis, this makes approving pull requests less work for me. 2017-10-02 00:36:01 +02:00
NeoandDatuX e6bd9adc03 [HT16K33_LED] Brightness control (#523)
Add command for controlling the LED display's brightness. Uses the function already available in the HT16K33 library.
2017-10-01 23:18:11 +02:00
Edwin Eefting 6f0c10dcd7 Merge branch 'mega' of github.com:letscontrolit/ESPEasy into mega 2017-10-01 23:15:29 +02:00
Edwin Eefting ddb3d1a0dd cleaned up more warnings and fixed a few real bug along the way. #235 2017-10-01 23:14:26 +02:00
Gijs NoorlanderandDatuX c187e7edc3 [INA219] Allow for multiple instances on the same controller (#519)
As described in #491.
The calibration settings are now stored per instance and the I2C address is now taken from the taskvalue array and no longer a global variable.
2017-10-01 01:46:44 +02:00
Edwin Eefting 9735e33e51 enabled warnings and started fixing all the warnings to reduce the noise. (because warnings where disabled wasted about 3 hours debugging a simple no-return bug) 2017-10-01 01:32:39 +02:00
Edwin Eefting 4eeb22110d solution for better error and warning highlighting when compiling with platformio 2017-09-30 23:50:41 +02:00
Edwin Eefting b190a43e7e cleaned up buildflags and created common build variable 2017-09-28 00:16:12 +02:00
Edwin Eefting 20b95c425e always define PLUGIN_BUILD_NORMAL so normal plugins are compiled 2017-09-28 00:06:21 +02:00
Edwin Eefting 5ba05ff769 fixed obscure crash caused by not returning a value in #235. we need to adjust compiler flags to detect these kinds of issues. 2017-09-24 00:54:55 +02:00
sassod 21398fbf8a Merge remote-tracking branch 'refs/remotes/letscontrolit/mega' into mega 2017-09-23 20:05:30 +02:00
Edwin Eefting 051f7c9f52 final fixes for #235, untested. all spiffs errors should be handled now and also show up in logs and webinterface 2017-09-23 16:19:22 +02:00
Edwin Eefting 0fa7817b2a more fixes for #235 2017-09-23 15:58:17 +02:00
mvdbro 95d5dd3c68 Bugfix: %eventvalue% parsing on literal strings
%eventvalue% parsing didn't correctly process literal strings (that
start with '!'). It tried to extract the value from the righthand of
'=', where it should parse the entire string.
2017-09-23 09:59:49 +02:00
Edwin Eefting 56fd1e0203 automaticly updated release notes for v2.0.0-dev12 2017-09-22 01:25:29 +02:00
Edwin Eefting 890487fcae fixed release-notes bug 2017-09-22 01:25:17 +02:00
Edwin Eefting 9b9dce0aaf automaticly updated release notes for 2.0.0-dev12 2017-09-22 01:07:19 +02:00
Alexander Schulz 139ae36d3e improvement: Configurable number of tasks for "Devices" page (TASKS_P…
…ER_PAGE)
2017-09-16 23:24:15 +02:00
beicandDatuX da6edeab86 Moving from Temperature to Environment naming (#506)
Moving from Temperature to Environment naming
2017-09-16 22:16:01 +02:00
JeroenandDatuX cdcf041073 Create _P071_Kamstrup401.ino (#504)
* Create _P070_Kamstrup401.ino

* Update and rename _P070_Kamstrup401.ino to _P071_Kamstrup401.ino

* Update _P071_Kamstrup401.ino

accidentally inserted a line break...

* Added [TESTING] to plugin name
2017-09-15 18:01:37 +02:00
papperoneandDatuX ec99795c1e HDC1080 plugin (#497)
* P010 plugin optimization

optimized code in P010 plugin (probably leftovers od previous versions)

* P010 Optimization

* HDC1080 plugin

HDC1080 plugin

* HDC1080 support

HDC1080 support

* Changed Plugin Number to 072

as 070 was used by another pull-request I renamed this to 072

* Update plugin name to fulfill developping guidelines
2017-09-15 18:00:27 +02:00
Edwin Eefting 0bc8570b4a plugin is not generic enough, so its disabled by default 2017-09-14 22:06:37 +02:00
Ovidiu SchiopuandDatuX 2d8e14eb87 Added _P070_NeoPixel_Clock.ino (#489)
* NeoPixel ring clock

A clock that uses a ring of 60 NeoPixel LEDs as display for a classic
clock.
The hours are RED, the minutes are GREEN, the seconds are BLUE and the
hour marks are WHITE.
The brightness of the clock hands and the hour marks can be set in the
device page, or can be set by HTTP  or Rules commands. The format is as
follows:
Clock,1,128,32 → 1=enable display, 128=hand brightness, 32=mark
brightness
Clock,0,, → 0=disable display, without changing the saved values of the
brightness
Clock,,65, → change only the brightness of the clock hands
Clock,,,10  → change only the brightness of the hour marks

* - The plugin declaration was cleaned up
- The commands are working
- Correction of offset

* Update _P070_NeoPixel_Clock.ino

* Fix

* Update _P070_NeoPixel_Clock.ino

* Changed the name of the plugin

Changed the name of the plugin to "Output - NeoPixel Ring Clock [TESTING]"

* GlobalSyncOption not needed

GlobalSyncOption not needed, therefore set to false.
2017-09-14 22:02:40 +02:00
beicandDatuX 4917dab1d3 Moving from Temperature to Environment naming (#492)
Moving from Temperature to Environment naming
2017-09-14 21:51:30 +02:00
SightofSilenceandDatuX 42e1eb33ef Add files via upload (#493) 2017-09-14 21:49:41 +02:00
Edwin Eefting c2fdd50655 fixes bug #486 in counter-plugin 2017-09-14 21:46:54 +02:00
Gijs NoorlanderandDatuX a643596c48 [MH-Z19] Add 'ABC disable' option to web config (#472)
* [MH-Z19] Add 'ABC disable' option to web config

As discussed in #466.
The default setting is the current behavior.
When changing the setting, it will be applied as soon as there is a stable reading.

* [MH-Z19] Read settings first before determine must apply flag.
2017-09-14 20:32:26 +02:00
Gerben MeijerandDatuX 04465454f4 Add SENSOR_TYPE_TRIPLE support to Domoticz MQTT (#468) 2017-09-13 19:36:09 +02:00
Edwin Eefting 190783f382 missed return after setting event buffer 2017-09-04 00:49:04 +02:00
mvdbro e51c5d8504 Moved HTML template logging to level LOG_LEVEL_DEBUG_DEV 2017-08-27 08:53:00 +02:00
mvdbro 3849befeaf Fixed a tasksettings load bug that was introduced with commit dcfc1e3 on july 18th. 2017-08-10 10:02:42 +02:00
mvdbro 05c61879f9 Finished work on Level Control & config 2017-08-08 18:46:59 +02:00
mvdbro 71f6b58dd7 Custom WEB page handler (SPIFFS) 2017-08-07 16:51:46 +02:00
Daniel TedenljungandDatuX c30074afc5 This plugin is tested and working good. (#428)
* This plugin is tested and working good.

* Renamed plugin

Renamed the plugin as @jkDesignDE and @Grovkillen suggested.
2017-07-30 01:09:18 +02:00
Jochen KrapfandDatuX 5aef196306 Fixed HTML text box length for controller settings - Issue #453 (#455) 2017-07-30 00:51:37 +02:00
Jochen KrapfandDatuX e09f5ca0a1 Rework of Plugin _P056_SDS011-Dust (#451)
* First rework

* Moved classes to library

* Finished rework
2017-07-30 00:49:10 +02:00
Jochen KrapfandDatuX 716ae30d9d Descriptive GPIO-Names (#448)
Changes:

Added PLUGIN_GET_DEVICEGPIONAMES to retreive GPIO-names from plugins

Changed Webserver to ask for GPIO-names (backward compatibility for old plugins)

Added GPIO-names to plugins
 - Chiming
 - Encoder
 - TTP229_KeyPad
 - DRF0299_MP3
 - HX711_Load_Cell
 - (more will follow)

Changed GPIO-names in hardware-page for uniformity

And because it was on the way:
Added PLUGIN_EXIT and prepared to unload members and memory from deselected device plugins
2017-07-20 14:06:25 +02:00
Jochen KrapfandDatuX 116c653db5 Added Plugins for SHT3x and LM75A - Issue #433 (#442)
* Added Plugins for SHT3x and LM75A - Issue #433

* Added I2C addresses to the I2C Scanner

* Added CONFIG define
2017-07-19 17:52:19 +02:00
Edwin Eefting dcfc1e3689 first set of changes for #235. added spiffs error checking and loging, and cleaner flashguarding code. next change will show feedback in web interface as well. also need to cleanup loose SPIFFS filehandling at other places in webserver.ino (create a save-function for all those things and use FLASH_GUARD) 2017-07-18 00:50:59 +02:00
Edwin Eefting 7ba981eaea automaticly updated release notes for v2.0.0-dev11 2017-07-17 00:55:29 +02:00
Jochen KrapfandDatuX ede5ed8b0d Plugin HX711 - Added Tare function (#419)
* Plugin HX711 - Added Tare function

* Added command "tare"
2017-07-16 19:35:27 +02:00
Jochen KrapfandDatuX b8877c53ed Plugin65 MP3 - volume updated in device menu - issue #424 (#438) 2017-07-16 19:34:04 +02:00
Edwin Eefting 296271007b added note to inverse logic to fix #318 2017-07-16 17:27:15 +02:00
Edwin Eefting d49a91c4a2 imlemented setting name, unit and password via serial. implements #317 2017-07-16 17:07:32 +02:00
Edwin Eefting 2b567f5578 gave some html logging debug-level 2017-07-16 16:50:11 +02:00
Edwin Eefting 8469188f75 Merge branch 'mega' of github.com:letscontrolit/ESPEasy into mega 2017-07-16 16:42:17 +02:00
Edwin Eefting 2409df4f5b made mdns a feature. consitent use of hostname for both mdns and dhcp client. hostname now is name_unitnumber, with spaces replaced by - 2017-07-16 16:42:07 +02:00
mvdbro c5c33cf6b6 Merge branch 'mega' of https://github.com/letscontrolit/ESPEasy into mega 2017-07-16 15:49:18 +02:00
mvdbro cea1d8b825 Revert to default ESP Easy colorscheme 2017-07-16 15:48:00 +02:00
SloMustiandDatuX 982ed4d677 added mDNS implementation (#418) 2017-07-16 15:47:34 +02:00
Edwin Eefting d424803cac more details AP mode serial output 2017-07-16 15:36:31 +02:00
SloMustiandDatuX 6cd3f514a6 Implemented a better WiFI AP naming strategy. ESP_Easy has replaced the newdevice text as the default name and now the name is used as and AP SSID (#410) 2017-07-16 15:09:54 +02:00
Edwin Eefting b5d4b96f14 Merge branch 'mega' of github.com:letscontrolit/ESPEasy into mega 2017-07-14 01:43:05 +02:00
Edwin Eefting f9ce235b32 fix HTTP chunked transfer encoding, since WebServer class doesnt support it. this fixes the 2 second delay in some browsers. (we where out of spec.) 2017-07-14 01:42:50 +02:00
Jochen KrapfandDatuX 491fa5c0a2 Added Value Logger on SD Card (#429) 2017-07-13 21:22:14 +02:00
Daniel TedenljungandDatuX 1bbbaa18f7 Renamed command to be unique. (#427) 2017-07-11 22:30:10 +02:00
Jochen KrapfandDatuX eff68b2173 Fixed multiline define bug on CRLF (#416)
Because of compiler-bug (multiline defines gives an error if file ending is CRLF) the define is striped to a single line
2017-07-07 14:42:44 +02:00
Jochen KrapfandDatuX 8b6adac269 Added Plugin for HX711 Load Cell - Request #408 (#415)
* First draft

* Added Plugin for HX711 Load Cell

* Typo
2017-07-07 14:38:54 +02:00
Jochen KrapfandDatuX e0edd56413 Added Plugin for Color Sensor VEML6040 (#412)
* First draft

* Added Plugin for Color Sensor VEML6040
2017-07-05 11:58:18 +02:00
Jochen KrapfandDatuX c95d04aa6b Added Plugin for Gesture Sensor APDS9960 (#409)
* First draft

* Work release

* work release

* Working release

Known BUG: While performing a gesture the reader function blocks rest of ESPEasy processing!!! (Feel free to fix...)
2017-07-05 11:55:12 +02:00
Jochen KrapfandDatuX 9a88269e28 Minor corrections and documentation (#404) 2017-07-05 11:53:34 +02:00
papperoneandDatuX d5847f9ea1 P010 plugin optimization (#403)
* P010 plugin optimization

optimized code in P010 plugin (probably leftovers od previous versions)

* P010 Optimization
2017-07-03 21:43:07 +02:00
mvdbro b3a75c0105 Merge branch 'mega' of https://github.com/letscontrolit/ESPEasy into mega 2017-07-02 16:07:04 +02:00
mvdbro 3ba2f38408 Update checkRAM function 2017-07-02 16:06:02 +02:00
Jochen KrapfandDatuX b455a676d8 Added Plugin for MP3 module (#402)
* Added Plugin for MP3 module

* Added [Testing] to name

* Documentation and cleanup

* Renaming to WTV020

* Documentation and corrections
2017-07-02 12:06:57 +02:00
Daniel TedenljungandDatuX e5dbb3c680 Added relay control from commands (#395) 2017-07-01 22:36:47 +02:00
Daniel TedenljungandDatuX 7d236e8564 Reading error code in other way (#394)
* Updated the way errorcodes are handled.

* Update of code after taliking with Trieb. Implemented function getBitOfInt(int reg, int pos).

* Read all bits

* Small update

Changed the way mask was defined
2017-07-01 22:36:05 +02:00
Gustavo SpadariandDatuX ae18a47bc9 Adding comments on RAW code (#386) (#393)
* Adding comments on RAW code (#386)

* Add some other comments
2017-06-29 23:39:06 +02:00
PieVoandDatuX 5dd4d49517 Update P053 (PMSx003) to support software serial and minor cleanup (#390)
* PMSx003: fix typo in description

* PMSx003: remove unused variable

* P053_PMSx003: make preparations for supporting hw and sw serial, read on plugin_read only

* P053_PMSx003: fix build and buffer reading (hw serial tested, sw not yet)

* P053_PMSx003: move serial reading to 10x sec, add debug levels, fix empty buffer read

* P053_PMSx003: drop log message in read, already posted as EVENT
2017-06-28 22:29:18 +02:00
Jochen KrapfandDatuX d708d6a057 Check plugin-array size on init - issue #119 (#389)
very nice! another issue fixed:)
2017-06-27 23:57:59 +02:00
imthemichiandDatuX c3db03ea5e Plugin_008-RFID extended with wiegand 34-bits and key-pad (#387)
* Plugin_008-RFID extended with wiegand 34-bits and key-pad (4-bits per key) support

* removed millis from interupt-handler and volatile from keyBuffer because of high IRAM usage
2017-06-26 10:07:02 +02:00
mvdbroandGitHub b65812ebf3 Merge pull request #385 from jkDesignDE/menu3
Reenabled javascript for device-selector
2017-06-24 09:49:15 +02:00
mvdbroandGitHub 698299f918 Merge pull request #384 from papperone/mega
P038 - optimization
2017-06-24 09:49:00 +02:00
JK 277d12205d Reenabled javascript for device-selector 2017-06-23 18:00:20 +02:00
papperone 52b3c2e962 P038 - optimization
deleted unneded parsing line in the WRITE function and used only the
event->Par1/5 variables already available
2017-06-22 22:41:30 +02:00
mvdbroandGitHub f6cadc43f3 Merge pull request #383 from jkDesignDE/menu2
Fine tuning of CSS and menu
2017-06-22 18:57:03 +02:00
mvdbroandGitHub e393d66283 Merge pull request #382 from tedenda/C011_Rename_constants
Renamed constants
2017-06-22 18:56:27 +02:00
JK 10e33de018 Fine tuning of CSS and menu 2017-06-22 13:20:13 +02:00
tedenda 842dc38805 Missed one... 2017-06-22 13:07:27 +02:00
tedenda 52ef5c06fd Renamed Prefix from P011 to C011 2017-06-22 12:57:41 +02:00
Edwin Eefting 1c63589b3d upgraded IRremoteESP8266 from v1.0.2 to v1.2.0. fixes #188 2017-06-21 17:17:21 +02:00
Jochen KrapfandDatuX 3e230310b9 Step back to style-based-css for speed up + pimp menu (#376)
* Renaming

* Fixed DEVICES_MAX for testing and dev

* Experiments with delivering HTML

* Step back to style-based-css for speed up

* pimp menu

* pimp menu
2017-06-21 01:52:39 +02:00
SloMustiandDatuX ce249aaa4a fixed deep sleep, such that it can be enabled from Rules (#375) 2017-06-21 01:50:28 +02:00
Jochen KrapfandDatuX bd216674d4 Fixed DEVICES_MAX for testing and dev (#374) 2017-06-20 13:16:27 +02:00
Edwin Eefting 32c4b1d614 add caching headers to static content 2017-06-20 00:30:59 +02:00
Edwin Eefting 1847746077 serial now no longer resonds to empty commands 2017-06-19 22:41:19 +02:00
Edwin Eefting 56741b425c fix #372 2017-06-19 22:31:13 +02:00
DatuXandGitHub 4f3a8e6acb Update issue_template.md 2017-06-19 21:10:54 +02:00
DatuXandGitHub f40d8c3cf4 Update issue_template.md 2017-06-19 21:10:35 +02:00
mvdbroandGitHub d7a3c74ad9 Merge pull request #370 from jkDesignDE/TTP229
Added Plugin for Touch KeyPad Chip TTP229
2017-06-19 20:02:17 +02:00
JK b5049cd9ca Added Plugin for Touch KeyPad Chip TTP229 2017-06-19 19:42:38 +02:00
mvdbroandGitHub 55536cc4b3 Merge pull request #366 from papperone/mega
Fixed Broken P038
2017-06-19 19:41:00 +02:00
mvdbroandGitHub cbbec517d6 Merge pull request #364 from jkDesignDE/ChunkedSend
Send web page as junked data - issue #352
2017-06-19 19:39:07 +02:00
mvdbroandGitHub db2624d49d Merge pull request #368 from jkDesignDE/CRLF
Accept CR and LF at serial commands
2017-06-19 19:33:27 +02:00
JK d7116735e9 First draft 2017-06-19 15:19:49 +02:00
papperone 43ba235e68 reverted some changes due to bug fixed in the "webserver.ino #348" 2017-06-18 23:10:50 +02:00
papperone 2c3c8f6e0d Merge remote-tracking branch 'refs/remotes/letscontrolit/mega' into mega 2017-06-18 23:07:51 +02:00
JK 6dc816869f Merge remote-tracking branch 'base/mega' into CRLF 2017-06-18 06:57:40 +02:00
mvdbro 5fff3c6ce7 Added pin state buffer table page (mainly for debugging) 2017-06-17 22:51:34 +02:00
JK fe85b0908c Accept CR and LF at serial commands 2017-06-17 22:36:29 +02:00
papperone 612742f669 p038
BugFixing
2017-06-17 18:55:55 +02:00
mvdbro 8d2303db5f Fix default controller settings (#360) 2017-06-17 16:41:52 +02:00
JK 97b90a09db Send web page as junked data 2017-06-16 09:19:10 +02:00
papperone dcdf095575 Fixed Broken P038
Fixed GUI of plugin adding correct GPIO request
Fixed code for "NeoPixelAll" command
Tested on ESP8266 and WemosD1Mini with various WS2812 configuration
hardware
2017-06-16 07:42:19 +02:00
JK 9ecfce472d First draft 2017-06-16 02:52:49 +02:00
Jochen KrapfandDatuX 20e5bc0081 Write default CSS to SPIFFS on boot (#357)
* Write CSS to SPIFFS on boot

* Fixed DEFINE bug

In CPPCHECK:
-> error: 'CPLUGIN_ID_002' was not declared in this scope

@mvdbro: please take a look
2017-06-15 09:06:14 +02:00
Edwin Eefting 5136d4757c accidently enabled FEATURE_ARDUINO_OTA 2017-06-12 23:03:13 +02:00
Edwin Eefting 2729e341c8 saved ~800 bytes ram in handle_devices(), issue #352. left old code commented for reference, in case i created bugs. will remove later 2017-06-12 22:55:42 +02:00
Jochen KrapfandDatuX 6d0399c6c7 Increase DEVICES_MAX for more testing and dev plugins (#353) 2017-06-12 13:25:31 +02:00
krikkandDatuX 72d07bc303 implemented a measurement type selection to retain backward compability to Domoticz... hope this works... (#351) 2017-06-11 21:58:18 +02:00
Daniel TedenljungandDatuX c55bb28038 Senseair update (#333)
* New company name

* New sensor: Relay Status

* New sensor: Temperature adjustment

* Small update of log messages

* Some renaming
2017-06-11 21:57:20 +02:00
Jochen KrapfandDatuX 0a746d017e Added plugins for HT16K33 LED matrix driver and key pad scanner (#328)
* First draft

* work release

* work release

* Work release

* Work release

* Work release

* Work release

* rename file

* Work release (not working)

* Rework with library

* Working LED plugin with Clock

* Added plugins for HT16K33 LED matrix driver and key pad scanner

* Fixed typing of Arduino.h

* Documentation
2017-06-11 21:56:07 +02:00
mvdbro de4517f614 Fix incorrect ADC GPIO display 2017-06-11 09:39:10 +02:00
mvdbro 0dcd89a653 MQTT Controller enable/disable fix (#287) 2017-06-10 22:52:01 +02:00
mvdbro f70970c6f3 Enlarge MQTT buffer for Domoticz MQTT controller 2017-06-10 22:34:55 +02:00
mvdbro 4d28d2b837 Fix Domoticz helper plugin #330 2017-06-10 22:31:55 +02:00
Jochen KrapfandDatuX b63e76adfe Fixed issue #348 (#349) 2017-06-10 14:31:59 +02:00
Jochen KrapfandDatuX 77eedf5d6c Added Plugin _P062_MPR121_KeyPad (#346) 2017-06-10 14:28:19 +02:00
Jochen KrapfandDatuX 01ff98be05 Fixed issues #308 #305 (#345)
* Formula option for  _P013_HCSR04 plugin #343

* First draft

* Fixed issues #308 #305
2017-06-10 14:27:32 +02:00
Jochen KrapfandDatuX 6222041a30 Formula option for _P013_HCSR04 plugin issue #343 #313 (#344)
* Formula option for  _P013_HCSR04 plugin #343

* Minor fixes to #313
2017-06-10 14:25:07 +02:00
Jochen KrapfandDatuX 302e0d7fa7 Added Plugin _P060_MCP3221 (#342)
* First draft

* Working release
2017-06-10 13:57:32 +02:00
krikkandDatuX 894e9c3ff6 added local ip to sysinfo plugin, due to limitation of return type float, i had to split up the ip in its octets... fixes issue #228 (#341) 2017-06-10 13:56:15 +02:00
Jochen KrapfandDatuX 66bda6d531 Added Plugin _P061_KeyPad (#340) 2017-06-10 13:53:46 +02:00
krikkandDatuX f3c7c68248 seconds were displayed without leading zero issue #337 (#338) 2017-06-10 13:52:28 +02:00
krikkandDatuX 093767f2b1 delay option should be displayed even if the SendDataOption is false, because the delay option also controls the refresh rate of the oled display... fixes issue #336 (#339) 2017-06-10 13:31:16 +02:00
Jochen KrapfandDatuX 50f6c403e8 Added Plugin for Quadrature Encoder Interface (Rotary Encoder) (#335)
* First draft

* Functional QEI plugin

* Corrected spelling of limits.h
2017-06-10 13:11:49 +02:00
Edwin Eefting 3c41155ee4 backup 2017-06-06 23:57:23 +02:00
Edwin Eefting dcc2dbf0c6 converted all commands to python 2017-06-06 23:26:00 +02:00
Edwin Eefting fd1da876a4 dont want wifi passwords on github 2017-06-06 23:03:53 +02:00
Edwin Eefting 93fc1b6140 dont want wifi passwords on github 2017-06-06 23:01:26 +02:00
Edwin Eefting 80fb17ca05 esptesting framework 2017-06-06 22:58:21 +02:00
Edwin Eefting ee0069ffa4 Merge branch 'mega' of github.com:letscontrolit/ESPEasy into mega 2017-06-06 19:46:12 +02:00
Edwin Eefting b1bd7d63f6 working on test framework 2017-06-06 19:46:01 +02:00
DatuXandGitHub ef8059cf56 Update README.md 2017-06-06 15:15:29 +02:00
Edwin Eefting 8d246947c1 Merge branch 'mega' of github.com:letscontrolit/ESPEasy into mega 2017-06-06 00:32:28 +02:00
Edwin Eefting 8bcf29fa11 Fixed variable naming bug in FEATURE_ADC_VCC 2017-06-06 00:32:23 +02:00
elucas2uyandDatuX 4b900daa67 FIX Pass and Index on handle_controllers() (#331)
* FIX Pass and Index on handle_controllers()

* Update WebServer.ino
2017-06-05 17:43:53 +02:00
Edwin Eefting a84567c14e Fixed crashbug in email notification 2017-06-04 22:36:02 +02:00
Edwin Eefting d4420b9e36 better rtc error logging 2017-06-04 12:15:51 +02:00
Daniel TedenljungandDatuX 6daa9a1e3c Fixed decimal values (#329) 2017-06-04 01:51:38 +02:00
Edwin Eefting 6a4f8a6942 added option do deepsleep on connection failures. had to change boot order a bit, so the rebooted/warmboot message is the first one now. (this also makes more sense). issue #206 2017-06-02 17:56:45 +02:00
Edwin Eefting 41974d12e5 prevent recursion when processing background tasks. might help with issue #117 2017-06-02 17:05:41 +02:00
Edwin Eefting ea5168c08a large changes to wifi handling. code cleanup, more efficent connecting, only one connect retry in deepsleep. better serial logging for connections and APmode. always enable ap mode when wifi is disconnected 2017-06-02 02:02:19 +02:00
Edwin Eefting d07bb3574a started working on regression testing scripts for The Rig 2017-06-01 20:43:47 +02:00
Edwin Eefting fb83badfce cleaned up RTC initialisation. fixed some fuzzy issues after flashing/factory reset. improved flash-counter messages and added powercycle tips 2017-06-01 01:38:19 +02:00
Jochen KrapfandDatuX 1a9eedc6d6 Added _P056_SDS011-Dust (#324)
* Added _P056_SDS011-Dust

* removed SDS-lib as submodule

* added SDS-lib as files
2017-05-31 01:02:04 +02:00
Jochen KrapfandDatuX b26b4a1a93 Added _P055_Chiming (#323) 2017-05-31 00:57:33 +02:00
krikkandDatuX f3e7dffec4 changed the ina219 plugin so that is always sends 3 values, voltage, current, power... like a normal plugin should do... (#325)
also added measurement range selection
2017-05-31 00:54:13 +02:00
Jochen KrapfandDatuX 9341bde0da Added _P054_DMX512 (#322) 2017-05-31 00:53:35 +02:00
271 changed files with 39653 additions and 9973 deletions
+22
View File
@@ -0,0 +1,22 @@
# cmd: "cd {PROJECT_PATH}; platformio"
cmd: "platformio"
name: "Build with error highlighting (dev_ESP8266_4096)"
args:
- run --environment dev_ESP8266_4096
sh: true
cwd: "{PROJECT_PATH}"
# env:
# VARIABLE1: "VALUE1"
# VARIABLE2: "VALUE2"
errorMatch:
- "(?<file>[\\/0-9a-zA-Z\\._]+):(?<line>\\d+):(?<col>\\d+):\\s+error:\\s+(?<message>.+)"
warningMatch:
- "(?<file>[\\/0-9a-zA-Z\\._]+):(?<line>\\d+):(?<col>\\d+):\\s+warning:\\s+(?<message>.+)"
# keymap: <keymap string>
# atomCommandName: namespace:command
# targets:
# extraTargetName:
# cmd: "<command to execute>"
# args:
# # (any previous options are viable here except `targets` itself)
+11 -7
View File
@@ -15,15 +15,19 @@ Also there are more people on the forum that can help you with support.
## Pull requests
* Make sure your code compiles.
* Try to create different pull requests for different features/fixes.
* Make sure your code does not have warnings. (Warnings will be treated as errors by our Travis system.)
* Try to create different pull requests for different features/fixes.
* Dont combine a lot of different stuff in one huge pull request.
* The v2.0 branch should get only fixes, new stuff should go into the mega-branch. (We will merge those fixes from v2.0 to mega)
* 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.
* Do not modify any of the variables passed to your PLUGIN_WRITE handler.
* New plugins that seem to be working correctly should have a PLUGIN_BUILD_TESTING around until they are tested enough. Also add [TESTING] to the name
* Also see our general guidelines at: https://www.letscontrolit.com/wiki/index.php/ESPEasyDevelopmentGuidelines
+33 -7
View File
@@ -1,16 +1,42 @@
### Steps to reproduce
How can we trigger this problem?
<!--- NOTE: This is not a support forum! For questions and support go here: --->
<!--- https://www.letscontrolit.com/forum/viewforum.php?f=1 --->
<!--- Remove topics that are not applicable to your feature request of issue --->
<!--- Remember to have a "to the point" TITLE --->
Does the problem presist after powering off and on? (just resetting isnt enough sometimes)
### Summarize of the problem/feature request
<!--- Describe the problem or feature request --->
YOUR TEXT GOES HERE
### Expected behavior
Tell us what should happen?
<!--- Tell us what should happen? --->
YOUR TEXT GOES HERE
### Actual behavior
Tell us what happens instead?
<!--- Tell us what happens instead? --->
YOUR TEXT GOES HERE
### Steps to reproduce
<!--- How can we trigger this problem? --->
1.
2.
3.
<!--- Does the problem persists after powering off and on? (just resetting isn't enough sometimes) --->
<!--- Please document if you have restarted the unit and if the problem is then gone etc. etc. --->
### System configuration
<!--- Please add as much information and screenshots as possible --->
Hardware:
Software or git version:
<!--- You should also provide links to hardware pages etc where we can find more info --->
ESP Easy version:
<!--- In order to have a better readablity of your issue then you should place screenshots here --->
<!--- Simply drag and drop them onto this template, move the text string below the "ESP Easy settings/screenshots" topic --->
ESP Easy settings/screenshots:
### Rules or log data
<!--- place your code/rules between the two ``` rows --->
<!--- remove if not applicable! --->
```
```
+12
View File
@@ -1,6 +1,18 @@
## OS Specific Hidden Files ####
# MacOSX Finder *****
.DS_Store
# Fuse FileSystem ***
.fuse_hidden*
## PlatformIO ##################
.pioenvs
.clang_complete
.gcc-flags.json
.piolibdeps
## Project #####################
lib/readme.txt
src/Custom.h
+8 -3
View File
@@ -25,9 +25,14 @@ install:
- pip install -U platformio
script:
- 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
# - 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_BUILD_FLAGS="-D CONTINUOUS_INTEGRATION" platformio run
# patch platformio core libs for PUYA bug (https://github.com/letscontrolit/ESPEasy/issues/650)
- cd patches; ./check_puya_patch; cd ..
- PLATFORMIO_BUILD_FLAGS="-D CONTINUOUS_INTEGRATION" platformio run -s --environment dev_ESP8266PUYA_1024
before_deploy:
- ./before_deploy
+21 -27
View File
@@ -1,45 +1,39 @@
# ESPEasy (mega branch)
# ESPEasy (development branch)
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.
**MEGA**
:warning:This is the development branch of ESPEasy. All new untested features go into this branch. If you want to do a bugfix, do it on the stable branch, we will merge the fix to the development branch as well.:warning:
Next stable branch: https://github.com/letscontrolit/ESPEasy/tree/v2.0 (bug fixes only, since oct 2017))
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
## Automated binary releases
After this we will use more standard numbering. Next bugfix release will probably be 2.0.1.
Every night our build-bot will build a new binary release: https://github.com/letscontrolit/ESPEasy/releases
## Firmware binary releases
The releases are named something like 'mega-20180102' (last number is the build date)
Binary development releases are here: https://github.com/letscontrolit/ESPEasy/releases
Depending on your needs, we release different types of files:
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 |
Firmware name | Hardware | Included plugins |
----------------------------------------------|-------------------------|-----------------------------|
ESPEasy_mega-20180102_normal_ESP8266_1024.bin | ESP8266 with 1Mb flash | Stable |
ESPEasy_mega-20180102_test_ESP8266_1024.bin | ESP8266 with 1Mb flash | Stable + Test |
ESPEasy_mega-20180102_dev_ESP8266_1024.bin | ESP8266 with 1Mb flash | Stable + Test + Development |
ESPEasy_mega-20180102_normal_ESP8266_4096.bin | ESP8266 with 4Mb flash | Stable |
ESPEasy_mega-20180102_test_ESP8266_4096.bin | ESP8266 with 4Mb flash | Stable + Test |
ESPEasy_mega-20180102_dev_ESP8266_4096.bin | ESP8266 with 4Mb flash | Stable + Test + Development |
ESPEasy_mega-20180102_normal_ESP8285_1024.bin | ESP8285 with 1Mb flash | Stable |
ESPEasy_mega-20180102_test_ESP8285_1024.bin | ESP8285 with 1Mb flash | Stable + Test |
ESPEasy_mega-20180102_dev_ESP8285_1024.bin | ESP8285 with 1Mb flash | Stable + Test + Development |
## More info
Details and discussion are on the Experimental forum: http://www.letscontrolit.com/forum/viewtopic.php?f=18&t=2257&p=13600#p13600
Details and discussion are on the Experimental forum: https://www.letscontrolit.com/forum/viewforum.php?f=18
We're also on IRC: #ESPEasy @freenode
+26 -12
View File
@@ -1,21 +1,32 @@
#!/bin/bash
VERSION=$(git describe)
echo "Creating release archives for $VERSION ..."
#binaries
# cp .pioenvs/mini_512/firmware.bin dist/"ESPEasy_$VERSION""_mini_512.bin"
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"
#Naming convention:
# ESP_Easy_[github version]_[plugin set]_[chip type]_[flash memory].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"
for ENV in \
normal_ESP8266_1024 \
normal_ESP8266_4096 \
normal_ESP8285_1024 \
test_ESP8266_1024\
test_ESP8266_4096\
test_ESP8266_4096_VCC\
test_ESP8285_1024\
dev_ESP8266_1024\
dev_ESP8266_4096\
dev_ESP8285_1024\
dev_ESP8266PUYA_1024\
dev_ESP8266PUYA_1024_VCC;\
do
echo
echo "### Deploying environment $ENV for version $VERSION"
BIN=.pioenvs/$ENV/firmware.bin
python2 crc2.py $BIN
cp $BIN dist/"ESP_Easy_$VERSION""_$ENV.bin"
done
#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
@@ -25,4 +36,7 @@ cp -r src dist/Source/
cp platformio.ini dist/Source/
cd dist
echo
echo "### Creating zip archive"
zip ../ESPEasy_$VERSION.zip -r .
+116
View File
@@ -0,0 +1,116 @@
import sys
import binascii
import struct
import md5
import os
MD5DUMMY = "MD5_MD5_MD5_MD5_BoundariesOfTheSegmentsGoHere..." #48 chars
FILENAMEDUMMY = "ThisIsTheDummyPlaceHolderForTheBinaryFilename..." #48 chars
MemorySegmentStart,MemorySegmentEnd,MemoryContent=[],[],[]
##################################################################
# this subroutine shows the segments of a part
##################################################################
def showSegments (fileContent,offset):
global MemorySegmentStart, MemorySegmentEnd, MemoryContent
header = struct.unpack("ii", fileContent[offset:offset+8])
herestr =""
herestr2 =""
MemorySegmentStart.append(struct.pack("I",header[0]))
MemorySegmentEnd.append(struct.pack("I",header[0]+header[1]))
MemoryContent.append(fileContent[offset+8:offset+8+header[1]])
if fileContent.find( MD5DUMMY, offset+8, offset+8+header[1]) >0 :
herestr= " <-- CRC is here."
if fileContent.find( FILENAMEDUMMY, offset+8, offset+8+header[1]) >0 :
herestr2= " <-- filename is here."
print ("SEGMENT "+ str(len(MemorySegmentStart)-1)+ ": memory position: " + hex(header[0])+" to " + hex(header[0]+header[1]) + " length: " + hex(header[1])+herestr+herestr2)
#print ("first byte positoin in file: " + hex( offset+8))
#print ("last byte postion in file: " + hex(offset+8+header[1]-1))
return (8+offset+ header[1]); # return start of next segment
##################################################################
# this subroutine shows the parts of a binary file
##################################################################
def showParts(fileContent, offset):
header = struct.unpack("BBBBi", fileContent[offset:offset+8])
print ('\n\nBINARY PART\nSegments: ') + (hex(header[1]))
nextpos =offset+8
for x in range (0,header[1]):
nextpos = showSegments(fileContent,nextpos)
nextSegmentOffset = (fileContent.find("\xe9", nextpos))
return nextSegmentOffset
##################################################################
# MAIN
##################################################################
#if len(sys.argv) !=2 :
# print ("please give a filename")
# k=input("press close to exit")
# sys.exit(1)
FileName = sys.argv[1]#"C:/ArduinoPortable/sketchbooks/build/sketch_jan15a.ino.bin"
#FileName = "C:/ArduinoPortable/sketchbooks/build/sketch_jan15a.ino.bin"
print( "\n\nReplacing dummy MD5 checksum in .bin file")
with open(FileName, mode='rb') as file: # b is important -> binary
nextpos =0;
fileContent = file.read()
while nextpos >=0:
nextpos = showParts(fileContent,nextpos)
startArray,endArray,hashString = "","",""
includeStr = "hash includes segments:"
# memory sections:
# 0: bootloader (not readable)
# 1: program memory (SPI flash)
# 2: unknown but stable
# 3: RAM (initialized by bin file. Can be read but changes as you go :-( )
# 4: RAM
for i in (1,2 ): # use only stable segments, must be 4 in total. We use 2.
startArray =startArray + MemorySegmentStart[i]
endArray = endArray + MemorySegmentEnd[i]
hashString =hashString + MemoryContent[i]
with open(FileName+str(i), mode='wb') as file: # b is important -> binary
file.write(MemoryContent[i])
includeStr = includeStr +" "+ str(i)
print (includeStr)
# IMPORTANT: pad array with zeros if you use only 3 segments (see above)
while len(startArray) < 16 :
startArray =startArray + struct.pack("I",0)
endArray = endArray + struct.pack("I",0)
# debug print (binascii.hexlify(startArray))
# debug print (binascii.hexlify(endArray))
if (len(endArray) + len (startArray)) != 32 :
print("ERROR: please make sure you add / remove padding if you change the semgents.")
BinaryFileName = "";
if fileContent.find( FILENAMEDUMMY) < 0:
print("ERROR: FILENAMEDUMMY dummy not found in binary")
else:
BinaryFileName=os.path.basename(FileName) +"\0"
if len(BinaryFileName) >48: # check that filename is <48 chars
BinaryFileName=BinaryFileName[0:48] # truncate if necessary. 49th char in ESP is zero already
else:
BinaryFileName= BinaryFileName.ljust(48,'\0'); # pad with zeros.
if fileContent.find( MD5DUMMY) < 0:
print("ERROR: MD5 dummy not found in binary")
else:
hashString=hashString.replace (MD5DUMMY,"",1)
m = md5.new()
m.update (hashString) #use segment 1
md5hash = m.digest()
print("MD5 hash: "+ m.hexdigest())
print("\nwriting output file:\n" + FileName)
fileContent=fileContent.replace(MD5DUMMY,md5hash+startArray+endArray)
fileContent=fileContent.replace(FILENAMEDUMMY,BinaryFileName)
with open(FileName, mode='wb') as file: # b is important -> binary
file.write(fileContent)
#k=input("press close to exit")
+1807
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
+132
View File
@@ -0,0 +1,132 @@
/***************************************************
This is a library for the MPR121 I2C 12-chan Capacitive Sensor
Designed specifically to work with the MPR121 sensor from Adafruit
----> https://www.adafruit.com/products/1982
These sensors use I2C to communicate, 2+ pins are required to
interface
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries.
BSD license, all text above must be included in any redistribution
****************************************************/
#include "Adafruit_MPR121.h"
Adafruit_MPR121::Adafruit_MPR121() {
}
boolean Adafruit_MPR121::begin(uint8_t i2caddr) {
Wire.begin();
_i2caddr = i2caddr;
// soft reset
writeRegister(MPR121_SOFTRESET, 0x63);
delay(1);
for (uint8_t i=0; i<0x7F; i++) {
// Serial.print("$"); Serial.print(i, HEX);
// Serial.print(": 0x"); Serial.println(readRegister8(i));
}
writeRegister(MPR121_ECR, 0x0);
uint8_t c = readRegister8(MPR121_CONFIG2);
if (c != 0x24) return false;
setThresholds(12, 6);
writeRegister(MPR121_MHDR, 0x01);
writeRegister(MPR121_NHDR, 0x01);
writeRegister(MPR121_NCLR, 0x0E);
writeRegister(MPR121_FDLR, 0x00);
writeRegister(MPR121_MHDF, 0x01);
writeRegister(MPR121_NHDF, 0x05);
writeRegister(MPR121_NCLF, 0x01);
writeRegister(MPR121_FDLF, 0x00);
writeRegister(MPR121_NHDT, 0x00);
writeRegister(MPR121_NCLT, 0x00);
writeRegister(MPR121_FDLT, 0x00);
writeRegister(MPR121_DEBOUNCE, 0);
writeRegister(MPR121_CONFIG1, 0x10); // default, 16uA charge current
writeRegister(MPR121_CONFIG2, 0x20); // 0.5uS encoding, 1ms period
// writeRegister(MPR121_AUTOCONFIG0, 0x8F);
// writeRegister(MPR121_UPLIMIT, 150);
// writeRegister(MPR121_TARGETLIMIT, 100); // should be ~400 (100 shifted)
// writeRegister(MPR121_LOWLIMIT, 50);
// enable all electrodes
writeRegister(MPR121_ECR, 0x8F); // start with first 5 bits of baseline tracking
return true;
}
void Adafruit_MPR121::setThreshholds(uint8_t touch, uint8_t release) {
setThresholds(touch, release);
}
void Adafruit_MPR121::setThresholds(uint8_t touch, uint8_t release) {
for (uint8_t i=0; i<12; i++) {
writeRegister(MPR121_TOUCHTH_0 + 2*i, touch);
writeRegister(MPR121_RELEASETH_0 + 2*i, release);
}
}
uint16_t Adafruit_MPR121::filteredData(uint8_t t) {
if (t > 12) return 0;
return readRegister16(MPR121_FILTDATA_0L + t*2);
}
uint16_t Adafruit_MPR121::baselineData(uint8_t t) {
if (t > 12) return 0;
uint16_t bl = readRegister8(MPR121_BASELINE_0 + t);
return (bl << 2);
}
uint16_t Adafruit_MPR121::touched(void) {
uint16_t t = readRegister16(MPR121_TOUCHSTATUS_L);
return t & 0x0FFF;
}
/*********************************************************************/
uint8_t Adafruit_MPR121::readRegister8(uint8_t reg) {
Wire.beginTransmission(_i2caddr);
Wire.write(reg);
Wire.endTransmission(false);
while (Wire.requestFrom(_i2caddr, 1) != 1);
return ( Wire.read());
}
uint16_t Adafruit_MPR121::readRegister16(uint8_t reg) {
Wire.beginTransmission(_i2caddr);
Wire.write(reg);
Wire.endTransmission(false);
while (Wire.requestFrom(_i2caddr, 2) != 2);
uint16_t v = Wire.read();
v |= ((uint16_t) Wire.read()) << 8;
return v;
}
/**************************************************************************/
/*!
@brief Writes 8-bits to the specified destination register
*/
/**************************************************************************/
void Adafruit_MPR121::writeRegister(uint8_t reg, uint8_t value) {
Wire.beginTransmission(_i2caddr);
Wire.write((uint8_t)reg);
Wire.write((uint8_t)(value));
Wire.endTransmission();
}
+94
View File
@@ -0,0 +1,94 @@
/***************************************************
This is a library for the MPR121 12-Channel Capacitive Sensor
Designed specifically to work with the MPR121 breakout from Adafruit
----> https://www.adafruit.com/products/1982
These sensors use I2C to communicate, 2+ pins are required to
interface
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries.
BSD license, all text above must be included in any redistribution
****************************************************/
#ifndef ADAFRUIT_MPR121_H
#define ADAFRUIT_MPR121_H
#if (ARDUINO >= 100)
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
#include <Wire.h>
// The default I2C address
#define MPR121_I2CADDR_DEFAULT 0x5A
#define MPR121_TOUCHSTATUS_L 0x00
#define MPR121_TOUCHSTATUS_H 0x01
#define MPR121_FILTDATA_0L 0x04
#define MPR121_FILTDATA_0H 0x05
#define MPR121_BASELINE_0 0x1E
#define MPR121_MHDR 0x2B
#define MPR121_NHDR 0x2C
#define MPR121_NCLR 0x2D
#define MPR121_FDLR 0x2E
#define MPR121_MHDF 0x2F
#define MPR121_NHDF 0x30
#define MPR121_NCLF 0x31
#define MPR121_FDLF 0x32
#define MPR121_NHDT 0x33
#define MPR121_NCLT 0x34
#define MPR121_FDLT 0x35
#define MPR121_TOUCHTH_0 0x41
#define MPR121_RELEASETH_0 0x42
#define MPR121_DEBOUNCE 0x5B
#define MPR121_CONFIG1 0x5C
#define MPR121_CONFIG2 0x5D
#define MPR121_CHARGECURR_0 0x5F
#define MPR121_CHARGETIME_1 0x6C
#define MPR121_ECR 0x5E
#define MPR121_AUTOCONFIG0 0x7B
#define MPR121_AUTOCONFIG1 0x7C
#define MPR121_UPLIMIT 0x7D
#define MPR121_LOWLIMIT 0x7E
#define MPR121_TARGETLIMIT 0x7F
#define MPR121_GPIODIR 0x76
#define MPR121_GPIOEN 0x77
#define MPR121_GPIOSET 0x78
#define MPR121_GPIOCLR 0x79
#define MPR121_GPIOTOGGLE 0x7A
#define MPR121_SOFTRESET 0x80
//.. thru to 0x1C/0x1D
class Adafruit_MPR121 {
public:
// Hardware I2C
Adafruit_MPR121(void);
boolean begin(uint8_t i2caddr = MPR121_I2CADDR_DEFAULT);
uint16_t filteredData(uint8_t t);
uint16_t baselineData(uint8_t t);
uint8_t readRegister8(uint8_t reg);
uint16_t readRegister16(uint8_t reg);
void writeRegister(uint8_t reg, uint8_t value);
uint16_t touched(void);
// Add deprecated attribute so that the compiler shows a warning
__attribute__((deprecated)) void setThreshholds(uint8_t touch, uint8_t release);
void setThresholds(uint8_t touch, uint8_t release);
private:
int8_t _i2caddr;
};
#endif // ADAFRUIT_MPR121_H
+32
View File
@@ -0,0 +1,32 @@
# Adafruit_MPR121_Library
<!-- START COMPATIBILITY TABLE -->
## Compatibility
MCU | Tested Works | Doesn't Work | Not Tested | Notes
------------------ | :----------: | :----------: | :---------: | -----
Atmega328 @ 16MHz | X | | |
Atmega328 @ 12MHz | X | | |
Atmega32u4 @ 16MHz | X | | |
Atmega32u4 @ 8MHz | X | | |
ESP8266 | | X | |
Atmega2560 @ 16MHz | X | | |
ATSAM3X8E | | X | |
ATSAM21D | X | | |
ATtiny85 @ 16MHz | | | X |
ATtiny85 @ 8MHz | | | X |
Intel Curie @ 32MHz | | | X |
STM32F2 | | | X |
* ATmega328 @ 16MHz : Arduino UNO, Adafruit Pro Trinket 5V, Adafruit Metro 328, Adafruit Metro Mini
* ATmega328 @ 12MHz : Adafruit Pro Trinket 3V
* ATmega32u4 @ 16MHz : Arduino Leonardo, Arduino Micro, Arduino Yun, Teensy 2.0
* ATmega32u4 @ 8MHz : Adafruit Flora, Bluefruit Micro
* ESP8266 : Adafruit Huzzah
* ATmega2560 @ 16MHz : Arduino Mega
* ATSAM3X8E : Arduino Due
* ATSAM21D : Arduino Zero, M0 Pro
* ATtiny85 @ 16MHz : Adafruit Trinket 5V
* ATtiny85 @ 8MHz : Adafruit Gemma, Arduino Gemma, Adafruit Trinket 3V
<!-- END COMPATIBILITY TABLE -->
+25
View File
@@ -0,0 +1,25 @@
This is a library for the MPR121 12-channel Capacitive touch sensor
Designed specifically to work with the MPR121 Breakout in the Adafruit shop
----> https://www.adafruit.com/products/1982
These sensors use I2C communicate, at least 2 pins are required
to interface
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries.
BSD license, all text above must be included in any redistribution
Check out the links above for our tutorials and wiring diagrams
To download. click the ZIP button, and rename the uncompressed folder Adafruit_MPR121
Check that the Adafruit_MPR121 folder contains Adafruit_MPR121.cpp and Adafruit_MPR121.h
Place the Adafruit_MPR121 library folder your arduinosketchfolder/libraries/ folder.
You may need to create the libraries subfolder if its your first library. Restart the IDE.
We also have a great tutorial on Arduino library installation at:
http://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use
@@ -0,0 +1,83 @@
/*********************************************************
This is a library for the MPR121 12-channel Capacitive touch sensor
Designed specifically to work with the MPR121 Breakout in the Adafruit shop
----> https://www.adafruit.com/products/
These sensors use I2C communicate, at least 2 pins are required
to interface
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries.
BSD license, all text above must be included in any redistribution
**********************************************************/
#include <Wire.h>
#include "Adafruit_MPR121.h"
// You can have up to 4 on one i2c bus but one is enough for testing!
Adafruit_MPR121 cap = Adafruit_MPR121();
// Keeps track of the last pins touched
// so we know when buttons are 'released'
uint16_t lasttouched = 0;
uint16_t currtouched = 0;
void setup() {
Serial.begin(9600);
while (!Serial) { // needed to keep leonardo/micro from starting too fast!
delay(10);
}
Serial.println("Adafruit MPR121 Capacitive Touch sensor test");
// Default address is 0x5A, if tied to 3.3V its 0x5B
// If tied to SDA its 0x5C and if SCL then 0x5D
if (!cap.begin(0x5A)) {
Serial.println("MPR121 not found, check wiring?");
while (1);
}
Serial.println("MPR121 found!");
}
void loop() {
// Get the currently touched pads
currtouched = cap.touched();
for (uint8_t i=0; i<12; i++) {
// it if *is* touched and *wasnt* touched before, alert!
if ((currtouched & _BV(i)) && !(lasttouched & _BV(i)) ) {
Serial.print(i); Serial.println(" touched");
}
// if it *was* touched and now *isnt*, alert!
if (!(currtouched & _BV(i)) && (lasttouched & _BV(i)) ) {
Serial.print(i); Serial.println(" released");
}
}
// reset our state
lasttouched = currtouched;
// comment out this line for detailed data from the sensor!
return;
// debugging info, what
Serial.print("\t\t\t\t\t\t\t\t\t\t\t\t\t 0x"); Serial.println(cap.touched(), HEX);
Serial.print("Filt: ");
for (uint8_t i=0; i<12; i++) {
Serial.print(cap.filteredData(i)); Serial.print("\t");
}
Serial.println();
Serial.print("Base: ");
for (uint8_t i=0; i<12; i++) {
Serial.print(cap.baselineData(i)); Serial.print("\t");
}
Serial.println();
// put a delay so it isn't overwhelming
delay(100);
}
+6
View File
@@ -0,0 +1,6 @@
Adafruit_MPR121 KEYWORD1
begin KEYWORD2
filteredData KEYWORD2
baselineData KEYWORD2
touched KEYWORD2
setThresholds KEYWORD2
+9
View File
@@ -0,0 +1,9 @@
name=Adafruit MPR121
version=1.0.0
author=Adafruit <info@adafruit.com>
maintainer=Adafruit <info@adafruit.com>
sentence=Arduino library for the MPR121-based capacitive sensors in the Adafruit shop.
paragraph=Designed specifically to work with the MPR121 Breakout in the Adafruit shop.
category=Sensors
url=https://github.com/adafruit/Adafruit_MPR121
architectures=*
@@ -1,14 +1,14 @@
/******************************************************************
This is the library for the Adafruit Motor Shield V2 for Arduino.
This is the library for the Adafruit Motor Shield V2 for Arduino.
It supports DC motors & Stepper motors with microstepping as well
as stacking-support. It is *not* compatible with the V1 library!
It will only work with https://www.adafruit.com/products/1483
Adafruit invests time and resources providing this open
source code, please support Adafruit and open-source hardware
by purchasing products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries.
BSD license, check license.txt for more information.
All text above must be included in any redistribution.
@@ -48,14 +48,14 @@ void Adafruit_MotorShield::begin(uint16_t freq) {
_pwm.begin();
_freq = freq;
_pwm.setPWMFreq(_freq); // This is the maximum PWM frequency
for (uint8_t i=0; i<16; i++)
for (uint8_t i=0; i<16; i++)
_pwm.setPWM(i, 0, 0);
}
void Adafruit_MotorShield::setPWM(uint8_t pin, uint16_t value) {
if (value > 4095) {
_pwm.setPWM(pin, 4096, 0);
} else
} else
_pwm.setPWM(pin, 0, value);
}
void Adafruit_MotorShield::setPin(uint8_t pin, boolean value) {
@@ -170,7 +170,7 @@ uint16_t steps, Adafruit_MotorShield controller) {
if (steppernum == 1) {
latch_state &= ~_BV(MOTOR1_A) & ~_BV(MOTOR1_B) &
~_BV(MOTOR2_A) & ~_BV(MOTOR2_B); // all motor pins to 0
// enable both H bridges
pinMode(11, OUTPUT);
pinMode(3, OUTPUT);
@@ -282,7 +282,7 @@ uint8_t Adafruit_StepperMotor::onestep(uint8_t dir, uint8_t style) {
} else {
currentstep -= MICROSTEPS/2;
}
}
}
if (style == MICROSTEP) {
if (dir == FORWARD) {
@@ -316,12 +316,12 @@ uint8_t Adafruit_StepperMotor::onestep(uint8_t dir, uint8_t style) {
#ifdef MOTORDEBUG
Serial.print("current step: "); Serial.println(currentstep, DEC);
Serial.print(" pwmA = "); Serial.print(ocra, DEC);
Serial.print(" pwmB = "); Serial.println(ocrb, DEC);
Serial.print(" pwmA = "); Serial.print(ocra, DEC);
Serial.print(" pwmB = "); Serial.println(ocrb, DEC);
#endif
MC->setPWM(PWMApin, ocra*16);
MC->setPWM(PWMBpin, ocrb*16);
// release all
uint8_t latch_state = 0; // all motor pins to 0
@@ -352,7 +352,7 @@ uint8_t Adafruit_StepperMotor::onestep(uint8_t dir, uint8_t style) {
break;
case 4:
latch_state |= 0x4; // energize coil 3 only
break;
break;
case 5:
latch_state |= 0xC; // energize coil 3+4
break;
@@ -395,4 +395,3 @@ uint8_t Adafruit_StepperMotor::onestep(uint8_t dir, uint8_t style) {
return currentstep;
}
+154
View File
@@ -0,0 +1,154 @@
/*
* Copyright (C) 2008 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software< /span>
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* Update by K. Townsend (Adafruit Industries) for lighter typedefs, and
* extended sensor support to include color, voltage and current */
#ifndef _ADAFRUIT_SENSOR_H
#define _ADAFRUIT_SENSOR_H
#if ARDUINO >= 100
#include "Arduino.h"
#include "Print.h"
#else
#include "WProgram.h"
#endif
/* Intentionally modeled after sensors.h in the Android API:
* https://github.com/android/platform_hardware_libhardware/blob/master/include/hardware/sensors.h */
/* Constants */
#define SENSORS_GRAVITY_EARTH (9.80665F) /**< Earth's gravity in m/s^2 */
#define SENSORS_GRAVITY_MOON (1.6F) /**< The moon's gravity in m/s^2 */
#define SENSORS_GRAVITY_SUN (275.0F) /**< The sun's gravity in m/s^2 */
#define SENSORS_GRAVITY_STANDARD (SENSORS_GRAVITY_EARTH)
#define SENSORS_MAGFIELD_EARTH_MAX (60.0F) /**< Maximum magnetic field on Earth's surface */
#define SENSORS_MAGFIELD_EARTH_MIN (30.0F) /**< Minimum magnetic field on Earth's surface */
#define SENSORS_PRESSURE_SEALEVELHPA (1013.25F) /**< Average sea level pressure is 1013.25 hPa */
#define SENSORS_DPS_TO_RADS (0.017453293F) /**< Degrees/s to rad/s multiplier */
#define SENSORS_GAUSS_TO_MICROTESLA (100) /**< Gauss to micro-Tesla multiplier */
/** Sensor types */
typedef enum
{
SENSOR_TYPE_ACCELEROMETER = (1), /**< Gravity + linear acceleration */
SENSOR_TYPE_MAGNETIC_FIELD = (2),
SENSOR_TYPE_ORIENTATION = (3),
SENSOR_TYPE_GYROSCOPE = (4),
SENSOR_TYPE_LIGHT = (5),
SENSOR_TYPE_PRESSURE = (6),
SENSOR_TYPE_PROXIMITY = (8),
SENSOR_TYPE_GRAVITY = (9),
SENSOR_TYPE_LINEAR_ACCELERATION = (10), /**< Acceleration not including gravity */
SENSOR_TYPE_ROTATION_VECTOR = (11),
SENSOR_TYPE_RELATIVE_HUMIDITY = (12),
SENSOR_TYPE_AMBIENT_TEMPERATURE = (13),
SENSOR_TYPE_VOLTAGE = (15),
SENSOR_TYPE_CURRENT = (16),
SENSOR_TYPE_COLOR = (17)
} sensors_type_t;
/** struct sensors_vec_s is used to return a vector in a common format. */
typedef struct {
union {
float v[3];
struct {
float x;
float y;
float z;
};
/* Orientation sensors */
struct {
float roll; /**< Rotation around the longitudinal axis (the plane body, 'X axis'). Roll is positive and increasing when moving downward. -90°<=roll<=90° */
float pitch; /**< Rotation around the lateral axis (the wing span, 'Y axis'). Pitch is positive and increasing when moving upwards. -180°<=pitch<=180°) */
float heading; /**< Angle between the longitudinal axis (the plane body) and magnetic north, measured clockwise when viewing from the top of the device. 0-359° */
};
};
int8_t status;
uint8_t reserved[3];
} sensors_vec_t;
/** struct sensors_color_s is used to return color data in a common format. */
typedef struct {
union {
float c[3];
/* RGB color space */
struct {
float r; /**< Red component */
float g; /**< Green component */
float b; /**< Blue component */
};
};
uint32_t rgba; /**< 24-bit RGBA value */
} sensors_color_t;
/* Sensor event (36 bytes) */
/** struct sensor_event_s is used to provide a single sensor event in a common format. */
typedef struct
{
int32_t version; /**< must be sizeof(struct sensors_event_t) */
int32_t sensor_id; /**< unique sensor identifier */
int32_t type; /**< sensor type */
int32_t reserved0; /**< reserved */
int32_t timestamp; /**< time is in milliseconds */
union
{
float data[4];
sensors_vec_t acceleration; /**< acceleration values are in meter per second per second (m/s^2) */
sensors_vec_t magnetic; /**< magnetic vector values are in micro-Tesla (uT) */
sensors_vec_t orientation; /**< orientation values are in degrees */
sensors_vec_t gyro; /**< gyroscope values are in rad/s */
float temperature; /**< temperature is in degrees centigrade (Celsius) */
float distance; /**< distance in centimeters */
float light; /**< light in SI lux units */
float pressure; /**< pressure in hectopascal (hPa) */
float relative_humidity; /**< relative humidity in percent */
float current; /**< current in milliamps (mA) */
float voltage; /**< voltage in volts (V) */
sensors_color_t color; /**< color in RGB component values */
};
} sensors_event_t;
/* Sensor details (40 bytes) */
/** struct sensor_s is used to describe basic information about a specific sensor. */
typedef struct
{
char name[12]; /**< sensor name */
int32_t version; /**< version of the hardware + driver */
int32_t sensor_id; /**< unique sensor identifier */
int32_t type; /**< this sensor's type (ex. SENSOR_TYPE_LIGHT) */
float max_value; /**< maximum value of this sensor's value in SI units */
float min_value; /**< minimum value of this sensor's value in SI units */
float resolution; /**< smallest difference between two values reported by this sensor */
int32_t min_delay; /**< min delay in microseconds between events. zero = not a constant rate */
} sensor_t;
class Adafruit_Sensor {
public:
// Constructor(s)
Adafruit_Sensor() {}
virtual ~Adafruit_Sensor() {}
// These must be defined by the subclass
virtual void enableAutoRange(bool enabled) {};
virtual bool getEvent(sensors_event_t*) = 0;
virtual void getSensor(sensor_t*) = 0;
private:
bool _autoRange;
};
#endif
+221
View File
@@ -0,0 +1,221 @@
# Adafruit Unified Sensor Driver #
Many small embedded systems exist to collect data from sensors, analyse the data, and either take an appropriate action or send that sensor data to another system for processing.
One of the many challenges of embedded systems design is the fact that parts you used today may be out of production tomorrow, or system requirements may change and you may need to choose a different sensor down the road.
Creating new drivers is a relatively easy task, but integrating them into existing systems is both error prone and time consuming since sensors rarely use the exact same units of measurement.
By reducing all data to a single **sensors\_event\_t** 'type' and settling on specific, **standardised SI units** for each sensor family the same sensor types return values that are comparable with any other similar sensor. This enables you to switch sensor models with very little impact on the rest of the system, which can help mitigate some of the risks and problems of sensor availability and code reuse.
The unified sensor abstraction layer is also useful for data-logging and data-transmission since you only have one well-known type to log or transmit over the air or wire.
## Unified Sensor Drivers ##
The following drivers are based on the Adafruit Unified Sensor Driver:
**Accelerometers**
- [Adafruit\_ADXL345](https://github.com/adafruit/Adafruit_ADXL345)
- [Adafruit\_LSM303DLHC](https://github.com/adafruit/Adafruit_LSM303DLHC)
- [Adafruit\_MMA8451\_Library](https://github.com/adafruit/Adafruit_MMA8451_Library)
**Gyroscope**
- [Adafruit\_L3GD20\_U](https://github.com/adafruit/Adafruit_L3GD20_U)
**Light**
- [Adafruit\_TSL2561](https://github.com/adafruit/Adafruit_TSL2561)
- [Adafruit\_TSL2591\_Library](https://github.com/adafruit/Adafruit_TSL2591_Library)
**Magnetometers**
- [Adafruit\_LSM303DLHC](https://github.com/adafruit/Adafruit_LSM303DLHC)
- [Adafruit\_HMC5883\_Unified](https://github.com/adafruit/Adafruit_HMC5883_Unified)
**Barometric Pressure**
- [Adafruit\_BMP085\_Unified](https://github.com/adafruit/Adafruit_BMP085_Unified)
- [Adafruit\_BMP183\_Unified\_Library](https://github.com/adafruit/Adafruit_BMP183_Unified_Library)
**Humidity & Temperature**
- [DHT-sensor-library](https://github.com/adafruit/DHT-sensor-library)
**Orientation**
- [Adafruit_BNO055](https://github.com/adafruit/Adafruit_BNO055)
## How Does it Work? ##
Any driver that supports the Adafruit unified sensor abstraction layer will implement the Adafruit\_Sensor base class. There are two main typedefs and one enum defined in Adafruit_Sensor.h that are used to 'abstract' away the sensor details and values:
**Sensor Types (sensors\_type\_t)**
These pre-defined sensor types are used to properly handle the two related typedefs below, and allows us determine what types of units the sensor uses, etc.
```
/** Sensor types */
typedef enum
{
SENSOR_TYPE_ACCELEROMETER = (1),
SENSOR_TYPE_MAGNETIC_FIELD = (2),
SENSOR_TYPE_ORIENTATION = (3),
SENSOR_TYPE_GYROSCOPE = (4),
SENSOR_TYPE_LIGHT = (5),
SENSOR_TYPE_PRESSURE = (6),
SENSOR_TYPE_PROXIMITY = (8),
SENSOR_TYPE_GRAVITY = (9),
SENSOR_TYPE_LINEAR_ACCELERATION = (10),
SENSOR_TYPE_ROTATION_VECTOR = (11),
SENSOR_TYPE_RELATIVE_HUMIDITY = (12),
SENSOR_TYPE_AMBIENT_TEMPERATURE = (13),
SENSOR_TYPE_VOLTAGE = (15),
SENSOR_TYPE_CURRENT = (16),
SENSOR_TYPE_COLOR = (17)
} sensors_type_t;
```
**Sensor Details (sensor\_t)**
This typedef describes the specific capabilities of this sensor, and allows us to know what sensor we are using beneath the abstraction layer.
```
/* Sensor details (40 bytes) */
/** struct sensor_s is used to describe basic information about a specific sensor. */
typedef struct
{
char name[12];
int32_t version;
int32_t sensor_id;
int32_t type;
float max_value;
float min_value;
float resolution;
int32_t min_delay;
} sensor_t;
```
The individual fields are intended to be used as follows:
- **name**: The sensor name or ID, up to a maximum of twelve characters (ex. "MPL115A2")
- **version**: The version of the sensor HW and the driver to allow us to differentiate versions of the board or driver
- **sensor\_id**: A unique sensor identifier that is used to differentiate this specific sensor instance from any others that are present on the system or in the sensor network
- **type**: The sensor type, based on **sensors\_type\_t** in sensors.h
- **max\_value**: The maximum value that this sensor can return (in the appropriate SI unit)
- **min\_value**: The minimum value that this sensor can return (in the appropriate SI unit)
- **resolution**: The smallest difference between two values that this sensor can report (in the appropriate SI unit)
- **min\_delay**: The minimum delay in microseconds between two sensor events, or '0' if there is no constant sensor rate
**Sensor Data/Events (sensors\_event\_t)**
This typedef is used to return sensor data from any sensor supported by the abstraction layer, using standard SI units and scales.
```
/* Sensor event (36 bytes) */
/** struct sensor_event_s is used to provide a single sensor event in a common format. */
typedef struct
{
int32_t version;
int32_t sensor_id;
int32_t type;
int32_t reserved0;
int32_t timestamp;
union
{
float data[4];
sensors_vec_t acceleration;
sensors_vec_t magnetic;
sensors_vec_t orientation;
sensors_vec_t gyro;
float temperature;
float distance;
float light;
float pressure;
float relative_humidity;
float current;
float voltage;
sensors_color_t color;
};
} sensors_event_t;
```
It includes the following fields:
- **version**: Contain 'sizeof(sensors\_event\_t)' to identify which version of the API we're using in case this changes in the future
- **sensor\_id**: A unique sensor identifier that is used to differentiate this specific sensor instance from any others that are present on the system or in the sensor network (must match the sensor\_id value in the corresponding sensor\_t enum above!)
- **type**: the sensor type, based on **sensors\_type\_t** in sensors.h
- **timestamp**: time in milliseconds when the sensor value was read
- **data[4]**: An array of four 32-bit values that allows us to encapsulate any type of sensor data via a simple union (further described below)
**Required Functions**
In addition to the two standard types and the sensor type enum, all drivers based on Adafruit_Sensor must also implement the following two functions:
```
bool getEvent(sensors_event_t*);
```
Calling this function will populate the supplied sensors\_event\_t reference with the latest available sensor data. You should call this function as often as you want to update your data.
```
void getSensor(sensor_t*);
```
Calling this function will provide some basic information about the sensor (the sensor name, driver version, min and max values, etc.
**Standardised SI values for sensors\_event\_t**
A key part of the abstraction layer is the standardisation of values on SI units of a particular scale, which is accomplished via the data[4] union in sensors\_event\_t above. This 16 byte union includes fields for each main sensor type, and uses the following SI units and scales:
- **acceleration**: values are in **meter per second per second** (m/s^2)
- **magnetic**: values are in **micro-Tesla** (uT)
- **orientation**: values are in **degrees**
- **gyro**: values are in **rad/s**
- **temperature**: values in **degrees centigrade** (Celsius)
- **distance**: values are in **centimeters**
- **light**: values are in **SI lux** units
- **pressure**: values are in **hectopascal** (hPa)
- **relative\_humidity**: values are in **percent**
- **current**: values are in **milliamps** (mA)
- **voltage**: values are in **volts** (V)
- **color**: values are in 0..1.0 RGB channel luminosity and 32-bit RGBA format
## The Unified Driver Abstraction Layer in Practice ##
Using the unified sensor abstraction layer is relatively easy once a compliant driver has been created.
Every compliant sensor can now be read using a single, well-known 'type' (sensors\_event\_t), and there is a standardised way of interrogating a sensor about its specific capabilities (via sensor\_t).
An example of reading the [TSL2561](https://github.com/adafruit/Adafruit_TSL2561) light sensor can be seen below:
```
Adafruit_TSL2561 tsl = Adafruit_TSL2561(TSL2561_ADDR_FLOAT, 12345);
...
/* Get a new sensor event */
sensors_event_t event;
tsl.getEvent(&event);
/* Display the results (light is measured in lux) */
if (event.light)
{
Serial.print(event.light); Serial.println(" lux");
}
else
{
/* If event.light = 0 lux the sensor is probably saturated
and no reliable data could be generated! */
Serial.println("Sensor overload");
}
```
Similarly, we can get the basic technical capabilities of this sensor with the following code:
```
sensor_t sensor;
sensor_t sensor;
tsl.getSensor(&sensor);
/* Display the sensor details */
Serial.println("------------------------------------");
Serial.print ("Sensor: "); Serial.println(sensor.name);
Serial.print ("Driver Ver: "); Serial.println(sensor.version);
Serial.print ("Unique ID: "); Serial.println(sensor.sensor_id);
Serial.print ("Max Value: "); Serial.print(sensor.max_value); Serial.println(" lux");
Serial.print ("Min Value: "); Serial.print(sensor.min_value); Serial.println(" lux");
Serial.print ("Resolution: "); Serial.print(sensor.resolution); Serial.println(" lux");
Serial.println("------------------------------------");
Serial.println("");
```
+9
View File
@@ -0,0 +1,9 @@
name=Adafruit Unified Sensor
version=1.0.2
author=Adafruit <info@adafruit.com>
maintainer=Adafruit <info@adafruit.com>
sentence=Required for all Adafruit Unified Sensor based libraries.
paragraph=A unified sensor abstraction layer used by many Adafruit sensor libraries.
category=Sensors
url=https://github.com/adafruit/Adafruit_Sensor
architectures=*
+46
View File
@@ -0,0 +1,46 @@
Thank you for opening an issue on an Adafruit Arduino library repository. To
improve the speed of resolution please review the following guidelines and
common troubleshooting steps below before creating the issue:
- **Do not use GitHub issues for troubleshooting projects and issues.** Instead use
the forums at http://forums.adafruit.com to ask questions and troubleshoot why
something isn't working as expected. In many cases the problem is a common issue
that you will more quickly receive help from the forum community. GitHub issues
are meant for known defects in the code. If you don't know if there is a defect
in the code then start with troubleshooting on the forum first.
- **If following a tutorial or guide be sure you didn't miss a step.** Carefully
check all of the steps and commands to run have been followed. Consult the
forum if you're unsure or have questions about steps in a guide/tutorial.
- **For Arduino projects check these very common issues to ensure they don't apply**:
- For uploading sketches or communicating with the board make sure you're using
a **USB data cable** and **not** a **USB charge-only cable**. It is sometimes
very hard to tell the difference between a data and charge cable! Try using the
cable with other devices or swapping to another cable to confirm it is not
the problem.
- **Be sure you are supplying adequate power to the board.** Check the specs of
your board and plug in an external power supply. In many cases just
plugging a board into your computer is not enough to power it and other
peripherals.
- **Double check all soldering joints and connections.** Flakey connections
cause many mysterious problems. See the [guide to excellent soldering](https://learn.adafruit.com/adafruit-guide-excellent-soldering/tools) for examples of good solder joints.
- **Ensure you are using an official Arduino or Adafruit board.** We can't
guarantee a clone board will have the same functionality and work as expected
with this code and don't support them.
If you're sure this issue is a defect in the code and checked the steps above
please fill in the following fields to provide enough troubleshooting information.
You may delete the guideline and text above to just leave the following details:
- Arduino board: **INSERT ARDUINO BOARD NAME/TYPE HERE**
- Arduino IDE version (found in Arduino -> About Arduino menu): **INSERT ARDUINO
VERSION HERE**
- List the steps to reproduce the problem below (if possible attach a sketch or
copy the sketch code in too): **LIST REPRO STEPS BELOW**
+26
View File
@@ -0,0 +1,26 @@
Thank you for creating a pull request to contribute to Adafruit's GitHub code!
Before you open the request please review the following guidelines and tips to
help it be more easily integrated:
- **Describe the scope of your change--i.e. what the change does and what parts
of the code were modified.** This will help us understand any risks of integrating
the code.
- **Describe any known limitations with your change.** For example if the change
doesn't apply to a supported platform of the library please mention it.
- **Please run any tests or examples that can exercise your modified code.** We
strive to not break users of the code and running tests/examples helps with this
process.
Thank you again for contributing! We will try to test and integrate the change
as soon as we can, but be aware we have many GitHub repositories to manage and
can't immediately respond to every request. There is no need to bump or check in
on a pull request (it will clutter the discussion of the request).
Also don't be worried if the request is closed or not integrated--sometimes the
priorities of Adafruit's GitHub code (education, ease of use) might not match the
priorities of the pull request. Don't fret, the open source community thrives on
forks and GitHub makes it easy to keep your changes in a forked repo.
After reviewing the guidelines above you can delete this text from the pull request.
+504
View File
@@ -0,0 +1,504 @@
/**************************************************************************/
/*!
@file Adafruit_TSL2591.cpp
@author KT0WN (adafruit.com)
This is a library for the Adafruit TSL2591 breakout board
This library works with the Adafruit TSL2591 breakout
----> https://www.adafruit.com/products/1980
Check out the links above for our tutorials and wiring diagrams
These chips use I2C to communicate
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
@section LICENSE
Software License Agreement (BSD License)
Copyright (c) 2014 Adafruit Industries
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**************************************************************************/
#if defined(ESP8266) || defined(ESP32)
#include <pgmspace.h>
#else
#include <avr/pgmspace.h>
#endif
#if defined(__AVR__)
#include <util/delay.h>
#endif
#include <stdlib.h>
#include "Adafruit_TSL2591.h"
Adafruit_TSL2591::Adafruit_TSL2591(int32_t sensorID)
{
_initialized = false;
_integration = TSL2591_INTEGRATIONTIME_100MS;
_gain = TSL2591_GAIN_MED;
_sensorID = sensorID;
// we cant do wire initialization till later, because we havent loaded Wire yet
}
boolean Adafruit_TSL2591::begin(void)
{
Wire.begin();
/*
for (uint8_t i=0; i<0x20; i++)
{
uint8_t id = read8(0x12);
Serial.print("$"); Serial.print(i, HEX);
Serial.print(" = 0x"); Serial.println(read8(i), HEX);
}
*/
uint8_t id = read8(TSL2591_COMMAND_BIT | TSL2591_REGISTER_DEVICE_ID);
if (id == 0x50 )
{
// Serial.println("Found Adafruit_TSL2591");
}
else
{
return false;
}
_initialized = true;
// Set default integration time and gain
setTiming(_integration);
setGain(_gain);
// Note: by default, the device is in power down mode on bootup
disable();
return true;
}
void Adafruit_TSL2591::enable(void)
{
if (!_initialized)
{
if (!begin())
{
return;
}
}
// Enable the device by setting the control bit to 0x01
write8(TSL2591_COMMAND_BIT | TSL2591_REGISTER_ENABLE, TSL2591_ENABLE_POWERON | TSL2591_ENABLE_AEN | TSL2591_ENABLE_AIEN | TSL2591_ENABLE_NPIEN);
}
void Adafruit_TSL2591::disable(void)
{
if (!_initialized)
{
if (!begin())
{
return;
}
}
// Disable the device by setting the control bit to 0x00
write8(TSL2591_COMMAND_BIT | TSL2591_REGISTER_ENABLE, TSL2591_ENABLE_POWEROFF);
}
void Adafruit_TSL2591::setGain(tsl2591Gain_t gain)
{
if (!_initialized)
{
if (!begin())
{
return;
}
}
enable();
_gain = gain;
write8(TSL2591_COMMAND_BIT | TSL2591_REGISTER_CONTROL, _integration | _gain);
disable();
}
tsl2591Gain_t Adafruit_TSL2591::getGain()
{
return _gain;
}
void Adafruit_TSL2591::setTiming(tsl2591IntegrationTime_t integration)
{
if (!_initialized)
{
if (!begin())
{
return;
}
}
enable();
_integration = integration;
write8(TSL2591_COMMAND_BIT | TSL2591_REGISTER_CONTROL, _integration | _gain);
disable();
}
tsl2591IntegrationTime_t Adafruit_TSL2591::getTiming()
{
return _integration;
}
float Adafruit_TSL2591::calculateLuxf(uint16_t ch0, uint16_t ch1)
{
float atime, again;
float cpl, lux1, lux2, lux;
uint32_t chan0, chan1;
// Check for overflow conditions first
if ((ch0 == 0xFFFF) | (ch1 == 0xFFFF))
{
// Signal an overflow
return 0;
}
// Note: This algorithm is based on preliminary coefficients
// provided by AMS and may need to be updated in the future
switch (_integration)
{
case TSL2591_INTEGRATIONTIME_100MS :
atime = 100.0F;
break;
case TSL2591_INTEGRATIONTIME_200MS :
atime = 200.0F;
break;
case TSL2591_INTEGRATIONTIME_300MS :
atime = 300.0F;
break;
case TSL2591_INTEGRATIONTIME_400MS :
atime = 400.0F;
break;
case TSL2591_INTEGRATIONTIME_500MS :
atime = 500.0F;
break;
case TSL2591_INTEGRATIONTIME_600MS :
atime = 600.0F;
break;
default: // 100ms
atime = 100.0F;
break;
}
switch (_gain)
{
case TSL2591_GAIN_LOW :
again = 1.0F;
break;
case TSL2591_GAIN_MED :
again = 25.0F;
break;
case TSL2591_GAIN_HIGH :
again = 428.0F;
break;
case TSL2591_GAIN_MAX :
again = 9876.0F;
break;
default:
again = 1.0F;
break;
}
// cpl = (ATIME * AGAIN) / DF
cpl = (atime * again) / TSL2591_LUX_DF;
lux1 = (((float) ch0 - (float) ch1)) * (1.0F - ((float) ch1 / (float) ch0)) / cpl;//( (float)ch0 - (TSL2591_LUX_COEFB * (float)ch1) ) / cpl;
lux2 = ((TSL2591_LUX_COEFC * (float) ch0) - (TSL2591_LUX_COEFD * (float) ch1)) / cpl;
lux = lux1 > lux2 ? lux1 : lux2;
// Alternate lux calculation
//lux = ( (float)ch0 - ( 1.7F * (float)ch1 ) ) / cpl;
// Signal I2C had no errors
return lux;
}
uint32_t Adafruit_TSL2591::calculateLux(uint16_t ch0, uint16_t ch1)
{
return (uint32_t) calculateLuxf(ch0, ch1);
}
uint32_t Adafruit_TSL2591::getFullLuminosity (void)
{
if (!_initialized)
{
if (!begin())
{
return 0;
}
}
// Enable the device
enable();
// Wait x ms for ADC to complete
for (uint8_t d=0; d<=_integration; d++)
{
delay(120);
}
uint32_t x;
uint16_t y;
y |= read16(TSL2591_COMMAND_BIT | TSL2591_REGISTER_CHAN0_LOW);
x = read16(TSL2591_COMMAND_BIT | TSL2591_REGISTER_CHAN1_LOW);
x <<= 16;
x |= y;
disable();
return x;
}
uint16_t Adafruit_TSL2591::getLuminosity (uint8_t channel)
{
uint32_t x = getFullLuminosity();
if (channel == TSL2591_FULLSPECTRUM)
{
// Reads two byte value from channel 0 (visible + infrared)
return (x & 0xFFFF);
}
else if (channel == TSL2591_INFRARED)
{
// Reads two byte value from channel 1 (infrared)
return (x >> 16);
}
else if (channel == TSL2591_VISIBLE)
{
// Reads all and subtracts out just the visible!
return ( (x & 0xFFFF) - (x >> 16));
}
// unknown channel!
return 0;
}
void Adafruit_TSL2591::registerInterrupt(uint16_t lowerThreshold, uint16_t upperThreshold)
{
if (!_initialized)
{
if (!begin())
{
return;
}
}
enable();
write8(TSL2591_COMMAND_BIT | TSL2591_REGISTER_THRESHOLD_NPAILTL, lowerThreshold);
write8(TSL2591_COMMAND_BIT | TSL2591_REGISTER_THRESHOLD_NPAILTH, lowerThreshold >> 8);
write8(TSL2591_COMMAND_BIT | TSL2591_REGISTER_THRESHOLD_NPAIHTL, upperThreshold);
write8(TSL2591_COMMAND_BIT | TSL2591_REGISTER_THRESHOLD_NPAIHTH, upperThreshold >> 8);
disable();
}
void Adafruit_TSL2591::registerInterrupt(uint16_t lowerThreshold, uint16_t upperThreshold, tsl2591Persist_t persist)
{
if (!_initialized)
{
if (!begin())
{
return;
}
}
enable();
write8(TSL2591_COMMAND_BIT | TSL2591_REGISTER_PERSIST_FILTER, persist);
write8(TSL2591_COMMAND_BIT | TSL2591_REGISTER_THRESHOLD_AILTL, lowerThreshold);
write8(TSL2591_COMMAND_BIT | TSL2591_REGISTER_THRESHOLD_AILTH, lowerThreshold >> 8);
write8(TSL2591_COMMAND_BIT | TSL2591_REGISTER_THRESHOLD_AIHTL, upperThreshold);
write8(TSL2591_COMMAND_BIT | TSL2591_REGISTER_THRESHOLD_AIHTH, upperThreshold >> 8);
disable();
}
void Adafruit_TSL2591::clearInterrupt()
{
if (!_initialized)
{
if (!begin())
{
return;
}
}
enable();
write8(TSL2591_CLEAR_INT);
disable();
}
uint8_t Adafruit_TSL2591::getStatus()
{
if (!_initialized)
{
if (!begin())
{
return 0;
}
}
// Enable the device
enable();
uint8_t x;
x = read8(TSL2591_COMMAND_BIT | TSL2591_REGISTER_DEVICE_STATUS);
disable();
return x;
}
uint8_t Adafruit_TSL2591::read8(uint8_t reg)
{
uint8_t x;
Wire.beginTransmission(TSL2591_ADDR);
#if ARDUINO >= 100
Wire.write(reg);
#else
Wire.send(reg);
#endif
Wire.endTransmission();
Wire.requestFrom(TSL2591_ADDR, 1);
#if ARDUINO >= 100
x = Wire.read();
#else
x = Wire.receive();
#endif
// while (! Wire.available());
// return Wire.read();
return x;
}
uint16_t Adafruit_TSL2591::read16(uint8_t reg)
{
uint16_t x;
uint16_t t;
Wire.beginTransmission(TSL2591_ADDR);
#if ARDUINO >= 100
Wire.write(reg);
#else
Wire.send(reg);
#endif
Wire.endTransmission();
Wire.requestFrom(TSL2591_ADDR, 2);
#if ARDUINO >= 100
t = Wire.read();
x = Wire.read();
#else
t = Wire.receive();
x = Wire.receive();
#endif
x <<= 8;
x |= t;
return x;
}
void Adafruit_TSL2591::write8 (uint8_t reg, uint8_t value)
{
Wire.beginTransmission(TSL2591_ADDR);
#if ARDUINO >= 100
Wire.write(reg);
Wire.write(value);
#else
Wire.send(reg);
Wire.send(value);
#endif
Wire.endTransmission();
}
void Adafruit_TSL2591::write8 (uint8_t reg)
{
Wire.beginTransmission(TSL2591_ADDR);
#if ARDUINO >= 100
Wire.write(reg);
#else
Wire.send(reg);
#endif
Wire.endTransmission();
}
/**************************************************************************/
/*!
@brief Gets the most recent sensor event
*/
/**************************************************************************/
bool Adafruit_TSL2591::getEvent(sensors_event_t *event)
{
uint16_t ir, full;
uint32_t lum = getFullLuminosity();
/* Early silicon seems to have issues when there is a sudden jump in */
/* light levels. :( To work around this for now sample the sensor 2x */
lum = getFullLuminosity();
ir = lum >> 16;
full = lum & 0xFFFF;
/* Clear the event */
memset(event, 0, sizeof(sensors_event_t));
event->version = sizeof(sensors_event_t);
event->sensor_id = _sensorID;
event->type = SENSOR_TYPE_LIGHT;
event->timestamp = millis();
/* Calculate the actual lux value */
/* 0 = sensor overflow (too much light) */
event->light = calculateLux(full, ir);
return true;
}
/**************************************************************************/
/*!
@brief Gets the sensor_t data
*/
/**************************************************************************/
void Adafruit_TSL2591::getSensor(sensor_t *sensor)
{
/* Clear the sensor_t object */
memset(sensor, 0, sizeof(sensor_t));
/* Insert the sensor name in the fixed length char array */
strncpy (sensor->name, "TSL2591", sizeof(sensor->name) - 1);
sensor->name[sizeof(sensor->name)- 1] = 0;
sensor->version = 1;
sensor->sensor_id = _sensorID;
sensor->type = SENSOR_TYPE_LIGHT;
sensor->min_delay = 0;
sensor->max_value = 88000.0;
sensor->min_value = 0.0;
sensor->resolution = 1.0;
}
+187
View File
@@ -0,0 +1,187 @@
/**************************************************************************/
/*!
@file Adafruit_TSL2591.h
@author KT0WN (adafruit.com)
This is a library for the Adafruit TSL2591 breakout board
This library works with the Adafruit TSL2591 breakout
----> https://www.adafruit.com/products/1980
Check out the links above for our tutorials and wiring diagrams
These chips use I2C to communicate
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
@section LICENSE
Software License Agreement (BSD License)
Copyright (c) 2014 Adafruit Industries
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**************************************************************************/
#ifndef _TSL2591_H_
#define _TSL2591_H_
#if ARDUINO >= 100
#include <Arduino.h>
#else
#include <WProgram.h>
#endif
#include <Adafruit_Sensor.h>
#include <Wire.h>
#define TSL2591_VISIBLE (2) // channel 0 - channel 1
#define TSL2591_INFRARED (1) // channel 1
#define TSL2591_FULLSPECTRUM (0) // channel 0
#define TSL2591_ADDR (0x29)
#define TSL2591_READBIT (0x01)
#define TSL2591_COMMAND_BIT (0xA0) // 1010 0000: bits 7 and 5 for 'command normal'
#define TSL2591_CLEAR_INT (0xE7)
#define TSL2591_TEST_INT (0xE4)
#define TSL2591_WORD_BIT (0x20) // 1 = read/write word (rather than byte)
#define TSL2591_BLOCK_BIT (0x10) // 1 = using block read/write
#define TSL2591_ENABLE_POWEROFF (0x00)
#define TSL2591_ENABLE_POWERON (0x01)
#define TSL2591_ENABLE_AEN (0x02) // ALS Enable. This field activates ALS function. Writing a one activates the ALS. Writing a zero disables the ALS.
#define TSL2591_ENABLE_AIEN (0x10) // ALS Interrupt Enable. When asserted permits ALS interrupts to be generated, subject to the persist filter.
#define TSL2591_ENABLE_NPIEN (0x80) // No Persist Interrupt Enable. When asserted NP Threshold conditions will generate an interrupt, bypassing the persist filter
#define TSL2591_LUX_DF (408.0F)
#define TSL2591_LUX_COEFB (1.64F) // CH0 coefficient
#define TSL2591_LUX_COEFC (0.59F) // CH1 coefficient A
#define TSL2591_LUX_COEFD (0.86F) // CH2 coefficient B
enum
{
TSL2591_REGISTER_ENABLE = 0x00,
TSL2591_REGISTER_CONTROL = 0x01,
TSL2591_REGISTER_THRESHOLD_AILTL = 0x04, // ALS low threshold lower byte
TSL2591_REGISTER_THRESHOLD_AILTH = 0x05, // ALS low threshold upper byte
TSL2591_REGISTER_THRESHOLD_AIHTL = 0x06, // ALS high threshold lower byte
TSL2591_REGISTER_THRESHOLD_AIHTH = 0x07, // ALS high threshold upper byte
TSL2591_REGISTER_THRESHOLD_NPAILTL = 0x08, // No Persist ALS low threshold lower byte
TSL2591_REGISTER_THRESHOLD_NPAILTH = 0x09, // etc
TSL2591_REGISTER_THRESHOLD_NPAIHTL = 0x0A,
TSL2591_REGISTER_THRESHOLD_NPAIHTH = 0x0B,
TSL2591_REGISTER_PERSIST_FILTER = 0x0C,
TSL2591_REGISTER_PACKAGE_PID = 0x11,
TSL2591_REGISTER_DEVICE_ID = 0x12,
TSL2591_REGISTER_DEVICE_STATUS = 0x13,
TSL2591_REGISTER_CHAN0_LOW = 0x14,
TSL2591_REGISTER_CHAN0_HIGH = 0x15,
TSL2591_REGISTER_CHAN1_LOW = 0x16,
TSL2591_REGISTER_CHAN1_HIGH = 0x17
};
typedef enum
{
TSL2591_INTEGRATIONTIME_100MS = 0x00,
TSL2591_INTEGRATIONTIME_200MS = 0x01,
TSL2591_INTEGRATIONTIME_300MS = 0x02,
TSL2591_INTEGRATIONTIME_400MS = 0x03,
TSL2591_INTEGRATIONTIME_500MS = 0x04,
TSL2591_INTEGRATIONTIME_600MS = 0x05,
}
tsl2591IntegrationTime_t;
typedef enum
{
// bit 7:4: 0
TSL2591_PERSIST_EVERY = 0x00, // Every ALS cycle generates an interrupt
TSL2591_PERSIST_ANY = 0x01, // Any value outside of threshold range
TSL2591_PERSIST_2 = 0x02, // 2 consecutive values out of range
TSL2591_PERSIST_3 = 0x03, // 3 consecutive values out of range
TSL2591_PERSIST_5 = 0x04, // 5 consecutive values out of range
TSL2591_PERSIST_10 = 0x05, // 10 consecutive values out of range
TSL2591_PERSIST_15 = 0x06, // 15 consecutive values out of range
TSL2591_PERSIST_20 = 0x07, // 20 consecutive values out of range
TSL2591_PERSIST_25 = 0x08, // 25 consecutive values out of range
TSL2591_PERSIST_30 = 0x09, // 30 consecutive values out of range
TSL2591_PERSIST_35 = 0x0A, // 35 consecutive values out of range
TSL2591_PERSIST_40 = 0x0B, // 40 consecutive values out of range
TSL2591_PERSIST_45 = 0x0C, // 45 consecutive values out of range
TSL2591_PERSIST_50 = 0x0D, // 50 consecutive values out of range
TSL2591_PERSIST_55 = 0x0E, // 55 consecutive values out of range
TSL2591_PERSIST_60 = 0x0F, // 60 consecutive values out of range
}
tsl2591Persist_t;
typedef enum
{
TSL2591_GAIN_LOW = 0x00, // low gain (1x)
TSL2591_GAIN_MED = 0x10, // medium gain (25x)
TSL2591_GAIN_HIGH = 0x20, // medium gain (428x)
TSL2591_GAIN_MAX = 0x30, // max gain (9876x)
}
tsl2591Gain_t;
class Adafruit_TSL2591 : public Adafruit_Sensor
{
public:
Adafruit_TSL2591(int32_t sensorID = -1);
boolean begin ( void );
void enable ( void );
void disable ( void );
void write8 ( uint8_t r);
void write8 ( uint8_t r, uint8_t v );
uint16_t read16 ( uint8_t reg );
uint8_t read8 ( uint8_t reg );
uint32_t calculateLux ( uint16_t ch0, uint16_t ch1 );
float calculateLuxf ( uint16_t ch0, uint16_t ch1 );
void setGain ( tsl2591Gain_t gain );
void setTiming ( tsl2591IntegrationTime_t integration );
uint16_t getLuminosity (uint8_t channel );
uint32_t getFullLuminosity ( );
tsl2591IntegrationTime_t getTiming();
tsl2591Gain_t getGain();
// Interrupt
void clearInterrupt(void);
void registerInterrupt(uint16_t lowerThreshold, uint16_t upperThreshold);
void registerInterrupt(uint16_t lowerThreshold, uint16_t upperThreshold, tsl2591Persist_t persist);
uint8_t getStatus();
/* Unified Sensor API Functions */
bool getEvent ( sensors_event_t* );
void getSensor ( sensor_t* );
private:
tsl2591IntegrationTime_t _integration;
tsl2591Gain_t _gain;
int32_t _sensorID;
boolean _initialized;
};
#endif
+9
View File
@@ -0,0 +1,9 @@
This is an Arduino library for the TSL2591 digital luminosity (light) sensors.
Pick one up at http://www.adafruit.com/products/1980
To download. click the DOWNLOADS button in the top right corner, rename the uncompressed folder Adafruit_TSL2591. Check that the Adafruit_TSL2591 folder contains Adafruit_TSL2591.cpp and Adafruit_TSL2591.h
Place the Adafruit_TSL2591 library folder your <arduinosketchfolder>/libraries/ folder. You may need to create the libraries subfolder if its your first library. Restart the IDE.
You'll also need the Adafruit_Sensor library from https://github.com/adafruit/Adafruit_Sensor
@@ -0,0 +1,200 @@
/* TSL2591 Digital Light Sensor */
/* Dynamic Range: 600M:1 */
/* Maximum Lux: 88K */
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include "Adafruit_TSL2591.h"
// Example for demonstrating the TSL2591 library - public domain!
// connect SCL to analog 5
// connect SDA to analog 4
// connect Vin to 3.3-5V DC
// connect GROUND to common ground
Adafruit_TSL2591 tsl = Adafruit_TSL2591(2591); // pass in a number for the sensor identifier (for your use later)
/**************************************************************************/
/*
Displays some basic information on this sensor from the unified
sensor API sensor_t type (see Adafruit_Sensor for more information)
*/
/**************************************************************************/
void displaySensorDetails(void)
{
sensor_t sensor;
tsl.getSensor(&sensor);
Serial.println(F("------------------------------------"));
Serial.print (F("Sensor: ")); Serial.println(sensor.name);
Serial.print (F("Driver Ver: ")); Serial.println(sensor.version);
Serial.print (F("Unique ID: ")); Serial.println(sensor.sensor_id);
Serial.print (F("Max Value: ")); Serial.print(sensor.max_value); Serial.println(F(" lux"));
Serial.print (F("Min Value: ")); Serial.print(sensor.min_value); Serial.println(F(" lux"));
Serial.print (F("Resolution: ")); Serial.print(sensor.resolution); Serial.println(F(" lux"));
Serial.println(F("------------------------------------"));
Serial.println(F(""));
delay(500);
}
/**************************************************************************/
/*
Configures the gain and integration time for the TSL2591
*/
/**************************************************************************/
void configureSensor(void)
{
// You can change the gain on the fly, to adapt to brighter/dimmer light situations
//tsl.setGain(TSL2591_GAIN_LOW); // 1x gain (bright light)
tsl.setGain(TSL2591_GAIN_MED); // 25x gain
// tsl.setGain(TSL2591_GAIN_HIGH); // 428x gain
// Changing the integration time gives you a longer time over which to sense light
// longer timelines are slower, but are good in very low light situtations!
tsl.setTiming(TSL2591_INTEGRATIONTIME_100MS); // shortest integration time (bright light)
// tsl.setTiming(TSL2591_INTEGRATIONTIME_200MS);
// tsl.setTiming(TSL2591_INTEGRATIONTIME_300MS);
// tsl.setTiming(TSL2591_INTEGRATIONTIME_400MS);
// tsl.setTiming(TSL2591_INTEGRATIONTIME_500MS);
// tsl.setTiming(TSL2591_INTEGRATIONTIME_600MS); // longest integration time (dim light)
/* Display the gain and integration time for reference sake */
Serial.println(F("------------------------------------"));
Serial.print (F("Gain: "));
tsl2591Gain_t gain = tsl.getGain();
switch(gain)
{
case TSL2591_GAIN_LOW:
Serial.println(F("1x (Low)"));
break;
case TSL2591_GAIN_MED:
Serial.println(F("25x (Medium)"));
break;
case TSL2591_GAIN_HIGH:
Serial.println(F("428x (High)"));
break;
case TSL2591_GAIN_MAX:
Serial.println(F("9876x (Max)"));
break;
}
Serial.print (F("Timing: "));
Serial.print((tsl.getTiming() + 1) * 100, DEC);
Serial.println(F(" ms"));
Serial.println(F("------------------------------------"));
Serial.println(F(""));
}
/**************************************************************************/
/*
Program entry point for the Arduino sketch
*/
/**************************************************************************/
void setup(void)
{
Serial.begin(9600);
Serial.println(F("Starting Adafruit TSL2591 Test!"));
if (tsl.begin())
{
Serial.println(F("Found a TSL2591 sensor"));
}
else
{
Serial.println(F("No sensor found ... check your wiring?"));
while (1);
}
/* Display some basic information on this sensor */
displaySensorDetails();
/* Configure the sensor */
configureSensor();
// Now we're ready to get readings ... move on to loop()!
}
/**************************************************************************/
/*
Shows how to perform a basic read on visible, full spectrum or
infrared light (returns raw 16-bit ADC values)
*/
/**************************************************************************/
void simpleRead(void)
{
// Simple data read example. Just read the infrared, fullspecrtrum diode
// or 'visible' (difference between the two) channels.
// This can take 100-600 milliseconds! Uncomment whichever of the following you want to read
uint16_t x = tsl.getLuminosity(TSL2591_VISIBLE);
//uint16_t x = tsl.getLuminosity(TSL2591_FULLSPECTRUM);
//uint16_t x = tsl.getLuminosity(TSL2591_INFRARED);
Serial.print(F("[ ")); Serial.print(millis()); Serial.print(F(" ms ] "));
Serial.print(F("Luminosity: "));
Serial.println(x, DEC);
}
/**************************************************************************/
/*
Show how to read IR and Full Spectrum at once and convert to lux
*/
/**************************************************************************/
void advancedRead(void)
{
// More advanced data read example. Read 32 bits with top 16 bits IR, bottom 16 bits full spectrum
// That way you can do whatever math and comparisons you want!
uint32_t lum = tsl.getFullLuminosity();
uint16_t ir, full;
ir = lum >> 16;
full = lum & 0xFFFF;
Serial.print(F("[ ")); Serial.print(millis()); Serial.print(F(" ms ] "));
Serial.print(F("IR: ")); Serial.print(ir); Serial.print(F(" "));
Serial.print(F("Full: ")); Serial.print(full); Serial.print(F(" "));
Serial.print(F("Visible: ")); Serial.print(full - ir); Serial.print(F(" "));
Serial.print(F("Lux: ")); Serial.println(tsl.calculateLux(full, ir));
}
/**************************************************************************/
/*
Performs a read using the Adafruit Unified Sensor API.
*/
/**************************************************************************/
void unifiedSensorAPIRead(void)
{
/* Get a new sensor event */
sensors_event_t event;
tsl.getEvent(&event);
/* Display the results (light is measured in lux) */
Serial.print(F("[ ")); Serial.print(event.timestamp); Serial.print(F(" ms ] "));
if ((event.light == 0) |
(event.light > 4294966000.0) |
(event.light <-4294966000.0))
{
/* If event.light = 0 lux the sensor is probably saturated */
/* and no reliable data could be generated! */
/* if event.light is +/- 4294967040 there was a float over/underflow */
Serial.println(F("Invalid data (adjust gain or timing)"));
}
else
{
Serial.print(event.light); Serial.println(F(" lux"));
}
}
/**************************************************************************/
/*
Arduino loop function, called once 'setup' is complete (your own code
should go here)
*/
/**************************************************************************/
void loop(void)
{
//simpleRead();
advancedRead();
// unifiedSensorAPIRead();
delay(500);
}
@@ -0,0 +1,229 @@
/* TSL2591 Digital Light Sensor, example with (simple) interrupt support */
/* Dynamic Range: 600M:1 */
/* Maximum Lux: 88K */
/* This example shows how the interrupt system on the TLS2591
* can be used to detect a meaningful change in light levels.
*
* Two thresholds can be set:
*
* Lower Threshold - Any light sample on CHAN0 below this value
* will trigger an interrupt
* Upper Threshold - Any light sample on CHAN0 above this value
* will trigger an interrupt
*
* If CHAN0 (full light) crosses below the low threshold specified,
* or above the higher threshold, an interrupt is asserted on the interrupt
* pin. The use of the HW pin is optional, though, since the change can
* also be detected in software by looking at the status byte via
* tsl.getStatus().
*
* An optional third parameter can be used in the .registerInterrupt
* function to indicate the number of samples that must stay outside
* the threshold window before the interrupt fires, providing some basic
* debouncing of light level data.
*
* For example, the following code will fire an interrupt on any and every
* sample outside the window threshold (meaning a sample below 100 or above
* 1500 on CHAN0 or FULL light):
*
* tsl.registerInterrupt(100, 1500, TSL2591_PERSIST_ANY);
*
* This code would require five consecutive changes before the interrupt
* fires though (see tls2591Persist_t in Adafruit_TLS2591.h for possible
* values):
*
* tsl.registerInterrupt(100, 1500, TSL2591_PERSIST_5);
*/
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include "Adafruit_TSL2591.h"
// Example for demonstrating the TSL2591 library - public domain!
// connect SCL to analog 5
// connect SDA to analog 4
// connect Vin to 3.3-5V DC
// connect GROUND to common ground
// Interrupt thresholds and persistance
#define TLS2591_INT_THRESHOLD_LOWER (100)
#define TLS2591_INT_THRESHOLD_UPPER (1500)
//#define TLS2591_INT_PERSIST (TSL2591_PERSIST_ANY) // Fire on any valid change
#define TLS2591_INT_PERSIST (TSL2591_PERSIST_60) // Require at least 60 samples to fire
Adafruit_TSL2591 tsl = Adafruit_TSL2591(2591); // pass in a number for the sensor identifier (for your use later)
/**************************************************************************/
/*
Displays some basic information on this sensor from the unified
sensor API sensor_t type (see Adafruit_Sensor for more information)
*/
/**************************************************************************/
void displaySensorDetails(void)
{
sensor_t sensor;
tsl.getSensor(&sensor);
Serial.println("------------------------------------");
Serial.print ("Sensor: "); Serial.println(sensor.name);
Serial.print ("Driver Ver: "); Serial.println(sensor.version);
Serial.print ("Unique ID: "); Serial.println(sensor.sensor_id);
Serial.print ("Max Value: "); Serial.print(sensor.max_value); Serial.println(" lux");
Serial.print ("Min Value: "); Serial.print(sensor.min_value); Serial.println(" lux");
Serial.print ("Resolution: "); Serial.print(sensor.resolution); Serial.println(" lux");
Serial.println("------------------------------------");
Serial.println("");
delay(500);
}
/**************************************************************************/
/*
Configures the gain and integration time for the TSL2591
*/
/**************************************************************************/
void configureSensor(void)
{
// You can change the gain on the fly, to adapt to brighter/dimmer light situations
//tsl.setGain(TSL2591_GAIN_LOW); // 1x gain (bright light)
tsl.setGain(TSL2591_GAIN_MED); // 25x gain
// tsl.setGain(TSL2591_GAIN_HIGH); // 428x gain
// Changing the integration time gives you a longer time over which to sense light
// longer timelines are slower, but are good in very low light situtations!
tsl.setTiming(TSL2591_INTEGRATIONTIME_100MS); // shortest integration time (bright light)
// tsl.setTiming(TSL2591_INTEGRATIONTIME_200MS);
// tsl.setTiming(TSL2591_INTEGRATIONTIME_300MS);
// tsl.setTiming(TSL2591_INTEGRATIONTIME_400MS);
// tsl.setTiming(TSL2591_INTEGRATIONTIME_500MS);
// tsl.setTiming(TSL2591_INTEGRATIONTIME_600MS); // longest integration time (dim light)
/* Display the gain and integration time for reference sake */
Serial.println("------------------------------------");
Serial.print ("Gain: ");
tsl2591Gain_t gain = tsl.getGain();
switch (gain)
{
case TSL2591_GAIN_LOW:
Serial.println("1x (Low)");
break;
case TSL2591_GAIN_MED:
Serial.println("25x (Medium)");
break;
case TSL2591_GAIN_HIGH:
Serial.println("428x (High)");
break;
case TSL2591_GAIN_MAX:
Serial.println("9876x (Max)");
break;
}
Serial.print ("Timing: ");
Serial.print((tsl.getTiming() + 1) * 100, DEC);
Serial.println(" ms");
Serial.println("------------------------------------");
Serial.println("");
/* Setup the SW interrupt to trigger between 100 and 1500 lux */
/* Threshold values are defined at the top of this sketch */
tsl.clearInterrupt();
tsl.registerInterrupt(TLS2591_INT_THRESHOLD_LOWER,
TLS2591_INT_THRESHOLD_UPPER,
TLS2591_INT_PERSIST);
/* Display the interrupt threshold window */
Serial.print("Interrupt Threshold Window: -");
Serial.print(TLS2591_INT_THRESHOLD_LOWER, DEC);
Serial.print(" to +");
Serial.println(TLS2591_INT_THRESHOLD_LOWER, DEC);
Serial.println("");
}
/**************************************************************************/
/*
Program entry point for the Arduino sketch
*/
/**************************************************************************/
void setup(void)
{
Serial.begin(9600);
// Enable this line for Flora, Zero and Feather boards with no FTDI chip
// Waits for the serial port to connect before sending data out
// while (!Serial) { delay(1); }
Serial.println("Starting Adafruit TSL2591 interrupt Test!");
if (tsl.begin())
{
Serial.println("Found a TSL2591 sensor");
}
else
{
Serial.println("No sensor found ... check your wiring?");
while (1);
}
/* Display some basic information on this sensor */
displaySensorDetails();
/* Configure the sensor (including the interrupt threshold) */
configureSensor();
// Now we're ready to get readings ... move on to loop()!
}
/**************************************************************************/
/*
Show how to read IR and Full Spectrum at once and convert to lux
*/
/**************************************************************************/
void advancedRead(void)
{
// More advanced data read example. Read 32 bits with top 16 bits IR, bottom 16 bits full spectrum
// That way you can do whatever math and comparisons you want!
uint32_t lum = tsl.getFullLuminosity();
uint16_t ir, full;
ir = lum >> 16;
full = lum & 0xFFFF;
Serial.print("[ "); Serial.print(millis()); Serial.print(" ms ] ");
Serial.print("IR: "); Serial.print(ir); Serial.print(" ");
Serial.print("Full: "); Serial.print(full); Serial.print(" ");
Serial.print("Visible: "); Serial.print(full - ir); Serial.print(" ");
Serial.print("Lux: "); Serial.println(tsl.calculateLux(full, ir));
}
void getStatus(void)
{
uint8_t x = tsl.getStatus();
// bit 4: ALS Interrupt occured
// bit 5: No-persist Interrupt occurence
if (x & 0x10) {
Serial.print("[ "); Serial.print(millis()); Serial.print(" ms ] ");
Serial.println("ALS Interrupt occured");
}
if (x & 0x20) {
Serial.print("[ "); Serial.print(millis()); Serial.print(" ms ] ");
Serial.println("No-persist Interrupt occured");
}
// Serial.print("[ "); Serial.print(millis()); Serial.print(" ms ] ");
Serial.print("Status: ");
Serial.println(x, BIN);
tsl.clearInterrupt();
}
/**************************************************************************/
/*
Arduino loop function, called once 'setup' is complete (your own code
should go here)
*/
/**************************************************************************/
void loop(void)
{
advancedRead();
getStatus();
delay(500);
}
+9
View File
@@ -0,0 +1,9 @@
name=Adafruit TSL2591 Library
version=1.0.2
author=Adafruit
maintainer=Adafruit <info@adafruit.com>
sentence=Library for the TSL2591 digital luminosity (light) sensors.
paragraph=Library for the TSL2591 digital luminosity (light) sensors.
category=Sensors
url=https://github.com/adafruit/Adafruit_TSL2591_Library
architectures=*
+74
View File
@@ -0,0 +1,74 @@
/*
Name: PingTest.ino
Created: 05/08/2017 10:20:19
Author: pbecc
*/
#undef PROVA_
#include <WiFi.h>
#include "esp32_ping.h"
// the setup function runs once when you press reset or power the board
const char ssid[] = "TP-LINK_C20B"; // your network SSID (name)
const char password[] = "paolo-48"; // your network password
void setup() {
Serial.begin(115200);
Serial.print("Connecting t ");
Serial.println(ssid);
// WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("Pinging address: 192.168.1.1");
}
// the loop function runs over and over again until power down or reset
void loop() {
int ia[4] = { 192,168,1,1 };
int i = 0;
while (Serial.available()) {
char c = Serial.read();
delay(100);
int val = 0;
while (c != '.' && c != 10 && c!=255) {
if (c >= '0'&& c<='9') {
val = val*10+(c-'0');
}
c = Serial.read();
}
ia[i++] =val ;
}
IPAddress adr = IPAddress(ia[0], ia[1], ia[2], ia[3]);
Serial.printf("Ping : %d . %d . %d . %d ->", ia[0], ia[1], ia[2], ia[3]);
if (ping_start(adr, 4, 0, 0, 5))
Serial.println("OK");
else
Serial.println("FAILED");
delay(10000);
}
int readnu(char s) {
char c = Serial.read();
Serial.print(c);
int digit = 1,val=0;
while (c != s && c != 10&&c>0) {
if(c>'0') val += digit*(c - '0');
digit *= 10;
c=Serial.read();
Serial.print(int(c));
}
Serial.println(digit);
return digit;
}
+4
View File
@@ -0,0 +1,4 @@
# ESP32_ping
Ping library for ESP32
WORK IN PROGRESS
+366
View File
@@ -0,0 +1,366 @@
/*
* ESP32 Ping library
*
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software
* and its documentation for any purpose and without fee is hereby
* granted, provided that the above copyright notice appear in all
* copies and that both that the copyright notice and this
* permission notice and warranty disclaimer appear in supporting
* documentation, and that the name of the author not be used in
* advertising or publicity pertaining to distribution of the
* software without specific, written prior permission.
*
* The author disclaim all warranties with regard to this
* software, including all implied warranties of merchantability
* and fitness. In no event shall the author be liable for any
* special, indirect or consequential damages or any damages
* whatsoever resulting from loss of use, data or profits, whether
* in an action of contract, negligence or other tortious action,
* arising out of or in connection with the use or performance of
* this software.
*
* --------------------------------------------------------------------------------
* Ping Library is based on the following source code:
*
* Lua RTOS, ping utility
*
*
* Author: Jaume Oliv (jolive@iberoxarxa.com / jolive@whitecatboard.org)
*
* --------------------------------------------------------------------------------
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
*/
#ifdef ESP32
#include <Arduino.h>
#include <math.h>
#include <float.h>
#include <signal.h>
#include <stdint.h>
#include <string.h>
#include <errno.h>
#include "esp32_ping.h"
#include "lwip/inet_chksum.h"
#include "lwip/ip.h"
#include "lwip/ip4.h"
#include "lwip/err.h"
#include "lwip/icmp.h"
#include "lwip/sockets.h"
#include "lwip/sys.h"
#include "lwip/netdb.h"
#include "lwip/dns.h"
static uint16_t ping_seq_num;
static uint8_t stopped = 0;
/*
* Statistics
*/
static uint32_t transmitted = 0;
static uint32_t received = 0;
static float min_time = 0;
static float max_time = 0;
static float mean_time = 0;
static float last_mean_time = 0;
static float var_time = 0;
#define PING_ID 0xAFAF
#define PING_DEFAULT_COUNT 10
#define PING_DEFAULT_INTERVAL 1
#define PING_DEFAULT_SIZE 32
#define PING_DEFAULT_TIMEOUT 1
/*
* Helper functions
*
*/
static void ping_prepare_echo(struct icmp_echo_hdr *iecho, uint16_t len) {
size_t i;
size_t data_len = len - sizeof(struct icmp_echo_hdr);
ICMPH_TYPE_SET(iecho, ICMP_ECHO);
ICMPH_CODE_SET(iecho, 0);
iecho->chksum = 0;
iecho->id = PING_ID;
iecho->seqno = htons(++ping_seq_num);
/* fill the additional data buffer with some data */
for (i = 0; i < data_len; i++) {
((char*)iecho)[sizeof(struct icmp_echo_hdr) + i] = (char)i;
}
iecho->chksum = inet_chksum(iecho, len);
}
static err_t ping_send(int s, ip4_addr_t *addr, int size) {
struct icmp_echo_hdr *iecho;
struct sockaddr_in to;
size_t ping_size = sizeof(struct icmp_echo_hdr) + size;
int err;
iecho = (struct icmp_echo_hdr *)mem_malloc((mem_size_t)ping_size);
if (!iecho) {
return ERR_MEM;
}
ping_prepare_echo(iecho, (uint16_t)ping_size);
to.sin_len = sizeof(to);
to.sin_family = AF_INET;
inet_addr_from_ipaddr(&to.sin_addr, addr);
if ((err = sendto(s, iecho, ping_size, 0, (struct sockaddr*)&to, sizeof(to)))) {
transmitted++;
}
return (err ? ERR_OK : ERR_VAL);
}
static void ping_recv(int s) {
char buf[64];
int fromlen, len;
struct sockaddr_in from;
struct ip_hdr *iphdr;
struct icmp_echo_hdr *iecho = NULL;
char ipa[16];
struct timeval begin;
struct timeval end;
uint64_t micros_begin;
uint64_t micros_end;
float elapsed;
// Register begin time
gettimeofday(&begin, NULL);
// Send
while ((len = recvfrom(s, buf, sizeof(buf), 0, (struct sockaddr*)&from, (socklen_t*)&fromlen)) > 0) {
if (len >= (int)(sizeof(struct ip_hdr) + sizeof(struct icmp_echo_hdr))) {
// Register end time
gettimeofday(&end, NULL);
/// Get from IP address
ip4_addr_t fromaddr;
inet_addr_to_ipaddr(&fromaddr, &from.sin_addr);
strcpy(ipa, inet_ntoa(fromaddr));
// Get echo
iphdr = (struct ip_hdr *)buf;
iecho = (struct icmp_echo_hdr *)(buf + (IPH_HL(iphdr) * 4));
// Print ....
if ((iecho->id == PING_ID) && (iecho->seqno == htons(ping_seq_num))) {
received++;
// Get elapsed time in milliseconds
micros_begin = begin.tv_sec * 1000000;
micros_begin += begin.tv_usec;
micros_end = end.tv_sec * 1000000;
micros_end += end.tv_usec;
elapsed = (float)(micros_end - micros_begin) / (float)1000.0;
// Update statistics
// Mean and variance are computed in an incremental way
if (elapsed < min_time) {
min_time = elapsed;
}
if (elapsed > max_time) {
max_time = elapsed;
}
last_mean_time = mean_time;
mean_time = (((received - 1) * mean_time) + elapsed) / received;
if (received > 1) {
var_time = var_time + ((elapsed - last_mean_time) * (elapsed - mean_time));
}
// Print ...
log_d("%d bytes from %s: icmp_seq=%d time=%.3f ms\r\n", len, ipa,
ntohs(iecho->seqno), elapsed
);
return;
}
else {
// TODO
}
}
}
if (len < 0) {
log_d("Request timeout for icmp_seq %d\r\n", ping_seq_num);
}
}
/*
static void stop_action(int i) {
signal(i, SIG_DFL);
stopped = 1;
}
+/
/*
* Operation functions
*
*/
void ping(const char *name, int count, int interval, int size, int timeout) {
// Resolve name
hostent * target = gethostbyname(name);
IPAddress adr = *target->h_addr_list[0];
if (target->h_length == 0) {
// TODO: error not found target?????
return;
}
ping_start(adr, count, interval, size, timeout);
}
bool ping_start(struct ping_option *ping_o) {
return ping_start(ping_o->ip,ping_o->count,0,0,0);
}
bool ping_start(IPAddress adr, int count=0, int interval=0, int size=0, int timeout=0) {
// driver_error_t *error;
struct sockaddr_in address;
ip4_addr_t ping_target;
int s;
// Get default values if argument are not provided
if (count == 0) {
count = PING_DEFAULT_COUNT;
}
if (interval == 0) {
interval = PING_DEFAULT_INTERVAL;
}
if (size == 0) {
size = PING_DEFAULT_SIZE;
}
if (timeout == 0) {
timeout = PING_DEFAULT_TIMEOUT;
}
// Create socket
if ((s = socket(AF_INET, SOCK_RAW, IP_PROTO_ICMP)) < 0) {
// TODO: error
return false;
}
address.sin_addr.s_addr = adr;
ping_target.addr = address.sin_addr.s_addr;
// Setup socket
struct timeval tout;
// Timeout
tout.tv_sec = timeout;
tout.tv_usec = 0;
if (setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &tout, sizeof(tout)) < 0) {
closesocket(s);
// TODO: error
return false;
}
stopped = 0;
transmitted = 0;
received = 0;
min_time = 1.E+9;// FLT_MAX;
max_time = 0.0;
mean_time = 0.0;
var_time = 0.0;
// Register signal for stop ping
//signal(SIGINT, stop_action);
// Begin ping ...
char ipa[16];
strcpy(ipa, inet_ntoa(ping_target));
log_i("PING %s: %d data bytes\r\n", ipa, size);
ping_seq_num = 0;
while ((ping_seq_num < count) && (!stopped)) {
if (ping_send(s, &ping_target, size) == ERR_OK) {
ping_recv(s);
}
delay( interval*1000L);
}
closesocket(s);
log_i("%d packets transmitted, %d packets received, %.1f%% packet loss\r\n",
transmitted,
received,
((((float)transmitted - (float)received) / (float)transmitted) * 100.0)
);
if (received) {
ping_resp pingresp;
log_i("round-trip min/avg/max/stddev = %.3f/%.3f/%.3f/%.3f ms\r\n", min_time, mean_time, max_time, sqrt(var_time / received));
pingresp.total_count = 10;
pingresp.timeout_count = 10;
pingresp.total_bytes = 1;
pingresp.total_time = mean_time;
pingresp.ping_err = 0;
return true;
// ping_o->sent_function(ping_o, (uint8*)&pingresp);
}
return false;
}
bool ping_regist_recv(struct ping_option *ping_opt, ping_recv_function ping_recv)
{
if (ping_opt == NULL)
return false;
ping_opt->recv_function = ping_recv;
return true;
}
bool ping_regist_sent(struct ping_option *ping_opt, ping_sent_function ping_sent)
{
if (ping_opt == NULL)
return false;
ping_opt->sent_function = ping_sent;
return true;
}
#endif
+36
View File
@@ -0,0 +1,36 @@
#ifndef _PING_
#define _PING_
#include <Arduino.h>
#ifdef ESP32
typedef void(*ping_recv_function)(void* arg, void *pdata);
typedef void(*ping_sent_function)(void* arg, void *pdata);
struct ping_option {
uint32_t count;
uint32_t ip;
uint32_t coarse_time;
ping_recv_function recv_function;
ping_sent_function sent_function;
void* reverse;
};
struct ping_resp {
uint32_t total_count;
uint32_t resp_time;
uint32_t seqno;
uint32_t timeout_count;
uint32_t bytes;
uint32_t total_bytes;
uint32_t total_time;
int8_t ping_err;
};
bool ping_start(struct ping_option *ping_opt);
void ping(const char *name, int count, int interval, int size, int timeout);
bool ping_start(IPAddress adr, int count, int interval, int size, int timeout);
#endif
#endif
@@ -0,0 +1,241 @@
/*
ESPeasySoftwareSerial.cpp - Implementation of the Arduino software serial for ESP8266.
Copyright (c) 2015-2016 Peter Lerup. All rights reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <Arduino.h>
// The Arduino standard GPIO routines are not enough,
// must use some from the Espressif SDK as well
extern "C" {
#include "gpio.h"
}
#include <ESPeasySoftwareSerial.h>
#define MAX_PIN 15
#define USABLE_PINS 10
#define NR_CONCURRENT_SOFT_SERIALS 3
// As the Arduino attachInterrupt has no parameter, lists of objects
// and callbacks corresponding to each possible GPIO pins have to be defined
static ESPeasySoftwareSerial *ObjList[NR_CONCURRENT_SOFT_SERIALS];
static uint8_t PinControllerMap[NR_CONCURRENT_SOFT_SERIALS]={}; // Zero all elements
void ICACHE_RAM_ATTR sws_isr_0() { ObjList[0]->rxRead(); };
void ICACHE_RAM_ATTR sws_isr_1() { ObjList[1]->rxRead(); };
void ICACHE_RAM_ATTR sws_isr_2() { ObjList[2]->rxRead(); };
/*void ICACHE_RAM_ATTR sws_isr_3() { ObjList[3]->rxRead(); };
void ICACHE_RAM_ATTR sws_isr_4() { ObjList[4]->rxRead(); };
void ICACHE_RAM_ATTR sws_isr_5() { ObjList[5]->rxRead(); };
// Pin 6 to 11 can not be used
void ICACHE_RAM_ATTR sws_isr_12() { ObjList[6]->rxRead(); };
void ICACHE_RAM_ATTR sws_isr_13() { ObjList[7]->rxRead(); };
void ICACHE_RAM_ATTR sws_isr_14() { ObjList[8]->rxRead(); };
void ICACHE_RAM_ATTR sws_isr_15() { ObjList[9]->rxRead(); };
*/
static void (*ISRList[NR_CONCURRENT_SOFT_SERIALS])() = {
sws_isr_0,
sws_isr_1,
sws_isr_2 /*,
sws_isr_3,
sws_isr_4,
sws_isr_5,
// Pin 6 to 11 can not be used
sws_isr_12,
sws_isr_13,
sws_isr_14,
sws_isr_15
*/
};
ESPeasySoftwareSerial::ESPeasySoftwareSerial(uint8_t receivePin, uint8_t transmitPin, bool inverse_logic, uint16_t buffSize) {
m_rxValid = m_txValid = m_txEnableValid = false;
m_buffer = NULL;
m_invert = inverse_logic;
if (isValidGPIOpin(receivePin)) {
m_rxPin = receivePin;
m_buffSize = buffSize;
m_buffer = (uint8_t*)malloc(m_buffSize);
if (m_buffer != NULL) {
m_rxValid = true;
m_inPos = m_outPos = 0;
pinMode(m_rxPin, INPUT);
const uint8_t index = pinToIndex(m_rxPin);
if (index == NR_CONCURRENT_SOFT_SERIALS) {
return; // Not possible to add software Serial.
}
ObjList[index] = this;
enableRx(true);
}
}
if (isValidGPIOpin(transmitPin)) {
m_txValid = true;
m_txPin = transmitPin;
pinMode(m_txPin, OUTPUT);
digitalWrite(m_txPin, !m_invert);
}
// Default speed
begin(9600);
}
ESPeasySoftwareSerial::~ESPeasySoftwareSerial() {
enableRx(false);
if (m_rxValid) {
const uint8_t index = pinToIndex(m_rxPin);
if (index < NR_CONCURRENT_SOFT_SERIALS) {
PinControllerMap[index] = 0;
ObjList[index] = NULL;
}
}
if (m_buffer)
free(m_buffer);
}
bool ESPeasySoftwareSerial::isValidGPIOpin(uint8_t pin) {
if (pin >= 0 && pin <= 5) {
return true;
}
if (pin >= 12 && pin <= MAX_PIN) {
return true;
}
return false;
}
uint8_t ESPeasySoftwareSerial::pinToIndex(uint8_t pin) {
// Pin will be stored in the map, only "1" will be added,
// to allow simple initialize to 0 and still use GPIO-0.
const uint8_t stored_pin = pin + 1;
for (unsigned i = 0; i < NR_CONCURRENT_SOFT_SERIALS; ++i) {
if (PinControllerMap[i] == stored_pin) return i;
}
// Not found, add as first free option.
for (unsigned i = 0; i < NR_CONCURRENT_SOFT_SERIALS; ++i) {
if (PinControllerMap[i] == 0) {
PinControllerMap[i] = stored_pin;
return i;
}
}
// No more controllers available.
return NR_CONCURRENT_SOFT_SERIALS;
}
void ESPeasySoftwareSerial::begin(long speed) {
// Use getCycleCount() loop to get as exact timing as possible
m_bitTime = ESP.getCpuFreqMHz()*1000000/speed;
}
void ESPeasySoftwareSerial::setTransmitEnablePin(uint8_t transmitEnablePin) {
if (isValidGPIOpin(transmitEnablePin)) {
m_txEnableValid = true;
m_txEnablePin = transmitEnablePin;
pinMode(m_txEnablePin, OUTPUT);
digitalWrite(m_txEnablePin, LOW);
} else {
m_txEnableValid = false;
}
}
void ESPeasySoftwareSerial::enableRx(bool on) {
if (m_rxValid) {
if (on) {
attachInterrupt(m_rxPin, ISRList[pinToIndex(m_rxPin)], m_invert ? RISING : FALLING);
} else {
detachInterrupt(m_rxPin);
}
}
}
int ESPeasySoftwareSerial::read() {
if (!m_rxValid || (m_inPos == m_outPos)) return -1;
uint8_t ch = m_buffer[m_outPos];
m_outPos = (m_outPos+1) % m_buffSize;
return ch;
}
int ESPeasySoftwareSerial::available() {
if (!m_rxValid) return 0;
int avail = m_inPos - m_outPos;
if (avail < 0) avail += m_buffSize;
return avail;
}
#define WAIT { while (ESP.getCycleCount()-start < wait); wait += m_bitTime; }
size_t ESPeasySoftwareSerial::write(uint8_t b) {
if (!m_txValid) return 0;
if (m_invert) b = ~b;
// Disable interrupts in order to get a clean transmit
cli();
if (m_txEnableValid) digitalWrite(m_txEnablePin, HIGH);
unsigned long wait = m_bitTime;
digitalWrite(m_txPin, HIGH);
unsigned long start = ESP.getCycleCount();
// Start bit;
digitalWrite(m_txPin, LOW);
WAIT;
for (int i = 0; i < 8; i++) {
digitalWrite(m_txPin, (b & 1) ? HIGH : LOW);
WAIT;
b >>= 1;
}
// Stop bit
digitalWrite(m_txPin, HIGH);
WAIT;
if (m_txEnableValid) digitalWrite(m_txEnablePin, LOW);
sei();
return 1;
}
void ESPeasySoftwareSerial::flush() {
m_inPos = m_outPos = 0;
}
int ESPeasySoftwareSerial::peek() {
if (!m_rxValid || (m_inPos == m_outPos)) return -1;
return m_buffer[m_outPos];
}
void ICACHE_RAM_ATTR ESPeasySoftwareSerial::rxRead() {
// Advance the starting point for the samples but compensate for the
// initial delay which occurs before the interrupt is delivered
unsigned long wait = m_bitTime + m_bitTime/3 - 500;
unsigned long start = ESP.getCycleCount();
uint8_t rec = 0;
for (uint8_t i = 0; i < 8; i++) {
WAIT;
rec >>= 1;
if (digitalRead(m_rxPin))
rec |= 0x80;
}
if (m_invert) rec = ~rec;
// Stop bit
WAIT;
// Store the received value in the buffer unless we have an overflow
uint16_t next = (m_inPos+1) % m_buffSize;
if (next != m_inPos) {
m_buffer[m_inPos] = rec;
m_inPos = next;
}
// Must clear this bit in the interrupt register,
// it gets set even when interrupts are disabled
GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS, 1 << m_rxPin);
}
@@ -0,0 +1,78 @@
/*
ESPeasySoftwareSerial.h
ESPeasySoftwareSerial.cpp - Implementation of the Arduino software serial for ESP8266.
Copyright (c) 2015-2016 Peter Lerup. All rights reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef ESPeasySoftwareSerial_h
#define ESPeasySoftwareSerial_h
#include <inttypes.h>
#include <Stream.h>
// This class is compatible with the corresponding AVR one,
// the constructor however has an optional rx buffer size.
// Speed up to 115200 can be used.
class ESPeasySoftwareSerial : public Stream
{
public:
ESPeasySoftwareSerial(uint8_t receivePin, uint8_t transmitPin, bool inverse_logic = false, uint16_t buffSize = 64);
virtual ~ESPeasySoftwareSerial();
void begin(long speed);
void setTransmitEnablePin(uint8_t transmitEnablePin);
int peek();
virtual size_t write(uint8_t byte);
virtual int read();
virtual int available();
virtual void flush();
operator bool() {return m_rxValid || m_txValid;}
// Disable or enable interrupts on the rx pin
void enableRx(bool on);
void rxRead();
using Print::write;
private:
bool isValidGPIOpin(uint8_t pin);
uint8_t pinToIndex(uint8_t pin);
// Member variables
uint8_t m_rxPin, m_txPin, m_txEnablePin;
bool m_rxValid, m_txValid, m_txEnableValid;
bool m_invert;
unsigned long m_bitTime;
uint16_t m_inPos, m_outPos;
uint16_t m_buffSize;
uint8_t *m_buffer;
};
// If only one tx or rx wanted then use this as parameter for the unused pin
#define SW_SERIAL_UNUSED_PIN -1
#endif
+9
View File
@@ -0,0 +1,9 @@
# ESPeasySoftwareSerial
Implementation of the Arduino software serial library for the ESP8266
Same functionality as the corresponding AVR library but several instances can be active at the same time.
Speed up to 115200 baud is supported. The constructor also has an optional input buffer size.
Please note that due to the fact that the ESP always have other activities ongoing, there will be some inexactness in interrupt
timings. This may lead to bit errors when having heavy data traffic in high baud rates.
@@ -0,0 +1,27 @@
#include <ESPeasySoftwareSerial.h>
ESPeasySoftwareSerial swSer(14, 12, false, 256);
void setup() {
Serial.begin(115200);
swSer.begin(115200);
Serial.println("\nSoftware serial test started");
for (char ch = ' '; ch <= 'z'; ch++) {
swSer.write(ch);
}
swSer.println("");
}
void loop() {
while (swSer.available() > 0) {
Serial.write(swSer.read());
}
while (Serial.available() > 0) {
swSer.write(Serial.read());
}
}
+31
View File
@@ -0,0 +1,31 @@
#######################################
# Syntax Coloring Map for ESPeasySoftwareSerial
# (esp8266)
#######################################
#######################################
# Datatypes (KEYWORD1)
#######################################
ESPeasySoftwareSerial KEYWORD1
#######################################
# Methods and Functions (KEYWORD2)
#######################################
begin KEYWORD2
read KEYWORD2
write KEYWORD2
available KEYWORD2
flush KEYWORD2
overflow KEYWORD2
peek KEYWORD2
listen KEYWORD2
end KEYWORD2
isListening KEYWORD2
stopListening KEYWORD2
#######################################
# Constants (LITERAL1)
#######################################
+15
View File
@@ -0,0 +1,15 @@
{
"name": "ESPeasySoftwareSerial",
"version": "3.3.1",
"keywords": [
"serial", "io", "softwareserial"
],
"description": "Implementation of the Arduino software serial for ESP8266. Adjusted to reduce memory footprint for ESPeasy",
"repository":
{
"type": "git",
"url": "https://github.com/plerup/espsoftwareserial"
},
"frameworks": "arduino",
"platforms": "espressif8266"
}
@@ -0,0 +1,9 @@
name=ESPeasySoftwareSerial
version=1.0
author=Peter Lerup
maintainer=Peter Lerup <peter@lerup.com>
sentence=Implementation of the Arduino software serial for ESP8266.
paragraph=
category=Signal Input/Output
url=
architectures=esp8266
+456
View File
@@ -0,0 +1,456 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
+40
View File
@@ -0,0 +1,40 @@
# ESP8266Ping
Let the ESP8266 ping a remote machine.
With this library an ESP8266 can ping a remote machine and know if it's reachable.
It provide some basic measurements on ping messages (avg response time).
## Usage
First, include the library in your sketch along with WiFi library:
```Arduino
#include <ESP8266WiFi.h>
#include <ESP8266Ping.h>
```
Next, simply call the `Ping.ping()` function
```Arduino
IPAddress ip (192, 168, 0, 1); // The remote ip to ping
bool ret = Ping.ping(ip);
```
`ret` will be true if the remote responded to pings, false if not reachable.
The library supports hostname too, just pass a string instead of the ip address:
```Arduino
bool ret = Ping.ping("www.google.com");
```
Additionally, the function accept a second integer parameter `count` that specify how many pings has to be sent:
```Arduino
bool ret = Ping.ping(ip_or_host, 10);
```
After `Ping.ping()` has been called, the average response time (in milliseconds) can be retrieved with
```Arduino
int avg_time_ms = Ping.averageTime();
```
@@ -0,0 +1,43 @@
/*
* This example show how to ping a remote machine using it's hostname
*/
#include <ESP8266WiFi.h>
#include <ESP8266Ping.h>
const char* ssid = "ssid";
const char* password = "passphrase";
const char* remote_host = "www.google.com";
void setup() {
Serial.begin(115200);
delay(10);
// We start by connecting to a WiFi network
Serial.println();
Serial.println("Connecting to WiFi");
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(100);
Serial.print(".");
}
Serial.println();
Serial.print("WiFi connected with ip ");
Serial.println(WiFi.localIP());
Serial.print("Pinging host ");
Serial.println(remote_host);
if(Ping.ping(remote_host)) {
Serial.println("Success!!");
} else {
Serial.println("Error :(");
}
}
void loop() { }
@@ -0,0 +1,44 @@
/*
* With this library an ESP8266 can ping a remote machine and know if it's reachable.
* It provides some basic measurements on ping messages (avg response time).
*/
#include <ESP8266WiFi.h>
#include <ESP8266Ping.h>
const char* ssid = "ssid";
const char* password = "passphrase";
const IPAddress remote_ip(192, 168, 0, 1);
void setup() {
Serial.begin(115200);
delay(10);
// We start by connecting to a WiFi network
Serial.println();
Serial.println("Connecting to WiFi");
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(100);
Serial.print(".");
}
Serial.println();
Serial.print("WiFi connected with ip ");
Serial.println(WiFi.localIP());
Serial.print("Pinging ip ");
Serial.println(remote_ip);
if(Ping.ping(remote_ip)) {
Serial.println("Success!!");
} else {
Serial.println("Error :(");
}
}
void loop() { }
+26
View File
@@ -0,0 +1,26 @@
#######################################
# Syntax Coloring Map For ESP8266Ping
#######################################
#######################################
# Library (KEYWORD3)
#######################################
ESP8266Ping KEYWORD3
#######################################
# Datatypes (KEYWORD1)
#######################################
Ping KEYWORD1
#######################################
# Methods and Functions (KEYWORD2)
#######################################
ping KEYWORD2
#######################################
# Constants (LITERAL1)
#######################################
@@ -0,0 +1,9 @@
name=ESPEasy_ESP8266Ping
version=1.0
author=Daniele Colanardi
maintainer=Daniele Colanardi <dancol90@gmail.com>
sentence=Let the ESP8266 ping a remote machine.
paragraph=With this library an ESP8266 can ping a remote machine and know if it's reachable. It provide some basic measurements on ping messages (avg response time). Lib name renamed to avoid conflicts in Arduino IDE.
category=Communication
url=
architectures=esp8266
+61
View File
@@ -0,0 +1,61 @@
/*
ESP8266Ping - Ping library for ESP8266
Copyright (c) 2015 Daniele Colanardi. All rights reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef ESP8266Ping_H
#define ESP8266Ping_H
#if defined(ESP8266)
#include <Arduino.h>
#include <ESP8266WiFi.h>
extern "C" {
#include <ping.h>
}
#ifdef ENABLE_DEBUG_PING
#define DEBUG_PING(...) Serial.printf(__VA_ARGS__)
#else
#define DEBUG_PING(...)
#endif
class PingClass {
public:
PingClass();
bool ping(IPAddress dest, byte count = 5);
bool ping(const char* host, byte count = 5);
int averageTime();
protected:
static void _ping_sent_cb(void *opt, void *pdata);
static void _ping_recv_cb(void *opt, void *pdata);
IPAddress _dest;
ping_option _options;
static byte _expected_count, _errors, _success;
static int _avg_time;
};
#include "ESP8266Ping.impl.h"
PingClass Ping;
#endif
#endif
@@ -0,0 +1,112 @@
/*
ESP8266Ping - Ping library for ESP8266
Copyright (c) 2015 Daniele Colanardi. All rights reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
extern "C" void esp_schedule();
extern "C" void esp_yield();
PingClass::PingClass() {}
bool PingClass::ping(IPAddress dest, byte count) {
_expected_count = count;
_errors = 0;
_success = 0;
_avg_time = 0;
memset(&_options, 0, sizeof(struct ping_option));
// Repeat count (how many time send a ping message to destination)
_options.count = count;
// Time interval between two ping (seconds??)
_options.coarse_time = 1;
// Destination machine
_options.ip = dest;
// Callbacks
_options.recv_function = reinterpret_cast<ping_recv_function>(&PingClass::_ping_recv_cb);
_options.sent_function = NULL; //reinterpret_cast<ping_sent_function>(&_ping_sent_cb);
// Let's go!
if(ping_start(&_options)) {
// Suspend till the process end
esp_yield();
}
return (_success > 0);
}
bool PingClass::ping(const char* host, byte count) {
IPAddress remote_addr;
if (WiFi.hostByName(host, remote_addr))
return ping(remote_addr, count);
return false;
}
int PingClass::averageTime() {
return _avg_time;
}
void PingClass::_ping_recv_cb(void *opt, void *resp) {
// Cast the parameters to get some usable info
ping_resp* ping_resp = reinterpret_cast<struct ping_resp*>(resp);
//ping_option* ping_opt = reinterpret_cast<struct ping_option*>(opt);
// Error or success?
if (ping_resp->ping_err == -1)
_errors++;
else {
_success++;
_avg_time += ping_resp->resp_time;
}
// Some debug info
DEBUG_PING(
"DEBUG: ping reply\n"
"\ttotal_count = %d \n"
"\tresp_time = %d \n"
"\tseqno = %d \n"
"\ttimeout_count = %d \n"
"\tbytes = %d \n"
"\ttotal_bytes = %d \n"
"\ttotal_time = %d \n"
"\tping_err = %d \n",
ping_resp->total_count, ping_resp->resp_time, ping_resp->seqno,
ping_resp->timeout_count, ping_resp->bytes, ping_resp->total_bytes,
ping_resp->total_time, ping_resp->ping_err
);
// Is it time to end?
// Don't using seqno because it does not increase on error
if (_success + _errors == _expected_count) {
_avg_time = _avg_time / _expected_count;
DEBUG_PING("Avg resp time %d ms\n", _avg_time);
// Done, return to main functiom
esp_schedule();
}
}
byte PingClass::_expected_count = 0;
byte PingClass::_errors = 0;
byte PingClass::_success = 0;
int PingClass::_avg_time = 0;
+174
View File
@@ -0,0 +1,174 @@
#include "HT16K33.h"
#include <Wire.h>
CHT16K33::CHT16K33(void)
{
};
void CHT16K33::Init(uint8_t addr)
{
_addr = addr;
// System Setup Register
Wire.beginTransmission(_addr);
Wire.write(0x21); // oscillator on
Wire.endTransmission();
// Display Setup Register
Wire.beginTransmission(_addr);
Wire.write(0x81); // blink off; display on
Wire.endTransmission();
SetBrightness(15);
ClearRowBuffer();
TransmitRowBuffer();
};
void CHT16K33::SetBrightness(uint8_t b)
{
if (b > 15)
b = 15;
// Digital Dimming Data Input
Wire.beginTransmission(_addr);
Wire.write(0xE0 | b); // brightness
Wire.endTransmission();
};
void CHT16K33::TransmitRowBuffer(void)
{
// Display Memory
Wire.beginTransmission(_addr);
Wire.write(0); // start data at address 0
for (byte i=0; i<8; i++)
{
Wire.write(_rowBuffer[i] & 0xFF);
Wire.write(_rowBuffer[i] >> 8);
}
Wire.endTransmission();
};
void CHT16K33::ClearRowBuffer(void)
{
for (byte i=0; i<8; i++)
_rowBuffer[i] = 0;
};
void CHT16K33::SetRow(uint8_t com, uint16_t data)
{
if (com < 8)
_rowBuffer[com] = data;
};
uint16_t CHT16K33::GetRow(uint8_t com)
{
if (com < 8)
return _rowBuffer[com];
else
return 0;
};
void CHT16K33::SetDigit(uint8_t com, uint8_t c)
{
uint16_t value = 0;
if (c <= 0xF)
value = _digits[c];
switch (c)
{
case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
case 'a':
case 'b':
case 'c':
case 'd':
case 'e':
case 'f':
value = c + 10 - 'A';
value = _digits[value & 0xF];
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
value = c - '0';
value = _digits[value & 0xF];
break;
case ' ':
value = 0;
break;
case ':':
value = 0x02; //special for China 4 x 7-seg big display
break;
case '-':
value = 0x40;
break;
}
SetRow(com, value);
}
uint8_t CHT16K33::ReadKeys(void)
{
// Display Memory
Wire.beginTransmission(_addr);
Wire.write(0x40); // start data at address 0x40
Wire.endTransmission();
Wire.requestFrom(_addr, (uint8_t)6);
if (Wire.available() == 6)
{
for (byte i=0; i<3; i++)
{
_keyBuffer[i] = Wire.read() | (Wire.read() << 8);
}
Wire.endTransmission();
}
for (byte i=0; i<3; i++)
{
byte mask = 1;
for (byte k=0; k<12; k++)
{
if (_keyBuffer[i] & mask)
{
_keydown = 16*(i+1) + (k+1);
return _keydown;
}
mask <<= 1;
}
}
_keydown = 0;
return _keydown;
};
const uint8_t CHT16K33::_digits[16] =
{
0x3F, // 0
0x06, // 1
0x5B, // 2
0x4F, // 3
0x66, // 4
0x6D, // 5
0x7D, // 6
0x07, // 7
0x7F, // 8
0x6F, // 9
0x77, // A
0x7C, // B
0x39, // C
0x5E, // D
0x79, // E
0x71, // F
};
+34
View File
@@ -0,0 +1,34 @@
#ifndef CHT16K33_h
#define CHT16K33_h
#include <Arduino.h>
class CHT16K33 {
public:
CHT16K33(void);
void Init(uint8_t addr);
// LED buffer
void ClearRowBuffer(void);
void SetRow(uint8_t com, uint16_t data);
uint16_t GetRow(uint8_t com);
void SetDigit(uint8_t com, uint8_t c);
// LED output and control
void SetBrightness(uint8_t b);
void TransmitRowBuffer(void);
//KeyPad Scan
uint8_t ReadKeys(void);
protected:
uint8_t _addr;
uint16_t _rowBuffer[8];
uint16_t _keyBuffer[3];
byte _keydown;
static const uint8_t _digits[16];
};
#endif
+9
View File
@@ -0,0 +1,9 @@
name=CHT16K33 LED Matrix Library
version=0.0.1
author=Jochen Krapf
maintainer=Jochen Krapf <jk@nerd2nerd.org>
sentence=CHT16K33 16x8 LED and 13x3 KeyPad Matrix Library
paragraph=CHT16K33 16x8 LED and 13x3 KeyPad Matrix Library
category=LED
url=https://github.com/???
architectures=esp8266,avr
+5 -4
View File
@@ -1,13 +1,14 @@
language: c
env:
- BD=esp8266:esp8266:nodemcuv2:CpuFrequency=80,FlashSize=4M3M
- BD=esp8266:esp8266:d1_mini:CpuFrequency=80,FlashSize=4M3M
before_install:
- "/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_1.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :1 -ac -screen 0 1280x1024x16"
- sleep 3
- export DISPLAY=:1.0
- wget http://downloads.arduino.cc/arduino-1.8.1-linux64.tar.xz
- tar xf arduino-1.8.1-linux64.tar.xz
- sudo mv arduino-1.8.1 /usr/local/share/arduino
- wget http://downloads.arduino.cc/arduino-1.8.2-linux64.tar.xz
- tar xf arduino-1.8.2-linux64.tar.xz
- sudo mv arduino-1.8.2 /usr/local/share/arduino
- sudo ln -s /usr/local/share/arduino/arduino /usr/local/bin/arduino
install:
- ln -s $PWD /usr/local/share/arduino/libraries/
@@ -25,7 +26,7 @@ script:
- arduino --verify --board $BD $PWD/examples/JVCPanasonicSendDemo/JVCPanasonicSendDemo.ino
- arduino --verify --board $BD $PWD/examples/TurnOnDaikinAC/TurnOnDaikinAC.ino
- arduino --verify --board $BD $PWD/examples/TurnOnKelvinatorAC/TurnOnKelvinatorAC.ino
- arduino --verify --board $BD $PWD/examples/TurnOnKelvinatorAC/TurnOnMitsubishiAC.ino
- arduino --verify --board $BD $PWD/examples/TurnOnMitsubishiAC/TurnOnMitsubishiAC.ino
notifications:
email:
+18 -18
View File
@@ -9,17 +9,17 @@ IRDaikinESP::IRDaikinESP(int pin) : _irsend(pin)
{
}
void IRDaikinESP::begin()
void ICACHE_FLASH_ATTR IRDaikinESP::begin()
{
_irsend.begin();
}
void IRDaikinESP::send()
void ICACHE_FLASH_ATTR IRDaikinESP::send()
{
_irsend.sendDaikin(daikin);
}
void IRDaikinESP::checksum()
void ICACHE_FLASH_ATTR IRDaikinESP::checksum()
{
uint8_t sum = 0;
uint8_t i;
@@ -36,39 +36,39 @@ void IRDaikinESP::checksum()
daikin[26] = sum &0xFF;
}
void IRDaikinESP::on()
void ICACHE_FLASH_ATTR IRDaikinESP::on()
{
//state = ON;
daikin[13] |= 0x01;
checksum();
}
void IRDaikinESP::off()
void ICACHE_FLASH_ATTR IRDaikinESP::off()
{
//state = OFF;
daikin[13] &= 0xFE;
checksum();
}
uint8_t IRDaikinESP::getPower()
uint8_t ICACHE_FLASH_ATTR IRDaikinESP::getPower()
{
return (daikin[13])&0x01;
}
// DAIKIN_SILENT or DAIKIN_POWERFUL
void IRDaikinESP::setAux(uint8_t aux)
void ICACHE_FLASH_ATTR IRDaikinESP::setAux(uint8_t aux)
{
daikin[21] = aux;
checksum();
}
uint8_t IRDaikinESP::getAux(){
uint8_t ICACHE_FLASH_ATTR IRDaikinESP::getAux(){
return daikin[21];
}
// Set the temp in deg C
void IRDaikinESP::setTemp(uint8_t temp)
void ICACHE_FLASH_ATTR IRDaikinESP::setTemp(uint8_t temp)
{
if (temp < 18)
temp = 18;
@@ -78,13 +78,13 @@ void IRDaikinESP::setTemp(uint8_t temp)
checksum();
}
uint8_t IRDaikinESP::getTemp()
uint8_t ICACHE_FLASH_ATTR IRDaikinESP::getTemp()
{
return (daikin[14])/2;
}
// Set the speed of the fan, 0-5, 0 is auto, 1-5 is the speed
void IRDaikinESP::setFan(uint8_t fan)
void ICACHE_FLASH_ATTR IRDaikinESP::setFan(uint8_t fan)
{
// Set the fan speed bits, leave low 4 bits alone
uint8_t fanset;
@@ -97,7 +97,7 @@ void IRDaikinESP::setFan(uint8_t fan)
checksum();
}
uint8_t IRDaikinESP::getFan()
uint8_t ICACHE_FLASH_ATTR IRDaikinESP::getFan()
{
uint8_t fan = daikin[16] >> 4;
fan = fan - 2;
@@ -106,7 +106,7 @@ uint8_t IRDaikinESP::getFan()
return fan;
}
uint8_t IRDaikinESP::getMode()
uint8_t ICACHE_FLASH_ATTR IRDaikinESP::getMode()
{/*
DAIKIN_COOL
DAIKIN_HEAT
@@ -117,13 +117,13 @@ uint8_t IRDaikinESP::getMode()
return (daikin[13])>>4;
}
void IRDaikinESP::setMode(uint8_t mode)
void ICACHE_FLASH_ATTR IRDaikinESP::setMode(uint8_t mode)
{
daikin[13]=mode<<4 | getPower();
checksum();
}
void IRDaikinESP::setSwingVertical(uint8_t swing)
void ICACHE_FLASH_ATTR IRDaikinESP::setSwingVertical(uint8_t swing)
{
if (swing)
daikin[16] = daikin[16] | 0x0F;
@@ -132,12 +132,12 @@ void IRDaikinESP::setSwingVertical(uint8_t swing)
checksum();
}
uint8_t IRDaikinESP::getSwingVertical()
uint8_t ICACHE_FLASH_ATTR IRDaikinESP::getSwingVertical()
{
return (daikin[16])&0x01;
}
void IRDaikinESP::setSwingHorizontal(uint8_t swing)
void ICACHE_FLASH_ATTR IRDaikinESP::setSwingHorizontal(uint8_t swing)
{
if (swing)
daikin[17] = daikin[17] | 0x0F;
@@ -146,7 +146,7 @@ void IRDaikinESP::setSwingHorizontal(uint8_t swing)
checksum();
}
uint8_t IRDaikinESP::getSwingHorizontal()
uint8_t ICACHE_FLASH_ATTR IRDaikinESP::getSwingHorizontal()
{
return (daikin[17])&0x01;
}
+34 -34
View File
@@ -20,36 +20,36 @@ IRKelvinatorAC::IRKelvinatorAC(int pin) : _irsend(pin) {
stateReset();
}
void IRKelvinatorAC::stateReset() {
void ICACHE_FLASH_ATTR IRKelvinatorAC::stateReset() {
for (uint8_t i = 0; i < KELVINATOR_STATE_LENGTH; i++)
remote_state[i] = 0x0;
remote_state[3] = 0x50;
remote_state[11] = 0x70;
}
void IRKelvinatorAC::begin() {
void ICACHE_FLASH_ATTR IRKelvinatorAC::begin() {
_irsend.begin();
}
void IRKelvinatorAC::fixup() {
void ICACHE_FLASH_ATTR IRKelvinatorAC::fixup() {
// X-Fan mode is only valid in COOL or DRY modes.
if (getMode() != KELVINATOR_COOL && getMode() != KELVINATOR_DRY)
setXFan(false);
checksum(); // Calculate the checksums
}
void IRKelvinatorAC::send() {
void ICACHE_FLASH_ATTR IRKelvinatorAC::send() {
fixup(); // Ensure correct settings before sending.
_irsend.sendKelvinator(remote_state);
}
uint8_t* IRKelvinatorAC::getRaw() {
uint8_t* ICACHE_FLASH_ATTR IRKelvinatorAC::getRaw() {
fixup(); // Ensure correct settings before sending.
return remote_state;
}
// Many Bothans died to bring us this information.
void IRKelvinatorAC::checksum() {
void ICACHE_FLASH_ATTR IRKelvinatorAC::checksum() {
// For each command + options block.
for (uint8_t offset = 0; offset < KELVINATOR_STATE_LENGTH; offset += 8) {
uint8_t sum = KELVINATOR_CHECKSUM_START;
@@ -68,50 +68,50 @@ void IRKelvinatorAC::checksum() {
}
}
void IRKelvinatorAC::on() {
void ICACHE_FLASH_ATTR IRKelvinatorAC::on() {
//state = ON;
remote_state[0] |= KELVINATOR_POWER;
remote_state[8] = remote_state[0]; // Duplicate to the 2nd command chunk.
}
void IRKelvinatorAC::off() {
void ICACHE_FLASH_ATTR IRKelvinatorAC::off() {
//state = OFF;
remote_state[0] &= ~KELVINATOR_POWER;
remote_state[8] = remote_state[0]; // Duplicate to the 2nd command chunk.
}
void IRKelvinatorAC::setPower(bool state) {
void ICACHE_FLASH_ATTR IRKelvinatorAC::setPower(bool state) {
if (state)
on();
else
off();
}
bool IRKelvinatorAC::getPower() {
bool ICACHE_FLASH_ATTR IRKelvinatorAC::getPower() {
return ((remote_state[0] & KELVINATOR_POWER) != 0);
}
// Set the temp. in deg C
void IRKelvinatorAC::setTemp(uint8_t temp) {
temp = max(KELVINATOR_MIN_TEMP, temp);
temp = min(KELVINATOR_MAX_TEMP, temp);
void ICACHE_FLASH_ATTR IRKelvinatorAC::setTemp(uint8_t temp) {
temp = max(static_cast<uint8_t>(KELVINATOR_MIN_TEMP), temp);
temp = min(static_cast<uint8_t>(KELVINATOR_MAX_TEMP), temp);
remote_state[1] = (remote_state[1] & 0xF0U) | (temp - KELVINATOR_MIN_TEMP);
remote_state[9] = remote_state[1]; // Duplicate to the 2nd command chunk.
}
// Return the set temp. in deg C
uint8_t IRKelvinatorAC::getTemp() {
uint8_t ICACHE_FLASH_ATTR IRKelvinatorAC::getTemp() {
return ((remote_state[1] & 0xFU) + KELVINATOR_MIN_TEMP);
}
// Set the speed of the fan, 0-5, 0 is auto, 1-5 is the speed
void IRKelvinatorAC::setFan(uint8_t fan) {
fan = min(KELVINATOR_FAN_MAX, fan); // Bounds check
void ICACHE_FLASH_ATTR IRKelvinatorAC::setFan(uint8_t fan) {
fan = min(static_cast<uint8_t>(KELVINATOR_FAN_MAX), fan); // Bounds check
// Only change things if we need to.
if (fan != getFan()) {
// Set the basic fan values.
uint8_t fan_basic = min(KELVINATOR_BASIC_FAN_MAX, fan);
uint8_t fan_basic = min(static_cast<uint8_t>(KELVINATOR_BASIC_FAN_MAX), fan);
remote_state[0] = (remote_state[0] & KELVINATOR_BASIC_FAN_MASK) |
(fan_basic << KELVINATOR_FAN_OFFSET);
remote_state[8] = remote_state[0]; // Duplicate to the 2nd command chunk.
@@ -122,11 +122,11 @@ void IRKelvinatorAC::setFan(uint8_t fan) {
}
}
uint8_t IRKelvinatorAC::getFan() {
uint8_t ICACHE_FLASH_ATTR IRKelvinatorAC::getFan() {
return ((remote_state[14] & ~KELVINATOR_FAN_MASK) >> KELVINATOR_FAN_OFFSET);
}
uint8_t IRKelvinatorAC::getMode() {
uint8_t ICACHE_FLASH_ATTR IRKelvinatorAC::getMode() {
/*
KELVINATOR_AUTO
KELVINATOR_COOL
@@ -137,7 +137,7 @@ uint8_t IRKelvinatorAC::getMode() {
return (remote_state[0] & ~KELVINATOR_MODE_MASK);
}
void IRKelvinatorAC::setMode(uint8_t mode) {
void ICACHE_FLASH_ATTR IRKelvinatorAC::setMode(uint8_t mode) {
// If we get an unexpected mode, default to AUTO.
if (mode > KELVINATOR_HEAT) mode = KELVINATOR_AUTO;
remote_state[0] = (remote_state[0] & KELVINATOR_MODE_MASK) | mode;
@@ -147,7 +147,7 @@ void IRKelvinatorAC::setMode(uint8_t mode) {
setTemp(KELVINATOR_AUTO_TEMP);
}
void IRKelvinatorAC::setSwingVertical(bool state) {
void ICACHE_FLASH_ATTR IRKelvinatorAC::setSwingVertical(bool state) {
if (state) {
remote_state[0] |= KELVINATOR_VENT_SWING;
remote_state[4] |= KELVINATOR_VENT_SWING_V;
@@ -160,11 +160,11 @@ void IRKelvinatorAC::setSwingVertical(bool state) {
remote_state[8] = remote_state[0]; // Duplicate to the 2nd command chunk.
}
bool IRKelvinatorAC::getSwingVertical() {
bool ICACHE_FLASH_ATTR IRKelvinatorAC::getSwingVertical() {
return ((remote_state[4] & KELVINATOR_VENT_SWING_V) != 0);
}
void IRKelvinatorAC::setSwingHorizontal(bool state) {
void ICACHE_FLASH_ATTR IRKelvinatorAC::setSwingHorizontal(bool state) {
if (state) {
remote_state[0] |= KELVINATOR_VENT_SWING;
remote_state[4] |= KELVINATOR_VENT_SWING_H;
@@ -177,57 +177,57 @@ void IRKelvinatorAC::setSwingHorizontal(bool state) {
remote_state[8] = remote_state[0]; // Duplicate to the 2nd command chunk.
}
bool IRKelvinatorAC::getSwingHorizontal() {
bool ICACHE_FLASH_ATTR IRKelvinatorAC::getSwingHorizontal() {
return ((remote_state[4] & KELVINATOR_VENT_SWING_H) != 0);
}
void IRKelvinatorAC::setQuiet(bool state) {
void ICACHE_FLASH_ATTR IRKelvinatorAC::setQuiet(bool state) {
remote_state[12] &= ~KELVINATOR_QUIET;
remote_state[12] |= (state << KELVINATOR_QUIET_OFFSET);
}
bool IRKelvinatorAC::getQuiet() {
bool ICACHE_FLASH_ATTR IRKelvinatorAC::getQuiet() {
return ((remote_state[12] & KELVINATOR_QUIET) != 0);
}
void IRKelvinatorAC::setIonFilter(bool state) {
void ICACHE_FLASH_ATTR IRKelvinatorAC::setIonFilter(bool state) {
remote_state[2] &= ~KELVINATOR_ION_FILTER;
remote_state[2] |= (state << KELVINATOR_ION_FILTER_OFFSET);
remote_state[10] = remote_state[2]; // Duplicate to the 2nd command chunk.
}
bool IRKelvinatorAC::getIonFilter() {
bool ICACHE_FLASH_ATTR IRKelvinatorAC::getIonFilter() {
return ((remote_state[2] & KELVINATOR_ION_FILTER) != 0);
}
void IRKelvinatorAC::setLight(bool state) {
void ICACHE_FLASH_ATTR IRKelvinatorAC::setLight(bool state) {
remote_state[2] &= ~KELVINATOR_LIGHT;
remote_state[2] |= (state << KELVINATOR_LIGHT_OFFSET);
remote_state[10] = remote_state[2]; // Duplicate to the 2nd command chunk.
}
bool IRKelvinatorAC::getLight() {
bool ICACHE_FLASH_ATTR IRKelvinatorAC::getLight() {
return ((remote_state[2] & KELVINATOR_LIGHT) != 0);
}
// Note: XFan mode is only valid in Cool or Dry mode.
void IRKelvinatorAC::setXFan(bool state) {
void ICACHE_FLASH_ATTR IRKelvinatorAC::setXFan(bool state) {
remote_state[2] &= ~KELVINATOR_XFAN;
remote_state[2] |= (state << KELVINATOR_XFAN_OFFSET);
remote_state[10] = remote_state[2]; // Duplicate to the 2nd command chunk.
}
bool IRKelvinatorAC::getXFan() {
bool ICACHE_FLASH_ATTR IRKelvinatorAC::getXFan() {
return ((remote_state[2] & KELVINATOR_XFAN) != 0);
}
// Note: Turbo mode is turned off if the fan speed is changed.
void IRKelvinatorAC::setTurbo(bool state) {
void ICACHE_FLASH_ATTR IRKelvinatorAC::setTurbo(bool state) {
remote_state[2] &= ~KELVINATOR_TURBO;
remote_state[2] |= (state << KELVINATOR_TURBO_OFFSET);
remote_state[10] = remote_state[2]; // Duplicate to the 2nd command chunk.
}
bool IRKelvinatorAC::getTurbo() {
bool ICACHE_FLASH_ATTR IRKelvinatorAC::getTurbo() {
return ((remote_state[2] & KELVINATOR_TURBO) != 0);
}
+20 -20
View File
@@ -17,31 +17,31 @@ IRMitsubishiAC::IRMitsubishiAC(int pin) : _irsend(pin) {
}
// Reset the state of the remote to a known good state/sequence.
void IRMitsubishiAC::stateReset() {
void ICACHE_FLASH_ATTR IRMitsubishiAC::stateReset() {
for (uint8_t i = 0; i < MITSUBISHI_AC_STATE_LENGTH; i++)
remote_state[i] = known_good_state[i];
checksum(); // Calculate the checksum
}
// Configure the pin for output.
void IRMitsubishiAC::begin() {
void ICACHE_FLASH_ATTR IRMitsubishiAC::begin() {
_irsend.begin();
}
// Send the current desired state to the IR LED.
void IRMitsubishiAC::send() {
void ICACHE_FLASH_ATTR IRMitsubishiAC::send() {
checksum(); // Ensure correct checksum before sending.
_irsend.sendMitsubishiAC(remote_state);
}
// Return a pointer to the internal state date of the remote.
uint8_t* IRMitsubishiAC::getRaw() {
uint8_t* ICACHE_FLASH_ATTR IRMitsubishiAC::getRaw() {
checksum();
return remote_state;
}
// Calculate the checksum for the current internal state of the remote.
void IRMitsubishiAC::checksum() {
void ICACHE_FLASH_ATTR IRMitsubishiAC::checksum() {
uint8_t sum = 0;
// Checksum is simple addition of all previous bytes stored
// as a 8 bit value.
@@ -51,19 +51,19 @@ void IRMitsubishiAC::checksum() {
}
// Set the requested power state of the A/C to off.
void IRMitsubishiAC::on() {
void ICACHE_FLASH_ATTR IRMitsubishiAC::on() {
//state = ON;
remote_state[5] |= MITSUBISHI_AC_POWER;
}
// Set the requested power state of the A/C to off.
void IRMitsubishiAC::off() {
void ICACHE_FLASH_ATTR IRMitsubishiAC::off() {
//state = OFF;
remote_state[5] &= ~MITSUBISHI_AC_POWER;
}
// Set the requested power state of the A/C.
void IRMitsubishiAC::setPower(bool state) {
void ICACHE_FLASH_ATTR IRMitsubishiAC::setPower(bool state) {
if (state)
on();
else
@@ -71,25 +71,25 @@ void IRMitsubishiAC::setPower(bool state) {
}
// Return the requested power state of the A/C.
bool IRMitsubishiAC::getPower() {
bool ICACHE_FLASH_ATTR IRMitsubishiAC::getPower() {
return((remote_state[5] & MITSUBISHI_AC_POWER) != 0);
}
// Set the temp. in deg C
void IRMitsubishiAC::setTemp(uint8_t temp) {
temp = max(MITSUBISHI_AC_MIN_TEMP, temp);
temp = min(MITSUBISHI_AC_MAX_TEMP, temp);
void ICACHE_FLASH_ATTR IRMitsubishiAC::setTemp(uint8_t temp) {
temp = max(static_cast<uint8_t>(MITSUBISHI_AC_MIN_TEMP), temp);
temp = min(static_cast<uint8_t>(MITSUBISHI_AC_MAX_TEMP), temp);
remote_state[7] = temp - MITSUBISHI_AC_MIN_TEMP;
}
// Return the set temp. in deg C
uint8_t IRMitsubishiAC::getTemp() {
uint8_t ICACHE_FLASH_ATTR IRMitsubishiAC::getTemp() {
return(remote_state[7] + MITSUBISHI_AC_MIN_TEMP);
}
// Set the speed of the fan, 0-6.
// 0 is auto, 1-5 is the speed, 6 is silent.
void IRMitsubishiAC::setFan(uint8_t fan) {
void ICACHE_FLASH_ATTR IRMitsubishiAC::setFan(uint8_t fan) {
// Bounds check
if (fan > MITSUBISHI_AC_FAN_SILENT)
fan = MITSUBISHI_AC_FAN_MAX; // Set the fan to maximum if out of range.
@@ -103,7 +103,7 @@ void IRMitsubishiAC::setFan(uint8_t fan) {
}
// Return the requested state of the unit's fan.
uint8_t IRMitsubishiAC::getFan() {
uint8_t ICACHE_FLASH_ATTR IRMitsubishiAC::getFan() {
uint8_t fan = remote_state[9] & B111;
if (fan == MITSUBISHI_AC_FAN_MAX)
return MITSUBISHI_AC_FAN_SILENT;
@@ -111,7 +111,7 @@ uint8_t IRMitsubishiAC::getFan() {
}
// Return the requested climate operation mode of the a/c unit.
uint8_t IRMitsubishiAC::getMode() {
uint8_t ICACHE_FLASH_ATTR IRMitsubishiAC::getMode() {
/*
MITSUBISHI_AC_AUTO
MITSUBISHI_AC_COOL
@@ -122,7 +122,7 @@ uint8_t IRMitsubishiAC::getMode() {
}
// Set the requested climate operation mode of the a/c unit.
void IRMitsubishiAC::setMode(uint8_t mode) {
void ICACHE_FLASH_ATTR IRMitsubishiAC::setMode(uint8_t mode) {
// If we get an unexpected mode, default to AUTO.
switch (mode) {
case MITSUBISHI_AC_AUTO: break;
@@ -135,14 +135,14 @@ void IRMitsubishiAC::setMode(uint8_t mode) {
}
// Set the requested vane operation mode of the a/c unit.
void IRMitsubishiAC::setVane(uint8_t mode) {
mode = max(mode, B111); // bounds check
void ICACHE_FLASH_ATTR IRMitsubishiAC::setVane(uint8_t mode) {
mode = max(mode, static_cast<uint8_t>(B111)); // bounds check
mode |= B1000;
mode <<= 3;
remote_state[9] |= mode;
}
// Return the requested vane operation mode of the a/c unit.
uint8_t IRMitsubishiAC::getVane() {
uint8_t ICACHE_FLASH_ATTR IRMitsubishiAC::getVane() {
return ((remote_state[9] & B00111000) >> 3);
}
File diff suppressed because it is too large Load Diff
+44 -28
View File
@@ -32,6 +32,7 @@
#define IRremote_h
#include <stdint.h>
#include "IRremoteInt.h"
// The following are compile-time library options.
// If you change them, recompile the library.
@@ -52,6 +53,7 @@ enum decode_type_t {
RC5,
RC6,
NEC,
PIONEER,
SONY,
PANASONIC,
JVC,
@@ -68,7 +70,8 @@ enum decode_type_t {
DENON,
KELVINATOR,
SHERWOOD,
MITSUBISHI_AC
MITSUBISHI_AC,
RCMM
};
// Results returned from the decoder
@@ -89,30 +92,34 @@ public:
// Decoded value for NEC when a repeat code is received
#define REPEAT 0xffffffff
#define SEND_PROTOCOL_NEC case NEC: sendNEC(data, nbits); break;
#define SEND_PROTOCOL_SONY case SONY: sendSony(data, nbits); break;
#define SEND_PROTOCOL_RC5 case RC5: sendRC5(data, nbits); break;
#define SEND_PROTOCOL_RC6 case RC6: sendRC6(data, nbits); break;
#define SEND_PROTOCOL_DISH case DISH: sendDISH(data, nbits); break;
#define SEND_PROTOCOL_JVC case JVC: sendJVC(data, nbits, 0); break;
#define SEND_PROTOCOL_SAMSUNG case SAMSUNG: sendSAMSUNG(data, nbits); break;
#define SEND_PROTOCOL_LG case LG: sendLG(data, nbits); break;
#define SEND_PROTOCOL_WHYNTER case WHYNTER: sendWhynter(data, nbits); break;
#define SEND_PROTOCOL_COOLIX case COOLIX: sendCOOLIX(data, nbits); break;
#define SEND_PROTOCOL_DENON case DENON: sendDenon(data, nbits); break;
#define SEND_PROTOCOL_NEC case NEC: sendNEC(data, nbits); break;
#define SEND_PROTOCOL_PIONEER case PIONEER: sendPioneer(data, nbits, 1, 0ul); break;
#define SEND_PROTOCOL_SONY case SONY: sendSony(data, nbits); break;
#define SEND_PROTOCOL_RC5 case RC5: sendRC5(data, nbits); break;
#define SEND_PROTOCOL_RC6 case RC6: sendRC6(data, nbits); break;
#define SEND_PROTOCOL_DISH case DISH: sendDISH(data, nbits); break;
#define SEND_PROTOCOL_JVC case JVC: sendJVC(data, nbits, 0); break;
#define SEND_PROTOCOL_SAMSUNG case SAMSUNG: sendSAMSUNG(data, nbits); break;
#define SEND_PROTOCOL_LG case LG: sendLG(data, nbits); break;
#define SEND_PROTOCOL_WHYNTER case WHYNTER: sendWhynter(data, nbits); break;
#define SEND_PROTOCOL_COOLIX case COOLIX: sendCOOLIX(data, nbits); break;
#define SEND_PROTOCOL_DENON case DENON: sendDenon(data, nbits); break;
#define SEND_PROTOCOL_SHERWOOD case SHERWOOD: sendSherwood(data, nbits); break;
#define SEND_PROTOCOL_RCMM case RCMM: sendRCMM(data, nbits); break;
// main class for receiving IR
class IRrecv
{
public:
IRrecv(int recvpin);
bool decode(decode_results *results);
bool decode(decode_results *results, irparams_t *save=NULL);
void enableIRIn();
void disableIRIn();
void resume();
private:
// These are called by decode
void copyIrParams(irparams_t *dest);
int getRClevel(decode_results *results, int *offset, int *used, int t1);
bool decodeNEC(decode_results *results);
bool decodeSony(decode_results *results);
@@ -120,6 +127,7 @@ public:
bool decodeMitsubishi(decode_results *results);
bool decodeRC5(decode_results *results);
bool decodeRC6(decode_results *results);
bool decodeRCMM(decode_results *results);
bool decodePanasonic(decode_results *results);
bool decodeLG(decode_results *results);
bool decodeJVC(decode_results *results);
@@ -131,6 +139,14 @@ public:
bool decodeDaikin(decode_results *results);
bool decodeDenon(decode_results *results);
int compare(unsigned int oldval, unsigned int newval);
uint32_t ticksLow(uint32_t usecs, uint8_t tolerance=TOLERANCE);
uint32_t ticksHigh(uint32_t usecs, uint8_t tolerance=TOLERANCE);
bool match(uint32_t measured_ticks, uint32_t desired_us,
uint8_t tolerance=TOLERANCE);
bool matchMark(uint32_t measured_ticks, uint32_t desired_us,
uint8_t tolerance=TOLERANCE, int excess=MARK_EXCESS);
bool matchSpace(uint32_t measured_ticks, uint32_t desired_us,
uint8_t tolerance=TOLERANCE, int excess=MARK_EXCESS);
};
// Only used for testing; can remove virtual for shorter code
@@ -139,6 +155,7 @@ public:
#else
#define VIRTUAL
#endif
class IRsend
{
public:
@@ -147,6 +164,7 @@ public:
void send(int type, unsigned long data, int nbits) {
switch (type) {
SEND_PROTOCOL_NEC
SEND_PROTOCOL_PIONEER
SEND_PROTOCOL_SONY
SEND_PROTOCOL_RC5
SEND_PROTOCOL_RC6
@@ -158,12 +176,14 @@ public:
SEND_PROTOCOL_COOLIX
SEND_PROTOCOL_DENON
SEND_PROTOCOL_SHERWOOD
SEND_PROTOCOL_RCMM
}
};
void sendCOOLIX(unsigned long data, int nbits);
void sendWhynter(unsigned long data, int nbits);
void sendNEC(unsigned long data, int nbits=32, unsigned int repeat=0);
void sendLG(unsigned long data, int nbits);
void sendPioneer(unsigned long data, int nbits=32, unsigned int repeat=0, unsigned long secondData=0ul);
void sendLG(unsigned long data, int nbits=28, unsigned int repeat=0);
// sendSony() should typically be called with repeat=2 as Sony devices
// expect the code to be sent at least 3 times. (code + 2 repeats = 3 codes)
// As the legacy use of this procedure was only to send a single code
@@ -176,15 +196,19 @@ public:
void sendGC(unsigned int buf[], int len);
void sendRC5(unsigned long data, int nbits);
void sendRC6(unsigned long data, int nbits);
void sendDISH(unsigned long data, int nbits);
void sendRCMM(uint32_t data, uint8_t nbits=24);
// sendDISH() should typically be called with repeat=3 as DISH devices
// expect the code to be sent at least 4 times. (code + 3 repeats = 4 codes)
// As the legacy use of this procedure was only to send a single code
// it defaults to repeat=0 for backward compatiblity.
void sendDISH(unsigned long data, int nbits, unsigned int repeat=0);
void sendSharp(unsigned int address, unsigned int command);
void sendSharpRaw(unsigned long data, int nbits);
void sendPanasonic(unsigned int address, unsigned long data);
void sendJVC(unsigned long data, int nbits, int repeat); // *Note instead of sending the REPEAT constant if you want the JVC repeat signal sent, send the original code value and change the repeat argument from 0 to 1. JVC protocol repeats by skipping the header NOT by sending a separate code value like NEC does.
void sendSAMSUNG(unsigned long data, int nbits);
void sendDaikin(unsigned char daikin[]);
void sendDaikinChunk(unsigned char buf[], int len, int start);
void sendDenon(unsigned long data, int nbits);
void sendJVC(unsigned long data, int nbits, unsigned int repeat=0);
void sendSAMSUNG(unsigned long data, int nbits=32);
void sendDaikin(unsigned char data[]);
void sendDenon(unsigned long data, int nbits=14);
void sendKelvinator(unsigned char data[]);
void sendSherwood(unsigned long data, int nbits=32, unsigned int repeat=1);
void sendMitsubishiAC(unsigned char data[]);
@@ -210,12 +234,4 @@ private:
uint32_t start;
};
// Some useful constants
#define USECPERTICK 50 // microseconds per clock interrupt tick
#define RAWBUF 100 // Length of raw duration buffer
// Marks tend to be 100us too long, and spaces 100us too short
// when received due to sensor lag.
#define MARK_EXCESS 100
#endif
+49 -19
View File
@@ -60,10 +60,19 @@
#define NEC_RPT_SPACE 2250
#define NEC_MIN_COMMAND_LENGTH 108000UL
#define PIONEER_HDR_MARK 8000
#define PIONEER_HDR_SPACE 4000
#define PIONEER_BIT_MARK 500
#define PIONEER_ONE_SPACE 1500
#define PIONEER_ZERO_SPACE 500
#define PIONEER_RPT_SPACE 2250
#define PIONEER_MIN_COMMAND_LENGTH 90000UL
// Timings based on http://www.sbprojects.com/knowledge/ir/sirc.php
#define SONY_HDR_MARK 2400
#define SONY_HDR_SPACE 600
#define SONY_ONE_MARK 1200
#define SONY_ZERO_MARK 600
#define SONY_ONE_MARK 1250 // Experiments suggest +50 to spec is better.
#define SONY_ZERO_MARK 650 // Experiments suggest +50 to spec is better.
#define SONY_RPT_LENGTH 45000
#define SONY_DOUBLE_SPACE_USECS 500 // usually see 713 - not using ticks as get number wrapround
@@ -105,6 +114,20 @@
#define RC6_T1 444
#define RC6_RPT_LENGTH 46000
// http://www.sbprojects.com/knowledge/ir/rcmm.php
#define RCMM_HDR_MARK 416
#define RCMM_HDR_SPACE 277
#define RCMM_BIT_MARK 166
#define RCMM_BIT_SPACE_0 277
#define RCMM_BIT_SPACE_1 444
#define RCMM_BIT_SPACE_2 611
#define RCMM_BIT_SPACE_3 777
#define RCMM_RPT_LENGTH 27778
#define RCMM_MIN_GAP 3360
// Use a tolerance of +/-10% when matching some data spaces.
#define RCMM_TOLERANCE 10
#define RCMM_EXCESS 50
#define SHARP_BIT_MARK 245
#define SHARP_ONE_SPACE 1805
#define SHARP_ZERO_SPACE 795
@@ -118,13 +141,13 @@
#define DISH_ONE_SPACE 1700
#define DISH_ZERO_SPACE 2800
#define DISH_RPT_SPACE 6200
#define DISH_TOP_BIT 0x8000
#define PANASONIC_HDR_MARK 3502
#define PANASONIC_HDR_SPACE 1750
#define PANASONIC_BIT_MARK 502
#define PANASONIC_ONE_SPACE 1244
#define PANASONIC_ZERO_SPACE 400
// Ref: http://www.remotecentral.com/cgi-bin/mboard/rc-pronto/thread.cgi?26152
#define PANASONIC_HDR_MARK 3456
#define PANASONIC_HDR_SPACE 1728
#define PANASONIC_BIT_MARK 432
#define PANASONIC_ONE_SPACE 1296
#define PANASONIC_ZERO_SPACE 432
#define JVC_HDR_MARK 8000
#define JVC_HDR_SPACE 4000
@@ -184,15 +207,18 @@
#define KELVINATOR_GAP_SPACE 19950U
#define KELVINATOR_CMD_FOOTER 2U
#define TOLERANCE 25 // percent tolerance in measurements
#define LTOL (1.0 - TOLERANCE/100.)
#define UTOL (1.0 + TOLERANCE/100.)
// Some useful constants
#define USECPERTICK 50 // microseconds per clock interrupt tick
#define RAWBUF 100 // Length of raw duration buffer
// Marks tend to be 100us too long, and spaces 100us too short
// when received due to sensor lag.
#define MARK_EXCESS 100
#define _GAP 5000 // Minimum map between transmissions
#define GAP_TICKS (_GAP/USECPERTICK)
#define TICKS_LOW(us) (int) (((us)*LTOL/USECPERTICK))
#define TICKS_HIGH(us) (int) (((us)*UTOL/USECPERTICK + 1))
#define TOLERANCE 25 // default percent tolerance in measurements
// receiver states
#define STATE_IDLE 2
@@ -200,14 +226,18 @@
#define STATE_SPACE 4
#define STATE_STOP 5
#define RAWBUF 100 // Length of raw duration buffer
// information for the interrupt handler
typedef struct {
uint8_t recvpin; // pin for IR data from detector
uint8_t rcvstate; // state machine
unsigned int timer; // state timer, counts 50uS ticks.
unsigned int rawbuf[RAWBUF]; // raw data
uint8_t rawlen; // counter of entries in rawbuf
uint8_t overflow;
uint8_t recvpin; // pin for IR data from detector
uint8_t rcvstate; // state machine
unsigned int timer; // state timer, counts 50uS ticks.
unsigned int rawbuf[RAWBUF]; // raw data
// uint16_t is used for rawlen as it saves 3 bytes of iram in the interrupt
// handler. Don't ask why, I don't know. It just does.
uint16_t rawlen; // counter of entries in rawbuf.
uint8_t overflow; // Buffer overflow indicator.
}
irparams_t;
+9
View File
@@ -18,6 +18,15 @@ Seb's notes : I also changed the pulse parameters for Samsung, update the Panaso
5. Restart your Arduino ide
6. Check out the examples
###### Using Git to install library ( Linux )
```
cd ~/Arduino/libraries
git clone https://github.com/markszabo/IRremoteESP8266.git
```
###### To Update to the latest version of the library
`
cd ~/Arduino/libraries/IRremoteESP8266 && git pull
`
## Contributing
If you want to contribute to this project:
- Report bugs and errors
@@ -26,7 +26,7 @@ void handleIr(){
for (uint8_t i=0; i<server.args(); i++){
if(server.argName(i) == "code")
{
unsigned long code = server.arg(i).toInt();
unsigned long code = strtoul(server.arg(i).c_str(), NULL, 10);
irsend.sendNEC(code, 32);
}
}
@@ -1,33 +1,39 @@
/*
* IRremoteESP8266: IRrecvDumpV2 - dump details of IR codes with IRrecv
* An IR detector/demodulator must be connected to the input RECV_PIN.
* Version 0.1 Sept, 2015
* Example circuit diagram:
* https://github.com/markszabo/IRremoteESP8266/wiki#ir-receiving
* Changes:
* Version 0.2 April, 2017
* - Decode from a copy of the data so we can start capturing faster thus
* reduce the likelihood of miscaptures.
* Based on Ken Shirriff's IrsendDemo Version 0.1 July, 2009, Copyright 2009 Ken Shirriff, http://arcfn.com
*/
#include <IRremoteESP8266.h>
int RECV_PIN = 2; //an IR detector/demodulator is connected to GPIO pin 2
// An IR detector/demodulator is connected to GPIO pin 14(D5 on a NodeMCU board).
int RECV_PIN = 14;
IRrecv irrecv(RECV_PIN);
void setup ( )
{
Serial.begin(9600); // Status message will be sent to PC at 9600 baud
decode_results results; // Somewhere to store the results
irparams_t save; // A place to copy the interrupt state while decoding.
void setup() {
Serial.begin(115200, SERIAL_8N1, SERIAL_TX_ONLY); // Status message will be sent to the PC at 115200 baud
irrecv.enableIRIn(); // Start the receiver
}
//+=============================================================================
// Display IR code
//
void ircode (decode_results *results)
{
void ircode(decode_results *results) {
// Panasonic has an Address
if (results->decode_type == PANASONIC) {
Serial.print(results->panasonicAddress, HEX);
Serial.print(":");
}
// Print Code
Serial.print(results->value, HEX);
}
@@ -35,8 +41,7 @@ void ircode (decode_results *results)
//+=============================================================================
// Display encoding type
//
void encoding (decode_results *results)
{
void encoding(decode_results *results) {
switch (results->decode_type) {
default:
case UNKNOWN: Serial.print("UNKNOWN"); break ;
@@ -54,14 +59,14 @@ void encoding (decode_results *results)
case WHYNTER: Serial.print("WHYNTER"); break ;
case AIWA_RC_T501: Serial.print("AIWA_RC_T501"); break ;
case PANASONIC: Serial.print("PANASONIC"); break ;
case DENON: Serial.print("DENON"); break ;
}
}
//+=============================================================================
// Dump out the decode_results structure.
//
void dumpInfo (decode_results *results)
{
void dumpInfo (decode_results *results) {
if (results->overflow) {
Serial.println("IR code too long. Edit IRremoteInt.h and increase RAWBUF");
return;
@@ -83,8 +88,7 @@ void dumpInfo (decode_results *results)
//+=============================================================================
// Dump out the decode_results structure.
//
void dumpRaw (decode_results *results)
{
void dumpRaw(decode_results *results) {
// Print Raw data
Serial.print("Timing[");
Serial.print(results->rawlen-1, DEC);
@@ -113,8 +117,7 @@ void dumpRaw (decode_results *results)
//+=============================================================================
// Dump out the decode_results structure.
//
void dumpCode (decode_results *results)
{
void dumpCode (decode_results *results) {
// Start declaration
Serial.print("unsigned int "); // variable type
Serial.print("rawData["); // array name
@@ -129,7 +132,7 @@ void dumpCode (decode_results *results)
}
// End declaration
Serial.print("};"); //
Serial.print("};"); //
// Comment
Serial.print(" // ");
@@ -142,7 +145,6 @@ void dumpCode (decode_results *results)
// Now dump "known" codes
if (results->decode_type != UNKNOWN) {
// Some protocols have an address
if (results->decode_type == PANASONIC) {
Serial.print("unsigned int addr = 0x");
@@ -160,15 +162,12 @@ void dumpCode (decode_results *results)
//+=============================================================================
// The repeating section of the code
//
void loop ( )
{
decode_results results; // Somewhere to store the results
if (irrecv.decode(&results)) { // Grab an IR code
void loop() {
// Check if the IR code has been received.
if (irrecv.decode(&results, &save)) {
dumpInfo(&results); // Output the results
dumpRaw(&results); // Output the results in RAW format
dumpCode(&results); // Output the results as source code
Serial.println(""); // Blank line between entries
irrecv.resume(); // Prepare for the next value
}
}
@@ -1,18 +1,40 @@
/*
* IRremoteESP8266: IRsendDemo - demonstrates sending IR codes with IRsend
* An IR LED must be connected to ESP8266 pin 0.
* Version 0.1 June, 2015
* IRremoteESP8266: IRsendDemo - demonstrates sending IR codes with IRsend.
*
* An IR LED circuit *MUST* be connected to ESP8266 pin 4 (D2).
*
* TL;DR: The IR LED needs to be driven by a transistor for a good result.
*
* Suggested circuit:
* https://github.com/markszabo/IRremoteESP8266/wiki#ir-sending
*
* Common mistakes & tips:
* * Don't just connect the IR LED directly to the pin, it won't
* have enough current to drive the IR LED effectively.
* * Make sure you have the IR LED polarity correct.
* See: https://learn.sparkfun.com/tutorials/polarity/diode-and-led-polarity
* * Typical digital camera/phones can be used to see if the IR LED is flashed.
* Replace the IR LED with a normal LED if you don't have a digital camera
* when debugging.
* * Avoid using the following pins unless you really know what you are doing:
* * Pin 0/D3: Can interfere with the boot/program mode & support circuits.
* * Pin 1/TX/TXD0: Any serial transmissions from the ESP8266 will interfere.
* * Pin 3/RX/RXD0: Any serial transmissions to the ESP8266 will interfere.
* * ESP-01 modules are tricky. We suggest you use a module with more GPIOs
* for your first time. e.g. ESP-12 etc.
*
* Version 1.0 April, 2017
* Based on Ken Shirriff's IrsendDemo Version 0.1 July, 2009, Copyright 2009 Ken Shirriff, http://arcfn.com
*/
#include <IRremoteESP8266.h>
IRsend irsend(0); //an IR led is connected to GPIO pin 0
IRsend irsend(4); //an IR led is connected to GPIO pin 4 (D2)
void setup()
{
irsend.begin();
Serial.begin(9600);
Serial.begin(115200, SERIAL_8N1, SERIAL_TX_ONLY);
}
void loop() {
@@ -20,6 +42,6 @@ void loop() {
irsend.sendNEC(0x00FFE01FUL, 32);
delay(2000);
Serial.println("Sony");
irsend.sendSony(0xa90, 12);
irsend.sendSony(0xa90, 12, 2);
delay(2000);
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "IRremoteESP8266",
"version": "1.0.2",
"version": "1.2.0",
"keywords": "infrared, ir, remote, esp8266",
"description": "Send and receive infrared signals with multiple protocols (ESP8266)",
"repository":
+1 -1
View File
@@ -1,5 +1,5 @@
name=IRremoteESP8266
version=1.0.2
version=1.2.0
author=Sebastien Warin, Mark Szabo, Ken Shirriff, David Conran
maintainer=Mark Szabo, David Conran, Sebastien Warin, Roi Dayan, Massimiliano Pinto
sentence=Send and receive infrared signals with multiple protocols (ESP8266)
+21 -11
View File
@@ -1,11 +1,4 @@
//www.DFRobot.com
//last updated on 21/12/2011
//Tim Starling Fix the reset bug (Thanks Tim)
//wiki doc http://www.dfrobot.com/wiki/index.php?title=I2C/TWI_LCD1602_Module_(SKU:_DFR0063)
//Support Forum: http://www.dfrobot.com/forum/
//Compatible with the Arduino IDE 1.0
//Library version:1.1
// Based on the work by DFRobot
#include "LiquidCrystal_I2C.h"
#include <inttypes.h>
@@ -16,7 +9,7 @@
#define printIIC(args) Wire.write(args)
inline size_t LiquidCrystal_I2C::write(uint8_t value) {
send(value, Rs);
return 0;
return 1;
}
#else
@@ -59,6 +52,11 @@ LiquidCrystal_I2C::LiquidCrystal_I2C(uint8_t lcd_Addr,uint8_t lcd_cols,uint8_t l
_backlightval = LCD_NOBACKLIGHT;
}
void LiquidCrystal_I2C::oled_init(){
_oled = true;
init_priv();
}
void LiquidCrystal_I2C::init(){
init_priv();
}
@@ -134,6 +132,7 @@ void LiquidCrystal_I2C::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) {
void LiquidCrystal_I2C::clear(){
command(LCD_CLEARDISPLAY);// clear display, set cursor position to zero
delayMicroseconds(2000); // this command takes a long time!
if (_oled) setCursor(0,0);
}
void LiquidCrystal_I2C::home(){
@@ -221,6 +220,15 @@ void LiquidCrystal_I2C::createChar(uint8_t location, uint8_t charmap[]) {
}
}
//createChar with PROGMEM input
void LiquidCrystal_I2C::createChar(uint8_t location, const char *charmap) {
location &= 0x7; // we only have 8 locations 0-7
command(LCD_SETCGRAMADDR | (location << 3));
for (int i=0; i<8; i++) {
write(pgm_read_byte_near(charmap++));
}
}
// Turn the (optional) backlight off/on
void LiquidCrystal_I2C::noBacklight(void) {
_backlightval=LCD_NOBACKLIGHT;
@@ -309,6 +317,8 @@ void LiquidCrystal_I2C::printstr(const char c[]){
// unsupported API functions
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
void LiquidCrystal_I2C::off(){}
void LiquidCrystal_I2C::on(){}
void LiquidCrystal_I2C::setDelay (int cmdDelay,int charDelay) {}
@@ -318,5 +328,5 @@ uint8_t LiquidCrystal_I2C::init_bargraph(uint8_t graphtype){return 0;}
void LiquidCrystal_I2C::draw_horizontal_graph(uint8_t row, uint8_t column, uint8_t len, uint8_t pixel_col_end){}
void LiquidCrystal_I2C::draw_vertical_graph(uint8_t row, uint8_t column, uint8_t len, uint8_t pixel_row_end){}
void LiquidCrystal_I2C::setContrast(uint8_t new_val){}
#pragma GCC diagnostic pop
+7 -2
View File
@@ -1,4 +1,4 @@
//DFRobot.com
//YWROBOT
#ifndef LiquidCrystal_I2C_h
#define LiquidCrystal_I2C_h
@@ -77,14 +77,18 @@ public:
void autoscroll();
void noAutoscroll();
void createChar(uint8_t, uint8_t[]);
void createChar(uint8_t location, const char *charmap);
// Example: const char bell[8] PROGMEM = {B00100,B01110,B01110,B01110,B11111,B00000,B00100,B00000};
void setCursor(uint8_t, uint8_t);
#if defined(ARDUINO) && ARDUINO >= 100
#if defined(ARDUINO) && ARDUINO >= 100
virtual size_t write(uint8_t);
#else
virtual void write(uint8_t);
#endif
void command(uint8_t);
void init();
void oled_init();
////compatibility API function aliases
void blink_on(); // alias for blink()
@@ -118,6 +122,7 @@ private:
uint8_t _displaycontrol;
uint8_t _displaymode;
uint8_t _numlines;
bool _oled = false;
uint8_t _cols;
uint8_t _rows;
uint8_t _backlightval;
+2
View File
@@ -0,0 +1,2 @@
# LiquidCrystal_I2C
LiquidCrystal Arduino library for the DFRobot I2C LCD displays
-69
View File
@@ -1,69 +0,0 @@
1,6c1
< //www.DFRobot.com
< //last updated on 26/11/2010
< //Tim Starling Fix the reset bug (Thanks Tim)
< //wiki doc http://www.dfrobot.com/wiki/index.php?title=I2C/TWI_LCD1602_Module_(SKU:_DFR0063)
< //Support Forum: http://www.dfrobot.com/forum/
<
---
> // LiquidCrystal_I2C V2.0
10d4
< #include "WProgram.h"
12c6
<
---
> #include "Arduino.h"
67c61
< delay(50);
---
> delayMicroseconds(50000);
77,90c71,84
< // we start in 8bit mode, try to set 4 bit mode
< write4bits(0x03 << 4);
< delayMicroseconds(4500); // wait min 4.1ms
<
< // second try
< write4bits(0x03 << 4);
< delayMicroseconds(4500); // wait min 4.1ms
<
< // third go!
< write4bits(0x03 << 4);
< delayMicroseconds(150);
<
< // finally, set to 4-bit interface
< write4bits(0x02 << 4);
---
> // we start in 8bit mode, try to set 4 bit mode
> write4bits(0x03);
> delayMicroseconds(4500); // wait min 4.1ms
>
> // second try
> write4bits(0x03);
> delayMicroseconds(4500); // wait min 4.1ms
>
> // third go!
> write4bits(0x03);
> delayMicroseconds(150);
>
> // finally, set to 4-bit interface
> write4bits(0x02);
225c219
< inline void LiquidCrystal_I2C::write(uint8_t value) {
---
> inline size_t LiquidCrystal_I2C::write(uint8_t value) {
226a221
> return 0;
235,238c230,233
< uint8_t highnib=value&0xf0;
< uint8_t lownib=(value<<4)&0xf0;
< write4bits((highnib)|mode);
< write4bits((lownib)|mode);
---
> uint8_t highnib=value>>4;
> uint8_t lownib=value & 0x0F;
> write4bits((highnib)|mode);
> write4bits((lownib)|mode);
248c243
< Wire.send((int)(_data) | _backlightval);
---
> Wire.write((int)(_data) | _backlightval);
+4 -4
View File
@@ -1,4 +1,4 @@
//DFRobot.com
//YWROBOT
//Compatible with the Arduino IDE 1.0
//Library version:1.1
#include <Wire.h>
@@ -19,7 +19,7 @@ uint8_t check[8] = {0x0,0x1,0x3,0x16,0x1c,0x8,0x0};
uint8_t cross[8] = {0x0,0x1b,0xe,0x4,0xe,0x1b,0x0};
uint8_t retarrow[8] = { 0x1,0x1,0x5,0x9,0x1f,0x8,0x4};
LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 for a 16 chars and 2 line display
void setup()
{
@@ -52,7 +52,7 @@ void displayKeyCodes(void) {
while (1) {
lcd.clear();
lcd.print("Codes 0x"); lcd.print(i, HEX);
lcd.print("-0x"); lcd.print(i+16, HEX);
lcd.print("-0x"); lcd.print(i+15, HEX);
lcd.setCursor(0, 1);
for (int j=0; j<16; j++) {
lcd.printByte(i+j);
@@ -67,4 +67,4 @@ void loop()
{
}
+11 -3
View File
@@ -1,20 +1,28 @@
//DFRobot.com
//YWROBOT
//Compatible with the Arduino IDE 1.0
//Library version:1.1
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 for a 16 chars and 2 line display
void setup()
{
lcd.init(); // initialize the lcd
lcd.init();
// Print a message to the LCD.
lcd.backlight();
lcd.setCursor(3,0);
lcd.print("Hello, world!");
lcd.setCursor(2,1);
lcd.print("Ywrobot Arduino!");
lcd.setCursor(0,2);
lcd.print("Arduino LCM IIC 2004");
lcd.setCursor(2,3);
lcd.print("Power By Ec-yuan!");
}
void loop()
{
}
+2 -2
View File
@@ -1,14 +1,14 @@
/*
* Displays text sent over the serial port (e.g. from the Serial Monitor) on
* an attached LCD.
* DFRobot.com
* YWROBOT
*Compatible with the Arduino IDE 1.0
*Library version:1.1
*/
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 for a 16 chars and 2 line display
void setup()
{
View File
+16
View File
@@ -0,0 +1,16 @@
{
"name": "LiquidCrystal_I2C",
"keywords": "LCD, liquidcrystal, I2C",
"description": "A library for DFRobot I2C LCD displays",
"repository":
{
"type": "git",
"url": "https://github.com/marcoschwartz/LiquidCrystal_I2C.git"
},
"frameworks": "arduino",
"platforms":
[
"atmelavr",
"espressif8266"
]
}
+9
View File
@@ -0,0 +1,9 @@
name=LiquidCrystal_I2C
version=1.1.4
author=Frank de Brabander
maintainer=Marco Schwartz <marcolivier.schwartz@gmail.com>
sentence=A library for I2C LCD displays.
paragraph= The library allows to control I2C displays with functions extremely similar to LiquidCrystal library. THIS LIBRARY MIGHT NOT BE COMPATIBLE WITH EXISTING SKETCHES.
category=Display
url=https://github.com/marcoschwartz/LiquidCrystal_I2C
architectures=avr
+165
View File
@@ -0,0 +1,165 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
+241
View File
@@ -0,0 +1,241 @@
/*-------------------------------------------------------------------------
Arduino library to ...
Written by Jochen Krapf,
contributions by ... and other members of the open
source community.
-------------------------------------------------------------------------
This file is part of the MechInputs library.
MechInputs is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
MechInputs is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with MechInputs. If not, see
<http://www.gnu.org/licenses/>.
-------------------------------------------------------------------------*/
#include "QEIx4.h"
#include <limits.h>
// bit masks for state machine - don't change!!!
#define QEIx4_STATE 0xC
#define QEIx4_MASK 0x1C
#define QEIx4_1x_INC 0x0100
#define QEIx4_2x_INC 0x0200
#define QEIx4_4x_INC 0x0400
#define QEIx4_1x_DEC 0x1000
#define QEIx4_2x_DEC 0x2000
#define QEIx4_4x_DEC 0x4000
#define QEIx4_1x_MASK 0x11FF
#define QEIx4_2x_MASK 0x33FF
#define QEIx4_4x_MASK 0x77FF
#define QEIx4_DIR 0x20
#define QEIx4_A 1
#define QEIx4_B 2
#define QEIx4_AB 3
#define QEIx4_S0 0x0
#define QEIx4_S1 0x4
#define QEIx4_S2 0x8
#define QEIx4_S3 0xC
#define QEIx4_CCW 0
#define QEIx4_CW 0x10
#define QEIx4_IS_CHG 0x7700
#define QEIx4_IS_INC 0x0700
#define QEIx4_IS_DEC 0x7000
#define QEIx4_IS_DIR 0x20
// state machine for decoting - don't change!!!
uint16_t QEIx4::__stateLUT[32] = {
// act state S0 in CCW direction
QEIx4_CCW | QEIx4_S0,
QEIx4_CW | QEIx4_S1 | QEIx4_A | QEIx4_4x_INC | QEIx4_DIR,
QEIx4_CCW | QEIx4_S0 | QEIx4_B,
QEIx4_CCW | QEIx4_S3 | QEIx4_AB | QEIx4_1x_DEC,
// act state S1 in CCW direction
QEIx4_CCW | QEIx4_S1,
QEIx4_CCW | QEIx4_S1 | QEIx4_A,
QEIx4_CCW | QEIx4_S0 | QEIx4_B | QEIx4_4x_DEC,
QEIx4_CW | QEIx4_S2 | QEIx4_AB | QEIx4_1x_INC | QEIx4_DIR,
// act state S2 in CCW direction
QEIx4_CCW | QEIx4_S1 | QEIx4_2x_DEC,
QEIx4_CCW | QEIx4_S2 | QEIx4_A,
QEIx4_CW | QEIx4_S3 | QEIx4_B | QEIx4_4x_INC | QEIx4_DIR,
QEIx4_CCW | QEIx4_S2 | QEIx4_AB,
// act state S3 in CCW direction
QEIx4_CW | QEIx4_S0 | QEIx4_2x_INC | QEIx4_DIR,
QEIx4_CCW | QEIx4_S2 | QEIx4_A | QEIx4_4x_DEC,
QEIx4_CCW | QEIx4_S3 | QEIx4_B,
QEIx4_CCW | QEIx4_S3 | QEIx4_AB,
// act state S0 in CW direction
QEIx4_CW | QEIx4_S0,
QEIx4_CW | QEIx4_S1 | QEIx4_A | QEIx4_4x_INC,
QEIx4_CW | QEIx4_S0 | QEIx4_B,
QEIx4_CCW | QEIx4_S3 | QEIx4_AB | QEIx4_1x_DEC | QEIx4_DIR,
// act state S1 in CW direction
QEIx4_CW | QEIx4_S1,
QEIx4_CW | QEIx4_S1 | QEIx4_A,
QEIx4_CCW | QEIx4_S0 | QEIx4_B | QEIx4_4x_DEC | QEIx4_DIR,
QEIx4_CW | QEIx4_S2 | QEIx4_AB | QEIx4_1x_INC,
// act state S2 in CW direction
QEIx4_CCW | QEIx4_S1 | QEIx4_2x_DEC | QEIx4_DIR,
QEIx4_CW | QEIx4_S2 | QEIx4_A,
QEIx4_CW | QEIx4_S3 | QEIx4_B | QEIx4_4x_INC,
QEIx4_CW | QEIx4_S2 | QEIx4_AB,
// act state S3 in CW direction
QEIx4_CW | QEIx4_S0 | QEIx4_2x_INC,
QEIx4_CCW | QEIx4_S2 | QEIx4_A | QEIx4_4x_DEC | QEIx4_DIR,
QEIx4_CW | QEIx4_S3 | QEIx4_B,
QEIx4_CW | QEIx4_S3 | QEIx4_AB
};
// Helper for ISR call
QEIx4* QEIx4::__instance[4] = { 0 };
//#define DEB(x) printf (x)
#define DEB(x)
///////////////////////////////////////////////////////////////////////////////
QEIx4::QEIx4()
{
for (byte i=0; i<4; i++)
if (__instance[i] == 0)
{
__instance[i] = this;
DEB("::");
break;
}
_pinA = -1;
_pinB = -1;
_pinI = -1;
_state = 0;
_limitMin = LONG_MIN;
_limitMax = LONG_MAX;
}
///////////////////////////////////////////////////////////////////////////////
QEIx4::~QEIx4()
{
for (byte i=0; i<4; i++)
if (__instance[i] == this)
{
__instance[i] = 0;
}
}
///////////////////////////////////////////////////////////////////////////////
void QEIx4::begin(int16_t pinA, int16_t pinB, int16_t pinI, uint8_t mode)
{
if (_pinA >= 0)
detachInterrupt(digitalPinToInterrupt(_pinA));
if (_pinB >= 0)
detachInterrupt(digitalPinToInterrupt(_pinB));
_pinA = pinA;
_pinB = pinB;
_pinI = pinI;
_counter = 0;
_bHasChanged = true;
if (mode == 1)
_eventMask = QEIx4_1x_MASK;
else if (mode == 2)
_eventMask = QEIx4_2x_MASK;
else
_eventMask = QEIx4_4x_MASK;
pinMode(_pinA, INPUT_PULLUP);
pinMode(_pinB, INPUT_PULLUP);
pinMode(_pinI, INPUT_PULLUP);
if (_pinA >= 0)
attachInterrupt(digitalPinToInterrupt(_pinA), ISR, CHANGE);
if (_pinB >= 0)
attachInterrupt(digitalPinToInterrupt(_pinB), ISR, CHANGE);
}
///////////////////////////////////////////////////////////////////////////////
long QEIx4::read()
{
noInterrupts();
_bHasChanged = false;
long ret = _counter;
interrupts();
return ret;
}
void QEIx4::loop()
{
noInterrupts();
processStateMachine();
interrupts();
}
///////////////////////////////////////////////////////////////////////////////
void QEIx4::processStateMachine()
{
DEB(".");
_state &= QEIx4_MASK;
if (digitalRead(_pinA)) _state |= QEIx4_A;
if (digitalRead(_pinB)) _state |= QEIx4_B;
_state = __stateLUT[_state]; // magic is done by lookup-table
_state &= _eventMask;
if (_state & QEIx4_IS_CHG) { // is any change?
bool bCounterChange = false;
if ((_state & QEIx4_IS_INC) && (_counter < _limitMax)) { // has moved foreward?
_counter++;
bCounterChange = true;
DEB("+");
}
if ((_state & QEIx4_IS_DEC) && (_counter > _limitMin)) { // has moved backward?
_counter--;
bCounterChange = true;
DEB("-");
}
if (_pinI >= 0 && _bIndexTrigger && bCounterChange && digitalRead(_pinI)) { // is index pin triggered?
_bIndexTrigger = false;
_counter = 0;
DEB("I");
}
if (bCounterChange) { // has counter changed?
_bHasChanged = true;
}
}
}
void QEIx4::ISR()
{
for (byte i=0; i<4; i++)
if (__instance[i])
{
__instance[i]->processStateMachine();
}
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
+133
View File
@@ -0,0 +1,133 @@
/*--------------------------------------------------------------------
Arduino library to ...
Written by Jochen Krapf,
contributions by ... and other members of the open
source community.
-------------------------------------------------------------------------
This file is part of the MechInputs library.
MechInputs is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
MechInputs is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with MechInputs. If not, see
<http://www.gnu.org/licenses/>.
--------------------------------------------------------------------*/
#ifndef QEIX4_H
#define QEIX4_H
#if (ARDUINO >= 100)
#include <Arduino.h>
#else
#include <WProgram.h>
#include <pins_arduino.h>
#endif
class QEIx4
{
public:
/** constructor of QEIx4 object
*/
QEIx4();
/** destructor of QEIx4 object
*/
~QEIx4();
void begin(int16_t pinA, int16_t pinB, int16_t pinI=-1, uint8_t mode=4);
/** Gets the actual counter value.
*
* @return Actual counter value
*/
long read();
/** Gets the actual counter value as long operator.
*
* @return Actual counter value as long operator
*/
operator long() { // int-Operator
return read();
}
/** Sets the counter value at actual encoder position to given value.
*
* @param Counter value
*/
void write(long counter) {
_counter = counter;
}
/** Sets the counter value at actual encoder position to given value as assign operator.
*
* @param Counter value
*/
int operator= (long counter) { // Assign-Operator
write(counter);
return counter;
}
void setLimit(long limitMin, long limitMax)
{
_limitMin = limitMin;
_limitMax = limitMax;
}
/** Sets the flag for zeroing on next high on index pin while AB lines triggers next counting. The trigger calls tha callback function in which the counter can be set to zero or the actual counter can be latched in for later offset calculation
*
* @param Flag for triggering. Set to 1 for call the attached callback. It is reseted after this call
*/
void setIndexTrigger(bool bIndexTrigger=true) {
if (_pinI < 0)
bIndexTrigger = false;
_bIndexTrigger = bIndexTrigger;
}
bool hasChanged(){
return _bHasChanged;
}
void loop();
protected:
/** Polls the state machine and updates the counter value.
*/
void processStateMachine();
/** Entry point for arduino interrupts - route to class instances
*/
static void ISR();
protected:
volatile long _counter;
volatile bool _bHasChanged;
volatile bool _bIndexTrigger;
int16_t _pinA;
int16_t _pinB;
int16_t _pinI;
long _limitMin;
long _limitMax;
uint16_t _state;
uint16_t _eMode;
private:
static uint16_t __stateLUT[32];
static QEIx4* __instance[4];
uint16_t _eventMask;
};
#endif // QEIX4_H
+28
View File
@@ -0,0 +1,28 @@
# MechInputs Library (https://github.com/jkDesignDE/MechInputs)
Arduino library for reading and debouncing mechanical inputs Like buttons, switches and encoders.
After downloading, rename folder to 'MechInputs' and install in Arduino Libraries folder. Restart Arduino IDE, then open File->Sketchbook->Library->MechInputs->* sketches.
# QEI (quadrature encoder interface) library, for decoding AB signals from a rotary encoder
Use cases:
- Rotary encoder in closed loop motor regulation
- Hand wheel
- Input device for motion control (MoCo)
A class to decode pulses on a rotary encoder with AB signals (quadrature encoder).
It uses all 4 edges of the AB signals to increase the counter resolution 4 times of cycles per rotation/revolution (CPR) (e.g. an encoder with 500 CPR get 2000 counts per rotation)
In opposite to most common QEI implementation this is resistant to jitter and chatter on AB signals and motor vibrations.
Whes reaching the next position the edge that triggerd this position (state) is ignored to aboid oscillating up/down counts.
It can also be used in polling mode i.g. in idle routines if interrupts are not desired.
At this mode be sure that the sampling frequency is heigher than the maximum rotation speed (expeced counts per second)
The internal state machine is based on a look up table (LUT) to minimize interrupt retention time and get all necessary flags at once.
The library is designed to support closed loop speed- and motion-controller for also slow and smooth motions like movie camera motion control.
+9
View File
@@ -0,0 +1,9 @@
name=MechInputs
version=0.0.1
author=Jochen Krapf
maintainer=Jochen Krapf <jk@nerd2nerd.org>
sentence=Library for Reading and Debouncing Mechanical Inputs Like Buttons, Switches and Encoders with Arduino-Based Controllers.
paragraph=Library for Reading and Debouncing Mechanical Inputs Like Buttons, Switches and Encoders with Arduino-Based Controllers.
category=Input
url=https://github.com/jkDesignDE/MechInputs
architectures=esp8266,avr
+165
View File
@@ -0,0 +1,165 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
+81
View File
@@ -0,0 +1,81 @@
/*-------------------------------------------------------------------------
Arduino library to ...
Written by Jochen Krapf,
contributions by ... and other members of the open
source community.
-------------------------------------------------------------------------
This file is part of the MechInputs library.
MechInputs is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
MechInputs is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with MechInputs. If not, see
<http://www.gnu.org/licenses/>.
-------------------------------------------------------------------------*/
#include <SensorSerial.h>
SensorSerial::SensorSerial(int receivePin, int transmitPin, bool inverse_logic, unsigned int buffSize) : ESPeasySoftwareSerial(receivePin, transmitPin, inverse_logic, buffSize)
{
//boolean sws = isValidGPIOpin(receivePin);
_hw = receivePin < 0;
}
void SensorSerial::begin(long speed)
{
if (_hw)
Serial.begin(speed);
else
ESPeasySoftwareSerial::begin(speed);
}
int SensorSerial::peek()
{
if (_hw)
return Serial.peek();
else
return ESPeasySoftwareSerial::peek();
}
size_t SensorSerial::write(uint8_t byte)
{
if (_hw)
return Serial.write(byte);
else
return ESPeasySoftwareSerial::write(byte);
}
int SensorSerial::read()
{
if (_hw)
return Serial.read();
else
return ESPeasySoftwareSerial::read();
}
int SensorSerial::available()
{
if (_hw)
return Serial.available();
else
return ESPeasySoftwareSerial::available();
}
void SensorSerial::flush()
{
if (_hw)
Serial.flush();
else
ESPeasySoftwareSerial::flush();
}
+53
View File
@@ -0,0 +1,53 @@
/*-------------------------------------------------------------------------
Arduino library to ...
Written by Jochen Krapf,
contributions by ... and other members of the open
source community.
-------------------------------------------------------------------------
This file is part of the MechInputs library.
MechInputs is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
MechInputs is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with MechInputs. If not, see
<http://www.gnu.org/licenses/>.
-------------------------------------------------------------------------*/
#ifndef _SENSORSERIAL_H_
#define _SENSORSERIAL_H_
#include "Arduino.h"
#include <ESPeasySoftwareSerial.h>
class SensorSerial : public ESPeasySoftwareSerial
{
public:
SensorSerial(int receivePin, int transmitPin = -1, bool inverse_logic = false, unsigned int buffSize = 64);
void begin(long speed);
int peek();
virtual size_t write(uint8_t byte);
virtual int read();
virtual int available();
virtual void flush();
protected:
boolean _hw;
};
#endif
+59
View File
@@ -0,0 +1,59 @@
/*-------------------------------------------------------------------------
Arduino library to ...
Written by Jochen Krapf,
contributions by ... and other members of the open
source community.
-------------------------------------------------------------------------
This file is part of the MechInputs library.
MechInputs is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
MechInputs is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with MechInputs. If not, see
<http://www.gnu.org/licenses/>.
-------------------------------------------------------------------------*/
#include "SensorSerialBuffer.h"
CSensorSerialBuffer::CSensorSerialBuffer()
{
_writeIndex = 0;
_packetLength = 0;
Clear();
}
void CSensorSerialBuffer::Clear ()
{
for (byte i=0; i<SERIALBUFFER_SIZE; i++)
_buffer[i] = 0;
}
void CSensorSerialBuffer::AddData (byte b)
{
_buffer[_writeIndex] = b;
_writeIndex++;
_writeIndex &= SERIALBUFFER_MASK;
}
void CSensorSerialBuffer::SetPacketLength (byte len)
{
_packetLength = len;
}
byte& CSensorSerialBuffer::operator[] (byte x)
{
x += _writeIndex;
x -= _packetLength;
x &= SERIALBUFFER_MASK;
return _buffer[x];
}
+53
View File
@@ -0,0 +1,53 @@
/*-------------------------------------------------------------------------
Arduino library to ...
Written by Jochen Krapf,
contributions by ... and other members of the open
source community.
-------------------------------------------------------------------------
This file is part of the MechInputs library.
MechInputs is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
MechInputs is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with MechInputs. If not, see
<http://www.gnu.org/licenses/>.
-------------------------------------------------------------------------*/
#ifndef _SENSORSERIALBUFFER_H_
#define _SENSORSERIALBUFFER_H_
#include "Arduino.h"
#define SERIALBUFFER_SIZE 32
#define SERIALBUFFER_MASK 31
class CSensorSerialBuffer
{
public:
CSensorSerialBuffer();
void Clear ();
void AddData (byte b);
void SetPacketLength (byte len);
byte& operator[] (byte x);
private:
byte _buffer[SERIALBUFFER_SIZE];
byte _writeIndex;
byte _packetLength;
};
#endif
+188
View File
@@ -0,0 +1,188 @@
/*-------------------------------------------------------------------------
Arduino library to ...
Written by Jochen Krapf,
contributions by ... and other members of the open
source community.
-------------------------------------------------------------------------
This file is part of the MechInputs library.
MechInputs is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
MechInputs is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with MechInputs. If not, see
<http://www.gnu.org/licenses/>.
-------------------------------------------------------------------------*/
#include "jkSDS011.h"
CjkSDS011::CjkSDS011(int16_t pinRX, int16_t pinTX)
{
_sws = ! ( pinRX < 0 || pinRX == 3 );
_pm2_5 = NAN;
_pm10_ = NAN;
_available = false;
_pm2_5avr = 0;
_pm10_avr = 0;
_avr = 0;
_data.SetPacketLength(10);
_command.SetPacketLength(19);
_working_period = -1;
_sleepmode_active = false;
_serial = new ESPeasySoftwareSerial(pinRX, pinTX);
_serial->begin(9600);
}
CjkSDS011::~CjkSDS011() {
delete _serial;
}
void CjkSDS011::SendCommand(byte byte1, byte byte2, byte byte3) {
_command[0] = 0xAA; // Head
_command[1] = 0xB4; // Command ID
_command[2] = byte1; // Data Byte 1
_command[3] = byte2; // Data Byte 2
_command[4] = byte3; // Data Byte 3
_command[5] = 0; // Data Byte 4
_command[6] = 0; // Data Byte 5
_command[7] = 0; // Data Byte 6
_command[8] = 0; // Data Byte 7
_command[9] = 0; // Data Byte 8
_command[10] = 0; // Data Byte 9
_command[11] = 0; // Data Byte 10
_command[12] = 0; // Data Byte 11
_command[13] = 0; // Data Byte 12
_command[14] = 0; // Data Byte 13
_command[15] = 0xFF; // Device ID byte 1, FF: All sensor response
_command[16] = 0xFF; // Device ID byte 2, FF: All sensor response
byte checksum = 0;
for (byte i=2; i< 17; ++i) {
checksum += _command[i];
}
_command[17] = checksum; // Checksum
_command[18] = 0xAB; // Tail
for (int i = 0; i < 19; ++i) {
_serial->write(_command[i]);
}
}
void CjkSDS011::SetSleepMode(bool enabled) {
byte databyte3 = enabled ? 0 : 1;
SendCommand(6, 1, databyte3);
}
void CjkSDS011::SetWorkingPeriod(int minutes) {
// Data byte 1: 8
// Data byte 2: 0: query the current mode
// 1: set mode
// Data byte 3: 0continuous(default)
// 1-30minutework 30 seconds and sleep n*60-30 seconds
if (minutes < 0 || minutes > 30) return;
// Working period is stored in the flash of the sensor. Only write to change.
const int currentWorkingPeriod = GetWorkingPeriod();
if (minutes != currentWorkingPeriod)
SendCommand(8, 1, minutes);
}
int CjkSDS011::GetWorkingPeriod() {
// Data byte 1: 8
// Data byte 2: 0: query the current mode
// 1: set mode
// Data byte 3: 0continuous(default)
// 1-30minutework 30 seconds and sleep n*60-30 seconds
SendCommand(8, 0, 0);
Process();
return _working_period;
}
void CjkSDS011::ParseCommandReply() {
switch(_data[2]) {
case 6: // Enable/Disable sleep mode.
if (_data[3] == 0)
_sleepmode_active = _data[4];
break;
case 8: // Set/Get working period
if (_data[3] == 0)
_working_period = _data[4];
break;
default:
// Not implemented.
break;
}
}
void CjkSDS011::Process()
{
while (_serial->available())
{
_data.AddData(_serial->read());
if (_data[0] == 0xAA && _data[9] == 0xAB) // correct packet frame?
{
byte checksum = 0;
for (byte i=2; i<= 7; i++)
checksum += _data[i];
if (checksum != _data[8])
continue;
switch(_data[1]) {
case 0xC0: // SDS011 or SDS018?
_pm2_5 = (float)((_data[3] << 8) | _data[2]) * 0.1;
_pm10_ = (float)((_data[5] << 8) | _data[4]) * 0.1;
_available = true;
break;
case 0xCF: // SDS198?
_pm2_5 = (float)((_data[5] << 8) | _data[4]);
_pm10_ = (float)((_data[3] << 8) | _data[2]);
_available = true;
break;
case 0xC5: // Reply on command ID 0xB4
ParseCommandReply();
break;
default:
break;
}
if (_available) {
_pm2_5avr += _pm2_5;
_pm10_avr += _pm10_;
_avr++;
_data.Clear();
return;
}
}
}
}
boolean CjkSDS011::available()
{
boolean ret = _available;
_available = false;
return ret;
}
boolean CjkSDS011::ReadAverage(float &pm25, float &pm10)
{
if (_avr)
{
pm25 = _pm2_5avr / _avr;
pm10 = _pm10_avr / _avr;
_pm2_5avr = 0;
_pm10_avr = 0;
_avr = 0;
return true;
}
pm25 = NAN;
pm10 = NAN;
return false;
}
+81
View File
@@ -0,0 +1,81 @@
/*-------------------------------------------------------------------------
Arduino library to ...
Written by Jochen Krapf,
contributions by ... and other members of the open
source community.
-------------------------------------------------------------------------
This file is part of the MechInputs library.
MechInputs is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
MechInputs is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with MechInputs. If not, see
<http://www.gnu.org/licenses/>.
-------------------------------------------------------------------------*/
#ifndef _jkSDS011_H_
#define _jkSDS011_H_
#include "Arduino.h"
//#include "SensorSerial.h"
#include "SensorSerialBuffer.h"
#include "ESPeasySoftwareSerial.h"
class CjkSDS011
{
public:
CjkSDS011(int16_t pinRX, int16_t pinTX);
virtual ~CjkSDS011();
void Process();
boolean available();
float GetPM2_5() { return _pm2_5; };
float GetPM10_() { return _pm10_; };
// Return true when there are valid samples.
boolean ReadAverage(float &pm25, float &pm10);
void SetSleepMode(bool enabled);
// Set interval to get new data, 0 .. 30 minutes.
// Minutes = 0 => continous mode.
// The setting is still effective after power off(factory default is continuous measurement)
void SetWorkingPeriod(int minutes);
// Get the working period in minutes (0 = continuous reading)
// Negative return value indicates error during communication.
int GetWorkingPeriod();
private:
void SendCommand(byte byte1, byte byte2, byte byte3);
void ParseCommandReply();
// SensorSerial _serial;
ESPeasySoftwareSerial *_serial;
CSensorSerialBuffer _data;
CSensorSerialBuffer _command;
float _pm2_5;
float _pm10_;
float _pm2_5avr;
float _pm10_avr;
uint16_t _avr;
boolean _available;
boolean _sws;
int _working_period;
boolean _sleepmode_active;
};
#endif
+9
View File
@@ -0,0 +1,9 @@
name=SerialSensors
version=0.0.1
author=Jochen Krapf
maintainer=Jochen Krapf <jk@nerd2nerd.org>
sentence=Library for Reading and Serial Data from Sensor Devices.
paragraph=Library for Reading and Serial Data from Sensor Devices.
category=Input
url=https://github.com/jkDesignDE/SerialSensors
architectures=esp8266,avr
@@ -0,0 +1,9 @@
License Information
-------------------
The hardware is released under [Creative Commons Share-alike 3.0](http://creativecommons.org/licenses/by-sa/3.0/).
All other code is open source so please feel free to do anything you want with it; you buy me a beer if you use this and we meet someday ([Beerware license](http://en.wikipedia.org/wiki/Beerware)).
@@ -0,0 +1,82 @@
SparkFun APDS9960 RGB and Gesture Sensor Arduino Library
=========================================================
![Avago APDS-9960 Breakout Board - SEN-12787 ](https://cdn.sparkfun.com/r/92-92/assets/parts/9/6/0/3/12787-01.jpg)
[*Avago APDS-9960 Breakout Board (SEN-12787)*](https://www.sparkfun.com/products/12787)
Getting Started
---------------
* Download the Git repository as a ZIP ("Download ZIP" button)
* Unzip
* Copy the entire library directory (APDS-9960_RGB_and_Gesture_Sensor_Arduino_Library
) to \<Arduino installation directory\>/libraries
* Open the Arduino program
* Select File -> Examples -> SparkFun_APDS9960 -> GestureTest
* Plug in your Arduino and APDS-9960 with the following connections
*-OR-*
* Use the library manager
| Arduino Pin | APDS-9960 Board | Function |
|---|---|---|
| 3.3V | VCC | Power |
| GND | GND | Ground |
| A4 | SDA | I2C Data |
| A5 | SCL | I2C Clock |
| 2 | INT | Interrupt |
* Go to Tools -> Board and select your Arduino board
* Go to Tools -> Serial Port and select the COM port of your Arduino board
* Click "Upload"
* Go to Tools -> Serial Monitor
* Ensure the baud rate is set at 9600 baud
* Swipe your hand over the sensor in various directions!
Repository Contents
-------------------
* **/examples** - Example sketches for the library (.ino). Run these from the Arduino IDE.
* **/src** - Source files for the library (.cpp, .h).
* **library.properties** - General library properties for the Arduino package manager.
Documentation
--------------
* **[Installing an Arduino Library Guide](https://learn.sparkfun.com/tutorials/installing-an-arduino-library)** - Basic information on how to install an Arduino library.
* **[Product Repository](https://github.com/sparkfun/APDS-9960_RGB_and_Gesture_Sensor)** - Main repository (including hardware files) for the SparkFun_APDS9960 RGB and Gesture Sensor.
* **[Hookup Guide](https://learn.sparkfun.com/tutorials/apds-9960-rgb-and-gesture-sensor-hookup-guide)** - Basic hookup guide for the sensor.
Products that use this Library
---------------------------------
* [SEN-12787](https://www.sparkfun.com/products/12787)- Avago APDS-9960
Version History
---------------
* [V_1.4.1](https://github.com/sparkfun/SparkFun_APDS-9960_Sensor_Arduino_Library/tree/V_1.4.1) - Removing blank files, updating library.properties file.
* [V_1.4.0](https://github.com/sparkfun/APDS-9960_RGB_and_Gesture_Sensor_Arduino_Library/tree/V_1.4.0) - Updated to new library structure
* V_1.3.0 - Implemented disableProximitySensor(). Thanks to jmg5150 for catching that!
* V_1.2.0 - Added pinMode line to GestureTest demo to fix interrupt bug with some Arduinos
* V_1.1.0 - Updated GestureTest demo to not freeze with fast swipes
* V_1.0.0: Initial release
* Ambient and RGB light sensing implemented
* Ambient light interrupts working
* Proximity sensing implemented
* Proximity interrupts working
* Gesture (UP, DOWN, LEFT, RIGHT, NEAR, FAR) sensing implemented
License Information
-------------------
This product is _**open source**_!
The **code** is beerware; if you see me (or any other SparkFun employee) at the local, and you've found our code helpful, please buy us a round!
Please use, reuse, and modify these files as you see fit. Please maintain attribution to SparkFun Electronics and release anything derivative under the same license.
Distributed as-is; no warranty is given.
- Your friends at SparkFun.
@@ -0,0 +1,161 @@
/****************************************************************
AmbientLightInterrupt.ino
APDS-9960 RGB and Gesture Sensor
Shawn Hymel @ SparkFun Electronics
October 24, 2014
https://github.com/sparkfun/APDS-9960_RGB_and_Gesture_Sensor
Tests the ambient light interrupt abilities of the APDS-9960.
Configures the APDS-9960 over I2C and waits for an external
interrupt based on high or low light conditions. Try covering
the sensor with your hand or bringing the sensor close to a
bright light source. You might need to adjust the LIGHT_INT_HIGH
and LIGHT_INT_LOW values to get the interrupt to work correctly.
Hardware Connections:
IMPORTANT: The APDS-9960 can only accept 3.3V!
Arduino Pin APDS-9960 Board Function
3.3V VCC Power
GND GND Ground
A4 SDA I2C Data
A5 SCL I2C Clock
2 INT Interrupt
13 - LED
Resources:
Include Wire.h and SparkFun_APDS-9960.h
Development environment specifics:
Written in Arduino 1.0.5
Tested with SparkFun Arduino Pro Mini 3.3V
This code is beerware; if you see me (or any other SparkFun
employee) at the local, and you've found our code helpful, please
buy us a round!
Distributed as-is; no warranty is given.
****************************************************************/
#include <Wire.h>
#include <SparkFun_APDS9960.h>
// Pins
#define APDS9960_INT 2 // Needs to be an interrupt pin
#define LED_PIN 13 // LED for showing interrupt
// Constants
#define LIGHT_INT_HIGH 1000 // High light level for interrupt
#define LIGHT_INT_LOW 10 // Low light level for interrupt
// Global variables
SparkFun_APDS9960 apds = SparkFun_APDS9960();
uint16_t ambient_light = 0;
uint16_t red_light = 0;
uint16_t green_light = 0;
uint16_t blue_light = 0;
int isr_flag = 0;
uint16_t threshold = 0;
void setup() {
// Set LED as output
pinMode(LED_PIN, OUTPUT);
pinMode(APDS9960_INT, INPUT);
// Initialize Serial port
Serial.begin(9600);
Serial.println();
Serial.println(F("-------------------------------------"));
Serial.println(F("SparkFun APDS-9960 - Light Interrupts"));
Serial.println(F("-------------------------------------"));
// Initialize interrupt service routine
attachInterrupt(0, interruptRoutine, FALLING);
// Initialize APDS-9960 (configure I2C and initial values)
if ( apds.init() ) {
Serial.println(F("APDS-9960 initialization complete"));
} else {
Serial.println(F("Something went wrong during APDS-9960 init!"));
}
// Set high and low interrupt thresholds
if ( !apds.setLightIntLowThreshold(LIGHT_INT_LOW) ) {
Serial.println(F("Error writing low threshold"));
}
if ( !apds.setLightIntHighThreshold(LIGHT_INT_HIGH) ) {
Serial.println(F("Error writing high threshold"));
}
// Start running the APDS-9960 light sensor (no interrupts)
if ( apds.enableLightSensor(false) ) {
Serial.println(F("Light sensor is now running"));
} else {
Serial.println(F("Something went wrong during light sensor init!"));
}
// Read high and low interrupt thresholds
if ( !apds.getLightIntLowThreshold(threshold) ) {
Serial.println(F("Error reading low threshold"));
} else {
Serial.print(F("Low Threshold: "));
Serial.println(threshold);
}
if ( !apds.getLightIntHighThreshold(threshold) ) {
Serial.println(F("Error reading high threshold"));
} else {
Serial.print(F("High Threshold: "));
Serial.println(threshold);
}
// Enable interrupts
if ( !apds.setAmbientLightIntEnable(1) ) {
Serial.println(F("Error enabling interrupts"));
}
// Wait for initialization and calibration to finish
delay(500);
}
void loop() {
// If interrupt occurs, print out the light levels
if ( isr_flag == 1 ) {
// Read the light levels (ambient, red, green, blue) and print
if ( !apds.readAmbientLight(ambient_light) ||
!apds.readRedLight(red_light) ||
!apds.readGreenLight(green_light) ||
!apds.readBlueLight(blue_light) ) {
Serial.println("Error reading light values");
} else {
Serial.print("Interrupt! Ambient: ");
Serial.print(ambient_light);
Serial.print(" R: ");
Serial.print(red_light);
Serial.print(" G: ");
Serial.print(green_light);
Serial.print(" B: ");
Serial.println(blue_light);
}
// Turn on LED for a half a second
digitalWrite(LED_PIN, HIGH);
delay(500);
digitalWrite(LED_PIN, LOW);
// Reset flag and clear APDS-9960 interrupt (IMPORTANT!)
isr_flag = 0;
if ( !apds.clearAmbientLightInt() ) {
Serial.println("Error clearing interrupt");
}
}
}
void interruptRoutine() {
isr_flag = 1;
}
@@ -0,0 +1,96 @@
/****************************************************************
ColorSensor.ino
APDS-9960 RGB and Gesture Sensor
Shawn Hymel @ SparkFun Electronics
October 15, 2014
https://github.com/sparkfun/APDS-9960_RGB_and_Gesture_Sensor
Tests the color and ambient light sensing abilities of the
APDS-9960. Configures APDS-9960 over I2C and polls the sensor for
ambient light and color levels, which are displayed over the
serial console.
Hardware Connections:
IMPORTANT: The APDS-9960 can only accept 3.3V!
Arduino Pin APDS-9960 Board Function
3.3V VCC Power
GND GND Ground
A4 SDA I2C Data
A5 SCL I2C Clock
Resources:
Include Wire.h and SparkFun_APDS-9960.h
Development environment specifics:
Written in Arduino 1.0.5
Tested with SparkFun Arduino Pro Mini 3.3V
This code is beerware; if you see me (or any other SparkFun
employee) at the local, and you've found our code helpful, please
buy us a round!
Distributed as-is; no warranty is given.
****************************************************************/
#include <Wire.h>
#include <SparkFun_APDS9960.h>
// Global Variables
SparkFun_APDS9960 apds = SparkFun_APDS9960();
uint16_t ambient_light = 0;
uint16_t red_light = 0;
uint16_t green_light = 0;
uint16_t blue_light = 0;
void setup() {
// Initialize Serial port
Serial.begin(9600);
Serial.println();
Serial.println(F("--------------------------------"));
Serial.println(F("SparkFun APDS-9960 - ColorSensor"));
Serial.println(F("--------------------------------"));
// Initialize APDS-9960 (configure I2C and initial values)
if ( apds.init() ) {
Serial.println(F("APDS-9960 initialization complete"));
} else {
Serial.println(F("Something went wrong during APDS-9960 init!"));
}
// Start running the APDS-9960 light sensor (no interrupts)
if ( apds.enableLightSensor(false) ) {
Serial.println(F("Light sensor is now running"));
} else {
Serial.println(F("Something went wrong during light sensor init!"));
}
// Wait for initialization and calibration to finish
delay(500);
}
void loop() {
// Read the light levels (ambient, red, green, blue)
if ( !apds.readAmbientLight(ambient_light) ||
!apds.readRedLight(red_light) ||
!apds.readGreenLight(green_light) ||
!apds.readBlueLight(blue_light) ) {
Serial.println("Error reading light values");
} else {
Serial.print("Ambient: ");
Serial.print(ambient_light);
Serial.print(" Red: ");
Serial.print(red_light);
Serial.print(" Green: ");
Serial.print(green_light);
Serial.print(" Blue: ");
Serial.println(blue_light);
}
// Wait 1 second before next reading
delay(1000);
}
@@ -0,0 +1,128 @@
/****************************************************************
GestureTest.ino
APDS-9960 RGB and Gesture Sensor
Shawn Hymel @ SparkFun Electronics
May 30, 2014
https://github.com/sparkfun/APDS-9960_RGB_and_Gesture_Sensor
Tests the gesture sensing abilities of the APDS-9960. Configures
APDS-9960 over I2C and waits for gesture events. Calculates the
direction of the swipe (up, down, left, right) and displays it
on a serial console.
To perform a NEAR gesture, hold your hand
far above the sensor and move it close to the sensor (within 2
inches). Hold your hand there for at least 1 second and move it
away.
To perform a FAR gesture, hold your hand within 2 inches of the
sensor for at least 1 second and then move it above (out of
range) of the sensor.
Hardware Connections:
IMPORTANT: The APDS-9960 can only accept 3.3V!
Arduino Pin APDS-9960 Board Function
3.3V VCC Power
GND GND Ground
A4 SDA I2C Data
A5 SCL I2C Clock
2 INT Interrupt
Resources:
Include Wire.h and SparkFun_APDS-9960.h
Development environment specifics:
Written in Arduino 1.0.5
Tested with SparkFun Arduino Pro Mini 3.3V
This code is beerware; if you see me (or any other SparkFun
employee) at the local, and you've found our code helpful, please
buy us a round!
Distributed as-is; no warranty is given.
****************************************************************/
#include <Wire.h>
#include <SparkFun_APDS9960.h>
// Pins
#define APDS9960_INT 2 // Needs to be an interrupt pin
// Constants
// Global Variables
SparkFun_APDS9960 apds = SparkFun_APDS9960();
int isr_flag = 0;
void setup() {
// Set interrupt pin as input
pinMode(APDS9960_INT, INPUT);
// Initialize Serial port
Serial.begin(9600);
Serial.println();
Serial.println(F("--------------------------------"));
Serial.println(F("SparkFun APDS-9960 - GestureTest"));
Serial.println(F("--------------------------------"));
// Initialize interrupt service routine
attachInterrupt(0, interruptRoutine, FALLING);
// Initialize APDS-9960 (configure I2C and initial values)
if ( apds.init() ) {
Serial.println(F("APDS-9960 initialization complete"));
} else {
Serial.println(F("Something went wrong during APDS-9960 init!"));
}
// Start running the APDS-9960 gesture sensor engine
if ( apds.enableGestureSensor(true) ) {
Serial.println(F("Gesture sensor is now running"));
} else {
Serial.println(F("Something went wrong during gesture sensor init!"));
}
}
void loop() {
if( isr_flag == 1 ) {
detachInterrupt(0);
handleGesture();
isr_flag = 0;
attachInterrupt(0, interruptRoutine, FALLING);
}
}
void interruptRoutine() {
isr_flag = 1;
}
void handleGesture() {
if ( apds.isGestureAvailable() ) {
switch ( apds.readGesture() ) {
case DIR_UP:
Serial.println("UP");
break;
case DIR_DOWN:
Serial.println("DOWN");
break;
case DIR_LEFT:
Serial.println("LEFT");
break;
case DIR_RIGHT:
Serial.println("RIGHT");
break;
case DIR_NEAR:
Serial.println("NEAR");
break;
case DIR_FAR:
Serial.println("FAR");
break;
default:
Serial.println("NONE");
}
}
}
@@ -0,0 +1,129 @@
/****************************************************************
ProximityInterrupt.ino
APDS-9960 RGB and Gesture Sensor
Shawn Hymel @ SparkFun Electronics
October 24, 2014
https://github.com/sparkfun/APDS-9960_RGB_and_Gesture_Sensor
Tests the proximity interrupt abilities of the APDS-9960.
Configures the APDS-9960 over I2C and waits for an external
interrupt based on high or low proximity conditions. Move your
hand near the sensor and watch the LED on pin 13.
Hardware Connections:
IMPORTANT: The APDS-9960 can only accept 3.3V!
Arduino Pin APDS-9960 Board Function
3.3V VCC Power
GND GND Ground
A4 SDA I2C Data
A5 SCL I2C Clock
2 INT Interrupt
13 - LED
Resources:
Include Wire.h and SparkFun_APDS-9960.h
Development environment specifics:
Written in Arduino 1.0.5
Tested with SparkFun Arduino Pro Mini 3.3V
This code is beerware; if you see me (or any other SparkFun
employee) at the local, and you've found our code helpful, please
buy us a round!
Distributed as-is; no warranty is given.
****************************************************************/
#include <Wire.h>
#include <SparkFun_APDS9960.h>
// Pins
#define APDS9960_INT 2 // Needs to be an interrupt pin
#define LED_PIN 13 // LED for showing interrupt
// Constants
#define PROX_INT_HIGH 50 // Proximity level for interrupt
#define PROX_INT_LOW 0 // No far interrupt
// Global variables
SparkFun_APDS9960 apds = SparkFun_APDS9960();
uint8_t proximity_data = 0;
int isr_flag = 0;
void setup() {
// Set LED as output
pinMode(LED_PIN, OUTPUT);
pinMode(APDS9960_INT, INPUT);
// Initialize Serial port
Serial.begin(9600);
Serial.println();
Serial.println(F("---------------------------------------"));
Serial.println(F("SparkFun APDS-9960 - ProximityInterrupt"));
Serial.println(F("---------------------------------------"));
// Initialize interrupt service routine
attachInterrupt(0, interruptRoutine, FALLING);
// Initialize APDS-9960 (configure I2C and initial values)
if ( apds.init() ) {
Serial.println(F("APDS-9960 initialization complete"));
} else {
Serial.println(F("Something went wrong during APDS-9960 init!"));
}
// Adjust the Proximity sensor gain
if ( !apds.setProximityGain(PGAIN_2X) ) {
Serial.println(F("Something went wrong trying to set PGAIN"));
}
// Set proximity interrupt thresholds
if ( !apds.setProximityIntLowThreshold(PROX_INT_LOW) ) {
Serial.println(F("Error writing low threshold"));
}
if ( !apds.setProximityIntHighThreshold(PROX_INT_HIGH) ) {
Serial.println(F("Error writing high threshold"));
}
// Start running the APDS-9960 proximity sensor (interrupts)
if ( apds.enableProximitySensor(true) ) {
Serial.println(F("Proximity sensor is now running"));
} else {
Serial.println(F("Something went wrong during sensor init!"));
}
}
void loop() {
// If interrupt occurs, print out the proximity level
if ( isr_flag == 1 ) {
// Read proximity level and print it out
if ( !apds.readProximity(proximity_data) ) {
Serial.println("Error reading proximity value");
} else {
Serial.print("Proximity detected! Level: ");
Serial.println(proximity_data);
}
// Turn on LED for a half a second
digitalWrite(LED_PIN, HIGH);
delay(500);
digitalWrite(LED_PIN, LOW);
// Reset flag and clear APDS-9960 interrupt (IMPORTANT!)
isr_flag = 0;
if ( !apds.clearProximityInt() ) {
Serial.println("Error clearing interrupt");
}
}
}
void interruptRoutine() {
isr_flag = 1;
}
@@ -0,0 +1,85 @@
/****************************************************************
ProximityTest.ino
APDS-9960 RGB and Gesture Sensor
Shawn Hymel @ SparkFun Electronics
October 28, 2014
https://github.com/sparkfun/APDS-9960_RGB_and_Gesture_Sensor
Tests the proximity sensing abilities of the APDS-9960.
Configures the APDS-9960 over I2C and polls for the distance to
the object nearest the sensor.
Hardware Connections:
IMPORTANT: The APDS-9960 can only accept 3.3V!
Arduino Pin APDS-9960 Board Function
3.3V VCC Power
GND GND Ground
A4 SDA I2C Data
A5 SCL I2C Clock
Resources:
Include Wire.h and SparkFun_APDS-9960.h
Development environment specifics:
Written in Arduino 1.0.5
Tested with SparkFun Arduino Pro Mini 3.3V
This code is beerware; if you see me (or any other SparkFun
employee) at the local, and you've found our code helpful, please
buy us a round!
Distributed as-is; no warranty is given.
****************************************************************/
#include <Wire.h>
#include <SparkFun_APDS9960.h>
// Global Variables
SparkFun_APDS9960 apds = SparkFun_APDS9960();
uint8_t proximity_data = 0;
void setup() {
// Initialize Serial port
Serial.begin(9600);
Serial.println();
Serial.println(F("------------------------------------"));
Serial.println(F("SparkFun APDS-9960 - ProximitySensor"));
Serial.println(F("------------------------------------"));
// Initialize APDS-9960 (configure I2C and initial values)
if ( apds.init() ) {
Serial.println(F("APDS-9960 initialization complete"));
} else {
Serial.println(F("Something went wrong during APDS-9960 init!"));
}
// Adjust the Proximity sensor gain
if ( !apds.setProximityGain(PGAIN_2X) ) {
Serial.println(F("Something went wrong trying to set PGAIN"));
}
// Start running the APDS-9960 proximity sensor (no interrupts)
if ( apds.enableProximitySensor(false) ) {
Serial.println(F("Proximity sensor is now running"));
} else {
Serial.println(F("Something went wrong during sensor init!"));
}
}
void loop() {
// Read the proximity value
if ( !apds.readProximity(proximity_data) ) {
Serial.println("Error reading proximity value");
} else {
Serial.print("Proximity: ");
Serial.println(proximity_data);
}
// Wait 250 ms before next reading
delay(250);
}
@@ -0,0 +1,9 @@
name=SparkFun APDS9960 RGB and Gesture Sensor
version=1.4.2
author=SparkFun Electronics <techsupport@sparkfun.com>
maintainer=SparkFun Electronics <sparkfun.com>
sentence=Library for the Avago APDS-9960 sensor
paragraph=This library works with the SparkFun Breakout board for the Avago APDS-9960 proximity, light, RGB, and gesture sensor, made by SparkFun Electronics.
category=Sensors
url=https://github.com/sparkfun/SparkFun_APDS-9960_Sensor_Arduino_Library
architectures=*
@@ -0,0 +1,5 @@
This folder should contain the .cpp and .h files for the library.
If backward compatibility is needed, source code should be placed in the library root folder and in a "utilyt" folder.
Check out the [library specification](https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification) for more details.
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,349 @@
/**
* @file SparkFun_APDS-9960.h
* @brief Library for the SparkFun APDS-9960 breakout board
* @author Shawn Hymel (SparkFun Electronics)
*
* @copyright This code is public domain but you buy me a beer if you use
* this and we meet someday (Beerware license).
*
* This library interfaces the Avago APDS-9960 to Arduino over I2C. The library
* relies on the Arduino Wire (I2C) library. to use the library, instantiate an
* APDS9960 object, call init(), and call the appropriate functions.
*/
#ifndef SparkFun_APDS9960_H
#define SparkFun_APDS9960_H
#include <Arduino.h>
/* Debug */
#define DEBUG 0
/* APDS-9960 I2C address */
#define APDS9960_I2C_ADDR 0x39
/* Gesture parameters */
#define GESTURE_THRESHOLD_OUT 10
#define GESTURE_SENSITIVITY_1 50
#define GESTURE_SENSITIVITY_2 20
/* Error code for returned values */
#define ERROR 0xFF
/* Acceptable device IDs */
#define APDS9960_ID_1 0xAB
#define APDS9960_ID_2 0x9C
/* Misc parameters */
#define FIFO_PAUSE_TIME 30 // Wait period (ms) between FIFO reads
/* APDS-9960 register addresses */
#define APDS9960_ENABLE 0x80
#define APDS9960_ATIME 0x81
#define APDS9960_WTIME 0x83
#define APDS9960_AILTL 0x84
#define APDS9960_AILTH 0x85
#define APDS9960_AIHTL 0x86
#define APDS9960_AIHTH 0x87
#define APDS9960_PILT 0x89
#define APDS9960_PIHT 0x8B
#define APDS9960_PERS 0x8C
#define APDS9960_CONFIG1 0x8D
#define APDS9960_PPULSE 0x8E
#define APDS9960_CONTROL 0x8F
#define APDS9960_CONFIG2 0x90
#define APDS9960_ID 0x92
#define APDS9960_STATUS 0x93
#define APDS9960_CDATAL 0x94
#define APDS9960_CDATAH 0x95
#define APDS9960_RDATAL 0x96
#define APDS9960_RDATAH 0x97
#define APDS9960_GDATAL 0x98
#define APDS9960_GDATAH 0x99
#define APDS9960_BDATAL 0x9A
#define APDS9960_BDATAH 0x9B
#define APDS9960_PDATA 0x9C
#define APDS9960_POFFSET_UR 0x9D
#define APDS9960_POFFSET_DL 0x9E
#define APDS9960_CONFIG3 0x9F
#define APDS9960_GPENTH 0xA0
#define APDS9960_GEXTH 0xA1
#define APDS9960_GCONF1 0xA2
#define APDS9960_GCONF2 0xA3
#define APDS9960_GOFFSET_U 0xA4
#define APDS9960_GOFFSET_D 0xA5
#define APDS9960_GOFFSET_L 0xA7
#define APDS9960_GOFFSET_R 0xA9
#define APDS9960_GPULSE 0xA6
#define APDS9960_GCONF3 0xAA
#define APDS9960_GCONF4 0xAB
#define APDS9960_GFLVL 0xAE
#define APDS9960_GSTATUS 0xAF
#define APDS9960_IFORCE 0xE4
#define APDS9960_PICLEAR 0xE5
#define APDS9960_CICLEAR 0xE6
#define APDS9960_AICLEAR 0xE7
#define APDS9960_GFIFO_U 0xFC
#define APDS9960_GFIFO_D 0xFD
#define APDS9960_GFIFO_L 0xFE
#define APDS9960_GFIFO_R 0xFF
/* Bit fields */
#define APDS9960_PON 0b00000001
#define APDS9960_AEN 0b00000010
#define APDS9960_PEN 0b00000100
#define APDS9960_WEN 0b00001000
#define APSD9960_AIEN 0b00010000
#define APDS9960_PIEN 0b00100000
#define APDS9960_GEN 0b01000000
#define APDS9960_GVALID 0b00000001
/* On/Off definitions */
#define OFF 0
#define ON 1
/* Acceptable parameters for setMode */
#define POWER 0
#define AMBIENT_LIGHT 1
#define PROXIMITY 2
#define WAIT 3
#define AMBIENT_LIGHT_INT 4
#define PROXIMITY_INT 5
#define GESTURE 6
#define ALL 7
/* LED Drive values */
#define LED_DRIVE_100MA 0
#define LED_DRIVE_50MA 1
#define LED_DRIVE_25MA 2
#define LED_DRIVE_12_5MA 3
/* Proximity Gain (PGAIN) values */
#define PGAIN_1X 0
#define PGAIN_2X 1
#define PGAIN_4X 2
#define PGAIN_8X 3
/* ALS Gain (AGAIN) values */
#define AGAIN_1X 0
#define AGAIN_4X 1
#define AGAIN_16X 2
#define AGAIN_64X 3
/* Gesture Gain (GGAIN) values */
#define GGAIN_1X 0
#define GGAIN_2X 1
#define GGAIN_4X 2
#define GGAIN_8X 3
/* LED Boost values */
#define LED_BOOST_100 0
#define LED_BOOST_150 1
#define LED_BOOST_200 2
#define LED_BOOST_300 3
/* Gesture wait time values */
#define GWTIME_0MS 0
#define GWTIME_2_8MS 1
#define GWTIME_5_6MS 2
#define GWTIME_8_4MS 3
#define GWTIME_14_0MS 4
#define GWTIME_22_4MS 5
#define GWTIME_30_8MS 6
#define GWTIME_39_2MS 7
/* Default values */
#define DEFAULT_ATIME 219 // 103ms
#define DEFAULT_WTIME 246 // 27ms
#define DEFAULT_PROX_PPULSE 0x87 // 16us, 8 pulses
#define DEFAULT_GESTURE_PPULSE 0x89 // 16us, 10 pulses
#define DEFAULT_POFFSET_UR 0 // 0 offset
#define DEFAULT_POFFSET_DL 0 // 0 offset
#define DEFAULT_CONFIG1 0x60 // No 12x wait (WTIME) factor
#define DEFAULT_LDRIVE LED_DRIVE_100MA
#define DEFAULT_PGAIN PGAIN_4X
#define DEFAULT_AGAIN AGAIN_4X
#define DEFAULT_PILT 0 // Low proximity threshold
#define DEFAULT_PIHT 50 // High proximity threshold
#define DEFAULT_AILT 0xFFFF // Force interrupt for calibration
#define DEFAULT_AIHT 0
#define DEFAULT_PERS 0x11 // 2 consecutive prox or ALS for int.
#define DEFAULT_CONFIG2 0x01 // No saturation interrupts or LED boost
#define DEFAULT_CONFIG3 0 // Enable all photodiodes, no SAI
#define DEFAULT_GPENTH 40 // Threshold for entering gesture mode
#define DEFAULT_GEXTH 30 // Threshold for exiting gesture mode
#define DEFAULT_GCONF1 0x40 // 4 gesture events for int., 1 for exit
#define DEFAULT_GGAIN GGAIN_4X
#define DEFAULT_GLDRIVE LED_DRIVE_100MA
#define DEFAULT_GWTIME GWTIME_2_8MS
#define DEFAULT_GOFFSET 0 // No offset scaling for gesture mode
#define DEFAULT_GPULSE 0xC9 // 32us, 10 pulses
#define DEFAULT_GCONF3 0 // All photodiodes active during gesture
#define DEFAULT_GIEN 0 // Disable gesture interrupts
/* Direction definitions */
enum {
DIR_NONE,
DIR_LEFT,
DIR_RIGHT,
DIR_UP,
DIR_DOWN,
DIR_NEAR,
DIR_FAR,
DIR_ALL
};
/* State definitions */
enum {
N_A_STATE, // NA_STATE - collision with ESP8266WiFi.h
NEAR_STATE,
FAR_STATE,
ALL_STATE
};
/* Container for gesture data */
typedef struct gesture_data_type {
uint8_t u_data[32];
uint8_t d_data[32];
uint8_t l_data[32];
uint8_t r_data[32];
uint8_t index;
uint8_t total_gestures;
uint8_t in_threshold;
uint8_t out_threshold;
} gesture_data_type;
/* APDS9960 Class */
class SparkFun_APDS9960 {
public:
/* Initialization methods */
SparkFun_APDS9960();
~SparkFun_APDS9960();
bool init();
uint8_t getMode();
bool setMode(uint8_t mode, uint8_t enable);
/* Turn the APDS-9960 on and off */
bool enablePower();
bool disablePower();
/* Enable or disable specific sensors */
bool enableLightSensor(bool interrupts = false);
bool disableLightSensor();
bool enableProximitySensor(bool interrupts = false);
bool disableProximitySensor();
bool enableGestureSensor(bool interrupts = true);
bool disableGestureSensor();
/* LED drive strength control */
uint8_t getLEDDrive();
bool setLEDDrive(uint8_t drive);
uint8_t getGestureLEDDrive();
bool setGestureLEDDrive(uint8_t drive);
/* Gain control */
uint8_t getAmbientLightGain();
bool setAmbientLightGain(uint8_t gain);
uint8_t getProximityGain();
bool setProximityGain(uint8_t gain);
uint8_t getGestureGain();
bool setGestureGain(uint8_t gain);
/* Get and set light interrupt thresholds */
bool getLightIntLowThreshold(uint16_t &threshold);
bool setLightIntLowThreshold(uint16_t threshold);
bool getLightIntHighThreshold(uint16_t &threshold);
bool setLightIntHighThreshold(uint16_t threshold);
/* Get and set proximity interrupt thresholds */
bool getProximityIntLowThreshold(uint8_t &threshold);
bool setProximityIntLowThreshold(uint8_t threshold);
bool getProximityIntHighThreshold(uint8_t &threshold);
bool setProximityIntHighThreshold(uint8_t threshold);
/* Get and set interrupt enables */
uint8_t getAmbientLightIntEnable();
bool setAmbientLightIntEnable(uint8_t enable);
uint8_t getProximityIntEnable();
bool setProximityIntEnable(uint8_t enable);
uint8_t getGestureIntEnable();
bool setGestureIntEnable(uint8_t enable);
/* Clear interrupts */
bool clearAmbientLightInt();
bool clearProximityInt();
/* Ambient light methods */
bool readAmbientLight(uint16_t &val);
bool readRedLight(uint16_t &val);
bool readGreenLight(uint16_t &val);
bool readBlueLight(uint16_t &val);
/* Proximity methods */
bool readProximity(uint8_t &val);
/* Gesture methods */
bool isGestureAvailable();
int readGesture();
int readGestureNonBlocking();
private:
/* Gesture processing */
void resetGestureParameters();
bool processGestureData();
bool decodeGesture();
/* Proximity Interrupt Threshold */
uint8_t getProxIntLowThresh();
bool setProxIntLowThresh(uint8_t threshold);
uint8_t getProxIntHighThresh();
bool setProxIntHighThresh(uint8_t threshold);
/* LED Boost Control */
uint8_t getLEDBoost();
bool setLEDBoost(uint8_t boost);
/* Proximity photodiode select */
uint8_t getProxGainCompEnable();
bool setProxGainCompEnable(uint8_t enable);
uint8_t getProxPhotoMask();
bool setProxPhotoMask(uint8_t mask);
/* Gesture threshold control */
uint8_t getGestureEnterThresh();
bool setGestureEnterThresh(uint8_t threshold);
uint8_t getGestureExitThresh();
bool setGestureExitThresh(uint8_t threshold);
/* Gesture LED, gain, and time control */
uint8_t getGestureWaitTime();
bool setGestureWaitTime(uint8_t time);
/* Gesture mode */
uint8_t getGestureMode();
bool setGestureMode(uint8_t mode);
/* Raw I2C Commands */
bool wireWriteByte(uint8_t val);
bool wireWriteDataByte(uint8_t reg, uint8_t val);
bool wireWriteDataBlock(uint8_t reg, uint8_t *val, unsigned int len);
bool wireReadDataByte(uint8_t reg, uint8_t &val);
int wireReadDataBlock(uint8_t reg, uint8_t *val, unsigned int len);
/* Members */
gesture_data_type gesture_data_;
int gesture_ud_delta_;
int gesture_lr_delta_;
int gesture_ud_count_;
int gesture_lr_count_;
int gesture_near_count_;
int gesture_far_count_;
int gesture_state_;
int gesture_motion_;
};
#endif
@@ -0,0 +1,490 @@
/**The MIT License (MIT)
Copyright (c) 2015 by Daniel Eichhorn
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
See more at http://blog.squix.ch
*/
#ifndef DIALOG_PLAIN_FONT_H
#define DIALOG_PLAIN_FONT_H
// OLED library version >= 3.0.0
// Created by http://oleddisplay.squix.ch/ Consider a donation
// In case of problems make sure that you are using the font file with the correct version!
const char Dialog_plain_12[] PROGMEM = {
0x0D, // Width: 13
0x0F, // Height: 15
0x20, // First Char: 32
0xE0, // Numbers of Chars: 224
// Jump Table:
0xFF, 0xFF, 0x00, 0x04, // 32:65535
0x00, 0x00, 0x06, 0x05, // 33:0
0x00, 0x06, 0x07, 0x05, // 34:6
0x00, 0x0D, 0x11, 0x0A, // 35:13
0x00, 0x1E, 0x0E, 0x08, // 36:30
0x00, 0x2C, 0x16, 0x0C, // 37:44
0x00, 0x42, 0x12, 0x09, // 38:66
0x00, 0x54, 0x03, 0x03, // 39:84
0x00, 0x57, 0x06, 0x05, // 40:87
0x00, 0x5D, 0x08, 0x05, // 41:93
0x00, 0x65, 0x0B, 0x07, // 42:101
0x00, 0x70, 0x12, 0x0A, // 43:112
0x00, 0x82, 0x04, 0x03, // 44:130
0x00, 0x86, 0x08, 0x05, // 45:134
0x00, 0x8E, 0x04, 0x03, // 46:142
0x00, 0x92, 0x07, 0x04, // 47:146
0x00, 0x99, 0x0E, 0x08, // 48:153
0x00, 0xA7, 0x0C, 0x07, // 49:167
0x00, 0xB3, 0x0C, 0x07, // 50:179
0x00, 0xBF, 0x0C, 0x07, // 51:191
0x00, 0xCB, 0x0E, 0x08, // 52:203
0x00, 0xD9, 0x0C, 0x07, // 53:217
0x00, 0xE5, 0x0E, 0x08, // 54:229
0x00, 0xF3, 0x0D, 0x08, // 55:243
0x01, 0x00, 0x0E, 0x08, // 56:256
0x01, 0x0E, 0x0E, 0x08, // 57:270
0x01, 0x1C, 0x04, 0x03, // 58:284
0x01, 0x20, 0x04, 0x03, // 59:288
0x01, 0x24, 0x12, 0x0A, // 60:292
0x01, 0x36, 0x12, 0x0A, // 61:310
0x01, 0x48, 0x12, 0x0A, // 62:328
0x01, 0x5A, 0x09, 0x06, // 63:346
0x01, 0x63, 0x16, 0x0C, // 64:355
0x01, 0x79, 0x10, 0x08, // 65:377
0x01, 0x89, 0x0E, 0x08, // 66:393
0x01, 0x97, 0x10, 0x09, // 67:407
0x01, 0xA7, 0x10, 0x09, // 68:423
0x01, 0xB7, 0x0C, 0x07, // 69:439
0x01, 0xC3, 0x0B, 0x07, // 70:451
0x01, 0xCE, 0x12, 0x0A, // 71:462
0x01, 0xE0, 0x10, 0x09, // 72:480
0x01, 0xF0, 0x04, 0x03, // 73:496
0x01, 0xF4, 0x04, 0x03, // 74:500
0x01, 0xF8, 0x0E, 0x08, // 75:504
0x02, 0x06, 0x0C, 0x06, // 76:518
0x02, 0x12, 0x12, 0x0A, // 77:530
0x02, 0x24, 0x10, 0x09, // 78:548
0x02, 0x34, 0x12, 0x0A, // 79:564
0x02, 0x46, 0x0D, 0x08, // 80:582
0x02, 0x53, 0x12, 0x0A, // 81:595
0x02, 0x65, 0x10, 0x09, // 82:613
0x02, 0x75, 0x0E, 0x08, // 83:629
0x02, 0x83, 0x0D, 0x07, // 84:643
0x02, 0x90, 0x10, 0x09, // 85:656
0x02, 0xA0, 0x0F, 0x08, // 86:672
0x02, 0xAF, 0x15, 0x0C, // 87:687
0x02, 0xC4, 0x10, 0x08, // 88:708
0x02, 0xD4, 0x0D, 0x07, // 89:724
0x02, 0xE1, 0x10, 0x09, // 90:737
0x02, 0xF1, 0x06, 0x05, // 91:753
0x02, 0xF7, 0x08, 0x04, // 92:759
0x02, 0xFF, 0x08, 0x05, // 93:767
0x03, 0x07, 0x11, 0x0A, // 94:775
0x03, 0x18, 0x0C, 0x06, // 95:792
0x03, 0x24, 0x05, 0x06, // 96:804
0x03, 0x29, 0x0E, 0x08, // 97:809
0x03, 0x37, 0x0E, 0x08, // 98:823
0x03, 0x45, 0x0C, 0x07, // 99:837
0x03, 0x51, 0x0E, 0x08, // 100:849
0x03, 0x5F, 0x0E, 0x08, // 101:863
0x03, 0x6D, 0x07, 0x04, // 102:877
0x03, 0x74, 0x0E, 0x08, // 103:884
0x03, 0x82, 0x0C, 0x07, // 104:898
0x03, 0x8E, 0x04, 0x03, // 105:910
0x03, 0x92, 0x04, 0x03, // 106:914
0x03, 0x96, 0x0C, 0x07, // 107:918
0x03, 0xA2, 0x04, 0x03, // 108:930
0x03, 0xA6, 0x14, 0x0B, // 109:934
0x03, 0xBA, 0x0C, 0x07, // 110:954
0x03, 0xC6, 0x0E, 0x08, // 111:966
0x03, 0xD4, 0x0E, 0x08, // 112:980
0x03, 0xE2, 0x0E, 0x08, // 113:994
0x03, 0xF0, 0x09, 0x05, // 114:1008
0x03, 0xF9, 0x0C, 0x07, // 115:1017
0x04, 0x05, 0x08, 0x05, // 116:1029
0x04, 0x0D, 0x0C, 0x07, // 117:1037
0x04, 0x19, 0x0D, 0x07, // 118:1049
0x04, 0x26, 0x11, 0x0A, // 119:1062
0x04, 0x37, 0x0C, 0x07, // 120:1079
0x04, 0x43, 0x0D, 0x07, // 121:1091
0x04, 0x50, 0x0E, 0x07, // 122:1104
0x04, 0x5E, 0x0C, 0x07, // 123:1118
0x04, 0x6A, 0x06, 0x05, // 124:1130
0x04, 0x70, 0x0B, 0x07, // 125:1136
0x04, 0x7B, 0x11, 0x0A, // 126:1147
0x04, 0x8C, 0x0C, 0x07, // 127:1164
0x04, 0x98, 0x0C, 0x07, // 128:1176
0x04, 0xA4, 0x0C, 0x07, // 129:1188
0x04, 0xB0, 0x0C, 0x07, // 130:1200
0x04, 0xBC, 0x0C, 0x07, // 131:1212
0x04, 0xC8, 0x0C, 0x07, // 132:1224
0x04, 0xD4, 0x0C, 0x07, // 133:1236
0x04, 0xE0, 0x0C, 0x07, // 134:1248
0x04, 0xEC, 0x0C, 0x07, // 135:1260
0x04, 0xF8, 0x0C, 0x07, // 136:1272
0x05, 0x04, 0x0C, 0x07, // 137:1284
0x05, 0x10, 0x0C, 0x07, // 138:1296
0x05, 0x1C, 0x0C, 0x07, // 139:1308
0x05, 0x28, 0x0C, 0x07, // 140:1320
0x05, 0x34, 0x0C, 0x07, // 141:1332
0x05, 0x40, 0x0C, 0x07, // 142:1344
0x05, 0x4C, 0x0C, 0x07, // 143:1356
0x05, 0x58, 0x0C, 0x07, // 144:1368
0x05, 0x64, 0x0C, 0x07, // 145:1380
0x05, 0x70, 0x0C, 0x07, // 146:1392
0x05, 0x7C, 0x0C, 0x07, // 147:1404
0x05, 0x88, 0x0C, 0x07, // 148:1416
0x05, 0x94, 0x0C, 0x07, // 149:1428
0x05, 0xA0, 0x0C, 0x07, // 150:1440
0x05, 0xAC, 0x0C, 0x07, // 151:1452
0x05, 0xB8, 0x0C, 0x07, // 152:1464
0x05, 0xC4, 0x0C, 0x07, // 153:1476
0x05, 0xD0, 0x0C, 0x07, // 154:1488
0x05, 0xDC, 0x0C, 0x07, // 155:1500
0x05, 0xE8, 0x0C, 0x07, // 156:1512
0x05, 0xF4, 0x0C, 0x07, // 157:1524
0x06, 0x00, 0x0C, 0x07, // 158:1536
0x06, 0x0C, 0x0C, 0x07, // 159:1548
0xFF, 0xFF, 0x00, 0x04, // 160:65535
0x06, 0x18, 0x06, 0x05, // 161:1560
0x06, 0x1E, 0x0E, 0x08, // 162:1566
0x06, 0x2C, 0x0E, 0x08, // 163:1580
0x06, 0x3A, 0x0C, 0x07, // 164:1594
0x06, 0x46, 0x0C, 0x07, // 165:1606
0x06, 0x52, 0x06, 0x05, // 166:1618
0x06, 0x58, 0x0C, 0x07, // 167:1624
0x06, 0x64, 0x07, 0x05, // 168:1636
0x06, 0x6B, 0x16, 0x0D, // 169:1643
0x06, 0x81, 0x0A, 0x06, // 170:1665
0x06, 0x8B, 0x0E, 0x08, // 171:1675
0x06, 0x99, 0x12, 0x0A, // 172:1689
0x06, 0xAB, 0x08, 0x05, // 173:1707
0x06, 0xB3, 0x16, 0x0D, // 174:1715
0x06, 0xC9, 0x09, 0x06, // 175:1737
0x06, 0xD2, 0x09, 0x06, // 176:1746
0x06, 0xDB, 0x12, 0x0A, // 177:1755
0x06, 0xED, 0x08, 0x05, // 178:1773
0x06, 0xF5, 0x07, 0x05, // 179:1781
0x06, 0xFC, 0x09, 0x06, // 180:1788
0x07, 0x05, 0x0E, 0x07, // 181:1797
0x07, 0x13, 0x0C, 0x07, // 182:1811
0x07, 0x1F, 0x03, 0x03, // 183:1823
0x07, 0x22, 0x08, 0x06, // 184:1826
0x07, 0x2A, 0x07, 0x05, // 185:1834
0x07, 0x31, 0x0C, 0x07, // 186:1841
0x07, 0x3D, 0x0E, 0x07, // 187:1853
0x07, 0x4B, 0x16, 0x0B, // 188:1867
0x07, 0x61, 0x16, 0x0C, // 189:1889
0x07, 0x77, 0x16, 0x0B, // 190:1911
0x07, 0x8D, 0x0A, 0x06, // 191:1933
0x07, 0x97, 0x10, 0x08, // 192:1943
0x07, 0xA7, 0x10, 0x08, // 193:1959
0x07, 0xB7, 0x10, 0x08, // 194:1975
0x07, 0xC7, 0x10, 0x08, // 195:1991
0x07, 0xD7, 0x0E, 0x07, // 196:2007
0x07, 0xE5, 0x0E, 0x07, // 197:2021
0x07, 0xF3, 0x14, 0x0B, // 198:2035
0x08, 0x07, 0x10, 0x09, // 199:2055
0x08, 0x17, 0x0C, 0x07, // 200:2071
0x08, 0x23, 0x0C, 0x07, // 201:2083
0x08, 0x2F, 0x0C, 0x07, // 202:2095
0x08, 0x3B, 0x0C, 0x07, // 203:2107
0x08, 0x47, 0x04, 0x03, // 204:2119
0x08, 0x4B, 0x05, 0x03, // 205:2123
0x08, 0x50, 0x05, 0x03, // 206:2128
0x08, 0x55, 0x07, 0x05, // 207:2133
0x08, 0x5C, 0x10, 0x09, // 208:2140
0x08, 0x6C, 0x10, 0x09, // 209:2156
0x08, 0x7C, 0x12, 0x0A, // 210:2172
0x08, 0x8E, 0x12, 0x0A, // 211:2190
0x08, 0xA0, 0x12, 0x0A, // 212:2208
0x08, 0xB2, 0x12, 0x0A, // 213:2226
0x08, 0xC4, 0x12, 0x0A, // 214:2244
0x08, 0xD6, 0x10, 0x0A, // 215:2262
0x08, 0xE6, 0x12, 0x0A, // 216:2278
0x08, 0xF8, 0x10, 0x09, // 217:2296
0x09, 0x08, 0x10, 0x09, // 218:2312
0x09, 0x18, 0x10, 0x09, // 219:2328
0x09, 0x28, 0x10, 0x09, // 220:2344
0x09, 0x38, 0x0D, 0x07, // 221:2360
0x09, 0x45, 0x0E, 0x08, // 222:2373
0x09, 0x53, 0x0E, 0x08, // 223:2387
0x09, 0x61, 0x0E, 0x08, // 224:2401
0x09, 0x6F, 0x0E, 0x08, // 225:2415
0x09, 0x7D, 0x0E, 0x08, // 226:2429
0x09, 0x8B, 0x0E, 0x08, // 227:2443
0x09, 0x99, 0x0E, 0x08, // 228:2457
0x09, 0xA7, 0x0E, 0x08, // 229:2471
0x09, 0xB5, 0x16, 0x0C, // 230:2485
0x09, 0xCB, 0x0C, 0x07, // 231:2507
0x09, 0xD7, 0x0E, 0x08, // 232:2519
0x09, 0xE5, 0x0E, 0x08, // 233:2533
0x09, 0xF3, 0x0E, 0x08, // 234:2547
0x0A, 0x01, 0x0E, 0x08, // 235:2561
0x0A, 0x0F, 0x04, 0x03, // 236:2575
0x0A, 0x13, 0x05, 0x03, // 237:2579
0x0A, 0x18, 0x05, 0x03, // 238:2584
0x0A, 0x1D, 0x05, 0x03, // 239:2589
0x0A, 0x22, 0x0E, 0x08, // 240:2594
0x0A, 0x30, 0x0C, 0x07, // 241:2608
0x0A, 0x3C, 0x0E, 0x08, // 242:2620
0x0A, 0x4A, 0x0E, 0x08, // 243:2634
0x0A, 0x58, 0x0E, 0x08, // 244:2648
0x0A, 0x66, 0x0E, 0x08, // 245:2662
0x0A, 0x74, 0x0E, 0x08, // 246:2676
0x0A, 0x82, 0x11, 0x0A, // 247:2690
0x0A, 0x93, 0x0E, 0x08, // 248:2707
0x0A, 0xA1, 0x0C, 0x07, // 249:2721
0x0A, 0xAD, 0x0C, 0x07, // 250:2733
0x0A, 0xB9, 0x0C, 0x07, // 251:2745
0x0A, 0xC5, 0x0C, 0x07, // 252:2757
0x0A, 0xD1, 0x0D, 0x07, // 253:2769
0x0A, 0xDE, 0x0E, 0x08, // 254:2782
0x0A, 0xEC, 0x0B, 0x07, // 255:2796
// Font Data:
0x00,0x00,0x00,0x00,0xF8,0x09, // 33
0x00,0x00,0x38,0x00,0x00,0x00,0x38, // 34
0x00,0x00,0x00,0x01,0x40,0x0D,0xC0,0x03,0x78,0x01,0x40,0x0F,0xE0,0x01,0x58,0x01,0x40, // 35
0x00,0x00,0x70,0x08,0xC8,0x08,0xFC,0x1F,0x88,0x08,0x88,0x0D,0x18,0x07, // 36
0x00,0x00,0x70,0x00,0x88,0x00,0x88,0x08,0x70,0x06,0x80,0x01,0x40,0x00,0x30,0x07,0x88,0x08,0x80,0x08,0x00,0x07, // 37
0x00,0x00,0x80,0x07,0xF0,0x0C,0x48,0x08,0x88,0x09,0x08,0x0B,0x00,0x06,0x80,0x0F,0x80,0x08, // 38
0x00,0x00,0x38, // 39
0x00,0x00,0xF0,0x07,0x0C,0x18, // 40
0x00,0x00,0x00,0x00,0x1C,0x18,0xE0,0x07, // 41
0x00,0x00,0x50,0x00,0x60,0x00,0xF8,0x00,0x60,0x00,0x50, // 42
0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x01,0xF0,0x0F,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01, // 43
0x00,0x10,0x00,0x0C, // 44
0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x01, // 45
0x00,0x00,0x00,0x08, // 46
0x00,0x30,0x00,0x0F,0xE0,0x00,0x18, // 47
0x00,0x00,0xE0,0x03,0x18,0x0C,0x08,0x08,0x08,0x08,0x18,0x0C,0xE0,0x03, // 48
0x00,0x00,0x08,0x08,0x08,0x08,0xF8,0x0F,0x00,0x08,0x00,0x08, // 49
0x00,0x00,0x18,0x0C,0x08,0x0E,0x08,0x0B,0x88,0x08,0x70,0x08, // 50
0x00,0x0C,0x08,0x08,0x48,0x08,0x48,0x08,0xC8,0x0C,0xB0,0x07, // 51
0x00,0x00,0x00,0x03,0xC0,0x02,0x60,0x02,0x18,0x02,0xF8,0x0F,0x00,0x02, // 52
0x00,0x0C,0x78,0x08,0x48,0x08,0x48,0x08,0xC8,0x0C,0x80,0x07, // 53
0x00,0x00,0xE0,0x03,0x90,0x0C,0x48,0x08,0x48,0x08,0xC8,0x0C,0x88,0x07, // 54
0x00,0x00,0x08,0x00,0x08,0x08,0x08,0x0E,0xC8,0x03,0x78,0x00,0x18, // 55
0x00,0x00,0x70,0x07,0x88,0x09,0x88,0x08,0x88,0x08,0x88,0x09,0x70,0x07, // 56
0x00,0x00,0xF0,0x08,0x98,0x09,0x08,0x09,0x08,0x09,0x98,0x04,0xE0,0x03, // 57
0x00,0x00,0x40,0x08, // 58
0x00,0x10,0x20,0x0C, // 59
0x00,0x00,0x80,0x01,0x80,0x01,0x80,0x03,0x40,0x02,0x40,0x02,0x60,0x04,0x20,0x04,0x20,0x04, // 60
0x00,0x00,0x40,0x02,0x40,0x02,0x40,0x02,0x40,0x02,0x40,0x02,0x40,0x02,0x40,0x02,0x40,0x02, // 61
0x00,0x00,0x20,0x04,0x20,0x04,0x40,0x02,0x40,0x02,0xC0,0x02,0x80,0x01,0x80,0x01,0x00,0x01, // 62
0x00,0x00,0x08,0x00,0x88,0x0B,0xC8,0x00,0x70, // 63
0x00,0x00,0xC0,0x07,0x20,0x08,0x10,0x10,0x88,0x23,0x48,0x24,0x48,0x24,0x48,0x24,0xD0,0x17,0x30,0x04,0xC0,0x03, // 64
0x00,0x08,0x00,0x0F,0xE0,0x03,0x38,0x02,0x18,0x02,0xE0,0x02,0x00,0x07,0x00,0x0C, // 65
0x00,0x00,0xF8,0x0F,0x88,0x08,0x88,0x08,0x88,0x08,0x88,0x08,0x70,0x07, // 66
0x00,0x00,0xE0,0x03,0x10,0x04,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x10,0x04, // 67
0x00,0x00,0xF8,0x0F,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x10,0x04,0xE0,0x03, // 68
0x00,0x00,0xF8,0x0F,0x88,0x08,0x88,0x08,0x88,0x08,0x88,0x08, // 69
0x00,0x00,0xF8,0x0F,0x88,0x00,0x88,0x00,0x88,0x00,0x08, // 70
0x00,0x00,0xE0,0x03,0x10,0x04,0x08,0x08,0x08,0x08,0x08,0x08,0x88,0x08,0x88,0x08,0x90,0x07, // 71
0x00,0x00,0xF8,0x0F,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0xF8,0x0F, // 72
0x00,0x00,0xF8,0x0F, // 73
0x00,0x40,0xF8,0x3F, // 74
0x00,0x00,0xF8,0x0F,0xC0,0x00,0x60,0x01,0x30,0x02,0x18,0x04,0x08,0x08, // 75
0x00,0x00,0xF8,0x0F,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08, // 76
0x00,0x00,0xF8,0x0F,0x18,0x00,0xE0,0x00,0x00,0x03,0x00,0x03,0xE0,0x00,0x18,0x00,0xF8,0x0F, // 77
0x00,0x00,0xF8,0x0F,0x18,0x00,0x60,0x00,0xC0,0x01,0x00,0x03,0x00,0x0C,0xF8,0x0F, // 78
0x00,0x00,0xE0,0x03,0x10,0x04,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x10,0x04,0xE0,0x03, // 79
0x00,0x00,0xF8,0x0F,0x88,0x00,0x88,0x00,0x88,0x00,0x88,0x00,0x70, // 80
0x00,0x00,0xE0,0x03,0x10,0x04,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x18,0x10,0x24,0xE0,0x03, // 81
0x00,0x00,0xF8,0x0F,0x88,0x00,0x88,0x00,0x88,0x00,0x88,0x01,0x70,0x07,0x00,0x0C, // 82
0x00,0x00,0x70,0x0C,0xC8,0x08,0x88,0x08,0x88,0x08,0x88,0x08,0x18,0x07, // 83
0x08,0x00,0x08,0x00,0x08,0x00,0xF8,0x0F,0x08,0x00,0x08,0x00,0x08, // 84
0x00,0x00,0xF8,0x07,0x00,0x0C,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x0C,0xF8,0x07, // 85
0x08,0x00,0x78,0x00,0xC0,0x01,0x00,0x0E,0x00,0x0E,0x80,0x03,0x70,0x00,0x18, // 86
0x00,0x00,0xF8,0x00,0x80,0x0F,0x00,0x0C,0xC0,0x03,0x38,0x00,0x78,0x00,0x80,0x07,0x00,0x0C,0xC0,0x07,0x78, // 87
0x00,0x00,0x08,0x0C,0x30,0x06,0xE0,0x01,0xC0,0x01,0x30,0x03,0x18,0x0C,0x00,0x08, // 88
0x08,0x00,0x10,0x00,0x60,0x00,0x80,0x0F,0x60,0x00,0x18,0x00,0x08, // 89
0x00,0x00,0x08,0x0C,0x08,0x0E,0x08,0x0B,0x88,0x08,0x68,0x08,0x38,0x08,0x18,0x08, // 90
0x00,0x00,0xFC,0x1F,0x04,0x10, // 91
0x18,0x00,0xE0,0x00,0x00,0x0F,0x00,0x30, // 92
0x00,0x00,0x00,0x00,0x04,0x10,0xFC,0x1F, // 93
0x00,0x00,0x40,0x00,0x20,0x00,0x30,0x00,0x18,0x00,0x08,0x00,0x10,0x00,0x20,0x00,0x40, // 94
0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x40, // 95
0x00,0x00,0x02,0x00,0x0C, // 96
0x00,0x00,0x60,0x06,0x20,0x09,0x20,0x09,0x20,0x09,0x60,0x05,0xC0,0x0F, // 97
0x00,0x00,0xFC,0x0F,0x40,0x04,0x20,0x08,0x20,0x08,0x60,0x0C,0xC0,0x07, // 98
0x00,0x00,0xC0,0x07,0x60,0x0C,0x20,0x08,0x20,0x08,0x20,0x08, // 99
0x00,0x00,0xC0,0x07,0x60,0x0C,0x20,0x08,0x20,0x08,0x40,0x04,0xFC,0x0F, // 100
0x00,0x00,0xC0,0x07,0x60,0x0D,0x20,0x09,0x20,0x09,0x60,0x09,0xC0,0x09, // 101
0x20,0x00,0xF8,0x0F,0x24,0x00,0x24, // 102
0x00,0x00,0xC0,0x07,0x60,0x4C,0x20,0x48,0x20,0x48,0x40,0x64,0xE0,0x3F, // 103
0x00,0x00,0xFC,0x0F,0x40,0x00,0x20,0x00,0x20,0x00,0xC0,0x0F, // 104
0x00,0x00,0xE4,0x0F, // 105
0x00,0x40,0xE4,0x3F, // 106
0x00,0x00,0xFC,0x0F,0x00,0x01,0x80,0x02,0x40,0x04,0x20,0x08, // 107
0x00,0x00,0xFC,0x0F, // 108
0x00,0x00,0xE0,0x0F,0x40,0x00,0x20,0x00,0x20,0x00,0xC0,0x0F,0x40,0x00,0x20,0x00,0x20,0x00,0xC0,0x0F, // 109
0x00,0x00,0xE0,0x0F,0x40,0x00,0x20,0x00,0x20,0x00,0xC0,0x0F, // 110
0x00,0x00,0xC0,0x07,0x60,0x0C,0x20,0x08,0x20,0x08,0x60,0x0C,0xC0,0x07, // 111
0x00,0x00,0xE0,0x7F,0x40,0x04,0x20,0x08,0x20,0x08,0x60,0x0C,0xC0,0x07, // 112
0x00,0x00,0xC0,0x07,0x60,0x0C,0x20,0x08,0x20,0x08,0x40,0x04,0xE0,0x7F, // 113
0x00,0x00,0xE0,0x0F,0x40,0x00,0x20,0x00,0x20, // 114
0x00,0x00,0xC0,0x08,0x20,0x09,0x20,0x09,0x20,0x09,0x20,0x06, // 115
0x20,0x00,0xF8,0x0F,0x20,0x08,0x20,0x08, // 116
0x00,0x00,0xE0,0x07,0x00,0x08,0x00,0x08,0x00,0x04,0xE0,0x0F, // 117
0x00,0x00,0xE0,0x00,0x00,0x07,0x00,0x08,0x00,0x07,0xE0,0x01,0x20, // 118
0x00,0x00,0xE0,0x01,0x00,0x0E,0x00,0x0F,0xE0,0x00,0xE0,0x01,0x00,0x0E,0x00,0x0F,0xE0, // 119
0x00,0x00,0x20,0x0C,0xC0,0x06,0x80,0x01,0xC0,0x06,0x60,0x0C, // 120
0x00,0x00,0xE0,0x40,0x00,0x67,0x00,0x38,0x00,0x07,0xE0,0x00,0x20, // 121
0x00,0x00,0x20,0x0C,0x20,0x0E,0x20,0x0B,0xA0,0x08,0x60,0x08,0x20,0x08, // 122
0x00,0x00,0x80,0x00,0x80,0x00,0x7C,0x3F,0x04,0x20,0x04,0x20, // 123
0x00,0x00,0x00,0x00,0xFC,0x3F, // 124
0x00,0x00,0x04,0x20,0x04,0x20,0x7C,0x3F,0x80,0x00,0x80, // 125
0x00,0x00,0x00,0x01,0x80,0x00,0x80,0x00,0x80,0x00,0x00,0x01,0x00,0x01,0x00,0x01,0x80, // 126
0xF8,0x3F,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0xF8,0x3F, // 127
0xF8,0x3F,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0xF8,0x3F, // 128
0xF8,0x3F,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0xF8,0x3F, // 129
0xF8,0x3F,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0xF8,0x3F, // 130
0xF8,0x3F,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0xF8,0x3F, // 131
0xF8,0x3F,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0xF8,0x3F, // 132
0xF8,0x3F,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0xF8,0x3F, // 133
0xF8,0x3F,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0xF8,0x3F, // 134
0xF8,0x3F,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0xF8,0x3F, // 135
0xF8,0x3F,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0xF8,0x3F, // 136
0xF8,0x3F,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0xF8,0x3F, // 137
0xF8,0x3F,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0xF8,0x3F, // 138
0xF8,0x3F,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0xF8,0x3F, // 139
0xF8,0x3F,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0xF8,0x3F, // 140
0xF8,0x3F,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0xF8,0x3F, // 141
0xF8,0x3F,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0xF8,0x3F, // 142
0xF8,0x3F,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0xF8,0x3F, // 143
0xF8,0x3F,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0xF8,0x3F, // 144
0xF8,0x3F,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0xF8,0x3F, // 145
0xF8,0x3F,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0xF8,0x3F, // 146
0xF8,0x3F,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0xF8,0x3F, // 147
0xF8,0x3F,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0xF8,0x3F, // 148
0xF8,0x3F,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0xF8,0x3F, // 149
0xF8,0x3F,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0xF8,0x3F, // 150
0xF8,0x3F,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0xF8,0x3F, // 151
0xF8,0x3F,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0xF8,0x3F, // 152
0xF8,0x3F,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0xF8,0x3F, // 153
0xF8,0x3F,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0xF8,0x3F, // 154
0xF8,0x3F,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0xF8,0x3F, // 155
0xF8,0x3F,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0xF8,0x3F, // 156
0xF8,0x3F,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0xF8,0x3F, // 157
0xF8,0x3F,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0xF8,0x3F, // 158
0xF8,0x3F,0x08,0x20,0x08,0x20,0x08,0x20,0x08,0x20,0xF8,0x3F, // 159
0x00,0x00,0x00,0x00,0xC8,0x0F, // 161
0x00,0x00,0xC0,0x07,0x60,0x0C,0x20,0x08,0xF0,0x3F,0x20,0x08,0x20,0x08, // 162
0x00,0x00,0x80,0x08,0xF0,0x0F,0x88,0x08,0x88,0x08,0x88,0x08,0x08,0x08, // 163
0x00,0x00,0xC0,0x07,0x40,0x04,0x40,0x04,0x40,0x04,0xC0,0x07, // 164
0x00,0x00,0x58,0x01,0x60,0x01,0x80,0x0F,0x60,0x01,0x58,0x01, // 165
0x00,0x00,0x00,0x00,0x78,0x3C, // 166
0x00,0x00,0xB0,0x21,0x48,0x22,0x48,0x24,0x88,0x1C,0x00,0x03, // 167
0x00,0x00,0x04,0x00,0x00,0x00,0x04, // 168
0x00,0x00,0x00,0x00,0xE0,0x03,0x30,0x06,0xD8,0x0D,0x28,0x0A,0x28,0x0A,0x28,0x0A,0x18,0x0C,0x30,0x06,0xE0,0x03, // 169
0x00,0x00,0xE8,0x02,0xA8,0x02,0xA8,0x02,0xF0,0x02, // 170
0x00,0x00,0x00,0x01,0x80,0x02,0x40,0x05,0x80,0x01,0xC0,0x02,0x40,0x04, // 171
0x00,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x07, // 172
0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x01, // 173
0x00,0x00,0x00,0x00,0xE0,0x03,0x30,0x06,0x18,0x0C,0xE8,0x0B,0xA8,0x08,0x68,0x0B,0x18,0x0C,0x30,0x06,0xE0,0x03, // 174
0x00,0x00,0x04,0x00,0x04,0x00,0x04,0x00,0x04, // 175
0x00,0x00,0x30,0x00,0x48,0x00,0x48,0x00,0x30, // 176
0x00,0x00,0x80,0x08,0x80,0x08,0x80,0x08,0xF0,0x0B,0x80,0x08,0x80,0x08,0x80,0x08,0x80,0x08, // 177
0x08,0x01,0x88,0x01,0x48,0x01,0x38,0x01, // 178
0x08,0x01,0x28,0x01,0x28,0x01,0xD8, // 179
0x00,0x00,0x00,0x00,0x08,0x00,0x04,0x00,0x02, // 180
0x00,0x00,0xE0,0x7F,0x00,0x08,0x00,0x08,0x00,0x08,0xE0,0x0F,0x00,0x08, // 181
0x20,0x00,0xF0,0x00,0xF8,0x00,0xF8,0x3F,0x08,0x00,0xF8,0x3F, // 182
0x00,0x00,0x80, // 183
0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x60, // 184
0x00,0x00,0x88,0x00,0xF8,0x00,0x80, // 185
0x00,0x00,0x70,0x02,0x88,0x02,0x88,0x02,0x88,0x02,0x70,0x02, // 186
0x00,0x00,0x40,0x06,0x80,0x02,0x40,0x05,0xC0,0x02,0x80,0x01,0x00,0x01, // 187
0x00,0x00,0x88,0x00,0xF8,0x00,0x80,0x0C,0x00,0x03,0x80,0x00,0x60,0x00,0x18,0x07,0x00,0x05,0x80,0x0F,0x00,0x04, // 188
0x00,0x00,0x88,0x00,0xF8,0x00,0x80,0x08,0x00,0x06,0x80,0x01,0x40,0x00,0xB0,0x08,0x88,0x0C,0x80,0x0A,0x80,0x09, // 189
0x88,0x00,0xA8,0x00,0xA8,0x00,0xD8,0x0C,0x00,0x03,0xC0,0x00,0x20,0x00,0x18,0x07,0x80,0x04,0x80,0x0F,0x00,0x04, // 190
0x00,0x00,0x00,0x07,0x80,0x09,0xE8,0x08,0x00,0x08, // 191
0x00,0x08,0x00,0x0F,0xE0,0x03,0x39,0x02,0x1A,0x02,0xE0,0x02,0x00,0x07,0x00,0x0C, // 192
0x00,0x08,0x00,0x0F,0xE0,0x03,0x38,0x02,0x1B,0x02,0xE1,0x02,0x00,0x07,0x00,0x0C, // 193
0x00,0x08,0x00,0x0F,0xE0,0x03,0x3A,0x02,0x1B,0x02,0xE0,0x02,0x00,0x07,0x00,0x0C, // 194
0x00,0x08,0x00,0x0F,0xE3,0x03,0x39,0x02,0x1A,0x02,0xE3,0x02,0x00,0x07,0x00,0x0C, // 195
0x00,0x0C,0x80,0x07,0xF2,0x02,0x08,0x02,0xF2,0x02,0x80,0x07,0x00,0x0C, // 196
0x00,0x0C,0x80,0x03,0x77,0x02,0x19,0x02,0x66,0x02,0x80,0x03,0x00,0x0C, // 197
0x00,0x0C,0x00,0x07,0xE0,0x03,0x38,0x02,0x08,0x02,0xF8,0x0F,0x88,0x08,0x88,0x08,0x88,0x08,0x88,0x08, // 198
0x00,0x00,0xE0,0x03,0x10,0x06,0x08,0x0C,0x08,0x4C,0x08,0x7C,0x08,0x0C,0x10,0x04, // 199
0x00,0x00,0xF8,0x0F,0x89,0x08,0x8A,0x08,0x88,0x08,0x88,0x08, // 200
0x00,0x00,0xF8,0x0F,0x88,0x08,0x8A,0x08,0x89,0x08,0x88,0x08, // 201
0x00,0x00,0xF8,0x0F,0x8A,0x08,0x89,0x08,0x8A,0x08,0x88,0x08, // 202
0x00,0x00,0xF8,0x0F,0x8A,0x08,0x88,0x08,0x8A,0x08,0x88,0x08, // 203
0x01,0x00,0xFA,0x0F, // 204
0x00,0x00,0xFA,0x0F,0x01, // 205
0x02,0x00,0xF9,0x0F,0x02, // 206
0x00,0x00,0x02,0x00,0xF8,0x0F,0x02, // 207
0x80,0x00,0xF8,0x0F,0x88,0x08,0x88,0x08,0x08,0x08,0x08,0x08,0x10,0x04,0xE0,0x03, // 208
0x00,0x00,0xF8,0x0F,0x1A,0x00,0x61,0x00,0xC3,0x01,0x02,0x03,0x01,0x0C,0xF8,0x0F, // 209
0x00,0x00,0xE0,0x03,0x10,0x04,0x08,0x08,0x09,0x08,0x0A,0x08,0x08,0x08,0x10,0x04,0xE0,0x03, // 210
0x00,0x00,0xE0,0x03,0x10,0x04,0x08,0x08,0x0A,0x08,0x09,0x08,0x08,0x08,0x10,0x04,0xE0,0x03, // 211
0x00,0x00,0xE0,0x03,0x10,0x04,0x0A,0x08,0x09,0x08,0x09,0x08,0x0A,0x08,0x10,0x04,0xE0,0x03, // 212
0x00,0x00,0xE0,0x03,0x10,0x04,0x0B,0x08,0x09,0x08,0x0A,0x08,0x0B,0x08,0x10,0x04,0xE0,0x03, // 213
0x00,0x00,0xE0,0x03,0x10,0x04,0x0A,0x08,0x08,0x08,0x08,0x08,0x0A,0x08,0x10,0x04,0xE0,0x03, // 214
0x00,0x00,0x00,0x00,0x20,0x04,0x40,0x02,0x80,0x01,0x80,0x01,0x40,0x02,0x20,0x04, // 215
0x00,0x00,0xE0,0x0B,0x10,0x04,0x08,0x0B,0x88,0x09,0xC8,0x08,0x68,0x08,0x10,0x04,0xE8,0x03, // 216
0x00,0x00,0xF8,0x07,0x00,0x0C,0x01,0x08,0x02,0x08,0x00,0x08,0x00,0x0C,0xF8,0x07, // 217
0x00,0x00,0xF8,0x07,0x00,0x0C,0x00,0x08,0x02,0x08,0x01,0x08,0x00,0x0C,0xF8,0x07, // 218
0x00,0x00,0xF8,0x07,0x00,0x0C,0x03,0x08,0x01,0x08,0x03,0x08,0x00,0x0C,0xF8,0x07, // 219
0x00,0x00,0xF8,0x07,0x00,0x0C,0x02,0x08,0x00,0x08,0x02,0x08,0x00,0x0C,0xF8,0x07, // 220
0x08,0x00,0x10,0x00,0x60,0x00,0x82,0x0F,0x60,0x00,0x18,0x00,0x08, // 221
0x00,0x00,0xF8,0x0F,0x20,0x02,0x20,0x02,0x20,0x02,0x20,0x02,0xC0,0x01, // 222
0x00,0x00,0xF8,0x0F,0x04,0x00,0xE4,0x08,0x94,0x08,0x18,0x09,0x00,0x06, // 223
0x00,0x00,0x60,0x06,0x24,0x09,0x28,0x09,0x30,0x09,0x60,0x05,0xC0,0x0F, // 224
0x00,0x00,0x60,0x06,0x20,0x09,0x30,0x09,0x28,0x09,0x64,0x05,0xC0,0x0F, // 225
0x00,0x00,0x60,0x06,0x38,0x09,0x24,0x09,0x2C,0x09,0x70,0x05,0xC0,0x0F, // 226
0x00,0x00,0x60,0x06,0x2C,0x09,0x24,0x09,0x28,0x09,0x6C,0x05,0xC0,0x0F, // 227
0x00,0x00,0x60,0x06,0x24,0x09,0x20,0x09,0x24,0x09,0x60,0x05,0xC0,0x0F, // 228
0x00,0x00,0x60,0x06,0x24,0x09,0x2A,0x09,0x2A,0x09,0x64,0x05,0xC0,0x0F, // 229
0x00,0x00,0x20,0x07,0xA0,0x08,0xA0,0x08,0xA0,0x0C,0xC0,0x07,0x60,0x0D,0x20,0x09,0x20,0x09,0x60,0x09,0xC0,0x09, // 230
0x00,0x00,0xC0,0x07,0x60,0x0C,0x20,0x4C,0x20,0x7C,0x20,0x04, // 231
0x00,0x00,0xC0,0x07,0x64,0x0D,0x2C,0x09,0x20,0x09,0x60,0x09,0xC0,0x09, // 232
0x00,0x00,0xC0,0x07,0x60,0x0D,0x20,0x09,0x2C,0x09,0x64,0x09,0xC0,0x09, // 233
0x00,0x00,0xC0,0x07,0x68,0x0D,0x24,0x09,0x24,0x09,0x68,0x09,0xC0,0x09, // 234
0x00,0x00,0xC0,0x07,0x60,0x0D,0x24,0x09,0x20,0x09,0x64,0x09,0xC0,0x09, // 235
0x04,0x00,0xF8,0x0F, // 236
0x00,0x00,0xF8,0x0F,0x04, // 237
0x08,0x00,0xE4,0x0F,0x08, // 238
0x04,0x00,0xE0,0x0F,0x04, // 239
0x00,0x00,0xC0,0x07,0x74,0x0C,0x2C,0x08,0x38,0x08,0x24,0x0C,0xC0,0x07, // 240
0x00,0x00,0xE0,0x0F,0x4C,0x00,0x2C,0x00,0x2C,0x00,0xC0,0x0F, // 241
0x00,0x00,0xC0,0x07,0x64,0x0C,0x2C,0x08,0x20,0x08,0x60,0x0C,0xC0,0x07, // 242
0x00,0x00,0xC0,0x07,0x60,0x0C,0x20,0x08,0x2C,0x08,0x64,0x0C,0xC0,0x07, // 243
0x00,0x00,0xC0,0x07,0x68,0x0C,0x24,0x08,0x24,0x08,0x68,0x0C,0xC0,0x07, // 244
0x00,0x00,0xC0,0x07,0x6C,0x0C,0x24,0x08,0x28,0x08,0x6C,0x0C,0xC0,0x07, // 245
0x00,0x00,0xC0,0x07,0x64,0x0C,0x20,0x08,0x20,0x08,0x64,0x0C,0xC0,0x07, // 246
0x00,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0xA0,0x02,0x80,0x00,0x80,0x00,0x80,0x00,0x80, // 247
0x00,0x00,0xC0,0x0F,0x60,0x0C,0x20,0x0B,0xA0,0x08,0x60,0x0C,0xE0,0x07, // 248
0x00,0x00,0xE0,0x07,0x04,0x08,0x18,0x08,0x00,0x04,0xE0,0x0F, // 249
0x00,0x00,0xE0,0x07,0x00,0x08,0x18,0x08,0x04,0x04,0xE0,0x0F, // 250
0x00,0x00,0xE0,0x07,0x18,0x08,0x04,0x08,0x18,0x04,0xE0,0x0F, // 251
0x00,0x00,0xE0,0x07,0x04,0x08,0x00,0x08,0x04,0x04,0xE0,0x0F, // 252
0x00,0x00,0xE0,0x40,0x00,0x67,0x10,0x38,0x0C,0x07,0xE4,0x01,0x20, // 253
0x00,0x00,0xFC,0x7F,0x40,0x04,0x20,0x08,0x20,0x08,0x60,0x0C,0xC0,0x07, // 254
0x00,0x00,0xE0,0x40,0x04,0x47,0x00,0x38,0x84,0x07,0xE0 // 255
};
#endif
+831
View File
@@ -0,0 +1,831 @@
/**
* The MIT License (MIT)
*
* Copyright (c) 2016 by Daniel Eichhorn
* Copyright (c) 2016 by Fabrice Weinberg
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* Credits for parts of this code go to Mike Rankin. Thank you so much for sharing!
*/
#include "OLEDDisplay.h"
OLEDDisplay::~OLEDDisplay() {
end();
}
bool OLEDDisplay::init() {
if (!this->connect()) {
DEBUG_OLEDDISPLAY("[OLEDDISPLAY][init] Can't establish connection to display\n");
return false;
}
if(this->buffer==NULL) {
this->buffer = (uint8_t*) malloc(sizeof(uint8_t) * DISPLAY_BUFFER_SIZE);
if(!this->buffer) {
DEBUG_OLEDDISPLAY("[OLEDDISPLAY][init] Not enough memory to create display\n");
return false;
}
}
#ifdef OLEDDISPLAY_DOUBLE_BUFFER
if(this->buffer_back==NULL) {
this->buffer_back = (uint8_t*) malloc(sizeof(uint8_t) * DISPLAY_BUFFER_SIZE);
if(!this->buffer_back) {
DEBUG_OLEDDISPLAY("[OLEDDISPLAY][init] Not enough memory to create back buffer\n");
free(this->buffer);
return false;
}
}
#endif
sendInitCommands();
resetDisplay();
return true;
}
void OLEDDisplay::end() {
if (this->buffer) { free(this->buffer); this->buffer = NULL; }
#ifdef OLEDDISPLAY_DOUBLE_BUFFER
if (this->buffer_back) { free(this->buffer_back); this->buffer_back = NULL; }
#endif
if (this->logBuffer != NULL) { free(this->logBuffer); this->logBuffer = NULL; }
}
void OLEDDisplay::resetDisplay(void) {
clear();
#ifdef OLEDDISPLAY_DOUBLE_BUFFER
memset(buffer_back, 1, DISPLAY_BUFFER_SIZE);
#endif
display();
}
void OLEDDisplay::setColor(OLEDDISPLAY_COLOR color) {
this->color = color;
}
void OLEDDisplay::setPixel(int16_t x, int16_t y) {
if (x >= 0 && x < this->width() && y >= 0 && y < this->height()) {
switch (color) {
case WHITE: buffer[x + (y / 8) * this->width()] |= (1 << (y & 7)); break;
case BLACK: buffer[x + (y / 8) * this->width()] &= ~(1 << (y & 7)); break;
case INVERSE: buffer[x + (y / 8) * this->width()] ^= (1 << (y & 7)); break;
}
}
}
// Bresenham's algorithm - thx wikipedia and Adafruit_GFX
void OLEDDisplay::drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1) {
int16_t steep = abs(y1 - y0) > abs(x1 - x0);
if (steep) {
_swap_int16_t(x0, y0);
_swap_int16_t(x1, y1);
}
if (x0 > x1) {
_swap_int16_t(x0, x1);
_swap_int16_t(y0, y1);
}
int16_t dx, dy;
dx = x1 - x0;
dy = abs(y1 - y0);
int16_t err = dx / 2;
int16_t ystep;
if (y0 < y1) {
ystep = 1;
} else {
ystep = -1;
}
for (; x0<=x1; x0++) {
if (steep) {
setPixel(y0, x0);
} else {
setPixel(x0, y0);
}
err -= dy;
if (err < 0) {
y0 += ystep;
err += dx;
}
}
}
void OLEDDisplay::drawRect(int16_t x, int16_t y, int16_t width, int16_t height) {
drawHorizontalLine(x, y, width);
drawVerticalLine(x, y, height);
drawVerticalLine(x + width - 1, y, height);
drawHorizontalLine(x, y + height - 1, width);
}
void OLEDDisplay::fillRect(int16_t xMove, int16_t yMove, int16_t width, int16_t height) {
for (int16_t x = xMove; x < xMove + width; x++) {
drawVerticalLine(x, yMove, height);
}
}
void OLEDDisplay::drawCircle(int16_t x0, int16_t y0, int16_t radius) {
int16_t x = 0, y = radius;
int16_t dp = 1 - radius;
do {
if (dp < 0)
dp = dp + 2 * (++x) + 3;
else
dp = dp + 2 * (++x) - 2 * (--y) + 5;
setPixel(x0 + x, y0 + y); //For the 8 octants
setPixel(x0 - x, y0 + y);
setPixel(x0 + x, y0 - y);
setPixel(x0 - x, y0 - y);
setPixel(x0 + y, y0 + x);
setPixel(x0 - y, y0 + x);
setPixel(x0 + y, y0 - x);
setPixel(x0 - y, y0 - x);
} while (x < y);
setPixel(x0 + radius, y0);
setPixel(x0, y0 + radius);
setPixel(x0 - radius, y0);
setPixel(x0, y0 - radius);
}
void OLEDDisplay::drawCircleQuads(int16_t x0, int16_t y0, int16_t radius, uint8_t quads) {
int16_t x = 0, y = radius;
int16_t dp = 1 - radius;
while (x < y) {
if (dp < 0)
dp = dp + 2 * (++x) + 3;
else
dp = dp + 2 * (++x) - 2 * (--y) + 5;
if (quads & 0x1) {
setPixel(x0 + x, y0 - y);
setPixel(x0 + y, y0 - x);
}
if (quads & 0x2) {
setPixel(x0 - y, y0 - x);
setPixel(x0 - x, y0 - y);
}
if (quads & 0x4) {
setPixel(x0 - y, y0 + x);
setPixel(x0 - x, y0 + y);
}
if (quads & 0x8) {
setPixel(x0 + x, y0 + y);
setPixel(x0 + y, y0 + x);
}
}
if (quads & 0x1 && quads & 0x8) {
setPixel(x0 + radius, y0);
}
if (quads & 0x4 && quads & 0x8) {
setPixel(x0, y0 + radius);
}
if (quads & 0x2 && quads & 0x4) {
setPixel(x0 - radius, y0);
}
if (quads & 0x1 && quads & 0x2) {
setPixel(x0, y0 - radius);
}
}
void OLEDDisplay::fillCircle(int16_t x0, int16_t y0, int16_t radius) {
int16_t x = 0, y = radius;
int16_t dp = 1 - radius;
do {
if (dp < 0)
dp = dp + 2 * (++x) + 3;
else
dp = dp + 2 * (++x) - 2 * (--y) + 5;
drawHorizontalLine(x0 - x, y0 - y, 2*x);
drawHorizontalLine(x0 - x, y0 + y, 2*x);
drawHorizontalLine(x0 - y, y0 - x, 2*y);
drawHorizontalLine(x0 - y, y0 + x, 2*y);
} while (x < y);
drawHorizontalLine(x0 - radius, y0, 2 * radius);
}
void OLEDDisplay::drawHorizontalLine(int16_t x, int16_t y, int16_t length) {
if (y < 0 || y >= this->height()) { return; }
if (x < 0) {
length += x;
x = 0;
}
if ( (x + length) > this->width()) {
length = (this->width() - x);
}
if (length <= 0) { return; }
uint8_t * bufferPtr = buffer;
bufferPtr += (y >> 3) * this->width();
bufferPtr += x;
uint8_t drawBit = 1 << (y & 7);
switch (color) {
case WHITE: while (length--) {
*bufferPtr++ |= drawBit;
}; break;
case BLACK: drawBit = ~drawBit; while (length--) {
*bufferPtr++ &= drawBit;
}; break;
case INVERSE: while (length--) {
*bufferPtr++ ^= drawBit;
}; break;
}
}
void OLEDDisplay::drawVerticalLine(int16_t x, int16_t y, int16_t length) {
if (x < 0 || x >= this->width()) return;
if (y < 0) {
length += y;
y = 0;
}
if ( (y + length) > this->height()) {
length = (this->height() - y);
}
if (length <= 0) return;
uint8_t yOffset = y & 7;
uint8_t drawBit;
uint8_t *bufferPtr = buffer;
bufferPtr += (y >> 3) * this->width();
bufferPtr += x;
if (yOffset) {
yOffset = 8 - yOffset;
drawBit = ~(0xFF >> (yOffset));
if (length < yOffset) {
drawBit &= (0xFF >> (yOffset - length));
}
switch (color) {
case WHITE: *bufferPtr |= drawBit; break;
case BLACK: *bufferPtr &= ~drawBit; break;
case INVERSE: *bufferPtr ^= drawBit; break;
}
if (length < yOffset) return;
length -= yOffset;
bufferPtr += this->width();
}
if (length >= 8) {
switch (color) {
case WHITE:
case BLACK:
drawBit = (color == WHITE) ? 0xFF : 0x00;
do {
*bufferPtr = drawBit;
bufferPtr += this->width();
length -= 8;
} while (length >= 8);
break;
case INVERSE:
do {
*bufferPtr = ~(*bufferPtr);
bufferPtr += this->width();
length -= 8;
} while (length >= 8);
break;
}
}
if (length > 0) {
drawBit = (1 << (length & 7)) - 1;
switch (color) {
case WHITE: *bufferPtr |= drawBit; break;
case BLACK: *bufferPtr &= ~drawBit; break;
case INVERSE: *bufferPtr ^= drawBit; break;
}
}
}
void OLEDDisplay::drawProgressBar(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint8_t progress) {
uint16_t radius = height / 2;
uint16_t xRadius = x + radius;
uint16_t yRadius = y + radius;
uint16_t doubleRadius = 2 * radius;
uint16_t innerRadius = radius - 2;
setColor(WHITE);
drawCircleQuads(xRadius, yRadius, radius, 0b00000110);
drawHorizontalLine(xRadius, y, width - doubleRadius + 1);
drawHorizontalLine(xRadius, y + height, width - doubleRadius + 1);
drawCircleQuads(x + width - radius, yRadius, radius, 0b00001001);
uint16_t maxProgressWidth = (width - doubleRadius + 1) * progress / 100;
fillCircle(xRadius, yRadius, innerRadius);
fillRect(xRadius + 1, y + 2, maxProgressWidth, height - 3);
fillCircle(xRadius + maxProgressWidth, yRadius, innerRadius);
}
void OLEDDisplay::drawFastImage(int16_t xMove, int16_t yMove, int16_t width, int16_t height, const char *image) {
drawInternal(xMove, yMove, width, height, image, 0, 0);
}
void OLEDDisplay::drawXbm(int16_t xMove, int16_t yMove, int16_t width, int16_t height, const char *xbm) {
int16_t widthInXbm = (width + 7) / 8;
uint8_t data = 0;
for(int16_t y = 0; y < height; y++) {
for(int16_t x = 0; x < width; x++ ) {
if (x & 7) {
data >>= 1; // Move a bit
} else { // Read new data every 8 bit
data = pgm_read_byte(xbm + (x / 8) + y * widthInXbm);
}
// if there is a bit draw it
if (data & 0x01) {
setPixel(xMove + x, yMove + y);
}
}
}
}
void OLEDDisplay::drawStringInternal(int16_t xMove, int16_t yMove, char* text, uint16_t textLength, uint16_t textWidth) {
uint8_t textHeight = pgm_read_byte(fontData + HEIGHT_POS);
uint8_t firstChar = pgm_read_byte(fontData + FIRST_CHAR_POS);
uint16_t sizeOfJumpTable = pgm_read_byte(fontData + CHAR_NUM_POS) * JUMPTABLE_BYTES;
uint8_t cursorX = 0;
uint8_t cursorY = 0;
switch (textAlignment) {
case TEXT_ALIGN_CENTER_BOTH:
yMove -= textHeight >> 1;
// Fallthrough
case TEXT_ALIGN_CENTER:
xMove -= textWidth >> 1; // divide by 2
break;
case TEXT_ALIGN_RIGHT:
xMove -= textWidth;
break;
case TEXT_ALIGN_LEFT:
break;
}
// Don't draw anything if it is not on the screen.
if (xMove + textWidth < 0 || xMove > this->width() ) {return;}
if (yMove + textHeight < 0 || yMove > this->width() ) {return;}
for (uint16_t j = 0; j < textLength; j++) {
int16_t xPos = xMove + cursorX;
int16_t yPos = yMove + cursorY;
byte code = text[j];
if (code >= firstChar) {
byte charCode = code - firstChar;
// 4 Bytes per char code
byte msbJumpToChar = pgm_read_byte( fontData + JUMPTABLE_START + charCode * JUMPTABLE_BYTES ); // MSB \ JumpAddress
byte lsbJumpToChar = pgm_read_byte( fontData + JUMPTABLE_START + charCode * JUMPTABLE_BYTES + JUMPTABLE_LSB); // LSB /
byte charByteSize = pgm_read_byte( fontData + JUMPTABLE_START + charCode * JUMPTABLE_BYTES + JUMPTABLE_SIZE); // Size
byte currentCharWidth = pgm_read_byte( fontData + JUMPTABLE_START + charCode * JUMPTABLE_BYTES + JUMPTABLE_WIDTH); // Width
// Test if the char is drawable
if (!(msbJumpToChar == 255 && lsbJumpToChar == 255)) {
// Get the position of the char data
uint16_t charDataPosition = JUMPTABLE_START + sizeOfJumpTable + ((msbJumpToChar << 8) + lsbJumpToChar);
drawInternal(xPos, yPos, currentCharWidth, textHeight, fontData, charDataPosition, charByteSize);
}
cursorX += currentCharWidth;
}
}
}
void OLEDDisplay::drawString(int16_t xMove, int16_t yMove, String strUser) {
uint16_t lineHeight = pgm_read_byte(fontData + HEIGHT_POS);
// char* text must be freed!
char* text = utf8ascii(strUser);
uint16_t yOffset = 0;
// If the string should be centered vertically too
// we need to now how heigh the string is.
if (textAlignment == TEXT_ALIGN_CENTER_BOTH) {
uint16_t lb = 0;
// Find number of linebreaks in text
for (uint16_t i=0;text[i] != 0; i++) {
lb += (text[i] == 10);
}
// Calculate center
yOffset = (lb * lineHeight) / 2;
}
uint16_t line = 0;
char* textPart = strtok(text,"\n");
while (textPart != NULL) {
uint16_t length = strlen(textPart);
drawStringInternal(xMove, yMove - yOffset + (line++) * lineHeight, textPart, length, getStringWidth(textPart, length));
textPart = strtok(NULL, "\n");
}
free(text);
}
void OLEDDisplay::drawStringMaxWidth(int16_t xMove, int16_t yMove, uint16_t maxLineWidth, String strUser) {
uint16_t firstChar = pgm_read_byte(fontData + FIRST_CHAR_POS);
uint16_t lineHeight = pgm_read_byte(fontData + HEIGHT_POS);
char* text = utf8ascii(strUser);
uint16_t length = strlen(text);
uint16_t lastDrawnPos = 0;
uint16_t lineNumber = 0;
uint16_t strWidth = 0;
uint16_t preferredBreakpoint = 0;
uint16_t widthAtBreakpoint = 0;
for (uint16_t i = 0; i < length; i++) {
strWidth += pgm_read_byte(fontData + JUMPTABLE_START + (text[i] - firstChar) * JUMPTABLE_BYTES + JUMPTABLE_WIDTH);
// Always try to break on a space or dash
if (text[i] == ' ' || text[i]== '-') {
preferredBreakpoint = i;
widthAtBreakpoint = strWidth;
}
if (strWidth >= maxLineWidth) {
if (preferredBreakpoint == 0) {
preferredBreakpoint = i;
widthAtBreakpoint = strWidth;
}
drawStringInternal(xMove, yMove + (lineNumber++) * lineHeight , &text[lastDrawnPos], preferredBreakpoint - lastDrawnPos, widthAtBreakpoint);
lastDrawnPos = preferredBreakpoint + 1;
// It is possible that we did not draw all letters to i so we need
// to account for the width of the chars from `i - preferredBreakpoint`
// by calculating the width we did not draw yet.
strWidth = strWidth - widthAtBreakpoint;
preferredBreakpoint = 0;
}
}
// Draw last part if needed
if (lastDrawnPos < length) {
drawStringInternal(xMove, yMove + lineNumber * lineHeight , &text[lastDrawnPos], length - lastDrawnPos, getStringWidth(&text[lastDrawnPos], length - lastDrawnPos));
}
free(text);
}
uint16_t OLEDDisplay::getStringWidth(const char* text, uint16_t length) {
uint16_t firstChar = pgm_read_byte(fontData + FIRST_CHAR_POS);
uint16_t stringWidth = 0;
uint16_t maxWidth = 0;
while (length--) {
stringWidth += pgm_read_byte(fontData + JUMPTABLE_START + (text[length] - firstChar) * JUMPTABLE_BYTES + JUMPTABLE_WIDTH);
if (text[length] == 10) {
maxWidth = max(maxWidth, stringWidth);
stringWidth = 0;
}
}
return max(maxWidth, stringWidth);
}
uint16_t OLEDDisplay::getStringWidth(String strUser) {
char* text = utf8ascii(strUser);
uint16_t length = strlen(text);
uint16_t width = getStringWidth(text, length);
free(text);
return width;
}
void OLEDDisplay::setTextAlignment(OLEDDISPLAY_TEXT_ALIGNMENT textAlignment) {
this->textAlignment = textAlignment;
}
void OLEDDisplay::setFont(const char *fontData) {
this->fontData = fontData;
}
void OLEDDisplay::displayOn(void) {
sendCommand(DISPLAYON);
}
void OLEDDisplay::displayOff(void) {
sendCommand(DISPLAYOFF);
}
void OLEDDisplay::invertDisplay(void) {
sendCommand(INVERTDISPLAY);
}
void OLEDDisplay::normalDisplay(void) {
sendCommand(NORMALDISPLAY);
}
void OLEDDisplay::setContrast(char contrast, char precharge, char comdetect) {
sendCommand(SETPRECHARGE); //0xD9
sendCommand(precharge); //0xF1 default, to lower the contrast, put 1-1F
sendCommand(SETCONTRAST);
sendCommand(contrast); // 0-255
sendCommand(SETVCOMDETECT); //0xDB, (additionally needed to lower the contrast)
sendCommand(comdetect); //0x40 default, to lower the contrast, put 0
sendCommand(DISPLAYALLON_RESUME);
sendCommand(NORMALDISPLAY);
sendCommand(DISPLAYON);
}
void OLEDDisplay::flipScreenVertically() {
sendCommand(SEGREMAP | 0x01);
sendCommand(COMSCANDEC); //Rotate screen 180 Deg
}
void OLEDDisplay::clear(void) {
memset(buffer, 0, DISPLAY_BUFFER_SIZE);
}
void OLEDDisplay::drawLogBuffer(uint16_t xMove, uint16_t yMove) {
uint16_t lineHeight = pgm_read_byte(fontData + HEIGHT_POS);
// Always align left
setTextAlignment(TEXT_ALIGN_LEFT);
// State values
uint16_t length = 0;
uint16_t line = 0;
uint16_t lastPos = 0;
for (uint16_t i=0;i<this->logBufferFilled;i++){
// Everytime we have a \n print
if (this->logBuffer[i] == 10) {
length++;
// Draw string on line `line` from lastPos to length
// Passing 0 as the lenght because we are in TEXT_ALIGN_LEFT
drawStringInternal(xMove, yMove + (line++) * lineHeight, &this->logBuffer[lastPos], length, 0);
// Remember last pos
lastPos = i;
// Reset length
length = 0;
} else {
// Count chars until next linebreak
length++;
}
}
// Draw the remaining string
if (length > 0) {
drawStringInternal(xMove, yMove + line * lineHeight, &this->logBuffer[lastPos], length, 0);
}
}
bool OLEDDisplay::setLogBuffer(uint16_t lines, uint16_t chars){
if (logBuffer != NULL) free(logBuffer);
uint16_t size = lines * chars;
if (size > 0) {
this->logBufferLine = 0; // Lines printed
this->logBufferFilled = 0; // Nothing stored yet
this->logBufferMaxLines = lines; // Lines max printable
this->logBufferSize = size; // Total number of characters the buffer can hold
this->logBuffer = (char *) malloc(size * sizeof(uint8_t));
if(!this->logBuffer) {
DEBUG_OLEDDISPLAY("[OLEDDISPLAY][setLogBuffer] Not enough memory to create log buffer\n");
return false;
}
}
return true;
}
size_t OLEDDisplay::write(uint8_t c) {
if (this->logBufferSize > 0) {
// Don't waste space on \r\n line endings, dropping \r
if (c == 13) return 1;
bool maxLineNotReached = this->logBufferLine < this->logBufferMaxLines;
bool bufferNotFull = this->logBufferFilled < this->logBufferSize;
// Can we write to the buffer?
if (bufferNotFull && maxLineNotReached) {
this->logBuffer[logBufferFilled] = utf8ascii(c);
this->logBufferFilled++;
// Keep track of lines written
if (c == 10) this->logBufferLine++;
} else {
// Max line number is reached
if (!maxLineNotReached) this->logBufferLine--;
// Find the end of the first line
uint16_t firstLineEnd = 0;
for (uint16_t i=0;i<this->logBufferFilled;i++) {
if (this->logBuffer[i] == 10){
// Include last char too
firstLineEnd = i + 1;
break;
}
}
// If there was a line ending
if (firstLineEnd > 0) {
// Calculate the new logBufferFilled value
this->logBufferFilled = logBufferFilled - firstLineEnd;
// Now we move the lines infront of the buffer
memcpy(this->logBuffer, &this->logBuffer[firstLineEnd], logBufferFilled);
} else {
// Let's reuse the buffer if it was full
if (!bufferNotFull) {
this->logBufferFilled = 0;
}// else {
// Nothing to do here
//}
}
write(c);
}
}
// We are always writing all uint8_t to the buffer
return 1;
}
size_t OLEDDisplay::write(const char* str) {
if (str == NULL) return 0;
size_t length = strlen(str);
for (size_t i = 0; i < length; i++) {
write(str[i]);
}
return length;
}
// Private functions
void OLEDDisplay::sendInitCommands(void) {
sendCommand(DISPLAYOFF);
sendCommand(SETDISPLAYCLOCKDIV);
sendCommand(0xF0); // Increase speed of the display max ~96Hz
sendCommand(SETMULTIPLEX);
sendCommand(this->height() - 1);
sendCommand(SETDISPLAYOFFSET);
sendCommand(0x00);
sendCommand(SETSTARTLINE);
sendCommand(CHARGEPUMP);
sendCommand(0x14);
sendCommand(MEMORYMODE);
sendCommand(0x00);
sendCommand(SEGREMAP);
sendCommand(COMSCANINC);
sendCommand(SETCOMPINS);
sendCommand(0x12); // according to the adafruit lib, sometimes this may need to be 0x02
sendCommand(SETCONTRAST);
sendCommand(0xCF);
sendCommand(SETPRECHARGE);
sendCommand(0xF1);
sendCommand(SETVCOMDETECT); //0xDB, (additionally needed to lower the contrast)
sendCommand(0x40); //0x40 default, to lower the contrast, put 0
sendCommand(DISPLAYALLON_RESUME);
sendCommand(NORMALDISPLAY);
sendCommand(0x2e); // stop scroll
sendCommand(DISPLAYON);
}
void inline OLEDDisplay::drawInternal(int16_t xMove, int16_t yMove, int16_t width, int16_t height, const char *data, uint16_t offset, uint16_t bytesInData) {
if (width < 0 || height < 0) return;
if (yMove + height < 0 || yMove > this->height()) return;
if (xMove + width < 0 || xMove > this->width()) return;
uint8_t rasterHeight = 1 + ((height - 1) >> 3); // fast ceil(height / 8.0)
int8_t yOffset = yMove & 7;
bytesInData = bytesInData == 0 ? width * rasterHeight : bytesInData;
int16_t initYMove = yMove;
int8_t initYOffset = yOffset;
for (uint16_t i = 0; i < bytesInData; i++) {
// Reset if next horizontal drawing phase is started.
if ( i % rasterHeight == 0) {
yMove = initYMove;
yOffset = initYOffset;
}
byte currentByte = pgm_read_byte(data + offset + i);
int16_t xPos = xMove + (i / rasterHeight);
int16_t yPos = ((yMove >> 3) + (i % rasterHeight)) * this->width();
// int16_t yScreenPos = yMove + yOffset;
int16_t dataPos = xPos + yPos;
if (dataPos >= 0 && dataPos < DISPLAY_BUFFER_SIZE &&
xPos >= 0 && xPos < this->width() ) {
if (yOffset >= 0) {
switch (this->color) {
case WHITE: buffer[dataPos] |= currentByte << yOffset; break;
case BLACK: buffer[dataPos] &= ~(currentByte << yOffset); break;
case INVERSE: buffer[dataPos] ^= currentByte << yOffset; break;
}
if (dataPos < (DISPLAY_BUFFER_SIZE - this->width())) {
switch (this->color) {
case WHITE: buffer[dataPos + this->width()] |= currentByte >> (8 - yOffset); break;
case BLACK: buffer[dataPos + this->width()] &= ~(currentByte >> (8 - yOffset)); break;
case INVERSE: buffer[dataPos + this->width()] ^= currentByte >> (8 - yOffset); break;
}
}
} else {
// Make new offset position
yOffset = -yOffset;
switch (this->color) {
case WHITE: buffer[dataPos] |= currentByte >> yOffset; break;
case BLACK: buffer[dataPos] &= ~(currentByte >> yOffset); break;
case INVERSE: buffer[dataPos] ^= currentByte >> yOffset; break;
}
// Prepare for next iteration by moving one block up
yMove -= 8;
// and setting the new yOffset
yOffset = 8 - yOffset;
}
yield();
}
}
}
// Code form http://playground.arduino.cc/Main/Utf8ascii
uint8_t OLEDDisplay::utf8ascii(byte ascii) {
static uint8_t LASTCHAR;
if ( ascii < 128 ) { // Standard ASCII-set 0..0x7F handling
LASTCHAR = 0;
return ascii;
}
uint8_t last = LASTCHAR; // get last char
LASTCHAR = ascii;
switch (last) { // conversion depnding on first UTF8-character
case 0xC2: return (ascii); break;
case 0xC3: return (ascii | 0xC0); break;
case 0x82: if (ascii == 0xAC) return (0x80); // special case Euro-symbol
}
return 0; // otherwise: return zero, if character has to be ignored
}
// You need to free the char!
char* OLEDDisplay::utf8ascii(String str) {
uint16_t k = 0;
uint16_t length = str.length() + 1;
// Copy the string into a char array
char* s = (char*) malloc(length * sizeof(char));
if(!s) {
DEBUG_OLEDDISPLAY("[OLEDDISPLAY][utf8ascii] Can't allocate another char array. Drop support for UTF-8.\n");
return (char*) str.c_str();
}
str.toCharArray(s, length);
length--;
for (uint16_t i=0; i < length; i++) {
char c = utf8ascii(s[i]);
if (c!=0) {
s[k++]=c;
}
}
s[k]=0;
// This will leak 's' be sure to free it in the calling function.
return s;
}

Some files were not shown because too many files have changed in this diff Show More