Compare commits

...

213 Commits

Author SHA1 Message Date
cschwinne
f4a2ffc5d2 Update platformio.ini 2019-10-26 01:01:16 +02:00
cschwinne
ba1117e10e Release v0.8.6 2019-10-26 00:00:44 +02:00
cschwinne
0cd46f932a Fix 2.4.0 2019-10-25 15:32:09 +02:00
cschwinne
937f404583 Fix ESP32 2019-10-25 11:54:47 +02:00
cschwinne
d13d60d752 New WiFi logic 2019-10-25 00:14:58 +02:00
cschwinne
31e4e7c709 HA discovery wdt reset 2019-10-20 17:38:25 +02:00
cschwinne
0d3a8ce31b Update MQTT library 2019-10-20 12:48:29 +02:00
cschwinne
be185b46a7 Reworked WiFi logic
Remaining issues:
MQTT reconnects too often
WiFI AP doesn't work if searching for STA
2019-10-18 23:47:11 +02:00
cschwinne
90fa5b3b93 Removed onlyAP 2019-10-18 14:06:07 +02:00
cschwinne
733996772b WLED_CONNECTED macro 2019-10-18 13:26:39 +02:00
cschwinne
d4c921ea2e Timebase sync 2019-10-18 12:19:52 +02:00
cschwinne
2852061699 Refactor WS812FX file names 2019-10-07 23:38:21 +02:00
cschwinne
d8859b9f0a Improved running effects 2019-10-07 23:22:56 +02:00
cschwinne
ae1bc96006 More effects use FRAMETIME 2019-10-07 20:17:52 +02:00
cschwinne
f30ffb4413 Improved rainbow effects 2019-10-05 01:56:55 +02:00
cschwinne
273c6467c8 Fix travis (ESP01 too little flash) 2019-10-04 01:38:42 +02:00
cschwinne
846a1d007c Improved fade modes 2019-10-04 01:21:18 +02:00
cschwinne
1dccc8dc78 Improved Color Wipe 2019-10-03 20:57:22 +02:00
cschwinne
e0d67bd057 Improved effects 2019-10-03 16:33:37 +02:00
cschwinne
4b4b93ac04 Added Halloween Eyes effect
Added Twinklecat
2019-10-02 01:17:26 +02:00
Aircoookie
4390aee1e0 Merge pull request #234 from pille/master
fix verison number of current release
2019-09-29 11:20:30 +02:00
pille
4cddb16788 fix verison number of current release 2019-09-28 13:43:57 +02:00
cschwinne
e1179fd8c8 Delete accidentallly included bin 2019-09-26 14:06:50 +02:00
cschwinne
cb77285277 Support APA102 on ESP32 2019-09-26 14:02:58 +02:00
cschwinne
6c9d161950 Fixed transitions and gamma 2019-09-19 21:15:20 +02:00
Aircoookie
40aaac5868 Merge pull request #218 from Aircoookie/captiveportal
Release v0.8.5
2019-09-12 15:30:34 +02:00
cschwinne
e16b69594e Fix PIO 2019-09-12 13:08:07 +02:00
cschwinne
4837bf007a Update welcome page 2019-09-12 12:41:51 +02:00
cschwinne
705fd4dafd Release v0.8.5 2019-09-12 12:40:06 +02:00
cschwinne
a3e28d3c66 First version of captive portal 2019-09-05 22:45:59 +02:00
cschwinne
4a6755c28a Added C9 and Sakura palettes 2019-08-31 01:41:25 +02:00
cschwinne
188fe5dc52 Added TwinkleFOX effect
Added Orangery palette
2019-08-30 15:39:34 +02:00
cschwinne
44a8ae457d Fixed JSON API POST requests
Speed set COOLING for Fire2012 (#208)
2019-08-25 23:52:40 +02:00
cschwinne
92eafcfe1a Fixed crash on opening settings in core 2.5.2 (#168) 2019-08-21 01:18:25 +02:00
Aircoookie
b12b031fdd Merge pull request #202 from timothybrown/mqttauth
MQTT Authentication Support
2019-08-19 23:20:35 +02:00
cschwinne
492ec489a1 Small changes to MQTT auth
Changed mqttPort to uint16 type
Password no longer transmitted to settings page
Chnaged topics and identifiers to last 6 bytes of mac format
Added security warning
2019-08-18 18:14:17 +02:00
Timothy Brown
c57124e876 Added MQTT port field, bumped user, pass and CID to 40 characters 2019-08-17 21:34:47 -04:00
Timothy Brown
95b33c9c34 Tidied up code 2019-08-17 07:26:40 -04:00
Timothy Brown
c6d8b63e54 Added MQTT authentication support 2019-08-17 06:27:06 -04:00
Aircoookie
f0f02c4ea6 Merge pull request #193 from stockklauser/0.8.4_master_extend_VS
Fix Compile Issues with Visual Studio 2017 / Visual Assist Arduino  and Add Visual Studio Project Files
2019-07-24 23:22:01 +02:00
thomas.stockklauser
eb2cb6810a Modify Structure to fix path issues 2019-07-23 18:51:26 +02:00
thomas.stockklauser
b3c090e9ed Add Visual Studio Support and fix a Compile Issue with Visual Assist / Studio 2017 2019-07-23 18:04:26 +02:00
thomas.stockklauser
13366fc9f8 Add Visual Studio Project Structure 2019-07-23 17:59:55 +02:00
thomas.stockklauser
929af7830a Add Visual Studio Project Structure
Fix a compile Issue in wled19_json.ino with Visual Studio / Visual Assist
2019-07-23 17:35:40 +02:00
cschwinne
13062cf0e4 Merge branch 'master' of https://github.com/Aircoookie/WLED.git 2019-06-21 23:14:36 +02:00
cschwinne
b897a8a35f Updated to ArduinoJson v6
Fixed JSON crash on core v2.5.2
2019-06-21 23:12:58 +02:00
cschwinne
117dc5288d Added basic segment support
Updated Espalexa
2019-06-20 14:40:12 +02:00
Aircoookie
4b5a3bd3d5 Revert LEDPIN to 2 2019-05-23 00:33:15 +02:00
cschwinne
b224a67ea7 Refactored WS2812FX variable names 2019-05-22 00:23:09 +02:00
cschwinne
793f919d59 Added MQTT auto reconnect 2019-05-21 18:50:56 +02:00
Aircoookie
315987b2f6 Merge pull request #160 from T-Arens/master
Added support for APA102 LEDs.
2019-05-04 15:54:33 +02:00
Thomas Arens
9b7db548a2 Only disable the button pin if it conflicts with one of the APA102 pins. 2019-05-01 16:52:22 +02:00
Thomas Arens
126b70f781 Added support for APA102 LEDs. Uncomment "#define USE_APA102" in NbpWrapper.h. Connect clock to GPIO 0 and data to GPIO 2. 2019-05-01 03:09:08 +02:00
Aircoookie
0bbff627e2 Merge pull request #152 from YeonV/patch-1
Fixed MQTT color response
2019-04-15 22:37:41 +02:00
Yeon Vinzenz Varapragasam
961d23e2a1 Fixed MQTT color response
Leading zeros are not trimmed on /c topic anymore :)
Before blue: #FF
After blue: #0000FF
2019-04-15 20:43:32 +02:00
cschwinne
b03ff9a48a Updated Espalexa to 2.4.2
Added UDP realtime 255 as keep state until changed
Added "true" and "false" MQTT payloads
2019-04-14 19:31:25 +02:00
cschwinne
3ffb40fafa Fixed HA autodiscovery and MQTT ON 2019-03-27 21:31:59 +01:00
cschwinne
1a3b4ac2ac Fixed meteor FX crashing 2019-03-27 21:06:07 +01:00
cschwinne
794e17442f Release of v0.8.4
Default to LwiP 2 in PIO
Fixed 12hr format time
2019-03-25 23:27:35 +01:00
cschwinne
238d7119e0 Completed HA autodiscovery
Modified platformio.ini
2019-03-24 18:28:36 +01:00
cschwinne
8a929a8348 Added new Homeassistent broadcast logic 2019-03-24 00:49:26 +01:00
cschwinne
cf77153647 Merge branch 'master' of https://github.com/Aircoookie/WLED.git 2019-03-19 12:21:56 +01:00
cschwinne
a2da0b0641 Fixed HTTP API XML response 2019-03-19 12:19:48 +01:00
Aircoookie
73faa13811 Merge pull request #134
Added Homeassistant autodiscovery
2019-03-18 19:56:53 +01:00
cschwinne
1a71872c7b Added flag to enable Homeassistant autodiscovery 2019-03-18 19:54:06 +01:00
Debashish Sahu
62fe7135bd PIO ESP01 fix
- fix core for ESP01, newer cores are too big
2019-03-18 13:30:47 -04:00
Debashish Sahu
078940d29f PIO & TravisCI fix
- fix errors while compiling for PIO and TravisCI
2019-03-18 13:13:04 -04:00
Debashish Sahu
2fafe42c18 HA Light Auto Discovery
- Send HA MQTT Discovery message ~2.4kB based on input by @YeonV from here: https://github.com/Aircoookie/WLED/issues/131
2019-03-18 12:23:39 -04:00
cschwinne
c8a7537157 Added support for SPIFFS
Fixed ESP32
2019-03-16 02:09:37 +01:00
cschwinne
d4bf1cb23d Added button double press macro option
Added toggle (relay) pin
2019-03-13 11:13:03 +01:00
cschwinne
46e4350013 Improved heap usage by 2k 2019-03-11 19:30:49 +01:00
cschwinne
202eb0d854 Fixed /json with ESP core <2.5.0 2019-03-11 17:57:06 +01:00
cschwinne
898702346e Fixed JSON API on bug
Fixed RN=1 not having an effect if default off
2019-03-11 00:20:17 +01:00
cschwinne
b72e6f16ca Small memory improvements 2019-03-09 21:41:23 +01:00
cschwinne
b9c27ed324 Added RD HTTP api call for realtime udp 2019-03-09 14:48:13 +01:00
cschwinne
0166dfe16e Fixed colorwheel 2019-03-07 23:22:52 +01:00
cschwinne
7274541722 Fixed platformio compilation
Added more debug info in serial on boot
2019-03-07 16:36:26 +01:00
cschwinne
709ff7a701 Finished JSON API
Added RV http api call
Fixed CY,PA,PC,PX api calls
Fixed CORS
2019-03-06 21:31:12 +01:00
cschwinne
66c224c954 Added JSON state API 2019-03-06 01:20:38 +01:00
cschwinne
3f9b37aa7f Added /json/state 2019-03-05 10:59:15 +01:00
cschwinne
0377958d8f Updated hue sync to use ArduinoJSON
Fixed brightness when ABL deactivated
2019-03-03 23:27:52 +01:00
cschwinne
cc1cfd70b8 Added ArduinoJSON 2019-03-03 18:05:56 +01:00
cschwinne
bc125ad76c Updated Espalexa to v2.4.0 2019-03-01 17:10:42 +01:00
cschwinne
62a2246448 Included effect and palette lists in LED settings 2019-02-25 22:23:26 +01:00
cschwinne
587cf751d8 Fixed preset loading 2019-02-25 19:14:13 +01:00
cschwinne
600181ed07 Updated platformio.ini 2019-02-22 22:53:39 +01:00
cschwinne
f0e525d2e2 Added relative API calls 2019-02-22 22:53:33 +01:00
cschwinne
f86cdd8cde Added /json/info page 2019-02-21 16:32:15 +01:00
cschwinne
4a4c537a0d Reverted to default LEDPIN 2019-02-21 00:21:35 +01:00
cschwinne
1caaf04dfa Various performance and reliability improvements 2019-02-20 23:44:34 +01:00
cschwinne
b422a80249 Fixed button-caused asyncserver unresponsiveness
Fixed RGBW power calculation
2019-02-20 15:18:04 +01:00
cschwinne
ba19e20833 Added Macro notification option
Removed realtime UI lock
2019-02-19 12:57:50 +01:00
cschwinne
c34ddb2bc3 Initial async hue client 2019-02-18 22:34:21 +01:00
cschwinne
aa315f8472 Switched from PubSubClient to AsyncMqttClient 2019-02-17 19:21:09 +01:00
cschwinne
2af6af2bf0 Added HTTP OTA update via ESPAsyncWebServer 2019-02-17 17:11:10 +01:00
cschwinne
5694ff7c97 Migrated to AsyncWebServer 2019-02-16 00:21:22 +01:00
cschwinne
76f1c689c1 Interim Async Update 2019-02-14 17:25:41 +01:00
cschwinne
a371239172 Fixed mobile UI effect list not loading 2019-02-12 14:50:19 +01:00
cschwinne
4fd904fbcc Merge branch 'master' of https://github.com/Aircoookie/WLED.git 2019-02-12 11:05:00 +01:00
cschwinne
b73a257389 Fixed broadcast IP compilation issue 2019-02-12 11:03:54 +01:00
Aircoookie
9e70d6b3e1 Merge pull request #105 from Aircoookie/development
Release of v0.8.3
2019-02-11 23:53:53 +01:00
cschwinne
9caca37ab1 Release of v0.8.3
Removed initLedsLast
Improved Fireworks
2019-02-11 23:49:04 +01:00
cschwinne
6e76fc0aa7 Added JSON FX + palette lists 2019-02-10 23:05:06 +01:00
cschwinne
6171883758 Split up WS2812FX.cpp in FX and helper files 2019-02-09 16:37:20 +01:00
cschwinne
942b68c948 Added shields.io to readme 2019-02-09 15:41:55 +01:00
cschwinne
9ca7ffa5a3 Refactored white to col[3]
Added Saw effect
2019-02-05 21:53:39 +01:00
cschwinne
d1ce23c5ac Unique mDNS name
Various optimizations
2019-02-05 19:40:24 +01:00
cschwinne
b7b6d0a6bc Improved ripple effect 2019-02-02 23:59:48 +01:00
cschwinne
10c51eea2c Added Ripple and revamped twinkle effects 2019-01-31 23:42:48 +01:00
cschwinne
48d20c02a1 Added timed macro weekday support 2019-01-31 00:09:44 +01:00
cschwinne
c5cc0b3f2b Updated Mobile UI
Fixed Smooth Meteor stuck pixels
Added CORS response
Added secondary color to http API response
2019-01-18 01:20:36 +01:00
cschwinne
6ebef8846c Merge branch 'development' of https://github.com/Aircoookie/WLED.git into development 2019-01-09 23:03:34 +01:00
cschwinne
5d1993935e Added Alexa Color support 2019-01-09 22:55:18 +01:00
Aircoookie
caab8943cb Merge pull request #90 from cboltz/cboltz-timezone-deps
Use time/time.h from local dependencies
2018-12-20 21:17:42 +01:00
Christian Boltz
f5c05b24fb Use time/time.h from local dependencies
This fixes a compile issue, which can be
a) file not found or
b) (after installing the Time library) redefinition of a variable
2018-12-17 22:07:43 +01:00
Aircoookie
940a0d006d Merge pull request #89 from definitio/master
Fix compiling on a case sensitive filesystems
2018-12-17 15:41:24 +01:00
definitio
8fe67a04d8 Fix compiling on a case sensitive file systems 2018-12-17 18:08:59 +04:00
cschwinne
bec745d095 Improved colortwinkles on longer strips
Added offMode
2018-12-16 20:38:00 +01:00
Aircoookie
223fd35138 Merge pull request #84 from Aircoookie/development
Updated platformio.ini for v0.8.2
2018-12-06 16:32:52 +01:00
cschwinne
d3fc0309c0 Updated platformio.ini for v0.8.2 2018-12-06 16:31:52 +01:00
Aircoookie
830223f6e2 Merge pull request #83 from Aircoookie/development
Fixed incorrect #defines for 0.8.2
2018-12-06 00:43:32 +01:00
cschwinne
eb53c52499 Fixed incorrect #defines for 0.8.2 2018-12-06 00:40:59 +01:00
Aircoookie
96c9e2b4d6 Merge pull request #82 from Aircoookie/development
Updated readme
2018-12-06 00:31:39 +01:00
cschwinne
c34b948bad Updated readme 2018-12-06 00:30:38 +01:00
Aircoookie
9ac609f846 Release of v0.8.2 (merge)
Release of v0.8.2 (PR)
2018-12-06 00:30:05 +01:00
cschwinne
6aa47bfd1b Release of v0.8.2
Improved settings page scaling on mobile devices
Added 2 new effects to web UIs
2018-12-06 00:27:36 +01:00
cschwinne
ff46e6ea86 Added Auto Brightness Limiter and power calculation 2018-12-04 00:58:06 +01:00
cschwinne
5489c74986 Added Smooth meteor and Railway effects 2018-12-02 02:49:05 +01:00
cschwinne
f6f8151150 Added meteor FX to web UI 2018-11-29 21:46:05 +01:00
cschwinne
a20d577f6c WS2812b Color Order changeable in settings
Meteor effect can now use palettes
2018-11-28 12:24:32 +01:00
cschwinne
c4c2494dd1 Improved binary size 2018-11-25 00:00:02 +01:00
cschwinne
c9c294a1d5 Merge branch 'development' of https://github.com/Aircoookie/WLED.git into development 2018-11-24 11:52:44 +01:00
cschwinne
6359a8a8a2 Improved effect updating internals 2018-11-24 11:52:23 +01:00
Aircoookie
f9b44381bd Merge pull request #77 from viknet365/master
add meteor effect
2018-11-23 00:21:07 +01:00
Aircoookie
eb1ccb600b Delete htmls00.h
0.8.2 will use the new gzip system with different files. HTML changes will be manually added
2018-11-23 00:20:26 +01:00
cschwinne
b2db61aa03 Merge branch 'development' of https://github.com/Aircoookie/WLED.git into development 2018-11-23 00:16:25 +01:00
cschwinne
ee55a574de Moved About section to Github wiki
Updated readme
2018-11-23 00:11:47 +01:00
cschwinne
0998fd32cd Moved About section to Github wiki 2018-11-23 00:03:44 +01:00
cschwinne
686f2c4aa6 IR codes will now also be printed without debug enabled 2018-11-22 22:43:44 +01:00
cschwinne
cd234673ea Fixed nightlight issues
Added custom infrared method
2018-11-22 00:09:30 +01:00
cschwinne
54d7a81f16 Incomplete commit for Nightlight Fixes
Interim state (Reason: Local Working Copy Data Corruption)
Affected files: (local changes will be re-implemented in next commit)
settings_sync.html (already recovered)
html_settings.h (already recovered)
wled03_set.ino
wled08_led.ino
wled09_button.ino
wled19_ir.ino
2018-11-21 23:28:20 +01:00
viknet365
9d8d2c0aa1 add meteor effect
This reverts commit f1371d6737.
2018-11-20 21:31:07 +01:00
viknet365
17ce6b9507 Revert "Add files via upload"
This reverts commit f1371d6737.
2018-11-20 21:09:06 +01:00
viknet365
296065a976 Revert "add meteor effect"
This reverts commit 0b0f600f97.
2018-11-20 20:59:13 +01:00
viknet365
0b0f600f97 add meteor effect 2018-11-20 20:42:47 +01:00
viknet365
f1371d6737 Add files via upload
add meteor effect
2018-11-20 20:35:04 +01:00
viknet365
03a33790e1 Update WS2812FX.cpp 2018-11-20 20:32:21 +01:00
cschwinne
c0816c80ae Infrared support added 2018-11-18 00:31:45 +01:00
cschwinne
071ebe6ef2 Gzipped UIs, improving speed and flash usage 2018-11-16 19:59:00 +01:00
Aircoookie
2126e42743 Merge pull request #74 from wiesendaniel/feature/pio-port
Added Plattform IO Support
2018-11-16 19:50:19 +01:00
Daniel Wiesendorf
8a2b34adb4 moved ws2812fx sources back 2018-11-16 15:02:09 +01:00
Daniel Wiesendorf
93eb4d21bf Added PIO recommendation when opening in vscode 2018-11-14 22:07:04 +01:00
Daniel Wiesendorf
868cedeed2 pio support for esp01 512k 2018-11-14 22:07:04 +01:00
Daniel Wiesendorf
5c794f428a added verbose flag to travisci.yml for debugging 2018-11-14 22:07:04 +01:00
Daniel Wiesendorf
612d6f85bd Pio support of esp32 2018-11-14 22:07:04 +01:00
Daniel Wiesendorf
e5cef6b877 fixed DEBUG constant for travis build 2018-11-14 22:07:04 +01:00
Daniel Wiesendorf
f2a63c04a8 fixed travisci build again... 2018-11-14 22:07:04 +01:00
Daniel Wiesendorf
5a5064e070 fixed travisci build 2018-11-14 22:07:04 +01:00
Daniel Wiesendorf
478fa3132c Minor fixes for PIO support 2018-11-14 22:07:04 +01:00
Daniel Wiesendorf
a84859c211 Changed platformio.ini. A few boards are building now 2018-11-14 22:07:04 +01:00
Daniel Wiesendorf
67013bd58f Changed platformio.ini. A few boards are building now 2018-11-14 22:07:04 +01:00
Daniel Wiesendorf
b51be31d8a added initial PlatformIO config. still needs work 2018-11-14 22:07:04 +01:00
Aircoookie
a3bef49124 Refactored code to improve readability (merge dev PR)
Refactored code to improve readability
Fixed non-2-char indentations
2018-11-09 17:02:58 +01:00
cschwinne
a5cf553f17 Refactored code to improve readability
Fixed non-2-char indentations
2018-11-09 17:00:36 +01:00
Aircoookie
640188f4e2 Merge pull request #68 from Aircoookie/development
Release of v0.8.0
2018-11-07 20:23:01 +01:00
cschwinne
48265bbe02 Release of WLED 0.8.1
Added Lake effect
2018-11-07 20:22:05 +01:00
cschwinne
6aaf544079 Auto-select pixel driving method based on LEDPIN 2018-11-05 02:24:13 +01:00
cschwinne
9904c10984 Added Colortwinkle effect 74 2018-11-04 20:14:23 +01:00
cschwinne
81c810eba4 Increased max. UDP leds from 341 to 490
MQTT now publishes state on connect
2018-11-01 16:16:38 +01:00
cschwinne
5e6b1e8175 Added defines for more granular feature disable control 2018-11-01 15:36:13 +01:00
cschwinne
48c165b0b4 Added support for E1.31 with more than 170 LEDs 2018-11-01 01:05:35 +01:00
cschwinne
042605701e Added DNRGB UDP protocol 2018-10-27 11:39:00 +02:00
cschwinne
32cf1495d3 Fixed tricolor chase modes
Added a new palette
2018-10-25 20:55:29 +02:00
cschwinne
9577e49231 Added Palette support for most effects
Fixed Analog Clock bugs
Added Tiamat palette
2018-10-24 02:06:07 +02:00
cschwinne
de19839145 Fixed overlay not unlocking on disable 2018-10-18 18:31:25 +02:00
cschwinne
f970780d6c Fixed Clock overlay not working in reverse mode
Removed need for Macros to start with capital letter
2018-10-18 18:06:46 +02:00
Aircoookie
1e69cc75c7 Merge pull request #57 from Aircoookie/development
Release of v0.8.0
2018-10-15 16:33:20 +02:00
cschwinne
377e4fa0a5 Release of v0.8.0 2018-10-15 16:15:51 +02:00
cschwinne
a5d6dc58d3 Fixed E1.31 multicast 2018-10-11 21:38:00 +02:00
cschwinne
a122c17340 Fixed Blynk power button and settings 2018-10-08 17:36:22 +02:00
cschwinne
34ddf104a9 Optimized EEPROM string read/write code
Changed DNS server to improve AP mode stability
2018-10-07 11:56:29 +02:00
cschwinne
f98b0beee5 Added Mobile UI power indicator 2018-10-06 14:53:15 +02:00
cschwinne
75a61f85db Cleaned up readme 2018-10-04 23:16:25 +02:00
cschwinne
c1cdf27507 Release of v0.8.0 to dev branch
Updating master after more testing
2018-10-04 22:41:35 +02:00
cschwinne
43e9743645 Fixed ESP32 version
Fixed Adalight serial Ambilight
2018-10-04 22:38:39 +02:00
cschwinne
c2972786f5 Attempted to improve AP only stability 2018-10-04 18:17:01 +02:00
cschwinne
eeb17b417c Added MQTT
Updated readme for 0.8.0
Fixed custom theme bug
Bumped version codes to 0.8.0
2018-10-04 16:50:12 +02:00
cschwinne
473991638c Fixed realtime mode not working 2018-10-01 21:31:31 +02:00
cschwinne
92b4b69b3f Split Server init code from wled05_init.ino to improve readability
Added MQTT logic
2018-09-30 20:24:57 +02:00
cschwinne
dbd6f134c1 Added CL= and C2= API calls to set HEX or DEC RGB or WRGB color
Started to add MQTT support
Pre server and init split-up
2018-09-28 23:53:51 +02:00
cschwinne
5f59487a88 Added basic Time Activated Macros function
Fixed Cronixie overlay
512K Flash mode (temporarily) unavailable
2018-09-22 22:49:24 +02:00
cschwinne
bb7f673ff9 Re-added support for 512K flash ESPs 2018-09-17 11:15:08 +02:00
cschwinne
4715180a32 Refactored wled00.ino
Attempted to fix AP mode lags
2018-09-15 17:29:01 +02:00
cschwinne
4b31610169 Updated UI with all new palettes
FastLED effects now have default palettes per effect
Fire2012 can now use Palettes
Option for palette blending added
Added new Palettes
2018-09-11 00:20:29 +02:00
cschwinne
2466c5a204 Merge branch 'development' of https://github.com/Aircoookie/WLED.git into development 2018-09-08 20:35:47 +02:00
Aircoookie
0505baff38 Resolve version code merge conflict 2018-09-08 20:34:59 +02:00
cschwinne
c55e3a37ae Added 33 gradient palette presets
Fixed welcome page not showing on fresh install
Fixed device not turning on on fresh install
2018-09-08 20:26:04 +02:00
cschwinne
ce5fec4d5f Added Pride2012 and Colorwaves effects
Adjusted Noise16 effects
Added palette fade transition option
2018-09-08 16:21:44 +02:00
cschwinne
6d4339b034 Added first palette functions
Attempted to fix welcome page
2018-09-06 02:05:56 +02:00
cschwinne
70d0aae07c First commit of 0.8.0 dev cycle
Updated to newer WS2812FX version which supports segments (not supported in WLED yet)
Added new (FastLED) effects
Adjusted FX speed timings
Removed Sweep transition and Custom Chase (seldomly used - hinder development)
Removed solid overlay (no longer needed once segments are added)
Fixed Blynk effect set
2018-09-04 15:51:38 +02:00
Aircoookie
e3b9b341fd Merge pull request #47 from Aircoookie/development
Fixed Blynk FX updates
2018-08-31 22:36:38 +02:00
Aircoookie
95083cf743 Merge pull request #46 from kayrozen/master
Fixed blynk code
2018-08-31 22:35:50 +02:00
Aircoookie
3842c4ac46 Bump version date code for blynk fix 2018-08-31 22:35:23 +02:00
kayrozen
fe178043ee fix blynk 2018-08-31 14:52:02 -04:00
Aircoookie
82d40f60f1 Release of WLED 0.7.1
Merge dev to master
2018-08-11 23:05:11 +02:00
cschwinne
1d4d885276 Release of WLED 0.7.1 to dev branch
Added E1.31 support
Added more realtime options
Attempted to fix welcome page not showing on fresh install
2018-08-11 22:59:37 +02:00
cschwinne
ed3557ffca Fixed Exception 28 loop on fresh install
Removed legacy binaries folder
2018-08-05 19:22:48 +02:00
cschwinne
1c3878fcb0 Added blynk UI updates 2018-07-29 14:03:02 +02:00
cschwinne
b3dcb9fe6c Fixed ESP32 resetting upon opening wifi settings 2018-07-22 21:21:18 +02:00
cschwinne
0462755922 further optimization 2018-07-22 14:55:10 +02:00
cschwinne
415dfd2750 Continued optimizing strings 2018-07-21 23:21:07 +02:00
cschwinne
72f203e4fa Started optimizing code by converting String to char* 2018-07-20 19:35:31 +02:00
cschwinne
4e3c83af94 Added Blynk support
Fixed AutoRGBW not disabling white slider in UI
Fixed possible UDP buffer out of bounds
2018-07-16 11:50:09 +02:00
150 changed files with 26857 additions and 8807 deletions

7
.gitignore vendored Normal file
View File

@@ -0,0 +1,7 @@
.pio
.pioenvs
.piolibdeps
.vscode
!.vscode/extensions.json
/wled00/Release
/wled00/extLibs

35
.travis.yml Normal file
View File

@@ -0,0 +1,35 @@
# Continuous Integration (CI) is the practice, in software
# engineering, of merging all developer working copies with a shared mainline
# several times a day < https://docs.platformio.org/page/ci/index.html >
#
# Documentation:
#
# * Travis CI Embedded Builds with PlatformIO
# < https://docs.travis-ci.com/user/integration/platformio/ >
#
# * PlatformIO integration with Travis CI
# < https://docs.platformio.org/page/ci/travis.html >
#
# * User Guide for `platformio ci` command
# < https://docs.platformio.org/page/userguide/cmd_ci.html >
#
#
# Please choose one of the following templates (proposed below) and uncomment
# it (remove "# " before each line) or use own configuration according to the
# Travis CI documentation (see above).
#
language: python
python:
- "2.7"
sudo: false
cache:
directories:
- "~/.platformio"
env:
- PLATFORMIO_CI_SRC=wled00
install:
- pip install -U platformio
- platformio update
script:
- platformio ci --project-conf=./platformio.ini -v

BIN
.vs/wled00/v15/.suo Normal file

Binary file not shown.

7
.vscode/extensions.json vendored Normal file
View File

@@ -0,0 +1,7 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"platformio.platformio-ide"
]
}

View File

@@ -1,7 +0,0 @@
## Where are the new binaries?
From v0.5.0 on forward, the GitHub [releases](https://github.com/Aircoookie/WLED/releases) system will be used for binaries.
### What binary should I choose?
You should always try to use the binaries from the release page. This directory is for legacy purposes only!

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

39
include/README Normal file
View File

@@ -0,0 +1,39 @@
This directory is intended for project header files.
A header file is a file containing C declarations and macro definitions
to be shared between several project source files. You request the use of a
header file in your project source file (C, C++, etc) located in `src` folder
by including it, with the C preprocessing directive `#include'.
```src/main.c
#include "header.h"
int main (void)
{
...
}
```
Including a header file produces the same results as copying the header file
into each source file that needs it. Such copying would be time-consuming
and error-prone. With a header file, the related declarations appear
in only one place. If they need to be changed, they can be changed in one
place, and programs that include the header file will automatically use the
new version when next recompiled. The header file eliminates the labor of
finding and changing all the copies as well as the risk that a failure to
find one copy will result in inconsistencies within a program.
In C, the usual convention is to give header files names that end with `.h'.
It is most portable to use only letters, digits, dashes, and underscores in
header file names, and at most one dot.
Read more about using header files in official GCC documentation:
* Include Syntax
* Include Operation
* Once-Only Headers
* Computed Includes
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html

46
lib/README Normal file
View File

@@ -0,0 +1,46 @@
This directory is intended for project specific (private) libraries.
PlatformIO will compile them to static libraries and link into executable file.
The source code of each library should be placed in a an own separate directory
("lib/your_library_name/[here are source files]").
For example, see a structure of the following two libraries `Foo` and `Bar`:
|--lib
| |
| |--Bar
| | |--docs
| | |--examples
| | |--src
| | |- Bar.c
| | |- Bar.h
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
| |
| |--Foo
| | |- Foo.c
| | |- Foo.h
| |
| |- README --> THIS FILE
|
|- platformio.ini
|--src
|- main.c
and a contents of `src/main.c`:
```
#include <Foo.h>
#include <Bar.h>
int main (void)
{
...
}
```
PlatformIO Library Dependency Finder will find automatically dependent
libraries scanning project source files.
More information about PlatformIO Library Dependency Finder
- https://docs.platformio.org/page/librarymanager/ldf.html

163
platformio.ini Normal file
View File

@@ -0,0 +1,163 @@
; PlatformIO Project Configuration File
; Please visit documentation: https://docs.platformio.org/page/projectconf.html
[platformio]
src_dir = ./wled00
data_dir = ./wled00/data
lib_extra_dirs = ./wled00/src
; Please uncomment one of the 5 lines below to select your board
; env_default = nodemcuv2
; env_default = esp01
; env_default = esp01_1m
; env_default = d1_mini
; env_default = esp32dev
[common]
framework = arduino
monitor_speed = 115200
board_build.flash_mode = dout
upload_speed = 115200
upload_speed_fast = 921600
build_flags =
-w ; supresses all C/C++ warnings
; -D VERSION=0.8.5
; -D DEBUG
# TODO replace libs in /lib with managed libs in here if possible.
# If they are not changed it's just a matter of setting the correct version and change the import statement
lib_deps_external =
#Blynk@0.5.4(changed)
#E131@1.0.0(changed)
FastLED@3.3.2
NeoPixelBus@2.5.1
ESPAsyncTCP@1.2.0
AsyncTCP@1.0.3
Esp Async WebServer@1.2.0
#ArduinoJson@5.13.5
IRremoteESP8266@2.5.5
#Time@1.5
#Timezone@1.2.1
[common:esp8266]
# ------------------------------------------------------------------------------
# PLATFORM:
# !! DO NOT confuse platformio's ESP8266 development platform with Arduino core for ESP8266
# We use Arduino Core 2.5.0 (platformIO 2.0.4) as default
#
# arduino core 2.3.0 = platformIO 1.5.0
# arduino core 2.4.0 = platformIO 1.6.0
# arduino core 2.4.1 = platformIO 1.7.3
# arduino core 2.4.2 = platformIO 1.8.0
# arduino core 2.5.0 = platformIO 2.0.4
# arduino core stage = platformIO feature#stage
# ------------------------------------------------------------------------------
arduino_core_2_3_0 = espressif8266@1.5.0
arduino_core_2_4_0 = espressif8266@1.6.0
arduino_core_2_4_1 = espressif8266@1.7.3
arduino_core_2_4_2 = espressif8266@1.8.0
arduino_core_2_5_0 = espressif8266@2.0.4
arduino_core_2_5_2 = espressif8266@2.2.3
arduino_core_stage = https://github.com/platformio/platform-espressif8266.git#feature/stage
platform = ${common:esp8266.arduino_core_2_5_2}
build_flags =
-D PIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH
-Wl,-Teagle.flash.4m1m.ld ;;;; Required for core > v2.5.0 or staging version 4MB Flash 3MB SPIFFs
[common:esp8266_1M]
platform = espressif8266@1.8.0
build_flags =
-D PIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH_LOW_FLASH
-Wl,-Teagle.flash.1m0.ld ;;;; Compile with no SPIFFS to leave space for OTA
; -D WLED_DISABLE_MOBILE_UI
; -D WLED_DISABLE_OTA
; -D WLED_DISABLE_ALEXA
-D WLED_DISABLE_BLYNK
-D WLED_DISABLE_CRONIXIE
; -D WLED_DISABLE_HUESYNC
-D WLED_DISABLE_INFRARED
[common:esp8266_512k]
platform = espressif8266@1.8.0
build_flags =
-D PIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH_LOW_FLASH
-Wl,-Teagle.flash.512k0.ld ;;;; Compile with no SPIFFS
; -D WLED_DISABLE_MOBILE_UI
-D WLED_DISABLE_OTA
; -D WLED_DISABLE_ALEXA
-D WLED_DISABLE_BLYNK
-D WLED_DISABLE_CRONIXIE
; -D WLED_DISABLE_HUESYNC
-D WLED_DISABLE_INFRARED
[common:esp32]
platform = espressif32@1.7.0
build_flags =
-D PIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH
-D ARDUINO_ARCH_ESP32
-D WLED_DISABLE_INFRARED
# see: http://docs.platformio.org/en/latest/platforms/espressif8266.html
[env:nodemcuv2]
board = nodemcuv2
platform = ${common:esp8266.platform}
monitor_speed = ${common.monitor_speed}
upload_speed = ${common.upload_speed}
framework = ${common.framework}
build_flags =
${common.build_flags}
${common:esp8266.build_flags}
lib_deps =
${common.lib_deps_external}
[env:d1_mini]
board = d1_mini
platform = ${common:esp8266.platform}
monitor_speed = ${common.monitor_speed}
upload_speed = ${common.upload_speed}
framework = ${common.framework}
build_flags =
${common.build_flags}
${common:esp8266.build_flags}
lib_deps =
${common.lib_deps_external}
[env:esp01_1m]
board = esp01_1m
platform = ${common:esp8266_1M.platform}
monitor_speed = ${common.monitor_speed}
upload_speed = ${common.upload_speed}
framework = ${common.framework}
build_flags =
${common.build_flags}
${common:esp8266_1M.build_flags}
# disable IR because there is no pin for it
-D WLED_DISABLE_INFRARED
lib_deps =
${common.lib_deps_external}
[env:esp01]
board = esp01
platform = ${common:esp8266_512k.platform}
monitor_speed = ${common.monitor_speed}
upload_speed = ${common.upload_speed}
framework = ${common.framework}
build_flags =
${common.build_flags}
${common:esp8266_512k.build_flags}
lib_deps =
${common.lib_deps_external}
# see: http://docs.platformio.org/en/latest/platforms/espressif32.html
[env:esp32dev]
board = esp32dev
platform = ${common:esp32.platform}
monitor_speed = ${common.monitor_speed}
upload_speed = ${common.upload_speed_fast}
framework = ${common.framework}
build_flags =
${common.build_flags}
${common:esp32.build_flags}
lib_deps =
${common.lib_deps_external}
lib_ignore =
IRremoteESP8266

View File

@@ -1,29 +1,42 @@
![WLED logo](https://raw.githubusercontent.com/Aircoookie/WLED/master/wled_logo.png)
[![](https://img.shields.io/github/release/Aircoookie/WLED.svg?style=flat-square)](https://github.com/Aircoookie/WLED/releases)
[![](https://img.shields.io/discord/473448917040758787.svg?colorB=blue&label=discord&style=flat-square)](https://discord.gg/KuqP7NE)
[![](https://img.shields.io/badge/quick_start-wiki-blue.svg?style=flat-square)](https://github.com/Aircoookie/WLED/wiki)
[![](https://img.shields.io/badge/app-wled-blue.svg?style=flat-square)](https://github.com/Aircoookie/WLED-App)
## Welcome to my project WLED!
WLED is a fast and (relatively) secure implementation of an ESP8266/ESP32 webserver to control NeoPixel (WS2812B) LEDs!
A fast and feature-rich implementation of an ESP8266/ESP32 webserver to control NeoPixel (WS2812B, WS2811, SK6812, APA102) LEDs!
### Features: (V0.7.0)
- RGB, HSB, and brightness sliders
- All new, mobile-friendly web UI!
- Settings page - configuration over network
- Access Point and station mode - automatic failsafe AP
- WS2812FX library integrated for over 50 special effects (+Custom Theater Chase)!
- Secondary color support lets you use even more effect combinations
- Alexa smart home device server (including dimming)
- Beta syncronization to Philips hue lights
- Support for RGBW strips
- 25 user presets! Save colors and effects and apply them easily! Supports cycling through them.
- HTTP request API for simple integration
- Macro functions to automatically execute API calls
- Nightlight function (gradually dims down)
- Notifier function (multiple ESPs sync color via UDP broadcast)
- Support for power pushbutton
- Support for the Adalight serial ambilight protocol!
- Full OTA software update capability (HTTP and ArduinoOTA)
- Password protected OTA page for added security (OTA lock)
- NTP and configurable analog clock function
- Support for the Cronixie Clock kit by Diamex
- Realtime UDP Packet Control (Hyperion, WARLS, DRGB, DRGBW)
### Features:
- WS2812FX library integrated for 80 special effects
- FastLED noise effects and palettes
- Customizable Mobile and desktop UI with color and effect controls
- Settings page - configuration over network
- Access Point and station mode - automatic failsafe AP
- Support for RGBW strips
- 25 user presets to save and load colors/effects easily, supports cycling through them.
- Macro functions to automatically execute API calls
- Nightlight function (gradually dims down)
- Full OTA software updatability (HTTP + ArduinoOTA), password protectable
- Configurable analog clock + support for the Cronixie kit by Diamex
- Configurable Auto Brightness limit for safer operation
### Supported light control interfaces:
- WLED app for Android and iOS
- JSON and HTTP request APIs
- MQTT
- Blynk IoT
- E1.31
- Hyperion
- UDP realtime
- Alexa voice control (including dimming and color)
- Sync to Philips hue lights
- Adalight (PC ambilight via serial)
- Sync color of multiple WLED devices (UDP notifier)
- Infrared remotes (24-key RGB, receiver required)
- Simple timers/schedules (time from NTP, timezones/DST supported)
### Quick start guide and documentation:
@@ -31,19 +44,11 @@ See the [wiki](https://github.com/Aircoookie/WLED/wiki)!
### Other
Licensed under the MIT license
Uses libraries:
ESP8266/ESP32 Arduino Core
NeoPixelBus by Makuna
[WS2812FX](https://github.com/kitesurfer1404/WS2812FX) by kitesurfer1404 (Aircoookie fork)
Time library
Timezone library by JChristensen
Alexa code based on arduino-esp8266-alexa-multiple-wemo-switch by kakopappa
Uses Linearicons by Perxis! (link in settings page)
Licensed under the MIT license
Credits [here](https://github.com/Aircoookie/WLED/wiki/Contributors-&-About)!
Uses Linearicons by Perxis!
Join the Discord [server](https://discord.gg/KuqP7NE) to discuss everything about WLED!
You can also send me mails to [dev.aircoookie@gmail.com](mailto:dev.aircoookie@gmail.com).
If WLED really brightens up your every day, you can [![](https://img.shields.io/badge/send%20me%20a%20small%20gift-paypal-blue.svg?style=flat-square)](https://paypal.me/aircoookie)

11
test/README Normal file
View File

@@ -0,0 +1,11 @@
This directory is intended for PIO Unit Testing and project tests.
Unit Testing is a software testing method by which individual units of
source code, sets of one or more MCU program modules together with associated
control data, usage procedures, and operating procedures, are tested to
determine whether they are fit for use. Unit testing finds problems early
in the development cycle.
More information about PIO Unit Testing:
- https://docs.platformio.org/page/plus/unit-testing.html

25
wled00.sln Normal file
View File

@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28010.2046
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wled00", "wled00\wled00.vcxproj", "{C5F80730-F44F-4478-BDAE-6634EFC2CA88}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C5F80730-F44F-4478-BDAE-6634EFC2CA88}.Debug|x86.ActiveCfg = Debug|Win32
{C5F80730-F44F-4478-BDAE-6634EFC2CA88}.Debug|x86.Build.0 = Debug|Win32
{C5F80730-F44F-4478-BDAE-6634EFC2CA88}.Release|x86.ActiveCfg = Release|Win32
{C5F80730-F44F-4478-BDAE-6634EFC2CA88}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {9A679C2B-61D3-400B-B96F-06E604E9CED2}
EndGlobalSection
EndGlobal

BIN
wled00/.vs/wled00/v15/.suo Normal file

Binary file not shown.

2318
wled00/FX.cpp Normal file

File diff suppressed because it is too large Load Diff

567
wled00/FX.h Normal file
View File

@@ -0,0 +1,567 @@
/*
WS2812FX.h - Library for WS2812 LED effects.
Harm Aldick - 2016
www.aldick.org
LICENSE
The MIT License (MIT)
Copyright (c) 2016 Harm Aldick
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.
Modified for WLED
*/
#ifndef WS2812FX_h
#define WS2812FX_h
#include "NpbWrapper.h"
#define FASTLED_INTERNAL //remove annoying pragma messages
#include "FastLED.h"
#define DEFAULT_BRIGHTNESS (uint8_t)127
#define DEFAULT_MODE (uint8_t)0
#define DEFAULT_SPEED (uint8_t)128
#define DEFAULT_COLOR (uint32_t)0xFFAA00
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
/* Not used in all effects yet */
#define WLED_FPS 42
#define FRAMETIME 1000/WLED_FPS
/* each segment uses 37 bytes of SRAM memory, so if you're application fails because of
insufficient memory, decreasing MAX_NUM_SEGMENTS may help */
#define MAX_NUM_SEGMENTS 10
#define NUM_COLORS 3 /* number of colors per segment */
#define SEGMENT _segments[_segment_index]
#define SEGCOLOR(x) gamma32(_segments[_segment_index].colors[x])
#define SEGENV _segment_runtimes[_segment_index]
#define SEGLEN SEGMENT.length()
#define SEGACT SEGMENT.stop
#define SPEED_FORMULA_L 5 + (50*(255 - SEGMENT.speed))/SEGLEN
#define RESET_RUNTIME memset(_segment_runtimes, 0, sizeof(_segment_runtimes))
// some common colors
#define RED (uint32_t)0xFF0000
#define GREEN (uint32_t)0x00FF00
#define BLUE (uint32_t)0x0000FF
#define WHITE (uint32_t)0xFFFFFF
#define BLACK (uint32_t)0x000000
#define YELLOW (uint32_t)0xFFFF00
#define CYAN (uint32_t)0x00FFFF
#define MAGENTA (uint32_t)0xFF00FF
#define PURPLE (uint32_t)0x400080
#define ORANGE (uint32_t)0xFF3000
#define PINK (uint32_t)0xFF1493
#define ULTRAWHITE (uint32_t)0xFFFFFFFF
// options
// bit 7: segment is in transition mode
// bits 2-6: TBD
// bit 1: reverse segment
// bit 0: segment is selected
#define NO_OPTIONS (uint8_t)0x00
#define TRANSITIONAL (uint8_t)0x80
#define REVERSE (uint8_t)0x02
#define SELECTED (uint8_t)0x01
#define IS_TRANSITIONAL ((SEGMENT.options & TRANSITIONAL) == TRANSITIONAL)
#define IS_REVERSE ((SEGMENT.options & REVERSE ) == REVERSE )
#define IS_SELECTED ((SEGMENT.options & SELECTED) == SELECTED )
#define MODE_COUNT 83
#define FX_MODE_STATIC 0
#define FX_MODE_BLINK 1
#define FX_MODE_BREATH 2
#define FX_MODE_COLOR_WIPE 3
#define FX_MODE_COLOR_WIPE_RANDOM 4
#define FX_MODE_RANDOM_COLOR 5
#define FX_MODE_COLOR_SWEEP 6
#define FX_MODE_DYNAMIC 7
#define FX_MODE_RAINBOW 8
#define FX_MODE_RAINBOW_CYCLE 9
#define FX_MODE_SCAN 10
#define FX_MODE_DUAL_SCAN 11
#define FX_MODE_FADE 12
#define FX_MODE_THEATER_CHASE 13
#define FX_MODE_THEATER_CHASE_RAINBOW 14
#define FX_MODE_RUNNING_LIGHTS 15
#define FX_MODE_SAW 16
#define FX_MODE_TWINKLE 17
#define FX_MODE_DISSOLVE 18
#define FX_MODE_DISSOLVE_RANDOM 19
#define FX_MODE_SPARKLE 20
#define FX_MODE_FLASH_SPARKLE 21
#define FX_MODE_HYPER_SPARKLE 22
#define FX_MODE_STROBE 23
#define FX_MODE_STROBE_RAINBOW 24
#define FX_MODE_MULTI_STROBE 25
#define FX_MODE_BLINK_RAINBOW 26
#define FX_MODE_ANDROID 27
#define FX_MODE_CHASE_COLOR 28
#define FX_MODE_CHASE_RANDOM 29
#define FX_MODE_CHASE_RAINBOW 30
#define FX_MODE_CHASE_FLASH 31
#define FX_MODE_CHASE_FLASH_RANDOM 32
#define FX_MODE_CHASE_RAINBOW_WHITE 33
#define FX_MODE_COLORFUL 34
#define FX_MODE_TRAFFIC_LIGHT 35
#define FX_MODE_COLOR_SWEEP_RANDOM 36
#define FX_MODE_RUNNING_COLOR 37
#define FX_MODE_RUNNING_RED_BLUE 38
#define FX_MODE_RUNNING_RANDOM 39
#define FX_MODE_LARSON_SCANNER 40
#define FX_MODE_COMET 41
#define FX_MODE_FIREWORKS 42
#define FX_MODE_RAIN 43
#define FX_MODE_MERRY_CHRISTMAS 44
#define FX_MODE_FIRE_FLICKER 45
#define FX_MODE_GRADIENT 46
#define FX_MODE_LOADING 47
#define FX_MODE_DUAL_COLOR_WIPE_IN_OUT 48
#define FX_MODE_DUAL_COLOR_WIPE_IN_IN 49
#define FX_MODE_DUAL_COLOR_WIPE_OUT_OUT 50
#define FX_MODE_DUAL_COLOR_WIPE_OUT_IN 51
#define FX_MODE_CIRCUS_COMBUSTUS 52
#define FX_MODE_HALLOWEEN 53
#define FX_MODE_TRICOLOR_CHASE 54
#define FX_MODE_TRICOLOR_WIPE 55
#define FX_MODE_TRICOLOR_FADE 56
#define FX_MODE_LIGHTNING 57
#define FX_MODE_ICU 58
#define FX_MODE_MULTI_COMET 59
#define FX_MODE_DUAL_LARSON_SCANNER 60
#define FX_MODE_RANDOM_CHASE 61
#define FX_MODE_OSCILLATE 62
//Modes that use FastLED -->
#define FX_MODE_PRIDE_2015 63
#define FX_MODE_JUGGLE 64
#define FX_MODE_PALETTE 65
#define FX_MODE_FIRE_2012 66
#define FX_MODE_COLORWAVES 67
#define FX_MODE_BPM 68
#define FX_MODE_FILLNOISE8 69
#define FX_MODE_NOISE16_1 70
#define FX_MODE_NOISE16_2 71
#define FX_MODE_NOISE16_3 72
#define FX_MODE_NOISE16_4 73
#define FX_MODE_COLORTWINKLE 74
#define FX_MODE_LAKE 75
#define FX_MODE_METEOR 76
#define FX_MODE_METEOR_SMOOTH 77
#define FX_MODE_RAILWAY 78
#define FX_MODE_RIPPLE 79
#define FX_MODE_TWINKLEFOX 80
#define FX_MODE_TWINKLECAT 81
#define FX_MODE_HALLOWEEN_EYES 82
class WS2812FX {
typedef uint16_t (WS2812FX::*mode_ptr)(void);
// segment parameters
public:
typedef struct Segment { // 21 bytes
uint16_t start;
uint16_t stop; //segment invalid if stop == 0
uint8_t speed;
uint8_t intensity;
uint8_t palette;
uint8_t mode;
uint8_t options; //bit pattern: msb first: transitional tbd tbd tbd tbd paused reverse selected
uint32_t colors[NUM_COLORS];
void setOption(uint8_t n, bool val)
{
if (val) {
options |= 0x01 << n;
} else
{
options &= ~(0x01 << n);
}
}
bool getOption(uint8_t n)
{
return ((options >> n) & 0x01);
}
bool isSelected()
{
return getOption(0);
}
bool isActive()
{
return stop > start;
}
uint16_t length()
{
return stop - start;
}
} segment;
// segment runtime parameters
typedef struct Segment_runtime { // 16 bytes
unsigned long next_time;
uint32_t step;
uint32_t call;
uint16_t aux0;
uint16_t aux1;
void reset(){next_time = 0; step = 0; call = 0; aux0 = 0; aux1 = 0;};
} segment_runtime;
WS2812FX() {
//assign each member of the _mode[] array to its respective function reference
_mode[FX_MODE_STATIC] = &WS2812FX::mode_static;
_mode[FX_MODE_BLINK] = &WS2812FX::mode_blink;
_mode[FX_MODE_COLOR_WIPE] = &WS2812FX::mode_color_wipe;
_mode[FX_MODE_COLOR_WIPE_RANDOM] = &WS2812FX::mode_color_wipe_random;
_mode[FX_MODE_RANDOM_COLOR] = &WS2812FX::mode_random_color;
_mode[FX_MODE_COLOR_SWEEP] = &WS2812FX::mode_color_sweep;
_mode[FX_MODE_DYNAMIC] = &WS2812FX::mode_dynamic;
_mode[FX_MODE_RAINBOW] = &WS2812FX::mode_rainbow;
_mode[FX_MODE_RAINBOW_CYCLE] = &WS2812FX::mode_rainbow_cycle;
_mode[FX_MODE_SCAN] = &WS2812FX::mode_scan;
_mode[FX_MODE_DUAL_SCAN] = &WS2812FX::mode_dual_scan;
_mode[FX_MODE_FADE] = &WS2812FX::mode_fade;
_mode[FX_MODE_THEATER_CHASE] = &WS2812FX::mode_theater_chase;
_mode[FX_MODE_THEATER_CHASE_RAINBOW] = &WS2812FX::mode_theater_chase_rainbow;
_mode[FX_MODE_SAW] = &WS2812FX::mode_saw;
_mode[FX_MODE_TWINKLE] = &WS2812FX::mode_twinkle;
_mode[FX_MODE_DISSOLVE] = &WS2812FX::mode_dissolve;
_mode[FX_MODE_DISSOLVE_RANDOM] = &WS2812FX::mode_dissolve_random;
_mode[FX_MODE_SPARKLE] = &WS2812FX::mode_sparkle;
_mode[FX_MODE_FLASH_SPARKLE] = &WS2812FX::mode_flash_sparkle;
_mode[FX_MODE_HYPER_SPARKLE] = &WS2812FX::mode_hyper_sparkle;
_mode[FX_MODE_STROBE] = &WS2812FX::mode_strobe;
_mode[FX_MODE_STROBE_RAINBOW] = &WS2812FX::mode_strobe_rainbow;
_mode[FX_MODE_MULTI_STROBE] = &WS2812FX::mode_multi_strobe;
_mode[FX_MODE_BLINK_RAINBOW] = &WS2812FX::mode_blink_rainbow;
_mode[FX_MODE_ANDROID] = &WS2812FX::mode_android;
_mode[FX_MODE_CHASE_COLOR] = &WS2812FX::mode_chase_color;
_mode[FX_MODE_CHASE_RANDOM] = &WS2812FX::mode_chase_random;
_mode[FX_MODE_CHASE_RAINBOW] = &WS2812FX::mode_chase_rainbow;
_mode[FX_MODE_CHASE_FLASH] = &WS2812FX::mode_chase_flash;
_mode[FX_MODE_CHASE_FLASH_RANDOM] = &WS2812FX::mode_chase_flash_random;
_mode[FX_MODE_CHASE_RAINBOW_WHITE] = &WS2812FX::mode_chase_rainbow_white;
_mode[FX_MODE_COLORFUL] = &WS2812FX::mode_colorful;
_mode[FX_MODE_TRAFFIC_LIGHT] = &WS2812FX::mode_traffic_light;
_mode[FX_MODE_COLOR_SWEEP_RANDOM] = &WS2812FX::mode_color_sweep_random;
_mode[FX_MODE_RUNNING_COLOR] = &WS2812FX::mode_running_color;
_mode[FX_MODE_RUNNING_RED_BLUE] = &WS2812FX::mode_running_red_blue;
_mode[FX_MODE_RUNNING_RANDOM] = &WS2812FX::mode_running_random;
_mode[FX_MODE_LARSON_SCANNER] = &WS2812FX::mode_larson_scanner;
_mode[FX_MODE_COMET] = &WS2812FX::mode_comet;
_mode[FX_MODE_FIREWORKS] = &WS2812FX::mode_fireworks;
_mode[FX_MODE_RAIN] = &WS2812FX::mode_rain;
_mode[FX_MODE_MERRY_CHRISTMAS] = &WS2812FX::mode_merry_christmas;
_mode[FX_MODE_FIRE_FLICKER] = &WS2812FX::mode_fire_flicker;
_mode[FX_MODE_GRADIENT] = &WS2812FX::mode_gradient;
_mode[FX_MODE_LOADING] = &WS2812FX::mode_loading;
_mode[FX_MODE_DUAL_COLOR_WIPE_IN_OUT] = &WS2812FX::mode_dual_color_wipe_in_out;
_mode[FX_MODE_DUAL_COLOR_WIPE_IN_IN] = &WS2812FX::mode_dual_color_wipe_in_in;
_mode[FX_MODE_DUAL_COLOR_WIPE_OUT_OUT] = &WS2812FX::mode_dual_color_wipe_out_out;
_mode[FX_MODE_DUAL_COLOR_WIPE_OUT_IN] = &WS2812FX::mode_dual_color_wipe_out_in;
_mode[FX_MODE_CIRCUS_COMBUSTUS] = &WS2812FX::mode_circus_combustus;
_mode[FX_MODE_HALLOWEEN] = &WS2812FX::mode_halloween;
_mode[FX_MODE_TRICOLOR_CHASE] = &WS2812FX::mode_tricolor_chase;
_mode[FX_MODE_TRICOLOR_WIPE] = &WS2812FX::mode_tricolor_wipe;
_mode[FX_MODE_TRICOLOR_FADE] = &WS2812FX::mode_tricolor_fade;
_mode[FX_MODE_BREATH] = &WS2812FX::mode_breath;
_mode[FX_MODE_RUNNING_LIGHTS] = &WS2812FX::mode_running_lights;
_mode[FX_MODE_LIGHTNING] = &WS2812FX::mode_lightning;
_mode[FX_MODE_ICU] = &WS2812FX::mode_icu;
_mode[FX_MODE_MULTI_COMET] = &WS2812FX::mode_multi_comet;
_mode[FX_MODE_DUAL_LARSON_SCANNER] = &WS2812FX::mode_dual_larson_scanner;
_mode[FX_MODE_RANDOM_CHASE] = &WS2812FX::mode_random_chase;
_mode[FX_MODE_OSCILLATE] = &WS2812FX::mode_oscillate;
_mode[FX_MODE_FIRE_2012] = &WS2812FX::mode_fire_2012;
_mode[FX_MODE_PRIDE_2015] = &WS2812FX::mode_pride_2015;
_mode[FX_MODE_BPM] = &WS2812FX::mode_bpm;
_mode[FX_MODE_JUGGLE] = &WS2812FX::mode_juggle;
_mode[FX_MODE_PALETTE] = &WS2812FX::mode_palette;
_mode[FX_MODE_COLORWAVES] = &WS2812FX::mode_colorwaves;
_mode[FX_MODE_FILLNOISE8] = &WS2812FX::mode_fillnoise8;
_mode[FX_MODE_NOISE16_1] = &WS2812FX::mode_noise16_1;
_mode[FX_MODE_NOISE16_2] = &WS2812FX::mode_noise16_2;
_mode[FX_MODE_NOISE16_3] = &WS2812FX::mode_noise16_3;
_mode[FX_MODE_NOISE16_4] = &WS2812FX::mode_noise16_4;
_mode[FX_MODE_COLORTWINKLE] = &WS2812FX::mode_colortwinkle;
_mode[FX_MODE_LAKE] = &WS2812FX::mode_lake;
_mode[FX_MODE_METEOR] = &WS2812FX::mode_meteor;
_mode[FX_MODE_METEOR_SMOOTH] = &WS2812FX::mode_meteor_smooth;
_mode[FX_MODE_RAILWAY] = &WS2812FX::mode_railway;
_mode[FX_MODE_RIPPLE] = &WS2812FX::mode_ripple;
_mode[FX_MODE_TWINKLEFOX] = &WS2812FX::mode_twinklefox;
_mode[FX_MODE_TWINKLECAT] = &WS2812FX::mode_twinklecat;
_mode[FX_MODE_HALLOWEEN_EYES] = &WS2812FX::mode_halloween_eyes;
_brightness = DEFAULT_BRIGHTNESS;
currentPalette = CRGBPalette16(CRGB::Black);
targetPalette = CloudColors_p;
ablMilliampsMax = 850;
currentMilliamps = 0;
timebase = 0;
_locked = nullptr;
_modeUsesLock = false;
bus = new NeoPixelWrapper();
resetSegments();
}
void
init(bool supportWhite, uint16_t countPixels, bool skipFirs),
service(void),
blur(uint8_t),
fade_out(uint8_t r),
setMode(uint8_t m),
setMode(uint8_t segid, uint8_t m),
setSpeed(uint8_t s),
setIntensity(uint8_t i),
setPalette(uint8_t p),
setColor(uint8_t slot, uint8_t r, uint8_t g, uint8_t b, uint8_t w = 0),
setColor(uint8_t slot, uint32_t c),
setBrightness(uint8_t b),
driverModeCronixie(bool b),
setCronixieDigits(byte* d),
setCronixieBacklight(bool b),
setIndividual(uint16_t i, uint32_t col),
setRange(uint16_t i, uint16_t i2, uint32_t col),
lock(uint16_t i),
lockRange(uint16_t i, uint16_t i2),
unlock(uint16_t i),
unlockRange(uint16_t i, uint16_t i2),
unlockAll(void),
setTransitionMode(bool t),
trigger(void),
setSegment(uint8_t n, uint16_t start, uint16_t stop),
resetSegments(),
setPixelColor(uint16_t n, uint32_t c),
setPixelColor(uint16_t n, uint8_t r, uint8_t g, uint8_t b, uint8_t w = 0),
show(void);
bool
reverseMode = false,
gammaCorrectBri = false,
gammaCorrectCol = true,
setEffectConfig(uint8_t m, uint8_t s, uint8_t i, uint8_t p);
uint8_t
returnedSegment = 0,
paletteFade = 0,
paletteBlend = 0,
colorOrder = 0,
getBrightness(void),
getMode(void),
getSpeed(void),
getModeCount(void),
getPaletteCount(void),
getMaxSegments(void),
getFirstSelectedSegment(void),
getReturnedSegmentId(void),
gamma8(uint8_t),
get_random_wheel_index(uint8_t);
uint16_t
ablMilliampsMax,
currentMilliamps;
uint32_t
timebase,
color_wheel(uint8_t),
color_from_palette(uint16_t, bool, bool, uint8_t, uint8_t pbri = 255),
color_blend(uint32_t,uint32_t,uint8_t),
gamma32(uint32_t),
getPixelColor(uint16_t),
getColor(void);
WS2812FX::Segment&
getSegment(uint8_t n);
WS2812FX::Segment_runtime
getSegmentRuntime(void);
WS2812FX::Segment*
getSegments(void);
// builtin modes
uint16_t
mode_static(void),
mode_blink(void),
mode_blink_rainbow(void),
mode_strobe(void),
mode_strobe_rainbow(void),
mode_color_wipe(void),
mode_color_sweep(void),
mode_color_wipe_random(void),
mode_color_sweep_random(void),
mode_random_color(void),
mode_dynamic(void),
mode_breath(void),
mode_fade(void),
mode_scan(void),
mode_dual_scan(void),
mode_theater_chase(void),
mode_theater_chase_rainbow(void),
mode_rainbow(void),
mode_rainbow_cycle(void),
mode_running_lights(void),
mode_saw(void),
mode_twinkle(void),
mode_dissolve(void),
mode_dissolve_random(void),
mode_sparkle(void),
mode_flash_sparkle(void),
mode_hyper_sparkle(void),
mode_multi_strobe(void),
mode_android(void),
mode_chase_color(void),
mode_chase_random(void),
mode_chase_rainbow(void),
mode_chase_flash(void),
mode_chase_flash_random(void),
mode_chase_rainbow_white(void),
mode_colorful(void),
mode_traffic_light(void),
mode_running_color(void),
mode_running_red_blue(void),
mode_running_random(void),
mode_larson_scanner(void),
mode_comet(void),
mode_fireworks(void),
mode_rain(void),
mode_merry_christmas(void),
mode_halloween(void),
mode_fire_flicker(void),
mode_gradient(void),
mode_loading(void),
mode_dual_color_wipe_in_out(void),
mode_dual_color_wipe_in_in(void),
mode_dual_color_wipe_out_out(void),
mode_dual_color_wipe_out_in(void),
mode_circus_combustus(void),
mode_bicolor_chase(void),
mode_tricolor_chase(void),
mode_tricolor_wipe(void),
mode_tricolor_fade(void),
mode_lightning(void),
mode_icu(void),
mode_multi_comet(void),
mode_dual_larson_scanner(void),
mode_random_chase(void),
mode_oscillate(void),
mode_fire_2012(void),
mode_pride_2015(void),
mode_bpm(void),
mode_juggle(void),
mode_palette(void),
mode_colorwaves(void),
mode_fillnoise8(void),
mode_noise16_1(void),
mode_noise16_2(void),
mode_noise16_3(void),
mode_noise16_4(void),
mode_colortwinkle(void),
mode_lake(void),
mode_meteor(void),
mode_meteor_smooth(void),
mode_railway(void),
mode_ripple(void),
mode_twinklefox(void),
mode_twinklecat(void),
mode_halloween_eyes(void);
private:
NeoPixelWrapper *bus;
uint32_t crgb_to_col(CRGB fastled);
CRGB col_to_crgb(uint32_t);
CRGBPalette16 currentPalette;
CRGBPalette16 targetPalette;
uint32_t now;
uint16_t _length;
uint16_t _rand16seed;
uint8_t _brightness;
void handle_palette(void);
void fill(uint32_t);
bool modeUsesLock(uint8_t);
void twinklefox_base(bool);
bool
_modeUsesLock,
_rgbwMode,
_cronixieMode,
_cronixieBacklightEnabled,
_skipFirstMode,
_triggered;
byte* _locked;
byte _cronixieDigits[6];
mode_ptr _mode[MODE_COUNT]; // SRAM footprint: 4 bytes per element
// mode helper functions
uint16_t
blink(uint32_t, uint32_t, bool strobe, bool),
color_wipe(bool, bool),
scan(bool),
theater_chase(uint32_t, uint32_t, bool),
running_base(bool),
dissolve(uint32_t),
chase(uint32_t, uint32_t, uint32_t, bool),
gradient_base(bool),
running(uint32_t, uint32_t),
tricolor_chase(uint32_t, uint32_t);
CRGB twinklefox_one_twinkle(uint32_t ms, uint8_t salt, bool cat);
uint32_t _lastPaletteChange = 0;
uint32_t _lastShow = 0;
uint8_t _segment_index = 0;
uint8_t _segment_index_palette_last = 99;
segment _segments[MAX_NUM_SEGMENTS] = { // SRAM footprint: 21 bytes per element
// start, stop, speed, intensity, palette, mode, options, color[]
{ 0, 7, DEFAULT_SPEED, 128, 0, DEFAULT_MODE, NO_OPTIONS, {DEFAULT_COLOR}}
};
segment_runtime _segment_runtimes[MAX_NUM_SEGMENTS]; // SRAM footprint: 16 bytes per element
};
//10 names per line
const char JSON_mode_names[] PROGMEM = R"=====([
"Solid","Blink","Breathe","Wipe","Wipe Random","Random Colors","Sweep","Dynamic","Colorloop","Rainbow",
"Scan","Dual Scan","Fade","Chase","Chase Rainbow","Running","Saw","Twinkle","Dissolve","Dissolve Rnd",
"Sparkle","Dark Sparkle","Sparkle+","Strobe","Strobe Rainbow","Mega Strobe","Blink Rainbow","Android","Chase","Chase Random",
"Chase Rainbow","Chase Flash","Chase Flash Rnd","Rainbow Runner","Colorful","Traffic Light","Sweep Random","Running 2","Red & Blue","Stream",
"Scanner","Lighthouse","Fireworks","Rain","Merry Christmas","Fire Flicker","Gradient","Loading","In Out","In In",
"Out Out","Out In","Circus","Halloween","Tri Chase","Tri Wipe","Tri Fade","Lightning","ICU","Multi Comet",
"Dual Scanner","Stream 2","Oscillate","Pride 2015","Juggle","Palette","Fire 2012","Colorwaves","BPM","Fill Noise",
"Noise 1","Noise 2","Noise 3","Noise 4","Colortwinkles","Lake","Meteor","Smooth Meteor","Railway","Ripple",
"Twinklefox","Twinklecat","Halloween Eyes"
])=====";
const char JSON_palette_names[] PROGMEM = R"=====([
"Default","Random Cycle","Primary Color","Based on Primary","Set Colors","Based on Set","Party","Cloud","Lava","Ocean",
"Forest","Rainbow","Rainbow Bands","Sunset","Rivendell","Breeze","Red & Blue","Yellowout","Analogous","Splash",
"Pastel","Sunset 2","Beech","Vintage","Departure","Landscape","Beach","Sherbet","Hult","Hult 64",
"Drywet","Jul","Grintage","Rewhi","Tertiary","Fire","Icefire","Cyane","Light Pink","Autumn",
"Magenta","Magred","Yelmag","Yelblu","Orange & Teal","Tiamat","April Night","Orangery","C9","Sakura"
])=====";
#endif

825
wled00/FX_fcn.cpp Normal file
View File

@@ -0,0 +1,825 @@
/*
WS2812FX_fcn.cpp contains all utility functions
Harm Aldick - 2016
www.aldick.org
LICENSE
The MIT License (MIT)
Copyright (c) 2016 Harm Aldick
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.
Modified heavily for WLED
*/
#include "FX.h"
#include "palettes.h"
#define LED_SKIP_AMOUNT 1
#define MIN_SHOW_DELAY 15
void WS2812FX::init(bool supportWhite, uint16_t countPixels, bool skipFirst)
{
if (supportWhite == _rgbwMode && countPixels == _length && _locked != NULL) return;
RESET_RUNTIME;
_rgbwMode = supportWhite;
_skipFirstMode = skipFirst;
_length = countPixels;
uint8_t ty = 1;
if (supportWhite) ty =2;
uint16_t lengthRaw = _length;
if (_skipFirstMode) lengthRaw += LED_SKIP_AMOUNT;
bus->Begin((NeoPixelType)ty, lengthRaw);
delete[] _locked;
_locked = new byte[_length];
_segments[0].start = 0;
_segments[0].stop = _length;
unlockAll();
setBrightness(_brightness);
}
void WS2812FX::service() {
now = millis() + timebase; // Be aware, millis() rolls over every 49 days
if (now - _lastShow < MIN_SHOW_DELAY) return;
bool doShow = false;
for(uint8_t i=0; i < MAX_NUM_SEGMENTS; i++)
{
_segment_index = i;
if (SEGMENT.isActive())
{
if(now > SEGENV.next_time || _triggered || (doShow && SEGMENT.mode == 0)) //last is temporary
{
doShow = true;
handle_palette();
uint16_t delay = (this->*_mode[SEGMENT.mode])();
SEGENV.next_time = now + delay;
if (SEGMENT.mode != FX_MODE_HALLOWEEN_EYES) SEGENV.call++;
}
}
}
if(doShow) {
yield();
show();
_lastShow = millis();
}
_triggered = false;
}
bool WS2812FX::modeUsesLock(uint8_t m)
{
if (m == FX_MODE_FIRE_2012 || m == FX_MODE_COLORTWINKLE ||
m == FX_MODE_METEOR || m == FX_MODE_METEOR_SMOOTH ||
m == FX_MODE_RIPPLE || m == FX_MODE_DYNAMIC ) return true;
return false;
}
void WS2812FX::setPixelColor(uint16_t n, uint32_t c) {
uint8_t w = (c >> 24) & 0xFF;
uint8_t r = (c >> 16) & 0xFF;
uint8_t g = (c >> 8) & 0xFF;
uint8_t b = c & 0xFF;
setPixelColor(n, r, g, b, w);
}
void WS2812FX::setPixelColor(uint16_t i, byte r, byte g, byte b, byte w)
{
if (_locked[i] && !_modeUsesLock) return;
if (IS_REVERSE) i = SEGMENT.stop -1 -i - SEGMENT.start; //reverse just individual segment
byte tmpg = g;
switch (colorOrder) //0 = Grb, default
{
case 0: break; //0 = Grb, default
case 1: g = r; r = tmpg; break; //1 = Rgb, common for WS2811
case 2: g = b; b = tmpg; break; //2 = Brg
case 3: g = b; b = r; r = tmpg; //3 = Rbg
}
if (!_cronixieMode)
{
if (reverseMode) i = _length -1 -i;
if (_skipFirstMode)
{
if (i < LED_SKIP_AMOUNT) bus->SetPixelColor(i, RgbwColor(0,0,0,0));
i += LED_SKIP_AMOUNT;
}
bus->SetPixelColor(i, RgbwColor(r,g,b,w));
} else {
if(i>6)return;
byte o = 10*i;
if (_cronixieBacklightEnabled && _cronixieDigits[i] <11)
{
byte r2 = (_segments[0].colors[1] >>16) & 0xFF;
byte g2 = (_segments[0].colors[1] >> 8) & 0xFF;
byte b2 = (_segments[0].colors[1] ) & 0xFF;
byte w2 = (_segments[0].colors[1] >>24) & 0xFF;
for (int j=o; j< o+19; j++)
{
bus->SetPixelColor(j, RgbwColor(r2,g2,b2,w2));
}
} else
{
for (int j=o; j< o+19; j++)
{
bus->SetPixelColor(j, RgbwColor(0,0,0,0));
}
}
if (_skipFirstMode) o += LED_SKIP_AMOUNT;
switch(_cronixieDigits[i])
{
case 0: bus->SetPixelColor(o+5, RgbwColor(r,g,b,w)); break;
case 1: bus->SetPixelColor(o+0, RgbwColor(r,g,b,w)); break;
case 2: bus->SetPixelColor(o+6, RgbwColor(r,g,b,w)); break;
case 3: bus->SetPixelColor(o+1, RgbwColor(r,g,b,w)); break;
case 4: bus->SetPixelColor(o+7, RgbwColor(r,g,b,w)); break;
case 5: bus->SetPixelColor(o+2, RgbwColor(r,g,b,w)); break;
case 6: bus->SetPixelColor(o+8, RgbwColor(r,g,b,w)); break;
case 7: bus->SetPixelColor(o+3, RgbwColor(r,g,b,w)); break;
case 8: bus->SetPixelColor(o+9, RgbwColor(r,g,b,w)); break;
case 9: bus->SetPixelColor(o+4, RgbwColor(r,g,b,w)); break;
}
}
}
void WS2812FX::driverModeCronixie(bool b)
{
_cronixieMode = b;
_segments[0].stop = (b) ? 6 : _length;
}
void WS2812FX::setCronixieBacklight(bool b)
{
_cronixieBacklightEnabled = b;
}
void WS2812FX::setCronixieDigits(byte d[])
{
for (int i = 0; i<6; i++)
{
_cronixieDigits[i] = d[i];
}
}
//DISCLAIMER
//The following function attemps to calculate the current LED power usage,
//and will limit the brightness to stay below a set amperage threshold.
//It is NOT a measurement and NOT guaranteed to stay within the ablMilliampsMax margin.
//Stay safe with high amperage and have a reasonable safety margin!
//I am NOT to be held liable for burned down garages!
//fine tune power estimation constants for your setup
#define PU_PER_MA 3600 //power units per milliamperere for accurate power estimation
//formula: 195075 divided by mA per fully lit LED, here ~54mA)
//lowering the value increases the estimated usage and therefore makes the ABL more aggressive
#define MA_FOR_ESP 100 //how much mA does the ESP use (Wemos D1 about 80mA, ESP32 about 120mA)
//you can set it to 0 if the ESP is powered by USB and the LEDs by external
void WS2812FX::show(void) {
//power limit calculation
//each LED can draw up 195075 "power units" (approx. 53mA)
//one PU is the power it takes to have 1 channel 1 step brighter per brightness step
//so A=2,R=255,G=0,B=0 would use 510 PU per LED (1mA is about 3700 PU)
if (ablMilliampsMax > 149 && ablMilliampsMax < 65000) //lower numbers and 65000 turn off calculation
{
uint32_t powerBudget = (ablMilliampsMax - MA_FOR_ESP) * PU_PER_MA; //100mA for ESP power
if (powerBudget > PU_PER_MA * _length) //each LED uses about 1mA in standby, exclude that from power budget
{
powerBudget -= PU_PER_MA * _length;
} else
{
powerBudget = 0;
}
uint32_t powerSum = 0;
for (uint16_t i = 0; i < _length; i++) //sum up the usage of each LED
{
RgbwColor c = bus->GetPixelColorRgbw(i);
powerSum += (c.R + c.G + c.B + c.W);
}
if (_rgbwMode) //RGBW led total output with white LEDs enabled is still 50mA, so each channel uses less
{
powerSum *= 3;
powerSum = powerSum >> 2; //same as /= 4
}
uint32_t powerSum0 = powerSum;
powerSum *= _brightness;
if (powerSum > powerBudget) //scale brightness down to stay in current limit
{
float scale = (float)powerBudget / (float)powerSum;
uint16_t scaleI = scale * 255;
uint8_t scaleB = (scaleI > 255) ? 255 : scaleI;
uint8_t newBri = scale8(_brightness, scaleB);
bus->SetBrightness(newBri);
currentMilliamps = (powerSum0 * newBri) / PU_PER_MA;
} else
{
currentMilliamps = powerSum / PU_PER_MA;
bus->SetBrightness(_brightness);
}
currentMilliamps += MA_FOR_ESP; //add power of ESP back to estimate
currentMilliamps += _length; //add standby power back to estimate
} else {
currentMilliamps = 0;
bus->SetBrightness(_brightness);
}
bus->Show();
}
void WS2812FX::trigger() {
_triggered = true;
}
void WS2812FX::setMode(uint8_t segid, uint8_t m) {
if (segid >= MAX_NUM_SEGMENTS) return;
bool anyUsedLock = _modeUsesLock, anyUseLock = false;
if (m >= MODE_COUNT) m = MODE_COUNT - 1;
if (_segments[segid].mode != m)
{
_segment_runtimes[segid].reset();
_segments[segid].mode = m;
}
for (uint8_t i = 0; i < MAX_NUM_SEGMENTS; i++)
{
if (modeUsesLock(_segments[i].mode)) anyUseLock = true;
}
if (anyUsedLock && !anyUseLock) unlockAll();
_modeUsesLock = anyUseLock;
}
uint8_t WS2812FX::getModeCount()
{
return MODE_COUNT;
}
uint8_t WS2812FX::getPaletteCount()
{
return 13 + gGradientPaletteCount;
}
//TODO transitions
void WS2812FX::setMode(uint8_t m) {
for (uint8_t i = 0; i < MAX_NUM_SEGMENTS; i++)
{
if (_segments[i].isSelected()) setMode(i, m);
}
}
void WS2812FX::setSpeed(uint8_t s) {
for (uint8_t i = 0; i < MAX_NUM_SEGMENTS; i++)
{
if (_segments[i].isSelected()) _segments[i].speed = s;
}
}
void WS2812FX::setIntensity(uint8_t in) {
for (uint8_t i = 0; i < MAX_NUM_SEGMENTS; i++)
{
if (_segments[i].isSelected()) _segments[i].intensity = in;
}
}
void WS2812FX::setPalette(uint8_t p) {
for (uint8_t i = 0; i < MAX_NUM_SEGMENTS; i++)
{
if (_segments[i].isSelected()) _segments[i].palette = p;
}
}
bool WS2812FX::setEffectConfig(uint8_t m, uint8_t s, uint8_t in, uint8_t p) {
uint8_t retSeg = getReturnedSegmentId();
Segment& seg = _segments[retSeg];
uint8_t modePrev = seg.mode, speedPrev = seg.speed, intensityPrev = seg.intensity, palettePrev = seg.palette;
for (uint8_t i = 0; i < MAX_NUM_SEGMENTS; i++)
{
if (_segments[i].isSelected())
{
_segments[i].speed = s;
_segments[i].intensity = in;
_segments[i].palette = p;
setMode(i, m);
}
}
if (seg.mode != modePrev || seg.speed != speedPrev || seg.intensity != intensityPrev || seg.palette != palettePrev) return true;
return false;
}
void WS2812FX::setColor(uint8_t slot, uint8_t r, uint8_t g, uint8_t b, uint8_t w) {
setColor(slot, ((uint32_t)w << 24) |((uint32_t)r << 16) | ((uint32_t)g << 8) | b);
}
void WS2812FX::setColor(uint8_t slot, uint32_t c) {
if (slot >= NUM_COLORS) return;
for (uint8_t i = 0; i < MAX_NUM_SEGMENTS; i++)
{
if (_segments[i].isSelected()) _segments[i].colors[slot] = c;
}
}
void WS2812FX::setBrightness(uint8_t b) {
if (_brightness == b) return;
_brightness = (gammaCorrectBri) ? gamma8(b) : b;
_segment_index = 0;
if (SEGENV.next_time > millis() + 22) show();//apply brightness change immediately if no refresh soon
}
uint8_t WS2812FX::getMode(void) {
return _segments[getReturnedSegmentId()].mode;
}
uint8_t WS2812FX::getSpeed(void) {
return _segments[getReturnedSegmentId()].speed;
}
uint8_t WS2812FX::getBrightness(void) {
return _brightness;
}
uint8_t WS2812FX::getMaxSegments(void) {
return MAX_NUM_SEGMENTS;
}
uint8_t WS2812FX::getFirstSelectedSegment(void)
{
for (uint8_t i = 0; i < MAX_NUM_SEGMENTS; i++)
{
if (_segments[i].isActive() && _segments[i].isSelected()) return i;
}
for (uint8_t i = 0; i < MAX_NUM_SEGMENTS; i++) //if none selected, get first active
{
if (_segments[i].isActive()) return i;
}
return 0;
}
uint8_t WS2812FX::getReturnedSegmentId(void) {
if (returnedSegment >= MAX_NUM_SEGMENTS || !_segments[returnedSegment].isActive())
{
return getFirstSelectedSegment();
}
return returnedSegment;
}
uint32_t WS2812FX::getColor(void) {
return _segments[getReturnedSegmentId()].colors[0];
}
uint32_t WS2812FX::getPixelColor(uint16_t i)
{
if (reverseMode) i = _length- 1 -i;
if (IS_REVERSE) i = SEGMENT.stop -1 -i - SEGMENT.start; //reverse just individual segment
if (_skipFirstMode) i += LED_SKIP_AMOUNT;
if (_cronixieMode)
{
if(i>6)return 0;
byte o = 10*i;
switch(_cronixieDigits[i])
{
case 0: i=o+5; break;
case 1: i=o+0; break;
case 2: i=o+6; break;
case 3: i=o+1; break;
case 4: i=o+7; break;
case 5: i=o+2; break;
case 6: i=o+8; break;
case 7: i=o+3; break;
case 8: i=o+9; break;
case 9: i=o+4; break;
default: return 0;
}
}
RgbwColor lColor = bus->GetPixelColorRgbw(i);
byte r = lColor.R, g = lColor.G, b = lColor.B;
switch (colorOrder)
{
case 0: break; //0 = Grb
case 1: r = lColor.G; g = lColor.R; break; //1 = Rgb, common for WS2811
case 2: g = lColor.B; b = lColor.G; break; //2 = Brg
case 3: r = lColor.B; g = lColor.R; b = lColor.G; //3 = Rbg
}
return ( (lColor.W << 24) | (r << 16) | (g << 8) | (b) );
}
WS2812FX::Segment& WS2812FX::getSegment(uint8_t id) {
if (id >= MAX_NUM_SEGMENTS) return _segments[0];
return _segments[id];
}
WS2812FX::Segment_runtime WS2812FX::getSegmentRuntime(void) {
return SEGENV;
}
WS2812FX::Segment* WS2812FX::getSegments(void) {
return _segments;
}
void WS2812FX::setSegment(uint8_t n, uint16_t i1, uint16_t i2) {
if (n >= MAX_NUM_SEGMENTS) return;
Segment& seg = _segments[n];
if (seg.start == i1 && seg.stop == i2) return;
if (seg.isActive() && modeUsesLock(seg.mode))
{
_modeUsesLock = false;
unlockRange(seg.start, seg.stop);
_modeUsesLock = true;
}
if (i2 <= i1) //disable segment
{
seg.stop = 0; return;
}
if (i1 < _length) seg.start = i1;
seg.stop = i2;
if (i2 > _length) seg.stop = _length;
_segment_runtimes[n].reset();
}
void WS2812FX::resetSegments() {
memset(_segments, 0, sizeof(_segments));
memset(_segment_runtimes, 0, sizeof(_segment_runtimes));
_segment_index = 0;
_segments[0].mode = DEFAULT_MODE;
_segments[0].colors[0] = DEFAULT_COLOR;
_segments[0].start = 0;
_segments[0].speed = DEFAULT_SPEED;
_segments[0].stop = _length;
_segments[0].setOption(0, 1); //select
}
void WS2812FX::setIndividual(uint16_t i, uint32_t col)
{
if (modeUsesLock(SEGMENT.mode)) return;
if (i >= 0 && i < _length)
{
_locked[i] = false;
setPixelColor(i, col);
_locked[i] = true;
}
}
void WS2812FX::setRange(uint16_t i, uint16_t i2, uint32_t col)
{
if (i2 >= i)
{
for (uint16_t x = i; x <= i2; x++) setIndividual(x,col);
} else
{
for (uint16_t x = i2; x <= i; x++) setIndividual(x,col);
}
}
void WS2812FX::lock(uint16_t i)
{
if (_modeUsesLock) return;
if (i < _length) _locked[i] = true;
}
void WS2812FX::lockRange(uint16_t i, uint16_t i2)
{
if (_modeUsesLock) return;
for (uint16_t x = i; x < i2; x++)
{
if (x < _length) _locked[i] = true;
}
}
void WS2812FX::unlock(uint16_t i)
{
if (_modeUsesLock) return;
if (i < _length) _locked[i] = false;
}
void WS2812FX::unlockRange(uint16_t i, uint16_t i2)
{
if (_modeUsesLock) return;
for (uint16_t x = i; x < i2; x++)
{
if (x < _length) _locked[x] = false;
}
}
void WS2812FX::unlockAll()
{
for (int i=0; i < _length; i++) _locked[i] = false;
}
void WS2812FX::setTransitionMode(bool t)
{
_segment_index = 0;
SEGMENT.setOption(7,t);
if (!t) return;
unsigned long waitMax = millis() + 20; //refresh after 20 ms if transition enabled
if (SEGMENT.mode == FX_MODE_STATIC && SEGENV.next_time > waitMax) SEGENV.next_time = waitMax;
}
/*
* color blend function
*/
uint32_t WS2812FX::color_blend(uint32_t color1, uint32_t color2, uint8_t blend) {
if(blend == 0) return color1;
if(blend == 255) return color2;
uint32_t w1 = (color1 >> 24) & 0xff;
uint32_t r1 = (color1 >> 16) & 0xff;
uint32_t g1 = (color1 >> 8) & 0xff;
uint32_t b1 = color1 & 0xff;
uint32_t w2 = (color2 >> 24) & 0xff;
uint32_t r2 = (color2 >> 16) & 0xff;
uint32_t g2 = (color2 >> 8) & 0xff;
uint32_t b2 = color2 & 0xff;
uint32_t w3 = ((w2 * blend) + (w1 * (255 - blend))) >> 8;
uint32_t r3 = ((r2 * blend) + (r1 * (255 - blend))) >> 8;
uint32_t g3 = ((g2 * blend) + (g1 * (255 - blend))) >> 8;
uint32_t b3 = ((b2 * blend) + (b1 * (255 - blend))) >> 8;
return ((w3 << 24) | (r3 << 16) | (g3 << 8) | (b3));
}
/*
* Fills segment with color
*/
void WS2812FX::fill(uint32_t c) {
for(uint16_t i=SEGMENT.start; i < SEGMENT.stop; i++) {
setPixelColor(i, c);
}
}
/*
* fade out function, higher rate = quicker fade
*/
void WS2812FX::fade_out(uint8_t rate) {
rate = (255-rate) >> 1;
float mappedRate = float(rate) +1.1;
uint32_t color = SEGCOLOR(1); // target color
int w2 = (color >> 24) & 0xff;
int r2 = (color >> 16) & 0xff;
int g2 = (color >> 8) & 0xff;
int b2 = color & 0xff;
for(uint16_t i=SEGMENT.start; i < SEGMENT.stop; i++) {
color = getPixelColor(i);
int w1 = (color >> 24) & 0xff;
int r1 = (color >> 16) & 0xff;
int g1 = (color >> 8) & 0xff;
int b1 = color & 0xff;
int wdelta = (w2 - w1) / mappedRate;
int rdelta = (r2 - r1) / mappedRate;
int gdelta = (g2 - g1) / mappedRate;
int bdelta = (b2 - b1) / mappedRate;
// if fade isn't complete, make sure delta is at least 1 (fixes rounding issues)
wdelta += (w2 == w1) ? 0 : (w2 > w1) ? 1 : -1;
rdelta += (r2 == r1) ? 0 : (r2 > r1) ? 1 : -1;
gdelta += (g2 == g1) ? 0 : (g2 > g1) ? 1 : -1;
bdelta += (b2 == b1) ? 0 : (b2 > b1) ? 1 : -1;
setPixelColor(i, r1 + rdelta, g1 + gdelta, b1 + bdelta, w1 + wdelta);
}
}
/*
* blurs segment content, source: FastLED colorutils.cpp
*/
void WS2812FX::blur(uint8_t blur_amount)
{
uint8_t keep = 255 - blur_amount;
uint8_t seep = blur_amount >> 1;
CRGB carryover = CRGB::Black;
for(uint16_t i = SEGMENT.start; i < SEGMENT.stop; i++)
{
CRGB cur = col_to_crgb(getPixelColor(i));
CRGB part = cur;
part.nscale8(seep);
cur.nscale8(keep);
cur += carryover;
if(i > SEGMENT.start) {
uint32_t c = getPixelColor(i-1);
uint8_t r = (c >> 16 & 0xFF);
uint8_t g = (c >> 8 & 0xFF);
uint8_t b = (c & 0xFF);
setPixelColor(i-1, qadd8(r, part.red), qadd8(g, part.green), qadd8(b, part.blue));
}
setPixelColor(i,cur.red, cur.green, cur.blue);
carryover = part;
}
}
/*
* Put a value 0 to 255 in to get a color value.
* The colours are a transition r -> g -> b -> back to r
* Inspired by the Adafruit examples.
*/
uint32_t WS2812FX::color_wheel(uint8_t pos) {
if (SEGMENT.palette) return color_from_palette(pos, false, true, 0);
pos = 255 - pos;
if(pos < 85) {
return ((uint32_t)(255 - pos * 3) << 16) | ((uint32_t)(0) << 8) | (pos * 3);
} else if(pos < 170) {
pos -= 85;
return ((uint32_t)(0) << 16) | ((uint32_t)(pos * 3) << 8) | (255 - pos * 3);
} else {
pos -= 170;
return ((uint32_t)(pos * 3) << 16) | ((uint32_t)(255 - pos * 3) << 8) | (0);
}
}
/*
* Returns a new, random wheel index with a minimum distance of 42 from pos.
*/
uint8_t WS2812FX::get_random_wheel_index(uint8_t pos) {
uint8_t r = 0, x = 0, y = 0, d = 0;
while(d < 42) {
r = random8();
x = abs(pos - r);
y = 255 - x;
d = min(x, y);
}
return r;
}
uint32_t WS2812FX::crgb_to_col(CRGB fastled)
{
return (((uint32_t)fastled.red << 16) | ((uint32_t)fastled.green << 8) | fastled.blue);
}
CRGB WS2812FX::col_to_crgb(uint32_t color)
{
CRGB fastled_col;
fastled_col.red = (color >> 16 & 0xFF);
fastled_col.green = (color >> 8 & 0xFF);
fastled_col.blue = (color & 0xFF);
return fastled_col;
}
/*
* FastLED palette modes helper function. Limitation: Due to memory reasons, multiple active segments with FastLED will disable the Palette transitions
*/
void WS2812FX::handle_palette(void)
{
bool singleSegmentMode = (_segment_index == _segment_index_palette_last);
_segment_index_palette_last = _segment_index;
byte paletteIndex = SEGMENT.palette;
if ((SEGMENT.mode >= FX_MODE_METEOR) && SEGMENT.palette == 0) paletteIndex = 4;
switch (paletteIndex)
{
case 0: {//default palette. Differs depending on effect
switch (SEGMENT.mode)
{
case FX_MODE_FIRE_2012 : targetPalette = gGradientPalettes[22]; break;//heat palette
case FX_MODE_COLORWAVES : targetPalette = gGradientPalettes[13]; break;//landscape 33
case FX_MODE_FILLNOISE8 : targetPalette = OceanColors_p; break;
case FX_MODE_NOISE16_1 : targetPalette = gGradientPalettes[17]; break;//Drywet
case FX_MODE_NOISE16_2 : targetPalette = gGradientPalettes[30]; break;//Blue cyan yellow
case FX_MODE_NOISE16_3 : targetPalette = gGradientPalettes[22]; break;//heat palette
case FX_MODE_NOISE16_4 : targetPalette = gGradientPalettes[13]; break;//landscape 33
default: targetPalette = PartyColors_p; break;//palette, bpm
}
break;}
case 1: {//periodically replace palette with a random one. Doesn't work with multiple FastLED segments
if (!singleSegmentMode)
{
targetPalette = PartyColors_p; break; //fallback
}
if (millis() - _lastPaletteChange > 1000 + ((uint32_t)(255-SEGMENT.intensity))*100)
{
targetPalette = CRGBPalette16(
CHSV(random8(), 255, random8(128, 255)),
CHSV(random8(), 255, random8(128, 255)),
CHSV(random8(), 192, random8(128, 255)),
CHSV(random8(), 255, random8(128, 255)));
_lastPaletteChange = millis();
} break;}
case 2: {//primary color only
CRGB prim = col_to_crgb(SEGCOLOR(0));
targetPalette = CRGBPalette16(prim); break;}
case 3: {//based on primary
//considering performance implications
CRGB prim = col_to_crgb(SEGCOLOR(0));
CHSV prim_hsv = rgb2hsv_approximate(prim);
targetPalette = CRGBPalette16(
CHSV(prim_hsv.h, prim_hsv.s, prim_hsv.v), //color itself
CHSV(prim_hsv.h, max(prim_hsv.s - 50,0), prim_hsv.v), //less saturated
CHSV(prim_hsv.h, prim_hsv.s, max(prim_hsv.v - 50,0)), //darker
CHSV(prim_hsv.h, prim_hsv.s, prim_hsv.v)); //color itself
break;}
case 4: {//primary + secondary
CRGB prim = col_to_crgb(SEGCOLOR(0));
CRGB sec = col_to_crgb(SEGCOLOR(1));
targetPalette = CRGBPalette16(sec,prim); break;}
case 5: {//based on primary + secondary
CRGB prim = col_to_crgb(SEGCOLOR(0));
CRGB sec = col_to_crgb(SEGCOLOR(1));
targetPalette = CRGBPalette16(sec,prim,CRGB::White); break;}
case 6: //Party colors
targetPalette = PartyColors_p; break;
case 7: //Cloud colors
targetPalette = CloudColors_p; break;
case 8: //Lava colors
targetPalette = LavaColors_p; break;
case 9: //Ocean colors
targetPalette = OceanColors_p; break;
case 10: //Forest colors
targetPalette = ForestColors_p; break;
case 11: //Rainbow colors
targetPalette = RainbowColors_p; break;
case 12: //Rainbow stripe colors
targetPalette = RainbowStripeColors_p; break;
default: //progmem palettes
targetPalette = gGradientPalettes[constrain(SEGMENT.palette -13, 0, gGradientPaletteCount -1)];
}
if (singleSegmentMode && paletteFade) //only blend if just one segment uses FastLED mode
{
nblendPaletteTowardPalette(currentPalette, targetPalette, 48);
} else
{
currentPalette = targetPalette;
}
}
uint32_t WS2812FX::color_from_palette(uint16_t i, bool mapping, bool wrap, uint8_t mcol, uint8_t pbri)
{
if (SEGMENT.palette == 0 && mcol < 3) return SEGCOLOR(mcol); //WS2812FX default
uint8_t paletteIndex = i;
if (mapping) paletteIndex = map(i,SEGMENT.start,SEGMENT.stop-1,0,255);
if (!wrap) paletteIndex = scale8(paletteIndex, 240); //cut off blend at palette "end"
CRGB fastled_col;
fastled_col = ColorFromPalette( currentPalette, paletteIndex, pbri, (paletteBlend == 3)? NOBLEND:LINEARBLEND);
return fastled_col.r*65536 + fastled_col.g*256 + fastled_col.b;
}
//gamma 2.4 lookup table used for color correction
const byte gammaT[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2,
2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5,
5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10,
10, 10, 11, 11, 11, 12, 12, 13, 13, 13, 14, 14, 15, 15, 16, 16,
17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 24, 24, 25,
25, 26, 27, 27, 28, 29, 29, 30, 31, 32, 32, 33, 34, 35, 35, 36,
37, 38, 39, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 50,
51, 52, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 66, 67, 68,
69, 70, 72, 73, 74, 75, 77, 78, 79, 81, 82, 83, 85, 86, 87, 89,
90, 92, 93, 95, 96, 98, 99,101,102,104,105,107,109,110,112,114,
115,117,119,120,122,124,126,127,129,131,133,135,137,138,140,142,
144,146,148,150,152,154,156,158,160,162,164,167,169,171,173,175,
177,180,182,184,186,189,191,193,196,198,200,203,205,208,210,213,
215,218,220,223,225,228,231,233,236,239,241,244,247,249,252,255 };
uint8_t WS2812FX::gamma8(uint8_t b)
{
return gammaT[b];
}
uint32_t WS2812FX::gamma32(uint32_t color)
{
if (!gammaCorrectCol) return color;
uint8_t w = (color >> 24) & 0xFF;
uint8_t r = (color >> 16) & 0xFF;
uint8_t g = (color >> 8) & 0xFF;
uint8_t b = color & 0xFF;
w = gammaT[w];
r = gammaT[r];
g = gammaT[g];
b = gammaT[b];
return ((w << 24) | (r << 16) | (g << 8) | (b));
}

View File

@@ -1,30 +1,58 @@
//this code is a modified version of https://github.com/Makuna/NeoPixelBus/issues/103
#ifndef NpbWrapper_h
#define NpbWrapper_h
#define WORKAROUND_ESP32_BITBANG
//see https://github.com/Aircoookie/WLED/issues/2 for flicker free ESP32 support
//PIN CONFIGURATION
#define LEDPIN 2 //strip pin. Any for ESP32, gpio2 or 3 is recommended for ESP8266 (gpio2/3 are labeled D4/RX on NodeMCU and Wemos)
//#define USE_APA102 // Uncomment for using APA102 LEDs.
#define BTNPIN 0 //button pin. Needs to have pullup (gpio0 recommended)
#define IR_PIN 4 //infrared pin (-1 to disable)
#define RLYPIN 12 //pin for relay, will be set HIGH if LEDs are on (-1 to disable). Also usable for standby leds, triggers,...
#define AUXPIN -1 //debug auxiliary output pin (-1 to disable)
#define RLYMDE 1 //mode for relay, 0: LOW if LEDs are on 1: HIGH if LEDs are on
#ifdef USE_APA102
#define CLKPIN 0
#define DATAPIN 2
#if BTNPIN == CLKPIN || BTNPIN == DATAPIN
#undef BTNPIN // Deactivate button pin if it conflicts with one of the APA102 pins.
#endif
#endif
//uncomment this if red and green are swapped
//#define SWAPRG
//automatically uses the right driver method for each platform
#ifdef ARDUINO_ARCH_ESP32
#ifdef WORKAROUND_ESP32_BITBANG
#define PIXELMETHOD NeoEsp32BitBangWs2813Method
#else
#define PIXELMETHOD NeoEsp32RmtWS2813_V3Method
#ifdef USE_APA102
#define PIXELMETHOD DotStarMethod
#else
#define PIXELMETHOD NeoEsp32Rmt0Ws2812xMethod
#endif
#else //esp8266
//autoselect the right method depending on strip pin
#ifdef USE_APA102
#define PIXELMETHOD DotStarMethod
#elif LEDPIN == 2
#define PIXELMETHOD NeoEsp8266Uart1Ws2813Method //if you get an error here, try to change to NeoEsp8266UartWs2813Method or update Neopixelbus
#elif LEDPIN == 3
#define PIXELMETHOD NeoEsp8266Dma800KbpsMethod
#else
#define PIXELMETHOD NeoEsp8266BitBang800KbpsMethod
#pragma message "Software BitBang will be used because of your selected LED pin. This may cause flicker. Use GPIO 2 or 3 for best results."
#endif
#endif
//you can now change the color order in the web settings
#ifdef USE_APA102
#define PIXELFEATURE3 DotStarBgrFeature
#define PIXELFEATURE4 DotStarLbgrFeature
#else
#define PIXELMETHOD NeoEsp8266Uart800KbpsMethod
#endif
//handle swapping Red and Green automatically
#ifdef SWAPRG
#define PIXELFEATURE3 NeoRgbFeature
#define PIXELFEATURE4 NeoRgbwFeature
#else
#define PIXELFEATURE3 NeoGrbFeature
#define PIXELFEATURE4 NeoGrbwFeature
#define PIXELFEATURE3 NeoGrbFeature
#define PIXELFEATURE4 NeoGrbwFeature
#endif
#include <NeoPixelBrightnessBus.h>
enum NeoPixelType
@@ -39,10 +67,10 @@ class NeoPixelWrapper
{
public:
NeoPixelWrapper() :
// initialize each member to null
_pGrb(NULL),
_pGrbw(NULL),
_type(NeoPixelType_None)
// initialize each member to null
_pGrb(NULL),
_pGrbw(NULL),
_type(NeoPixelType_None)
{
}
@@ -52,20 +80,28 @@ public:
cleanup();
}
void Begin(NeoPixelType type, uint16_t countPixels, uint8_t pin)
void Begin(NeoPixelType type, uint16_t countPixels)
{
cleanup();
_type = type;
switch (_type) {
switch (_type)
{
case NeoPixelType_Grb:
_pGrb = new NeoPixelBrightnessBus<PIXELFEATURE3,PIXELMETHOD>(countPixels, pin);
#ifdef USE_APA102
_pGrb = new NeoPixelBrightnessBus<PIXELFEATURE3,PIXELMETHOD>(countPixels, CLKPIN, DATAPIN);
#else
_pGrb = new NeoPixelBrightnessBus<PIXELFEATURE3,PIXELMETHOD>(countPixels, LEDPIN);
#endif
_pGrb->Begin();
break;
case NeoPixelType_Grbw:
_pGrbw = new NeoPixelBrightnessBus<PIXELFEATURE4,PIXELMETHOD>(countPixels, pin);
#ifdef USE_APA102
_pGrbw = new NeoPixelBrightnessBus<PIXELFEATURE4,PIXELMETHOD>(countPixels, CLKPIN, DATAPIN);
#else
_pGrbw = new NeoPixelBrightnessBus<PIXELFEATURE4,PIXELMETHOD>(countPixels, LEDPIN);
#endif
_pGrbw->Begin();
break;
}
@@ -73,24 +109,13 @@ public:
void Show()
{
#ifdef ARDUINO_ARCH_ESP32
#ifdef WORKAROUND_ESP32_BITBANG
delay(1);
portDISABLE_INTERRUPTS(); //this is a workaround to prevent flickering (see https://github.com/adafruit/Adafruit_NeoPixel/issues/139)
#endif
#endif
switch (_type) {
switch (_type)
{
case NeoPixelType_Grb: _pGrb->Show(); break;
case NeoPixelType_Grbw: _pGrbw->Show(); break;
}
#ifdef ARDUINO_ARCH_ESP32
#ifdef WORKAROUND_ESP32_BITBANG
portENABLE_INTERRUPTS();
#endif
#endif
}
bool CanShow() const
{
switch (_type) {
@@ -99,65 +124,65 @@ public:
}
}
void SetPixelColor(uint16_t indexPixel, RgbColor color)
{
switch (_type) {
case NeoPixelType_Grb: _pGrb->SetPixelColor(indexPixel, color); break;
case NeoPixelType_Grbw:_pGrbw->SetPixelColor(indexPixel, color); break;
}
void SetPixelColor(uint16_t indexPixel, RgbColor color)
{
switch (_type) {
case NeoPixelType_Grb: _pGrb->SetPixelColor(indexPixel, color); break;
case NeoPixelType_Grbw:_pGrbw->SetPixelColor(indexPixel, color); break;
}
}
void SetPixelColor(uint16_t indexPixel, RgbwColor color)
{
switch (_type) {
case NeoPixelType_Grb: _pGrbw->SetPixelColor(indexPixel, color); break;
case NeoPixelType_Grbw: _pGrbw->SetPixelColor(indexPixel, color); break;
}
void SetPixelColor(uint16_t indexPixel, RgbwColor color)
{
switch (_type) {
case NeoPixelType_Grb: _pGrb->SetPixelColor(indexPixel, RgbColor(color.R,color.G,color.B)); break;
case NeoPixelType_Grbw: _pGrbw->SetPixelColor(indexPixel, color); break;
}
}
void SetBrightness(byte b)
{
switch (_type) {
case NeoPixelType_Grb: _pGrb->SetBrightness(b); break;
case NeoPixelType_Grbw:_pGrbw->SetBrightness(b); break;
}
void SetBrightness(byte b)
{
switch (_type) {
case NeoPixelType_Grb: _pGrb->SetBrightness(b); break;
case NeoPixelType_Grbw:_pGrbw->SetBrightness(b); break;
}
}
RgbColor GetPixelColor(uint16_t indexPixel) const
{
switch (_type) {
case NeoPixelType_Grb: return _pGrb->GetPixelColor(indexPixel); break;
case NeoPixelType_Grbw: /*doesn't support it so we don't return it*/ break;
}
return 0;
RgbColor GetPixelColor(uint16_t indexPixel) const
{
switch (_type) {
case NeoPixelType_Grb: return _pGrb->GetPixelColor(indexPixel); break;
case NeoPixelType_Grbw: /*doesn't support it so we don't return it*/ break;
}
return 0;
}
// NOTE: Due to feature differences, some support RGBW but the method name
// here needs to be unique, thus GetPixeColorRgbw
RgbwColor GetPixelColorRgbw(uint16_t indexPixel) const
{
switch (_type) {
case NeoPixelType_Grb: return _pGrb->GetPixelColor(indexPixel); break;
case NeoPixelType_Grbw: return _pGrbw->GetPixelColor(indexPixel); break;
}
return 0;
// NOTE: Due to feature differences, some support RGBW but the method name
// here needs to be unique, thus GetPixeColorRgbw
RgbwColor GetPixelColorRgbw(uint16_t indexPixel) const
{
switch (_type) {
case NeoPixelType_Grb: return _pGrb->GetPixelColor(indexPixel); break;
case NeoPixelType_Grbw: return _pGrbw->GetPixelColor(indexPixel); break;
}
return 0;
}
void ClearTo(RgbColor color)
{
switch (_type) {
case NeoPixelType_Grb: _pGrb->ClearTo(color); break;
case NeoPixelType_Grbw:_pGrbw->ClearTo(color); break;
}
void ClearTo(RgbColor color)
{
switch (_type) {
case NeoPixelType_Grb: _pGrb->ClearTo(color); break;
case NeoPixelType_Grbw:_pGrbw->ClearTo(color); break;
}
}
void ClearTo(RgbwColor color)
{
switch (_type) {
case NeoPixelType_Grb: break;
case NeoPixelType_Grbw:_pGrbw->ClearTo(color); break;
}
void ClearTo(RgbwColor color)
{
switch (_type) {
case NeoPixelType_Grb: break;
case NeoPixelType_Grbw:_pGrbw->ClearTo(color); break;
}
}
private:
NeoPixelType _type;
@@ -174,3 +199,4 @@ private:
}
}
};
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,405 +0,0 @@
//pixelmethod now in NpbWrapper.h
/*
WS2812FX.h - Library for WS2812 LED effects.
Harm Aldick - 2016
www.aldick.org
FEATURES
* A lot of blinken modes and counting
* WS2812FX can be used as drop-in replacement for Adafruit Neopixel Library
NOTES
* Uses the Adafruit Neopixel library. Get it here:
https://github.com/adafruit/Adafruit_NeoPixel
LICENSE
The MIT License (MIT)
Copyright (c) 2016 Harm Aldick
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.
Heavily modified to work with WLED - differs from Github WS2812FX
*/
#ifndef WS2812FX_h
#define WS2812FX_h
#include "Arduino.h"
#include "NpbWrapper.h"
#define DEFAULT_BRIGHTNESS 50
#define DEFAULT_MODE 0
#define DEFAULT_SPEED 150
#define DEFAULT_COLOR 0xFFAA00
#define SPEED_MIN 0
#define SPEED_MAX 255
#define BRIGHTNESS_MIN 0
#define BRIGHTNESS_MAX 255
#define MODE_COUNT 58
#define FX_MODE_STATIC 0
#define FX_MODE_BLINK 1
#define FX_MODE_BREATH 2
#define FX_MODE_COLOR_WIPE 3
#define FX_MODE_COLOR_WIPE_RANDOM 4
#define FX_MODE_RANDOM_COLOR 5
#define FX_MODE_EASTER 6
#define FX_MODE_DYNAMIC 7
#define FX_MODE_RAINBOW 8
#define FX_MODE_RAINBOW_CYCLE 9
#define FX_MODE_SCAN 10
#define FX_MODE_DUAL_SCAN 11
#define FX_MODE_FADE 12
#define FX_MODE_THEATER_CHASE 13
#define FX_MODE_THEATER_CHASE_RAINBOW 14
#define FX_MODE_RUNNING_LIGHTS 15
#define FX_MODE_TWINKLE 16
#define FX_MODE_TWINKLE_RANDOM 17
#define FX_MODE_TWINKLE_FADE 18
#define FX_MODE_TWINKLE_FADE_RANDOM 19
#define FX_MODE_SPARKLE 20
#define FX_MODE_FLASH_SPARKLE 21
#define FX_MODE_HYPER_SPARKLE 22
#define FX_MODE_STROBE 23
#define FX_MODE_STROBE_RAINBOW 24
#define FX_MODE_MULTI_STROBE 25
#define FX_MODE_BLINK_RAINBOW 26
#define FX_MODE_ANDROID 27
#define FX_MODE_CHASE_COLOR 28
#define FX_MODE_CHASE_RANDOM 29
#define FX_MODE_CHASE_RAINBOW 30
#define FX_MODE_CHASE_FLASH 31
#define FX_MODE_CHASE_FLASH_RANDOM 32
#define FX_MODE_CHASE_RAINBOW_WHITE 33
#define FX_MODE_COLORFUL 34
#define FX_MODE_TRAFFIC_LIGHT 35
#define FX_MODE_COLOR_SWEEP_RANDOM 36
#define FX_MODE_RUNNING_COLOR 37
#define FX_MODE_RUNNING_RED_BLUE 38
#define FX_MODE_RUNNING_RANDOM 39
#define FX_MODE_LARSON_SCANNER 40
#define FX_MODE_COMET 41
#define FX_MODE_FIREWORKS 42
#define FX_MODE_FIREWORKS_RANDOM 43
#define FX_MODE_MERRY_CHRISTMAS 44
#define FX_MODE_FIRE_FLICKER 45
#define FX_MODE_GRADIENT 46
#define FX_MODE_LOADING 47
#define FX_MODE_DUAL_COLOR_WIPE_IN_OUT 48
#define FX_MODE_DUAL_COLOR_WIPE_IN_IN 49
#define FX_MODE_DUAL_COLOR_WIPE_OUT_OUT 50
#define FX_MODE_DUAL_COLOR_WIPE_OUT_IN 51
#define FX_MODE_CIRCUS_COMBUSTUS 52
#define FX_MODE_CUSTOM_CHASE 53
#define FX_MODE_CC_ON_RAINBOW 54
#define FX_MODE_CC_ON_RAINBOW_CYCLE 55
#define FX_MODE_CC_BLINK 56
#define FX_MODE_CC_RANDOM 57
class WS2812FX {
typedef void (WS2812FX::*mode_ptr)(void);
public:
WS2812FX(){
_mode[FX_MODE_STATIC] = &WS2812FX::mode_static;
_mode[FX_MODE_BLINK] = &WS2812FX::mode_blink;
_mode[FX_MODE_BREATH] = &WS2812FX::mode_breath;
_mode[FX_MODE_COLOR_WIPE] = &WS2812FX::mode_color_wipe;
_mode[FX_MODE_COLOR_WIPE_RANDOM] = &WS2812FX::mode_color_wipe_random;
_mode[FX_MODE_RANDOM_COLOR] = &WS2812FX::mode_random_color;
_mode[FX_MODE_EASTER] = &WS2812FX::mode_easter;
_mode[FX_MODE_DYNAMIC] = &WS2812FX::mode_dynamic;
_mode[FX_MODE_RAINBOW] = &WS2812FX::mode_rainbow;
_mode[FX_MODE_RAINBOW_CYCLE] = &WS2812FX::mode_rainbow_cycle;
_mode[FX_MODE_SCAN] = &WS2812FX::mode_scan;
_mode[FX_MODE_DUAL_SCAN] = &WS2812FX::mode_dual_scan;
_mode[FX_MODE_FADE] = &WS2812FX::mode_fade;
_mode[FX_MODE_THEATER_CHASE] = &WS2812FX::mode_theater_chase;
_mode[FX_MODE_THEATER_CHASE_RAINBOW] = &WS2812FX::mode_theater_chase_rainbow;
_mode[FX_MODE_RUNNING_LIGHTS] = &WS2812FX::mode_running_lights;
_mode[FX_MODE_TWINKLE] = &WS2812FX::mode_twinkle;
_mode[FX_MODE_TWINKLE_RANDOM] = &WS2812FX::mode_twinkle_random;
_mode[FX_MODE_TWINKLE_FADE] = &WS2812FX::mode_twinkle_fade;
_mode[FX_MODE_TWINKLE_FADE_RANDOM] = &WS2812FX::mode_twinkle_fade_random;
_mode[FX_MODE_SPARKLE] = &WS2812FX::mode_sparkle;
_mode[FX_MODE_FLASH_SPARKLE] = &WS2812FX::mode_flash_sparkle;
_mode[FX_MODE_HYPER_SPARKLE] = &WS2812FX::mode_hyper_sparkle;
_mode[FX_MODE_STROBE] = &WS2812FX::mode_strobe;
_mode[FX_MODE_STROBE_RAINBOW] = &WS2812FX::mode_strobe_rainbow;
_mode[FX_MODE_MULTI_STROBE] = &WS2812FX::mode_multi_strobe;
_mode[FX_MODE_BLINK_RAINBOW] = &WS2812FX::mode_blink_rainbow;
_mode[FX_MODE_ANDROID] = &WS2812FX::mode_android;
_mode[FX_MODE_CHASE_COLOR] = &WS2812FX::mode_chase_color;
_mode[FX_MODE_CHASE_RANDOM] = &WS2812FX::mode_chase_random;
_mode[FX_MODE_CHASE_RAINBOW] = &WS2812FX::mode_chase_rainbow;
_mode[FX_MODE_CHASE_FLASH] = &WS2812FX::mode_chase_flash;
_mode[FX_MODE_CHASE_FLASH_RANDOM] = &WS2812FX::mode_chase_flash_random;
_mode[FX_MODE_CHASE_RAINBOW_WHITE] = &WS2812FX::mode_chase_rainbow_white;
_mode[FX_MODE_COLORFUL] = &WS2812FX::mode_colorful;
_mode[FX_MODE_TRAFFIC_LIGHT] = &WS2812FX::mode_traffic_light;
_mode[FX_MODE_COLOR_SWEEP_RANDOM] = &WS2812FX::mode_color_sweep_random;
_mode[FX_MODE_RUNNING_COLOR] = &WS2812FX::mode_running_color;
_mode[FX_MODE_RUNNING_RED_BLUE] = &WS2812FX::mode_running_red_blue;
_mode[FX_MODE_RUNNING_RANDOM] = &WS2812FX::mode_running_random;
_mode[FX_MODE_LARSON_SCANNER] = &WS2812FX::mode_larson_scanner;
_mode[FX_MODE_COMET] = &WS2812FX::mode_comet;
_mode[FX_MODE_FIREWORKS] = &WS2812FX::mode_fireworks;
_mode[FX_MODE_FIREWORKS_RANDOM] = &WS2812FX::mode_fireworks_random;
_mode[FX_MODE_MERRY_CHRISTMAS] = &WS2812FX::mode_merry_christmas;
_mode[FX_MODE_FIRE_FLICKER] = &WS2812FX::mode_fire_flicker;
_mode[FX_MODE_GRADIENT] = &WS2812FX::mode_gradient;
_mode[FX_MODE_LOADING] = &WS2812FX::mode_loading;
_mode[FX_MODE_DUAL_COLOR_WIPE_IN_OUT] = &WS2812FX::mode_dual_color_wipe_in_out;
_mode[FX_MODE_DUAL_COLOR_WIPE_IN_IN] = &WS2812FX::mode_dual_color_wipe_in_in;
_mode[FX_MODE_DUAL_COLOR_WIPE_OUT_OUT] = &WS2812FX::mode_dual_color_wipe_out_out;
_mode[FX_MODE_DUAL_COLOR_WIPE_OUT_IN] = &WS2812FX::mode_dual_color_wipe_out_in;
_mode[FX_MODE_CIRCUS_COMBUSTUS] = &WS2812FX::mode_circus_combustus;
_mode[FX_MODE_CUSTOM_CHASE] = &WS2812FX::mode_cc_standard;
_mode[FX_MODE_CC_ON_RAINBOW] = &WS2812FX::mode_cc_rainbow;
_mode[FX_MODE_CC_ON_RAINBOW_CYCLE] = &WS2812FX::mode_cc_cycle;
_mode[FX_MODE_CC_BLINK] = &WS2812FX::mode_cc_blink;
_mode[FX_MODE_CC_RANDOM] = &WS2812FX::mode_cc_random;
_mode_index = DEFAULT_MODE;
_speed = DEFAULT_SPEED;
_brightness = DEFAULT_BRIGHTNESS;
_running = false;
_led_count = 255;
_mode_last_call_time = 0;
_mode_delay = 0;
_color = DEFAULT_COLOR;
_mode_color = DEFAULT_COLOR;
_color_sec = 0;
_mode_var1 = 0;
_cc_fs = true;
_cc_fe = false;
_cc_is = 0;
_cc_i1 = 0;
_cc_i2 = 254;
_cc_num1 = 5;
_cc_num2 = 5;
_ccStep = 1;
_counter_mode_call = 0;
_counter_mode_step = 0;
_counter_ccStep = 0;
_fastStandard = false;
_reverseMode = false;
_skipFirstMode = false;
_locked = NULL;
_cronixieDigits = new byte[6];
bus = new NeoPixelWrapper();
}
void
show(void),
setPixelColor(uint16_t i, byte r, byte g, byte b),
setPixelColor(uint16_t i, byte r, byte g, byte b, byte w),
init(bool supportWhite, uint16_t countPixels, uint8_t pin, bool skipFirst),
service(void),
start(void),
stop(void),
setMode(byte m),
setCustomChase(byte i1, uint16_t i2, byte is, byte np, byte ns, byte stp, bool fs, bool fe),
setCCIndex1(byte i1),
setCCIndex2(uint16_t i2),
setCCStart(byte is),
setCCNum1(byte np),
setCCNum2(byte ns),
setCCStep(byte stp),
setCCFS(bool fs),
setCCFE(bool fe),
setSpeed(byte s),
setIntensity(byte in),
increaseSpeed(byte s),
decreaseSpeed(byte s),
setColor(byte r, byte g, byte b),
setColor(byte r, byte g, byte b, byte w),
setColor(uint32_t c),
setSecondaryColor(byte r, byte g, byte b),
setSecondaryColor(byte r, byte g, byte b, byte w),
setSecondaryColor(uint32_t c),
setBrightness(byte b),
increaseBrightness(byte s),
decreaseBrightness(byte s),
setReverseMode(bool b),
driverModeCronixie(bool b),
setCronixieDigits(byte* d),
setCronixieBacklight(bool b),
setIndividual(int i),
setIndividual(int i, uint32_t col),
setRange(int i, int i2),
setRange(int i, int i2, uint32_t col),
lock(int i),
lockRange(int i, int i2),
lockAll(void),
unlock(int i),
unlockRange(int i, int i2),
unlockAll(void),
setFastUpdateMode(bool b),
trigger(void),
setFade(int sp);
bool
isRunning(void),
isLocked(int i);
byte
get_random_wheel_index(byte),
getMode(void),
getSpeed(void),
getIntensity(void),
getBrightness(void),
getModeCount(void);
uint32_t
color_wheel(byte),
getColor(void);
double
getPowerEstimate(uint16_t leds, uint32_t c, byte b),
getSafePowerMultiplier(double safeMilliAmps, uint16_t leds, uint32_t c, byte b);
private:
NeoPixelWrapper *bus;
void
begin(bool supportWhite, uint16_t countPixels, uint8_t pin, bool skipFirst),
clear(void),
setPixelColor(uint16_t i, uint32_t c),
setPixelColorRaw(uint16_t i, byte r, byte g, byte b, byte w),
dofade(void),
strip_off(void),
strip_off_respectLock(void),
mode_static(void),
mode_blink(void),
mode_color_wipe(void),
mode_color_wipe_random(void),
mode_random_color(void),
mode_easter(void),
mode_dynamic(void),
mode_breath(void),
mode_fade(void),
mode_scan(void),
mode_dual_scan(void),
mode_theater_chase(void),
mode_theater_chase_rainbow(void),
mode_rainbow(void),
mode_rainbow_cycle(void),
mode_running_lights(void),
mode_twinkle(void),
mode_twinkle_random(void),
mode_twinkle_fade(void),
mode_twinkle_fade_random(void),
mode_sparkle(void),
mode_flash_sparkle(void),
mode_hyper_sparkle(void),
mode_strobe(void),
mode_strobe_rainbow(void),
mode_multi_strobe(void),
mode_blink_rainbow(void),
mode_android(void),
mode_chase_color(void),
mode_chase_random(void),
mode_chase_rainbow(void),
mode_chase_flash(void),
mode_chase_flash_random(void),
mode_chase_rainbow_white(void),
mode_colorful(void),
mode_colorful_internal(uint32_t*),
mode_traffic_light(void),
mode_color_sweep_random(void),
mode_running_color(void),
mode_running_red_blue(void),
mode_running_random(void),
mode_larson_scanner(void),
mode_comet(void),
mode_fireworks(void),
mode_fireworks_random(void),
mode_merry_christmas(void),
mode_fire_flicker(void),
mode_gradient(void),
mode_loading(void),
mode_dual_color_wipe_in_out(void),
mode_dual_color_wipe_in_in(void),
mode_dual_color_wipe_out_out(void),
mode_dual_color_wipe_out_in(void),
mode_circus_combustus(void),
mode_cc_core(void),
mode_cc_standard(void),
mode_cc_rainbow(void),
mode_cc_cycle(void),
mode_cc_blink(void),
mode_cc_random(void);
bool
_triggered,
_rgbwMode,
_skipFirstMode,
_fastStandard,
_reverseMode,
_cronixieMode,
_cronixieBacklightEnabled,
_cc_fs,
_cc_fe,
_running;
bool*
_locked;
byte
_mode_index,
_speed,
_intensity,
_cc_i1,
_cc_is,
_cc_num1,
_cc_num2,
_ccStep,
_brightness;
byte*
_cronixieDigits;
uint16_t
minval(uint16_t v, uint16_t w),
maxval(uint16_t v, uint16_t w),
_cc_i2,
_led_count;
uint32_t
getPixelColor(uint16_t i),
_color,
_color_sec,
_counter_mode_call,
_counter_mode_step,
_counter_ccStep,
_mode_var1,
_mode_color,
_mode_delay;
double
_cronixieSecMultiplier;
unsigned long
_mode_last_call_time;
mode_ptr
_mode[MODE_COUNT];
};
#endif

View File

@@ -0,0 +1,129 @@
/*
Editor: https://www.visualmicro.com/
This file is for intellisense purpose only.
Visual micro (and the arduino ide) ignore this code during compilation. This code is automatically maintained by visualmicro, manual changes to this file will be overwritten
The contents of the _vm sub folder can be deleted prior to publishing a project
All non-arduino files created by visual micro and all visual studio project or solution files can be freely deleted and are not required to compile a sketch (do not delete your own code!).
Note: debugger breakpoints are stored in '.sln' or '.asln' files, knowledge of last uploaded breakpoints is stored in the upload.vmps.xml file. Both files are required to continue a previous debug session without needing to compile and upload again
Hardware: ESP32 Dev Module, Platform=esp32, Package=esp32
*/
#if defined(_VMICRO_INTELLISENSE)
#ifndef _VSARDUINO_H_
#define _VSARDUINO_H_
#define __ESP32_esp32__
#define __ESP32_ESP32__
#define ESP_PLATFORM
#define HAVE_CONFIG_H
#define F_CPU 240000000L
#define ARDUINO 10807
#define ARDUINO_ESP32_DEV
#define ARDUINO_ARCH_ESP32
#define ESP32
#define CORE_DEBUG_LEVEL 0
#define __cplusplus 201103L
#define _Pragma(x)
#undef __cplusplus
#define __cplusplus 201103L
#define __STDC__
#define __ARM__
#define __arm__
#define __inline__
#define __asm__(...)
#define __extension__
#define __ATTR_PURE__
#define __ATTR_CONST__
#define __volatile__
#define __ASM
#define __INLINE
#define __attribute__(noinline)
//#define _STD_BEGIN
//#define EMIT
#define WARNING
#define _Lockit
#define __CLR_OR_THIS_CALL
#define C4005
#define _NEW
typedef bool _Bool;
typedef int _read;
typedef int _seek;
typedef int _write;
typedef int _close;
typedef int __cleanup;
//#define inline
#define __builtin_clz
#define __builtin_clzl
#define __builtin_clzll
#define __builtin_labs
#define __builtin_va_list
typedef int __gnuc_va_list;
#define __ATOMIC_ACQ_REL
#define __CHAR_BIT__
#define _EXFUN()
typedef unsigned char byte;
extern "C" void __cxa_pure_virtual() {;}
typedef long __INTPTR_TYPE__ ;
typedef long __UINTPTR_TYPE__ ;
typedef long __SIZE_TYPE__ ;
typedef long __PTRDIFF_TYPE__;
typedef long pthread_t;
typedef long pthread_key_t;
typedef long pthread_once_t;
typedef long pthread_mutex_t;
typedef long pthread_mutex_t;
typedef long pthread_cond_t;
#include "arduino.h"
#include <pins_arduino.h>
//#include "..\generic\Common.h"
//#include "..\generic\pins_arduino.h"
//#undef F
//#define F(string_literal) ((const PROGMEM char *)(string_literal))
//#undef PSTR
//#define PSTR(string_literal) ((const PROGMEM char *)(string_literal))
//current vc++ does not understand this syntax so use older arduino example for intellisense
//todo:move to the new clang/gcc project types.
#define interrupts() sei()
#define noInterrupts() cli()
#include "wled00.ino"
#include "wled01_eeprom.ino"
#include "wled02_xml.ino"
#include "wled03_set.ino"
#include "wled04_file.ino"
#include "wled05_init.ino"
#include "wled06_usermod.ino"
#include "wled07_notify.ino"
#include "wled08_led.ino"
#include "wled09_button.ino"
#include "wled10_ntp.ino"
#include "wled11_ol.ino"
#include "wled12_alexa.ino"
#include "wled13_cronixie.ino"
#include "wled14_colors.ino"
#include "wled15_hue.ino"
#include "wled16_blynk.ino"
#include "wled17_mqtt.ino"
#include "wled18_server.ino"
#include "wled19_json.ino"
#include "wled20_ir.ino"
#endif
#endif

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -2,7 +2,7 @@
<html>
<head><meta charset="utf-8"><meta name="theme-color" content="#fff">
<link rel='shortcut icon' type='image/x-icon' href='/favicon.ico'/>
<title>WLED 0.7.0</title>
<title>WLED 0.8.6</title>
<script>
var d=document;
var w=window.getComputedStyle(d.querySelector("html"));
@@ -18,6 +18,9 @@
var nState = 0;
var cv=0;
var lm=0;
var fxi=0;
var fpi=0;
var fxn=1;
aC="";
bC="";
dC="";
@@ -26,17 +29,22 @@
{
return d.getElementById(s);
}
function Startup()
function UCol()
{
var w=window.getComputedStyle(d.querySelector("html"));
aC = w.getPropertyValue("--aCol");
bC = w.getPropertyValue("--bCol");
dC = w.getPropertyValue("--dCol");
d.querySelector("meta[name=theme-color]").setAttribute("content",bC);
}
function Startup()
{
var w=window.getComputedStyle(d.querySelector("html"));
UCol();
CV(0);
setInterval('GIO()', 5000);
setInterval(GIO, 5000);
GIO();
setTimeout(function(){fillfx(0);}, 200);
setTimeout(function(){fillfx(1);}, 500);
}
function GIO()
{
@@ -57,16 +65,29 @@
} else {
uwv = false;
}
Cf.TX.selectedIndex = this.responseXML.getElementsByTagName('fx')[0].childNodes[0].nodeValue;
fxi = this.responseXML.getElementsByTagName('fx')[0].childNodes[0].nodeValue;
fpi = this.responseXML.getElementsByTagName('fp')[0].childNodes[0].nodeValue;
d.Cf.SX.value = this.responseXML.getElementsByTagName('sx')[0].childNodes[0].nodeValue;
d.Cf.IX.value = this.responseXML.getElementsByTagName('ix')[0].childNodes[0].nodeValue;
nla = (this.responseXML.getElementsByTagName('nl')[0].innerHTML)!=0?true:false;
if(firstload){
d.Cf.NC.checked = (this.responseXML.getElementsByTagName('nf')[0].innerHTML)!=0?true:false;
d.Cf.SN.value = this.responseXML.getElementsByTagName('nd')[0].childNodes[0].nodeValue;
d.Cf.ST.value = this.responseXML.getElementsByTagName('nt')[0].childNodes[0].nodeValue;
CV(parseInt(this.responseXML.getElementsByTagName('md')[0].childNodes[0].nodeValue));
}firstload=false;
d.Cf.NC.checked = (this.responseXML.getElementsByTagName('nf')[0].innerHTML)!=0?true:false;
d.Cf.SN.value = this.responseXML.getElementsByTagName('nd')[0].childNodes[0].nodeValue;
d.Cf.ST.value = this.responseXML.getElementsByTagName('nt')[0].childNodes[0].nodeValue;
d.documentElement.style.setProperty("--aCol",this.responseXML.getElementsByTagName('ca')[0].childNodes[0].nodeValue);
d.documentElement.style.setProperty("--bCol",this.responseXML.getElementsByTagName('cb')[0].childNodes[0].nodeValue);
d.documentElement.style.setProperty("--cCol",this.responseXML.getElementsByTagName('cc')[0].childNodes[0].nodeValue);
d.documentElement.style.setProperty("--dCol",this.responseXML.getElementsByTagName('cd')[0].childNodes[0].nodeValue);
d.documentElement.style.setProperty("--sCol",this.responseXML.getElementsByTagName('cu')[0].childNodes[0].nodeValue);
d.documentElement.style.setProperty("--tCol",this.responseXML.getElementsByTagName('ct')[0].childNodes[0].nodeValue);
d.documentElement.style.setProperty("--cFn",this.responseXML.getElementsByTagName('cf')[0].childNodes[0].nodeValue);
UCol();
CV(parseInt(this.responseXML.getElementsByTagName('md')[0].childNodes[0].nodeValue));
}else{
Cf.TX.selectedIndex = fxi;
Cf.IX.selectedIndex = fpi;
}
firstload=false;
nState = 0;
nState = (this.responseXML.getElementsByTagName('nr')[0].innerHTML)!=0?1:0;
nState += (this.responseXML.getElementsByTagName('ns')[0].innerHTML)!=0?2:0;
@@ -76,6 +97,7 @@
}
}
}
if (firstload) resp+="&IT"
request.open("GET", "win" +resp +nocache, true);
request.send(null);
resp="";
@@ -120,16 +142,9 @@
d.Cf.SB.value=b;
GC();
}
function GetCC()
function GP()
{
resp+="&CP=";
resp+=d.Cf.PF.value;
resp+="&CS=";
resp+=d.Cf.SF.value;
resp+="&CM=";
resp+=d.Cf.HF.value;
resp+=(d.Cf.SC.checked)?"&CF=1":"&CF=0";
resp+=(d.Cf.EC.checked)?"&CE=1":"&CE=0";
resp+= "&FP=" + Cf.FP.selectedIndex;
GIO();
}
function CV(v)
@@ -178,8 +193,8 @@
case 3: gId("path1").style.fill = aC; gId("path2").style.fill = aC;
}
tgb.style.fill=(Cf.SA.value>0)?aC:dC;
ccX.style.display=(Cf.TX.selectedIndex>52)?"block":"none";
fof.style.fill=(Cf.TX.selectedIndex>52)?aC:dC;
fpX.style.display=(Cf.TX.selectedIndex>0)?"block":"none";
fof.style.fill=(Cf.TX.selectedIndex>64)?aC:dC;
fmr.style.fill=(Cf.TX.selectedIndex<1)?aC:dC;
}
function TgT()
@@ -198,10 +213,10 @@
function SwFX(s)
{
var n=Cf.TX.selectedIndex+s;
if (n==-1||n==58) return;
if (n==-1||n==fxn) return;
Cf.TX.selectedIndex =n;
if (n < 0) Cf.TX.selectedIndex = 0;
if (n > 57) Cf.TX.selectedIndex = 53;
if (n > fxn) Cf.TX.selectedIndex = Math.min(65,fxn-1);
GX();
}
function TgHSB()
@@ -308,7 +323,6 @@
rr=diffc(r);
gg=diffc(g);
bb=diffc(b);
if(r===v) {
h=bb-gg;
}else if (g===v){
@@ -351,6 +365,31 @@
{
resp+="&PL=0";GIO();
}
function fillfx(fp)
{
e="<option>Error loading list!</option>";
el = fp?Cf.FP:Cf.TX;
fetch(fp?'/json/pal':'/json/eff')
.then(res => {
if (!res.ok) {
el.innerHTML=e;
}
return res.json();
})
.then(json => {
var x="";
for (i in json) {
x += "<option value=\""+i+"\">"+json[i]+" ("+i+")</option>";
}
el.innerHTML=x;
el.selectedIndex=fp?fpi:fxi;
if(!fp)fxn=json.length;
UV();
})
.catch(function () {
el.innerHTML=e;
})
}
</script>
<style>
:root {
@@ -592,64 +631,7 @@
<svg id="fmf" onclick="SwFX(1)"><use xlink:href="#lnr-arrow-right-circle"></use></svg>
<svg id="fof" onclick="SwFX(99)"><use xlink:href="#lnr-rocket"></use></svg><br><br>
<select name="TX" onchange="GX()">
<option value="0" selected>Solid (0)</option>
<option value="1">Blink (1)</option>
<option value="2">Breath (2)</option>
<option value="3">Wipe (3)</option>
<option value="4">Wipe Random (4)</option>
<option value="5">Color R (5)</option>
<option value="6">Easter (6)</option>
<option value="7">Dynamic (7)</option>
<option value="8">Colorloop (8)</option>
<option value="9">Rainbow (9)</option>
<option value="10">Scan (10)</option>
<option value="11">Scan x2 (11)</option>
<option value="12">Fade (12)</option>
<option value="13">Chase (13)</option>
<option value="14">Chase Cl (14)</option>
<option value="15">Running (15)</option>
<option value="16">Twinkle (16)</option>
<option value="17">Twinkle R (17)</option>
<option value="18">Twinkle Fade (18)</option>
<option value="19">Twinkle RF (19)</option>
<option value="20">Sparkle (20)</option>
<option value="21">Sparkle Inv (21)</option>
<option value="22">Sparkle Inv+ (22)</option>
<option value="23">Strobe (23)</option>
<option value="24">Strobe Cl (24)</option>
<option value="25">Strobe + (25)</option>
<option value="26">Blink Cl (26)</option>
<option value="27">Android (27)</option>
<option value="28">Chase (28)</option>
<option value="29">Chase R (29)</option>
<option value="30">Chase Rainbow (30)</option>
<option value="31">Chase Flash (31)</option>
<option value="32">Chase RF (32)</option>
<option value="33">Chase Cl Inv (33)</option>
<option value="34">Colorful (34)</option>
<option value="35">Traffic Light (35)</option>
<option value="36">Sweep R(36)</option>
<option value="37">Running 2 (37)</option>
<option value="38">Red/Blue (38)</option>
<option value="39">Running R (39)</option>
<option value="40">Scanner (40)</option>
<option value="41">Lighthouse (41)</option>
<option value="42">Fireworks (42)</option>
<option value="43">Fireworks R (43)</option>
<option value="44">Christmas (44)</option>
<option value="45">Fire Flicker (45)</option>
<option value="46">Gradient (46)</option>
<option value="47">Loading (47)</option>
<option value="48">Wipe IO (48)</option>
<option value="49">Wipe II (49)</option>
<option value="50">Wipe OO (50)</option>
<option value="51">Wipe OI (51)</option>
<option value="52">Circus (52)</option>
<option value="53">Custom Chase (53)</option>
<option value="54">CC Colorloop (54)</option>
<option value="55">CC Rainbow (55)</option>
<option value="56">CC Blink (56)</option>
<option value="57">CC Random (57)</option>
<option>Loading...</option>
</select><br><br>
Set secondary color to
<button type="button" onclick="CS(0)">White</button>
@@ -658,12 +640,11 @@
<button type="button" onclick="CS(3)">Primary</button>
<button type="button" onclick="CS(4)">Swap P/S</button>
or <button type="button" onclick="CS(5)">Set Primary to Random</button>
<div id="ccX">
<br>Custom Theater Chase<br>
using <input id="ccP" name="PF" type="number" value="2" min="0" max="255" step="1" onchange="GetCC()"> primary and
<input id="ccS" name ="SF" type="number" value="4" min="0" max="255" step="1" onchange="GetCC()"> secondary color LEDs,<br>
doing <input id="ccH" name="HF" type="number" value="1" min="0" max="255" step="1" onchange="GetCC()"> steps per tick,
from <input type="checkbox" onchange="GetCC()" name="SC"> start and <input type="checkbox" onchange="GetCC()" name="EC"> end.
<div id="fpX">
<br>FastLED Palette<br><br>
<select name="FP" onchange="GP()">
<option>Loading...</option>
</select>
</div>
<div id="slX" class="sl">
<input type="range" title="Effect Speed" class="sds" name="SX" value="0" min="0" max="255" step="1" onchange="GX()"></div>
@@ -677,14 +658,14 @@
<svg id="psn" onclick="SwitchPS(1)"><use xlink:href="#lnr-arrow-right-circle"></use></svg>
<svg id="pss" onclick="PSIO(true)"><use xlink:href="#lnr-arrow-down-circle"></use></svg>
<br><input id="psI" name = "FF" type="number" value="1" min="1" max="25" step="1"><br><br>
Click checkmark to apply <input type="checkbox" checked="true" name="BC"> brightness, <input type="checkbox" checked="true" name="CC"> color and <input type="checkbox" checked="true" name="FC"> effects.<br><br>
Click checkmark to apply <input type="checkbox" checked name="CC"> color, <input type="checkbox" checked name="FC"> effects and <input type="checkbox" name="BC"> brightness.<br><br>
Cycle through presets <input id="cy1" name="P1" type="number" value="1" min="1" max="25" step="1"> to <input id="cy2" name="P2" type="number" value="5" min="1" max="25" step="1">, keep each for <input id="cyT" name="PT" type="number" value="1250" min="50" max="65501" step="1">ms: <input type="checkbox" name="CY" onclick="uCY()"><br><br>
<button type="button" onclick="R()">Apply boot config</button><br>
</div>
<div id="tlN" class="tools">
Timed Light<br><br>
<svg id="ntb" onclick="TgNl()"><use xlink:href="#lnr-power-switch"></use></svg><br><br>
Gradually dim down <input type="checkbox" checked="true" name="NC"><br>
Gradually dim down <input type="checkbox" checked name="NC"><br>
1st slider sets duration (1-255min), 2nd sets target brightness.
<div id="slN" class="sl">
<input type="range" title="Duration" class="sds" name="SN" value="60" min="1" max="255" step="1"></div>

File diff suppressed because one or more lines are too long

100
wled00/data/jsontest.htm Normal file
View File

@@ -0,0 +1,100 @@
<!DOCTYPE html>
<html>
<head>
<title>JSON client</title>
<style>
:root {
--bCol:#333;--cCol:#222;--dCol:#666;--tCol:#fff;
}
body {
font-family: Verdana, sans-serif;
text-align: center;
background: var(--cCol);
color: var(--tCol);
margin: 20px;
background-attachment: fixed;
}
button {
background: var(--cCol);
color: var(--tCol);
border: 0.3ch solid var(--cCol);
display: inline-block;
font-size: 20px;
margin: 8px;
margin-top: 12px;
}
input {
background: var(--cCol);
color: var(--tCol);
border: 0.5ch solid var(--cCol);
width: 100%;
}
h1{
margin: 0px;
font-size: 20px;
}
h2{
font-size: 16px;
margin-top: 20px;
}
form{
background: var(--bCol);
width: 500px;
padding: 20px;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
display: inline-block;
}
textarea{
background: var(--cCol);
color: var(--tCol);
padding-top: 10px;
width: 100%;
font-family: monaco,monospace;
font-size: 12px;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
}
</style>
</head>
<body>
<form name="cf">
<h1>JSON API test tool</h1>
<h2>URL:</h2>
<input name="cu" type="text" size="60" value="http://192.168.4.1/json">
<div id="buttons">
<button type="button" onclick="rq('GET')">GET</button>
<button type="button" onclick="rq('POST')">POST</button>
</div>
<h2>Body:</h2>
<textarea name="bd" rows="8" cols="100"></textarea>
<h2>Response:</h2>
<textarea name="rsp" rows="25" cols="100"></textarea>
</form>
</body>
</html>
<script>
function rq(cm)
{
var h = new XMLHttpRequest();
h.open(cm, document.cf.cu.value, true);
h.onreadystatechange = function()
{
if(h.readyState == 4)
{
if(h.status==200)
{
document.cf.rsp.value="Bad JSON: "+h.responseText
document.cf.rsp.value=JSON.stringify(JSON.parse(h.responseText), null, '\t');
}
else
{
document.cf.rsp.value="Error "+h.status+"\r\n\n"+h.responseText;
}
}
}
h.send(document.cf.bd.value);
}
</script>

View File

@@ -1,5 +1,6 @@
<!DOCTYPE html>
<html><head>
<meta content='width=device-width' name='viewport'>
<title>WLED Message</title>
<script>
function B() {
@@ -22,7 +23,7 @@
--tCol: #328CC1;
--cFn: Verdana;
}
button {
.bt {
background: var(--bCol);
color: var(--tCol);
border: 0.3ch solid var(--bCol);
@@ -33,6 +34,9 @@
margin: 8px;
margin-top: 12px;
}
input[type=file] {
font-size: 16px;
}
body {
font-family: var(--cFn), sans-serif;
text-align: center;
@@ -46,6 +50,7 @@
</head>
<body>
<h2>Sample message.</h2>
Sample detail.
</body>
</html>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

4
wled00/data/update.htm Normal file
View File

@@ -0,0 +1,4 @@
<!DOCTYPE html>
<html><head><meta content='width=device-width' name='viewport'><title>WLED Message</title><script>function B(){window.history.back()}</script>
<style>:root{--aCol:#D9B310;--bCol:#0B3C5D;--cCol:#1D2731;--dCol:#328CC1;--sCol:#000;--tCol:#328CC1;--cFn:Verdana;}.bt{background:var(--bCol);color:var(--tCol);font-family:var(--cFn),sans-serif;border:.3ch solid var(--bCol);display:inline-block;filter:drop-shadow(-5px -5px 5px var(--sCol));font-size:20px;margin:8px;margin-top:12px}input[type=file]{font-size:16px}body{font-family:var(--cFn),sans-serif;text-align:center;background:var(--cCol);color:var(--tCol);line-height:200%}</style></head>
<body><h2>WLED Software Update</h2>Installed version: 0.8.5-dev<br>Download the latest binary: <a href="https://github.com/Aircoookie/WLED/releases"><img src="https://img.shields.io/github/release/Aircoookie/WLED.svg?style=flat-square"></a><br><form method='POST' action='/update' enctype='multipart/form-data'><input type='file' class="bt" name='update' required><br><input type='submit' class="bt" value='Update!'></form><button type="button" class="bt" onclick="B()">Back</button></body></html>

View File

@@ -1,28 +1,36 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta content='width=device-width' name='viewport'>
<meta name="theme-color" content="#333333">
<title>WLED Setup</title>
<style>
:root {
--aCol: #D9B310;
--bCol: #0B3C5D;
--cCol: #1D2731;
--dCol: #328CC1;
--sCol: #000;
}
body {
font-family: Verdana, Helvetica, sans-serif;
text-align: center;
background: linear-gradient(var(--bCol),black);
height: 100%;
background-color: #333;
margin: 0;
background-repeat: no-repeat;
background-attachment: fixed;
color: var(--dCol);
color: #fff;
}
button {
outline: none;
cursor: pointer;
padding: 8px;
margin: 10px;
width: 230px;
text-transform: uppercase;
font-family: helvetica;
font-size: 19px;
background-color: #222;
color: white;
border: 0px solid white;
border-radius: 5px;
}
svg {
fill: var(--dCol);
fill: #fff;
}
</style>
</head>
@@ -35,10 +43,12 @@
<svg><use xlink:href="#lnr-smile"></use></svg>
<h1>Welcome to WLED!</h1>
<h3>Thank you for installing my application!</h3>
Take a quick look at the <a href="https://github.com/Aircoookie/WLED/wiki" target="_blank">wiki</a>!<br>
If you encounter a bug or have a question/feature suggestion, feel free to open a GitHub issue!<br><br>
<b>Next steps:</b><br><br>
Connect the module to your local WiFi <a href="/settings/wifi">here</a>!<br><br>
<i>Just trying this out in AP mode?</i> <a href="/sliders">Here are the controls.</a><br>
Connect the module to your local WiFi here!<br>
<button onclick="window.location.href='/settings/wifi'">WiFi settings</button><br>
<i>Just trying this out in AP mode?</i><br>
<button onclick="window.location.href='/sliders'">To the controls!</button>
</body>
</html>

657
wled00/html_classic.h Normal file
View File

@@ -0,0 +1,657 @@
/*
* Binary arrays for the classic desktop UI index page.
* gzip is used for smaller size and improved speeds.
*
* Workflow for creating them from HTML source:
* 1. Minify HTML (https://htmlcompressor.com/compressor/) (optional)
* 2. Compress with gzip (https://online-converting.com/archives/convert-to-gzip/)
* 3. Convert gzip binary to c array (https://littlevgl.com/image-to-c-array) (select RAW as color format)
* alternative: https://sourceforge.net/projects/bin2header/
* 4. update length value
*/
const uint16_t PAGE_index_L = 10256;
const uint8_t PAGE_index[] PROGMEM = {
0x1f, 0x8b, 0x08, 0x08, 0x58, 0x17, 0x80, 0x5c, 0x00, 0x03, 0x63, 0x6f, 0x6d, 0x70, 0x72, 0x65,
0x73, 0x73, 0x65, 0x64, 0x20, 0x28, 0x31, 0x34, 0x29, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0x00, 0xcc,
0x5a, 0xe9, 0x72, 0xdb, 0x46, 0xb6, 0xfe, 0xaf, 0xa7, 0x80, 0xe9, 0x4a, 0x4c, 0x46, 0x04, 0x88,
0x9d, 0x00, 0x29, 0x28, 0x65, 0x2b, 0xde, 0xaa, 0x1c, 0x45, 0x65, 0x69, 0x62, 0xa5, 0x32, 0x29,
0x17, 0x88, 0x85, 0xc4, 0x18, 0x04, 0x68, 0x00, 0xa4, 0xa4, 0x30, 0x7a, 0xf7, 0xf9, 0x4e, 0x77,
0x93, 0x04, 0xa8, 0x8d, 0xf4, 0x64, 0xe6, 0x5e, 0x57, 0x19, 0x40, 0xf7, 0x39, 0xdd, 0x67, 0x5f,
0xba, 0xa9, 0xa3, 0x67, 0x3f, 0xfd, 0x72, 0x72, 0xf1, 0xdb, 0xd9, 0x6b, 0x69, 0x52, 0x4d, 0xd3,
0xe3, 0x23, 0xf1, 0x8c, 0xfc, 0xf0, 0xf8, 0x68, 0x1a, 0x55, 0xbe, 0x14, 0x4c, 0xfc, 0xa2, 0x8c,
0x2a, 0x6f, 0x5e, 0xc5, 0xb2, 0x23, 0xe6, 0x32, 0x7f, 0x1a, 0x79, 0xd5, 0x24, 0x9a, 0x46, 0x72,
0x90, 0xa7, 0x79, 0x21, 0x05, 0x79, 0x56, 0x45, 0x59, 0xe5, 0x3d, 0x8f, 0xe3, 0xf8, 0xf8, 0x28,
0x4d, 0xb2, 0x2f, 0x52, 0x11, 0xa5, 0xde, 0x8b, 0x72, 0x92, 0x17, 0x55, 0x30, 0xaf, 0xa4, 0x04,
0x18, 0x2f, 0xa4, 0xea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2, 0x15, 0x10, 0xfb, 0x95, 0x1a, 0x41, 0xc8, 0x8a, 0x47, 0x66, 0x3d, 0x10, 0xeb, 0x35, 0xc0,
0x19, 0xab, 0xc8, 0xac, 0x28, 0x22, 0x3f, 0x00, 0x14, 0x08, 0x68, 0xe0, 0xe1, 0x83, 0x19, 0x09,
0xe1, 0x83, 0xc4, 0x3a, 0x15, 0xbd, 0xd9, 0x58, 0x83, 0xa5, 0x45, 0xd5, 0x10, 0xc0, 0x6e, 0x4a,
0x62, 0x6f, 0x29, 0x31, 0x72, 0x14, 0x76, 0x34, 0x48, 0x1e, 0xd6, 0x5a, 0x08, 0xaa, 0x68, 0x9a,
0x0c, 0xbd, 0xc1, 0x4a, 0x56, 0x34, 0xe9, 0x67, 0x29, 0x07, 0x45, 0x42, 0xa4, 0x03, 0x59, 0x15,
0x98, 0x4a, 0xc4, 0x0c, 0x69, 0x38, 0x20, 0xa9, 0x04, 0xfc, 0xa7, 0x84, 0x7a, 0x22, 0xeb, 0x83,
0xec, 0x10, 0x1b, 0xcb, 0xf5, 0x7c, 0x48, 0x65, 0xa3, 0xde, 0xb4, 0x56, 0x63, 0x22, 0x73, 0x8d,
0x09, 0x4c, 0x89, 0x80, 0x08, 0xa5, 0xd9, 0x4a, 0xc8, 0x2a, 0x43, 0x44, 0xa4, 0x9e, 0x03, 0x95,
0xb6, 0x4a, 0x9a, 0xe5, 0x96, 0xd9, 0x10, 0x80, 0xcf, 0x84, 0xa1, 0x83, 0xc7, 0xad, 0x59, 0x17,
0x2b, 0x33, 0xbe, 0x64, 0xc4, 0x1c, 0xd4, 0x35, 0x2d, 0x59, 0x76, 0x1a, 0x10, 0x02, 0x23, 0x94,
0x67, 0x22, 0x04, 0x85, 0xb9, 0x59, 0xa2, 0x43, 0x40, 0x6b, 0x72, 0x0e, 0x55, 0xa1, 0x05, 0xea,
0x42, 0x50, 0x34, 0x5a, 0xb2, 0x36, 0x18, 0x89, 0x31, 0x44, 0xd5, 0xb2, 0x46, 0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xbf, 0x59, 0xd6, 0xab, 0xdd, 0x06, 0x1b, 0x85,
0x67, 0x4a, 0x44, 0x4b, 0x2a, 0x1a, 0x31, 0x21, 0x32, 0xfa, 0x94, 0x13, 0xe6, 0xc2, 0x2c, 0x40,
0x83, 0x2c, 0x00, 0x26, 0x56, 0x21, 0x2d, 0x9e, 0x45, 0x41, 0xf8, 0x09, 0xe1, 0x40, 0x71, 0x16,
0x70, 0x12, 0x14, 0xc4, 0xc9, 0x90, 0x2d, 0x85, 0x53, 0x62, 0x87, 0x89, 0xc8, 0x98, 0x66, 0x26,
0x4c, 0x9b, 0x86, 0x99, 0xc7, 0x8a, 0xe5, 0x54, 0x0d, 0xba, 0xd5, 0x96, 0x42, 0x98, 0xa5, 0x53,
0x05, 0x11, 0x45, 0x6a, 0xb8, 0x2b, 0xd5, 0xac, 0x52, 0x68, 0x4a, 0xa2, 0x98, 0xc8, 0xa6, 0xc9,
0x10, 0x5b, 0x97, 0x09, 0xf6, 0xd4, 0x80, 0xa4, 0xf7, 0x4b, 0x3e, 0x88, 0x40, 0x9d, 0x88, 0x50,
0x57, 0x0d, 0xfd, 0x1d, 0xd1, 0xd3, 0x04, 0x6b, 0x19, 0x35, 0xdb, 0x61, 0xc2, 0xa4, 0xc2, 0xc5,
0xfc, 0x9f, 0x08, 0x7a, 0x1d, 0x81, 0x92, 0x03, 0x66, 0x41, 0xe5, 0x47, 0x5b, 0x42, 0x34, 0x07,
0x09, 0x55, 0x81, 0xad, 0x34, 0x62, 0x07, 0x1a, 0x85, 0x2a, 0x57, 0x59, 0x5f, 0xe4, 0xce, 0x25,
0x36, 0x03, 0xc4, 0xa2, 0x32, 0x1f, 0x34, 0x2f, 0x9a, 0x6a, 0x9a, 0x87, 0xd8, 0x70, 0xb5, 0x80,
0xe3, 0x42, 0x38, 0x80, 0x07, 0x00, 0x4c, 0x51, 0x55, 0xaa, 0xf6, 0xaa, 0x25, 0x8a, 0x82, 0xb1,
0xc2, 0x10, 0x25, 0xd8, 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 0x45, 0x47, 0xe1, 0xb8, 0x1c, 0x3c, 0xc0, 0x1f, 0x10,
0xe2, 0x47, 0x61, 0xf7, 0xbf, 0x7f, 0x74, 0x41, 0xa4, 0x8f, 0x67, 0x25, 0xde, 0x7b, 0x23, 0x9b,
0xcc, 0x58, 0xd6, 0xf6, 0x36, 0xf6, 0xd9, 0x0a, 0x1b, 0xfb, 0x9f, 0x4b, 0xfe, 0xe5, 0x33, 0x5b,
0xe3, 0x54, 0x4e, 0x44, 0xe6, 0xa0, 0x7c, 0x33, 0x83, 0xfe, 0x62, 0x8d, 0x41, 0x7f, 0xa1, 0xa3,
0x3d, 0x84, 0x59, 0xc7, 0xbb, 0xca, 0x8b, 0x7b, 0x2d, 0xfa, 0xc4, 0x86, 0xab, 0x09, 0xf9, 0x09,
0x61, 0xdf, 0xfe, 0x3f, 0xfa, 0x52, 0x5a, 0x0d, 0x37, 0x5f, 0x3b, 0xfc, 0x18, 0xc5, 0xe6, 0xd5,
0xf5, 0xc7, 0xbb, 0x9f, 0x5f, 0xed, 0x36, 0x57, 0xef, 0xe5, 0x2a, 0x3d, 0x2f, 0x5f, 0xf0, 0x56,
0x3e, 0xbc, 0xa2, 0x0f, 0x3f, 0x54, 0xfe, 0xff, 0x20, 0x24, 0xfe, 0x2a, 0xbe, 0x7c, 0x00, 0x00,
};

1223
wled00/html_mobile.h Normal file

File diff suppressed because it is too large Load Diff

53
wled00/html_other.h Normal file
View File

@@ -0,0 +1,53 @@
/*
* Various pages
*/
//USER HTML HERE (/u subpage)
const char PAGE_usermod[] PROGMEM = R"=====(<!DOCTYPE html>
<html><body>No usermod installed or it doesn't specify a custom web page.</body></html>)=====";
//server message
const char PAGE_msg[] PROGMEM = R"=====(<!DOCTYPE html>
<html><head><meta content='width=device-width' name='viewport'>
<title>WLED Message</title>
<script>function B(){window.history.back()};function RS(){window.location = "/settings";}function RP(){top.location.href="/";}</script>
%CSS%.bt{background:var(--bCol);color:var(--tCol);font-family:var(--cFn),sans-serif;border:.3ch solid var(--bCol);display:inline-block;filter:drop-shadow(-5px -5px 5px var(--sCol));font-size:20px;margin:8px;margin-top:12px}body{font-family:var(--cFn),sans-serif;text-align:center;background:var(--cCol);color:var(--tCol);line-height:200%%;margin:0}</style></head>
<body><h2>%MSG%</body></html>)=====";
//firmware update page
const char PAGE_update[] PROGMEM = R"=====(<!DOCTYPE html>
<html><head><meta content='width=device-width' name='viewport'><title>WLED Update</title><script>function B(){window.history.back()}</script>
%CSS%.bt{background:var(--bCol);color:var(--tCol);font-family:var(--cFn),sans-serif;border:.3ch solid var(--bCol);display:inline-block;filter:drop-shadow(-5px -5px 5px var(--sCol));font-size:20px;margin:8px;margin-top:12px}input[type=file]{font-size:16px}body{font-family:var(--cFn),sans-serif;text-align:center;background:var(--cCol);color:var(--tCol);line-height:200%%}</style></head>
<body><h2>WLED Software Update</h2>Installed version: 0.8.6<br>Download the latest binary: <a href="https://github.com/Aircoookie/WLED/releases"><img src="https://img.shields.io/github/release/Aircoookie/WLED.svg?style=flat-square"></a><br><form method='POST' action='/update' enctype='multipart/form-data'><input type='file' class="bt" name='update' required><br><input type='submit' class="bt" value='Update!'></form><button type="button" class="bt" onclick="B()">Back</button></body></html>)=====";
//new user welcome page
#ifndef WLED_DISABLE_MOBILE_UI
const char PAGE_welcome[] PROGMEM = R"=====(<!DOCTYPE html><html><head><meta charset=utf-8><meta content='width=device-width' name=viewport><meta name=theme-color content=#333333><title>WLED Setup</title> <style>body{font-family:Verdana,Helvetica,sans-serif;text-align:center;background-color:#333;margin:0;color:#fff}button{outline:0;cursor:pointer}.btn{padding:8px;margin:10px;width:230px;text-transform:uppercase;font-family:helvetica;font-size:19px;background-color:#222;color:white;border:0 solid white;border-radius:5px}svg{fill:#fff}</style></head>
<body> <svg style=position:absolute;width:0;height:0;overflow:hidden version=1.1 xmlns=http://www.w3.org/2000/svg> <defs> <symbol id=lnr-smile viewBox="0 0 1024 1024"><path d="M486.4 1024c-129.922 0-252.067-50.594-343.936-142.464s-142.464-214.014-142.464-343.936c0-129.923 50.595-252.067 142.464-343.936s214.013-142.464 343.936-142.464c129.922 0 252.067 50.595 343.936 142.464s142.464 214.014 142.464 343.936-50.594 252.067-142.464 343.936c-91.869 91.87-214.014 142.464-343.936 142.464zM486.4 102.4c-239.97 0-435.2 195.23-435.2 435.2s195.23 435.2 435.2 435.2 435.2-195.23 435.2-435.2-195.23-435.2-435.2-435.2z"></path><path d="M332.8 409.6c-42.347 0-76.8-34.453-76.8-76.8s34.453-76.8 76.8-76.8 76.8 34.453 76.8 76.8-34.453 76.8-76.8 76.8zM332.8 307.2c-14.115 0-25.6 11.485-25.6 25.6s11.485 25.6 25.6 25.6 25.6-11.485 25.6-25.6-11.485-25.6-25.6-25.6z"></path><path d="M640 409.6c-42.349 0-76.8-34.453-76.8-76.8s34.451-76.8 76.8-76.8 76.8 34.453 76.8 76.8-34.451 76.8-76.8 76.8zM640 307.2c-14.115 0-25.6 11.485-25.6 25.6s11.485 25.6 25.6 25.6 25.6-11.485 25.6-25.6-11.485-25.6-25.6-25.6z"></path><path d="M486.4 870.4c-183.506 0-332.8-149.294-332.8-332.8 0-14.139 11.462-25.6 25.6-25.6s25.6 11.461 25.6 25.6c0 155.275 126.325 281.6 281.6 281.6s281.6-126.325 281.6-281.6c0-14.139 11.461-25.6 25.6-25.6s25.6 11.461 25.6 25.6c0 183.506-149.294 332.8-332.8 332.8z"></path></symbol> </defs></svg> <br><br>
<svg><use xlink:href=#lnr-smile></use></svg><h1>Welcome to WLED!</h1><h3>Thank you for installing my application!</h3> If you encounter a bug or have a question/feature suggestion, feel free to open a GitHub issue!<br><br> <b>Next steps:</b><br><br> Connect the module to your local WiFi here!<br> <button class=btn onclick="window.location.href='/settings/wifi'">WiFi settings</button><br> <i>Just trying this out in AP mode?</i><br> <button class=btn onclick="window.location.href='/sliders'">To the controls!</button></body></html>)=====";
#else
const char PAGE_welcome[] PROGMEM = "";
#endif
/*
* favicon
*/
const uint8_t favicon[] PROGMEM = {
0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x10, 0x10, 0x00, 0x00, 0x01, 0x00,
0x18, 0x00, 0x86, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x89, 0x50,
0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D, 0x49, 0x48,
0x44, 0x52, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x08, 0x06,
0x00, 0x00, 0x00, 0x1F, 0xF3, 0xFF, 0x61, 0x00, 0x00, 0x00, 0x4D, 0x49,
0x44, 0x41, 0x54, 0x38, 0x8D, 0x63, 0xFC, 0xFF, 0xFF, 0x3F, 0x03, 0xB1,
0x80, 0xD1, 0x9E, 0x01, 0x43, 0x31, 0x13, 0xD1, 0xBA, 0x71, 0x00, 0x8A,
0x0D, 0x60, 0x21, 0xA4, 0x00, 0xD9, 0xD9, 0xFF, 0x0F, 0x32, 0x30, 0x52,
0xDD, 0x05, 0xB4, 0xF1, 0x02, 0xB6, 0xD0, 0xA6, 0x99, 0x0B, 0x68, 0x1F,
0x0B, 0xD8, 0x42, 0x9E, 0xAA, 0x2E, 0xA0, 0xD8, 0x00, 0x46, 0x06, 0x3B,
0xCC, 0xCC, 0x40, 0xC8, 0xD9, 0x54, 0x75, 0x01, 0xE5, 0x5E, 0x20, 0x25,
0x3B, 0x63, 0x03, 0x00, 0x3E, 0xB7, 0x11, 0x5A, 0x8D, 0x1C, 0x07, 0xB4,
0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4E, 0x44, 0xAE, 0x42, 0x60, 0x82
};

View File

@@ -1,19 +1,15 @@
/*
* Settings html
*/
const char PAGE_settingsCss[] PROGMEM = R"=====(
body{font-family:var(--cFn),sans-serif;text-align:center;background:var(--cCol);color:var(--tCol);line-height:200%;margin:0;background-attachment:fixed}hr{border-color:var(--dCol);filter:drop-shadow(-5px -5px 5px var(--sCol))}button{background:var(--bCol);color:var(--tCol);font-family:var(--cFn),sans-serif;border:.3ch solid var(--bCol);display:inline-block;filter:drop-shadow(-5px -5px 5px var(--sCol));font-size:20px;margin:8px;margin-top:12px}.helpB{text-align:left;position:absolute;width:60px}input{background:var(--bCol);color:var(--tCol);font-family:var(--cFn),sans-serif;border:.5ch solid var(--bCol);filter:drop-shadow(-5px -5px 5px var(--sCol))}input[type=number]{width:3em}select{background:var(--bCol);color:var(--tCol);font-family:var(--cFn),sans-serif;border:0.5ch solid var(--bCol);filter:drop-shadow( -5px -5px 5px var(--sCol) );}</style>
)=====";
const char PAGE_settings0[] PROGMEM = R"=====(
<!DOCTYPE html>
<html><head><title>WLED Settings</title>
)=====";
//common CSS of settings pages
const char PAGE_settingsCss[] PROGMEM = R"=====(body{font-family:var(--cFn),sans-serif;text-align:center;background:var(--cCol);color:var(--tCol);line-height:200%%;margin:0;background-attachment:fixed}hr{border-color:var(--dCol);filter:drop-shadow(-5px -5px 5px var(--sCol))}button{background:var(--bCol);color:var(--tCol);font-family:var(--cFn),sans-serif;border:.3ch solid var(--bCol);display:inline-block;filter:drop-shadow(-5px -5px 5px var(--sCol));font-size:20px;margin:8px;margin-top:12px}.helpB{text-align:left;position:absolute;width:60px}input{background:var(--bCol);color:var(--tCol);font-family:var(--cFn),sans-serif;border:.5ch solid var(--bCol);filter:drop-shadow(-5px -5px 5px var(--sCol))}input[type=number]{width:4em}select{background:var(--bCol);color:var(--tCol);font-family:var(--cFn),sans-serif;border:0.5ch solid var(--bCol);filter:drop-shadow( -5px -5px 5px var(--sCol) );}td{padding:2px;}</style>)=====";
const char PAGE_settings1[] PROGMEM = R"=====(
body{text-align:center;background:var(--cCol);height:100%;margin:0;background-attachment:fixed}html{--h:11.55vh}button{background:var(--bCol);color:var(--tCol);font-family:var(--cFn),Helvetica,sans-serif;border:.3ch solid var(--bCol);display:inline-block;filter:drop-shadow(-5px -5px 5px var(--sCol));font-size:8vmin;height:var(--h);width:95%;margin-top:2.4vh}</style>
<script>function BB(){if(window.frameElement){document.getElementById("b").style.display="none";document.documentElement.style.setProperty("--h","13.86vh")}};</script>
</head>
//settings menu
const char PAGE_settings[] PROGMEM = R"=====(<!DOCTYPE html>
<html><head><title>WLED Settings</title>%CSS%body{text-align:center;background:var(--cCol);height:100%%;margin:0;background-attachment:fixed}html{--h:11.55vh}button{background:var(--bCol);color:var(--tCol);font-family:var(--cFn),Helvetica,sans-serif;border:.3ch solid var(--bCol);display:inline-block;filter:drop-shadow(-5px -5px 5px var(--sCol));font-size:8vmin;height:var(--h);width:95%%;margin-top:2.4vh}</style>
<script>function BB(){if(window.frameElement){document.getElementById("b").style.display="none";document.documentElement.style.setProperty("--h","13.86vh")}};</script></head>
<body onload=BB()>
<form action=/><button type=submit id=b>Back</button></form>
<form action=/settings/wifi><button type=submit>WiFi Setup</button></form>
@@ -22,21 +18,17 @@ body{text-align:center;background:var(--cCol);height:100%;margin:0;background-at
<form action=/settings/sync><button type=submit>Sync Interfaces</button></form>
<form action=/settings/time><button type=submit>Time & Macros</button></form>
<form action=/settings/sec><button type=submit>Security & Updates</button></form>
</body>
</html>
)=====";
</body></html>)=====";
const char PAGE_settings_wifi0[] PROGMEM = R"=====(
<!DOCTYPE html>
<html><head>
<title>WiFi Settings</title><script>function H(){window.open("https://github.com/Aircoookie/WLED/wiki/Settings#wifi-settings");}function B(){window.history.back();}function GetV(){var d = document;
)=====";
const char PAGE_settings_wifi1[] PROGMEM = R"=====(
</head>
<body onload="GetV()">
//wifi settings
const char PAGE_settings_wifi[] PROGMEM = R"=====(<!DOCTYPE html>
<html><head><meta name="viewport" content="width=500">
<title>WiFi Settings</title><script>function H(){window.open("https://github.com/Aircoookie/WLED/wiki/Settings#wifi-settings");}function B(){window.history.back();}function GetV(){var d=document;
%CSS%%SCSS%</head><body onload="GetV()">
<form id="form_s" name="Sf" method="post">
<div class="helpB"><button type="button" onclick="H()">?</button></div>
<button type="button" onclick="B()">Back</button><button type="submit">Save & Reboot</button><hr>
<button type="button" onclick="B()">Back</button><button type="submit">Save & Connect</button><hr>
<h2>WiFi setup</h2>
<h3>Connect to existing network</h3>
Network name (SSID, empty to not connect): <br><input name="CS" maxlength="32"><br>
@@ -58,84 +50,120 @@ Static subnet mask:<br>
<input name="S3" type="number" min="0" max="255" required><br>
mDNS address (leave empty for no mDNS):<br/>
http:// <input name="CM" maxlength="32"> .local<br>
Try connecting before opening AP for: <input name="AT" type="number" min="0" max="255" required> s <br>
Client IP: <span class="sip"> Not connected </span><br>
<h3>Configure Access Point</h3>
AP SSID (leave empty for no AP):<br> <input name="AS" maxlength="32"><br>
AP SSID (leave empty for no AP):<br><input name="AS" maxlength="32"><br>
Hide AP name: <input type="checkbox" name="AH"><br>
AP password (leave empty for open):<br> <input type="password" name="AP" maxlength="63"> <br>
AP password (leave empty for open):<br> <input type="password" name="AP" maxlength="63"><br>
Access Point WiFi channel: <input name="AC" type="number" min="1" max="13" required><br>
AP opens:
<select name="AB">
<option value="0">No connection after boot</option>
<option value="1">Disconnected</option>
<option value="2">Always</option>
<option value="3">Never (not recommended)</option></select><br>
AP IP: <span class="sip"> Not active </span><hr>
<button type="button" onclick="B()">Back</button><button type="submit">Save & Reboot</button>
<button type="button" onclick="B()">Back</button><button type="submit">Save & Connect</button>
</form>
</body>
</html>
)=====";
</html>)=====";
const char PAGE_settings_leds0[] PROGMEM = R"=====(
<!DOCTYPE html>
<html><head>
<title>LED Settings</title><script>function H(){window.open("https://github.com/Aircoookie/WLED/wiki/Settings#led-settings");}function B(){window.history.back();}function GetV(){var d = document;
)=====";
const char PAGE_settings_leds1[] PROGMEM = R"=====(
</head>
<body onload="GetV()">
//LED settings
const char PAGE_settings_leds[] PROGMEM = R"=====(<!DOCTYPE html>
<html><head><meta name="viewport" content="width=500">
<title>LED Settings</title><script>var f=0,p=0;function H()
{window.open("https://github.com/Aircoookie/WLED/wiki/Settings#led-settings");}
function B(){window.open("/settings","_self");}function S(){GetV();setTimeout(function(){fillfx(0);},200);setTimeout(function(){fillfx(1);},400);UI();}
function UI(){var myC=document.querySelectorAll('.wc'),l=myC.length;for(i=0;i<l;i++){myC[i].style.display=(document.getElementById('rgbw').checked)?'inline':'none';}
var val=Math.ceil((100+document.Sf.LC.value*55)/500)/2;val=(val>5)?Math.ceil(val):val;var s="";if(val<1.02){s="ESP 5V pin with 1A USB supply";}else{s="External 5V ";s+=val;s+="A supply connected to LEDs";}document.getElementById('psu').innerHTML=s;}
function fillfx(pl){e="<option>Error loading list!</option>";el=pl?Sf.FP:Sf.FX;fetch(pl?'/json/pal':'/json/eff').then(res=>{if(!res.ok){el.innerHTML=e;}
return res.json();}).then(json=>{var x="";for(i in json){x+="<option value=\""+i+"\">"+json[i]+" ("+i+")</option>";}
el.innerHTML=x;el.selectedIndex=pl?p:f;}).catch(function(){el.innerHTML=e;})}function GetV(){var d=document;%CSS%%SCSS%</head>
<body onload="S()">
<form id="form_s" name="Sf" method="post">
<div class="helpB"><button type="button" onclick="H()">?</button></div>
<button type="button" onclick="B()">Back</button><button type="submit">Save</button><hr>
<h2>LED setup</h2>
LED count: <input name="LC" type="number" min="1" max="1200" required><br>
LEDs are 4-channel type (RGBW): <input type="checkbox" name="EW"><br>
Apply preset <input name="BP" type="number" min="0" max="25" required> at boot (0 uses defaults)<br>
Default RGB color:
LED count: <input name="LC" type="number" min="1" max="1500" oninput=UI() required><br>
<i>Recommended power supply for brightest white:</i><br>
<b><span id="psu">?</span></b><br><br>
Maximum Current: <input name="MA" type="number" min="250" max="65000" required> mA<br>
<i>Automatically limits brightness to stay close to the limit.<br>
Keep at &lt;1A if powering LEDs directly from the ESP 5V pin!<br>
If you are using an external 5V supply, enter its rating.<br>
"65000" completely diasbles the power calculation.<br>
(Current estimated usage: <span class="pow">unknown</span>)</i><br><br>
LEDs are 4-channel type (RGBW): <input type="checkbox" name="EW" onchange=UI() id="rgbw"><br>
Color order:
<select name="CO">
<option value="0">GRB</option>
<option value="1">RGB</option>
<option value="2">BRG</option>
<option value="3">RBG</option></select>
<h3>Defaults</h3>
Turn LEDs on after power up/reset: <input type="checkbox" name="BO"><br>
Default brightness: <input name="CA" type="number" min="0" max="255" required> (0-255)<br><br>
Set current color, brightness and effects as boot default: <input type="checkbox" name="IS"><br>
Set current preset cycle setting as boot default: <input type="checkbox" name="PC">
<br>- <i>or</i> -<br>
Apply preset <input name="BP" type="number" min="0" max="25" required> at boot (0 uses defaults)
<br>- <i>or</i> -<br>
Default RGB<span class="wc">W</span> color:<br>
<input name="CR" type="number" min="0" max="255" required>
<input name="CG" type="number" min="0" max="255" required>
<input name="CB" type="number" min="0" max="255" required><br>
Default white value (only RGBW): <input name="CW" type="number" min="0" max="255" required><br>
Auto-calculate white from RGB instead: <input type="checkbox" name="AW"><br>
Default brightness: <input name="CA" type="number" min="0" max="255" required> (0-255)<br>
Default effect ID: <input name="FX" type="number" min="0" max="57" required><br>
Default effect speed: <input name="SX" type="number" min="0" max="255" required><br>
Default effect intensity: <input name="IX" type="number" min="0" max="255" required><br>
Default secondary RGB(W):<br>
<input name="CB" type="number" min="0" max="255" required>
<span class="wc"><input name="CW" type="number" min="0" max="255" required><br>
Auto-calculate white from RGB instead: <input type="checkbox" name="AW"></span><br>
Default secondary RGB<span class="wc">W</span>:<br>
<input name="SR" type="number" min="0" max="255" required>
<input name="SG" type="number" min="0" max="255" required>
<input name="SB" type="number" min="0" max="255" required>
<input name="SW" type="number" min="0" max="255" required><br>
Ignore and use current color, brightness and effects: <input type="checkbox" name="IS"><br>
Save current preset cycle configuration as boot default: <input type="checkbox" name="PC"><br>
Turn on after power up/reset: <input type="checkbox" name="BO"><br>
Use Gamma correction for brightness: <input type="checkbox" name="GB"><br>
Use Gamma correction for color: <input type="checkbox" name="GC"><br>
Brightness factor: <input name="BF" type="number" min="0" max="255" required> %
<span class="wc"><input name="SW" type="number" min="0" max="255" required></span><br>
Default effect ID:<br>
<select name="FX">
<option>Loading...</option>
</select>
<br>Default color palette:<br>
<select name="FP">
<option>Loading...</option>
</select><br>
Default effect speed: <input name="SX" type="number" min="0" max="255" required><br>
Default effect intensity: <input name="IX" type="number" min="0" max="255" required><br><br>
Use Gamma correction for color: <input type="checkbox" name="GC"> (strongly recommended)<br>
Use Gamma correction for brightness: <input type="checkbox" name="GB"> (not recommended)<br><br>
Brightness factor: <input name="BF" type="number" min="0" max="255" required> %%
<h3>Transitions</h3>
Fade: <input type="checkbox" name="TF"><br>
Sweep: <input type="checkbox" name="TS"> Invert direction: <input type="checkbox" name="TI"><br>
Crossfade: <input type="checkbox" name="TF"><br>
Transition Time: <input name="TD" maxlength="5" size="2"> ms<br>
Enable transition for secondary color: <input type="checkbox" name="T2"><br>
Enable Palette transitions: <input type="checkbox" name="PF">
<h3>Timed light</h3>
Default Duration: <input name="TL" type="number" min="1" max="255" required> min<br>
Default Target brightness: <input name="TB" type="number" min="0" max="255" required><br>
Fade down: <input type="checkbox" name="TW"><br>
<h3>Advanced</h3>
Palette blending:
<select name="PB">
<option value="0">Linear (wrap if moving)</option>
<option value="1">Linear (always wrap)</option>
<option value="2">Linear (never wrap)</option>
<option value="3">None (not recommended)</option>
</select><br>
Reverse LED order (rotate 180): <input type="checkbox" name="RV"><br>
Init LEDs after WiFi: <input type="checkbox" name="EI"><br>
WARLS offset: <input name="WO" type="number" min="-255" max="255" required><br>
Skip first LED: <input type="checkbox" name="SL"><hr>
<button type="button" onclick="B()">Back</button><button type="submit">Save</button>
</form>
</body>
</html>
)=====";
</html>)=====";
const char PAGE_settings_ui0[] PROGMEM = R"=====(
<!DOCTYPE html>
<html><head>
//User Interface settings
const char PAGE_settings_ui[] PROGMEM = R"=====(<!DOCTYPE html>
<html><head><meta name="viewport" content="width=500">
<title>UI Settings</title><script>
function gId(s){return document.getElementById(s);}function S(){GetV();Ct();}function H(){window.open("https://github.com/Aircoookie/WLED/wiki/Settings#user-interface-settings");}function B(){window.history.back();}function Ct(){if (gId("co").selected){gId("cth").style.display="block";}else{gId("cth").style.display="none";}}function GetV(){var d = document;
)=====";
const char PAGE_settings_ui1[] PROGMEM = R"=====(
</head>
function gId(s){return document.getElementById(s);}function S(){GetV();Ct();}function H(){window.open("https://github.com/Aircoookie/WLED/wiki/Settings#user-interface-settings");}function B(){window.history.back();}function Ct(){if (gId("co").selected){gId("cth").style.display="block";}else{gId("cth").style.display="none";}}function GetV(){var d=document;
%CSS%%SCSS%</head>
<body onload="S()">
<form id="form_s" name="Sf" method="post">
<div class="helpB"><button type="button" onclick="H()">?</button></div>
@@ -159,13 +187,13 @@ Color Theme:
<option value="4">Electric</option>
<option value="5">Mint</option>
<option value="6">Amber</option>
<option value="7">Club</option>
<option value="7">Dark</option>
<option value="8">Air</option>
<option value="9">Nixie</option>
<option value="10">Terminal</option>
<option value="11">C64</option>
<option value="12">Easter</option>
<option value="13">Placeholder</option>
<option value="13">Christmas</option>
<option value="14">The End</option>
<option value="15" id="co">Custom</option>
</select><br>
@@ -182,36 +210,63 @@ Make sure the font you use is installed on your system!<br>
<hr><button type="button" onclick="B()">Back</button><button type="submit">Save</button>
</form>
</body>
</html>
)=====";
</html>)=====";
const char PAGE_settings_sync0[] PROGMEM = R"=====(
<!DOCTYPE html>
<html><head><title>Sync Settings</title>
<script>function H(){window.open("https://github.com/Aircoookie/WLED/wiki/Settings#sync-settings");}function B(){window.open("/settings","_self");}function GetV(){var d = document;
)=====";
const char PAGE_settings_sync1[] PROGMEM = R"=====(
</head>
//sync settings
const char PAGE_settings_sync[] PROGMEM = R"=====(<!DOCTYPE html>
<html><head><meta name="viewport" content="width=500"><title>Sync Settings</title>
<script>function H(){window.open("https://github.com/Aircoookie/WLED/wiki/Settings#sync-settings");}function B(){window.open("/settings","_self");}function GetV(){var d=document;
%CSS%%SCSS%</head>
<body onload="GetV()">
<form id="form_s" name="Sf" method="post">
<div class="helpB"><button type="button" onclick="H()">?</button></div>
<button type="button" onclick="B()">Back</button><button type="submit">Save</button><hr>
<h2>Sync setup</h2>
<h3>Button setup</h3>
On/Off button enabled: <input type="checkbox" name="BT">
On/Off button enabled: <input type="checkbox" name="BT"><br>
Infrared receiver enabled: <input type="checkbox" name="IR"><br>
<a href="https://github.com/Aircoookie/WLED/wiki/Infrared-Control" target="_blank">IR info</a>
<h3>WLED Broadcast</h3>
UDP Port: <input name="UP" maxlength="5" size="4"><br>
UDP Port: <input name="UP" type="number" min="1" max="65535" required><br>
Receive <input type="checkbox" name="RB">Brightness, <input type="checkbox" name="RC">Color, and <input type="checkbox" name="RX">Effects<br>
Send notifications on direct change: <input type="checkbox" name="SD"><br>
Send notifications on button press: <input type="checkbox" name="SB"><br>
Send Alexa notifications: <input type="checkbox" name="SA"><br>
Send Philips Hue change notifications: <input type="checkbox" name="SH"><br>
Send notifications twice: <input type="checkbox" name="S2"><br>
Receive UDP realtime: <input type="checkbox" name="RD"><br>
Enable UI access during realtime: <input type="checkbox" name="RU"> (can cause issues)
Send Macro notifications: <input type="checkbox" name="SM"><br>
Send notifications twice: <input type="checkbox" name="S2">
<h3>Realtime</h3>
Receive UDP realtime: <input type="checkbox" name="RD"><br><br>
<i>E1.31 (sACN)</i><br>
Use E1.31 multicast: <input type="checkbox" name="EM"><br>
E1.31 start universe: <input name="EU" type="number" min="1" max="63999" required><br>
<i>Reboot required.</i> Check out <a href="https://github.com/ahodges9/LedFx" target="_blank">LedFx</a>!<br><br>
Timeout: <input name="ET" type="number" min="1" max="65000" required> ms<br>
Force max brightness: <input type="checkbox" name="FB"><br>
Disable realtime gamma correction: <input type="checkbox" name="RG"><br>
Realtime LED offset: <input name="WO" type="number" min="-255" max="255" required>
<h3>Alexa Voice Assistant</h3>
Emulate Alexa device: <input type="checkbox" name="AL"><br>
Alexa invocation name: <input name="AI" maxlength="32"><br>
Alexa invocation name: <input name="AI" maxlength="32">
<h3>Blynk</h3>
<b>Blynk, MQTT and Hue sync all connect to external hosts!<br>
This may impact the responsiveness of the ESP8266.</b><br>
For best results, only use one of these services at a time.<br>
(alternatively, connect a second ESP to them and use the UDP sync)<br><br>
Device Auth token: <input name="BK" maxlength="33"><br>
<i>Clear the token field to disable. </i><a href="https://github.com/Aircoookie/WLED/wiki/Blynk" target="_blank">Setup info</a>
<h3>MQTT</h3>
Broker: <input name="MS" maxlength="32">
Port: <input name="MQPORT" type="number" min="1" max="65535" required><br>
<b>The MQTT credentials are sent over an unsecured connection.<br>
Never use the MQTT password for another service!</b><br>
Username: <input name="MQUSER" maxlength="40"><br>
Password: <input type="password" input name="MQPASS" maxlength="40"><br>
Client ID: <input name="MQCID" maxlength="40"><br>
Device Topic: <input name="MD" maxlength="32"><br>
Group Topic: <input name="MG" maxlength="32"><br>
<i>Reboot required to apply changes. </i><a href="https://github.com/Aircoookie/WLED/wiki/MQTT" target="_blank">MQTT info</a>
<h3>Philips Hue</h3>
<i>You can find the bridge IP and the light number in the 'About' section of the hue app.</i><br>
Poll Hue light <input name="HL" type="number" min="1" max="99" required> every <input name="HI" type="number" min="100" max="65000" required> ms: <input type="checkbox" name="HP"><br>
@@ -227,24 +282,25 @@ Hue status: <span class="hms"> Internal ESP Error! </span><hr>
<button type="button" onclick="B()">Back</button><button type="submit">Save</button>
</form>
</body>
</html>
)=====";
</html>)=====";
const char PAGE_settings_time0[] PROGMEM = R"=====(
<!DOCTYPE html>
<html><head><title>Time Settings</title>
<script>function H(){window.open("https://github.com/Aircoookie/WLED/wiki/Settings#time-settings");}function B(){window.open("/settings","_self");}function S(){GetV();Cs();}function gId(s){return document.getElementById(s);}function Cs(){gId("cac").style.display="none";gId("coc").style.display="block";gId("ccc").style.display="none";if (gId("ca").selected){gId("cac").style.display="block";}if (gId("cc").selected){gId("coc").style.display="none";gId("ccc").style.display="block";}if (gId("cn").selected){gId("coc").style.display="none";}}function GetV(){var d = document;
)=====";
const char PAGE_settings_time1[] PROGMEM = R"=====(
</head>
//time and macro settings
const char PAGE_settings_time[] PROGMEM = R"=====(<!DOCTYPE html>
<html><head><meta name="viewport" content="width=500"><title>Time Settings</title>
<script>var d=document;function H(){window.open("https://github.com/Aircoookie/WLED/wiki/Settings#time-settings");}function B(){window.open("/settings","_self");}function S(){BTa();GetV();Cs();FC();}function gId(s){return d.getElementById(s);}function Cs(){gId("cac").style.display="none";gId("coc").style.display="block";gId("ccc").style.display="none";if (gId("ca").selected){gId("cac").style.display="block";}if (gId("cc").selected){gId("coc").style.display="none";gId("ccc").style.display="block";}if (gId("cn").selected){gId("coc").style.display="none";}}
function BTa(){var ih="<tr><th>Active</th><th>Hour</th><th>Minute</th><th>Macro</th><th>M</th><th>T</th><th>W</th><th>T</th><th>F</th><th>S</th><th>S</th></tr>";for (i=0;i<8;i++){ih+="<tr><td><input name=\"W"+i+"\" id=\"W"+i+"\" type=\"number\" style=\"display:none\"><input id=\"W"+i+"0\" type=\"checkbox\"></td><td><input name=\"H"+i+"\" type=\"number\" min=\"0\" max=\"24\"></td><td><input name=\"N"+i+"\" type=\"number\" min=\"0\" max=\"59\"></td><td><input name=\"T"+i+"\" type=\"number\" min=\"0\" max=\"16\"></td>";for (j=1;j<8;j++) ih+="<td><input id=\"W"+i+j+"\" type=\"checkbox\"></td>";}gId("TMT").innerHTML=ih;}
function FC(){for(j=0;j<8;j++){for(i=0;i<8;i++)gId("W"+i+j).checked=gId("W"+i).value>>j&1;}}
function Wd(){a=[0,0,0,0,0,0,0,0];for(i=0;i<8;i++){m=1;for(j=0;j<8;j++){a[i]+=gId("W"+i+j).checked*m;m*=2;}gId("W"+i).value=a[i];}}function GetV(){
%CSS%%SCSS%</head>
<body onload="S()">
<form id="form_s" name="Sf" method="post">
<form id="form_s" name="Sf" method="post" onsubmit="Wd()">
<div class="helpB"><button type="button" onclick="H()">?</button></div>
<button type="button" onclick="B()">Back</button><button type="submit">Save</button><hr>
<h2>Time setup</h2>
Get time from NTP server: <input type="checkbox" name="NT"><br>
Use 24h format: <input type="checkbox" name="CF"><br>
Time zone:
Time zone:
<select name="TZ">
<option value="0" selected>GMT(UTC)</option>
<option value="1">GMT/BST</option>
@@ -267,10 +323,9 @@ Current local time is <span class="times">unknown</span>.
Clock Overlay:
<select name="OL" onchange="Cs()">
<option value="0" id="cn" selected>None</option>
<option value="1">Static color</option>
<option value="2" id="ca">Analog Clock</option>
<option value="3">Single Digit Clock</option>
<option value="4" id="cc">Cronixie Clock</option>
<option value="1" id="ca">Analog Clock</option>
<option value="2">Single Digit Clock</option>
<option value="3" id="cc">Cronixie Clock</option>
</select><br>
<div id="coc">
First LED: <input name="O1" type="number" min="0" max="255" required> Last LED: <input name="O2" type="number" min="0" max="255" required><br>
@@ -284,7 +339,8 @@ Cronixie Display: <input name="CX" maxlength="6"><br>
Cronixie Backlight: <input type="checkbox" name="CB"><br>
</div>
Countdown Mode: <input type="checkbox" name="CE"><br>
Countdown Goal: Year: 20 <input name="CY" type="number" min="0" max="99" required> Month: <input name="CI" type="number" min="1" max="12" required> Day: <input name="CD" type="number" min="1" max="31" required><br>
Countdown Goal:<br>
Year: 20 <input name="CY" type="number" min="0" max="99" required> Month: <input name="CI" type="number" min="1" max="12" required> Day: <input name="CD" type="number" min="1" max="31" required><br>
Hour: <input name="CH" type="number" min="0" max="23" required> Minute: <input name="CM" type="number" min="0" max="59" required> Second: <input name="CS" type="number" min="0" max="59" required><br>
<h3>Advanced Macros</h3>
Define API macros here:<br>
@@ -305,26 +361,28 @@ Define API macros here:<br>
15: <input name="M15" maxlength="64"><br>
16: <input name="M16" maxlength="64"><br><br>
<i>Use 0 for the default action instead of a macro</i><br>
Time controlled macros coming soon!<br>
Boot Macro: <input name="MB" type="number" min="0" max="16" required><br>
Alexa On/Off Macros: <input name="A0" type="number" min="0" max="16" required> <input name="A1" type="number" min="0" max="16" required><br>
Button Macro: <input name="MP" type="number" min="0" max="16" required> Long Press: <input name="ML" type="number" min="0" max="16" required><br>
Countdown-Over Macro: <input name="MC" type="number" min="0" max="16" required><br>
Timed-Light-Over Macro: <input name="MN" type="number" min="0" max="16" required><hr>
Boot macro: <input name="MB" type="number" min="0" max="16" required><br>
Alexa On/Off macros: <input name="A0" type="number" min="0" max="16" required> <input name="A1" type="number" min="0" max="16" required><br>
Button short press macro: <input name="MP" type="number" min="0" max="16" required><br>
Long press: <input name="ML" type="number" min="0" max="16" required> Double press: <input name="MD" type="number" min="0" max="16" required><br>
Countdown-Over macro: <input name="MC" type="number" min="0" max="16" required><br>
Timed-Light-Over macro: <input name="MN" type="number" min="0" max="16" required><br>
Time-Controlled macros:<br>
<div style="display: inline-block">
<table id="TMT">
</table></div><hr>
<button type="button" onclick="B()">Back</button><button type="submit">Save</button>
</form>
</body>
</html>
)=====";
</html>)=====";
const char PAGE_settings_sec0[] PROGMEM = R"=====(
<!DOCTYPE html>
<html><head>
//security settings and about
const char PAGE_settings_sec[] PROGMEM = R"=====(<!DOCTYPE html>
<html><head><meta name="viewport" content="width=500">
<title>Misc Settings</title>
<script>function H(){window.open("https://github.com/Aircoookie/WLED/wiki/Settings#security-settings");}function B(){window.open("/settings","_self");}function U(){window.open("/update","_self");}function GetV(){var d = document;
)=====";
const char PAGE_settings_sec1[] PROGMEM = R"=====(
</head>
<script>function H(){window.open("https://github.com/Aircoookie/WLED/wiki/Settings#security-settings");}function B(){window.open("/settings","_self");}function U(){window.open("/update","_self");}function GetV(){var d=document;
%CSS%%SCSS%</head>
<body onload="GetV()">
<form id="form_s" name="Sf" method="post">
<div class="helpB"><button type="button" onclick="H()">?</button></div>
@@ -337,9 +395,6 @@ The password should be changed when OTA is enabled.<br>
<b>Disable OTA when not in use, otherwise an attacker can reflash device software!</b><br>
<i>Settings on this page are only changable if OTA lock is disabled!</i><br>
Deny access to WiFi settings if locked: <input type="checkbox" name="OW"><br><br>
Disable recovery AP: <input type="checkbox" name="NA"><br>
In case of an error there will be no wireless recovery possible!<br>
Completely disables all Access Point functions.<br><br>
Factory reset: <input type="checkbox" name="RS"><br>
All EEPROM content (settings) will be erased.<br><br>
HTTP traffic is unencrypted. An attacker in the same network can intercept form data!
@@ -347,21 +402,13 @@ HTTP traffic is unencrypted. An attacker in the same network can intercept form
<button type="button" onclick="U()">Manual OTA Update</button><br>
Enable ArduinoOTA: <input type="checkbox" name="AO"><br>
<h3>About</h3>
<a href="https://github.com/Aircoookie/WLED">WLED</a> version 0.7.0<br><br>
<b>Contributors:</b><br>
StormPie <i>(Mobile HTML UI)</i><br><br>
(c) 2016-2018 Christian Schwinne <br>
<a href="https://github.com/Aircoookie/WLED" target="_blank">WLED</a> version 0.8.6<br><br>
<a href="https://github.com/Aircoookie/WLED/wiki/Contributors-&-About" target="_blank">Contributors, dependencies and special thanks</a><br>
A huge thank you to everyone who helped me create WLED!<br><br>
(c) 2016-2019 Christian Schwinne <br>
<i>Licensed under the MIT license</i><br><br>
<b>Uses libraries:</b><br>
<i>ESP8266/ESP32 Arduino Core</i><br>
<i>(ESP32) <a href="https://github.com/bbx10/WebServer_tng">WebServer_tng</a> by bbx10</i><br>
<i><a href="https://github.com/kitesurfer1404/WS2812FX">WS2812FX</a> by kitesurfer1404 (modified)</i><br>
<i><a href="https://github.com/JChristensen/Timezone">Timezone</a> library by JChristensen</i><br>
<i><a href="https://github.com/Aircoookie/Espalexa">Espalexa</a> by Aircoookie (modified)</i><br><br>
<i>UI icons by <a href="https://linearicons.com">Linearicons</a> created by <a href="https://perxis.com">Perxis</a>! (CC-BY-SA 4.0)</i> <br><br>
Server message: <span class="msg"> Response error! </span><hr>
<button type="button" onclick="B()">Back</button><button type="submit">Save & Reboot</button>
</form>
</body>
</html>
)=====";
</html>)=====";

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

95
wled00/ir_codes.h Normal file
View File

@@ -0,0 +1,95 @@
//Infrared codes
//Add your custom codes here
#define IRCUSTOM_ONOFF 0xA55AEA15 //Pioneer RC-975R "+FAV" button (example)
#define IRCUSTOM_MACRO1 0xFFFFFFFF //placeholder, will never be checked for
//Infrared codes for 24-key remote from http://woodsgood.ca/projects/2015/02/13/rgb-led-strip-controllers-ir-codes/
#define IR24_BRIGHTER 0xF700FF
#define IR24_DARKER 0xF7807F
#define IR24_OFF 0xF740BF
#define IR24_ON 0xF7C03F
#define IR24_RED 0xF720DF
#define IR24_REDDISH 0xF710EF
#define IR24_ORANGE 0xF730CF
#define IR24_YELLOWISH 0xF708F7
#define IR24_YELLOW 0xF728D7
#define IR24_GREEN 0xF7A05F
#define IR24_GREENISH 0xF7906F
#define IR24_TURQUOISE 0xF7B04F
#define IR24_CYAN 0xF78877
#define IR24_AQUA 0xF7A857
#define IR24_BLUE 0xF7609F
#define IR24_DEEPBLUE 0xF750AF
#define IR24_PURPLE 0xF7708F
#define IR24_MAGENTA 0xF748B7
#define IR24_PINK 0xF76897
#define IR24_WHITE 0xF7E01F
#define IR24_FLASH 0xF7D02F
#define IR24_STROBE 0xF7F00F
#define IR24_FADE 0xF7C837
#define IR24_SMOOTH 0xF7E817
/* 44-key defs, to be done later
#define IR44_BPlus 0xFF3AC5 //
#define IR44_BMinus 0xFFBA45 //
#define IR44_ON 0xFF827D //
#define IR44_OFF 0xFF02FD //
#define IR44_R 0xFF1AE5 //
#define IR44_G 0xFF9A65 //
#define IR44_B 0xFFA25D //
#define IR44_W 0xFF22DD //
#define IR44_B1 0xFF2AD5 //
#define IR44_B2 0xFFAA55 //
#define IR44_B3 0xFF926D //
#define IR44_B4 0xFF12ED //
#define IR44_B5 0xFF0AF5 //
#define IR44_B6 0xFF8A75 //
#define IR44_B7 0xFFB24D //
#define IR44_B8 0xFF32CD //
#define IR44_B9 0xFF38C7 //
#define IR44_B10 0xFFB847 //
#define IR44_B11 0xFF7887 //
#define IR44_B12 0xFFF807 //
#define IR44_B13 0xFF18E7 //
#define IR44_B14 0xFF9867 //
#define IR44_B15 0xFF58A7 //
#define IR44_B16 0xFFD827 //
#define IR44_UPR 0xFF28D7 //
#define IR44_UPG 0xFFA857 //
#define IR44_UPB 0xFF6897 //
#define IR44_QUICK 0xFFE817 //
#define IR44_DOWNR 0xFF08F7 //
#define IR44_DOWNG 0xFF8877 //
#define IR44_DOWNB 0xFF48B7 //
#define IR44_SLOW 0xFFC837 //
#define IR44_DIY1 0xFF30CF //
#define IR44_DIY2 0xFFB04F //
#define IR44_DIY3 0xFF708F //
#define IR44_AUTO 0xFFF00F //
#define IR44_DIY4 0xFF10EF //
#define IR44_DIY5 0xFF906F //
#define IR44_DIY6 0xFF50AF //
#define IR44_FLASH 0xFFD02F //
#define IR44_JUMP3 0xFF20DF //
#define IR44_JUMP7 0xFFA05F //
#define IR44_FADE3 0xFF609F //
#define IR44_FADE7 0xFFE01F //
*/
#define COLOR_RED 0xFF0000
#define COLOR_REDDISH 0xFF7800
#define COLOR_ORANGE 0xFFA000
#define COLOR_YELLOWISH 0xFFC800
#define COLOR_YELLOW 0xFFFF00
#define COLOR_GREEN 0x00FF00
#define COLOR_GREENISH 0x00FF78
#define COLOR_TURQUOISE 0x00FFA0
#define COLOR_CYAN 0x00FFDC
#define COLOR_AQUA 0x00C8FF
#define COLOR_BLUE 0x00A0FF
#define COLOR_DEEPBLUE 0x0000FF
#define COLOR_PURPLE 0xAA00FF
#define COLOR_MAGENTA 0xFF00DC
#define COLOR_PINK 0xFF00A0
#define COLOR_WHITE 0xFFFFDC

624
wled00/palettes.h Normal file
View File

@@ -0,0 +1,624 @@
/*
* Color palettes for FastLED effects (65-73).
*/
// From ColorWavesWithPalettes by Mark Kriegsman: https://gist.github.com/kriegsman/8281905786e8b2632aeb
// Unfortunaltely, these are stored in RAM!
// Gradient palette "ib_jul01_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/ing/xmas/tn/ib_jul01.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 16 bytes of program space.
#ifndef PalettesWLED_h
#define PalettesWLED_h
DEFINE_GRADIENT_PALETTE( ib_jul01_gp ) {
0, 194, 1, 1,
94, 1, 29, 18,
132, 57,131, 28,
255, 113, 1, 1};
// Gradient palette "es_vintage_57_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/vintage/tn/es_vintage_57.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 20 bytes of program space.
DEFINE_GRADIENT_PALETTE( es_vintage_57_gp ) {
0, 2, 1, 1,
53, 18, 1, 0,
104, 69, 29, 1,
153, 167,135, 10,
255, 46, 56, 4};
// Gradient palette "es_vintage_01_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/vintage/tn/es_vintage_01.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 32 bytes of program space.
DEFINE_GRADIENT_PALETTE( es_vintage_01_gp ) {
0, 4, 1, 1,
51, 16, 0, 1,
76, 97,104, 3,
101, 255,131, 19,
127, 67, 9, 4,
153, 16, 0, 1,
229, 4, 1, 1,
255, 4, 1, 1};
// Gradient palette "es_rivendell_15_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/rivendell/tn/es_rivendell_15.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 20 bytes of program space.
DEFINE_GRADIENT_PALETTE( es_rivendell_15_gp ) {
0, 1, 14, 5,
101, 16, 36, 14,
165, 56, 68, 30,
242, 150,156, 99,
255, 150,156, 99};
// Gradient palette "rgi_15_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/ds/rgi/tn/rgi_15.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 36 bytes of program space.
// Edited to be brighter
DEFINE_GRADIENT_PALETTE( rgi_15_gp ) {
0, 4, 1, 70,
31, 55, 1, 30,
63, 255, 4, 7,
95, 59, 2, 29,
127, 11, 3, 50,
159, 39, 8, 60,
191, 112, 19, 40,
223, 78, 11, 39,
255, 29, 8, 59};
// Gradient palette "retro2_16_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/ma/retro2/tn/retro2_16.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 8 bytes of program space.
DEFINE_GRADIENT_PALETTE( retro2_16_gp ) {
0, 188,135, 1,
255, 46, 7, 1};
// Gradient palette "Analogous_1_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/red/tn/Analogous_1.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 20 bytes of program space.
DEFINE_GRADIENT_PALETTE( Analogous_1_gp ) {
0, 3, 0,255,
63, 23, 0,255,
127, 67, 0,255,
191, 142, 0, 45,
255, 255, 0, 0};
// Gradient palette "es_pinksplash_08_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/pink_splash/tn/es_pinksplash_08.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 20 bytes of program space.
DEFINE_GRADIENT_PALETTE( es_pinksplash_08_gp ) {
0, 126, 11,255,
127, 197, 1, 22,
175, 210,157,172,
221, 157, 3,112,
255, 157, 3,112};
// Gradient palette "es_ocean_breeze_036_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/ocean_breeze/tn/es_ocean_breeze_036.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 16 bytes of program space.
DEFINE_GRADIENT_PALETTE( es_ocean_breeze_036_gp ) {
0, 1, 6, 7,
89, 1, 99,111,
153, 144,209,255,
255, 0, 73, 82};
// Gradient palette "departure_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/mjf/tn/departure.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 88 bytes of program space.
DEFINE_GRADIENT_PALETTE( departure_gp ) {
0, 8, 3, 0,
42, 23, 7, 0,
63, 75, 38, 6,
84, 169, 99, 38,
106, 213,169,119,
116, 255,255,255,
138, 135,255,138,
148, 22,255, 24,
170, 0,255, 0,
191, 0,136, 0,
212, 0, 55, 0,
255, 0, 55, 0};
// Gradient palette "es_landscape_64_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/landscape/tn/es_landscape_64.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 36 bytes of program space.
DEFINE_GRADIENT_PALETTE( es_landscape_64_gp ) {
0, 0, 0, 0,
37, 2, 25, 1,
76, 15,115, 5,
127, 79,213, 1,
128, 126,211, 47,
130, 188,209,247,
153, 144,182,205,
204, 59,117,250,
255, 1, 37,192};
// Gradient palette "es_landscape_33_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/landscape/tn/es_landscape_33.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 24 bytes of program space.
DEFINE_GRADIENT_PALETTE( es_landscape_33_gp ) {
0, 1, 5, 0,
19, 32, 23, 1,
38, 161, 55, 1,
63, 229,144, 1,
66, 39,142, 74,
255, 1, 4, 1};
// Gradient palette "rainbowsherbet_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/ma/icecream/tn/rainbowsherbet.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 28 bytes of program space.
DEFINE_GRADIENT_PALETTE( rainbowsherbet_gp ) {
0, 255, 33, 4,
43, 255, 68, 25,
86, 255, 7, 25,
127, 255, 82,103,
170, 255,255,242,
209, 42,255, 22,
255, 87,255, 65};
// Gradient palette "gr65_hult_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/hult/tn/gr65_hult.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 24 bytes of program space.
DEFINE_GRADIENT_PALETTE( gr65_hult_gp ) {
0, 247,176,247,
48, 255,136,255,
89, 220, 29,226,
160, 7, 82,178,
216, 1,124,109,
255, 1,124,109};
// Gradient palette "gr64_hult_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/hult/tn/gr64_hult.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 32 bytes of program space.
DEFINE_GRADIENT_PALETTE( gr64_hult_gp ) {
0, 1,124,109,
66, 1, 93, 79,
104, 52, 65, 1,
130, 115,127, 1,
150, 52, 65, 1,
201, 1, 86, 72,
239, 0, 55, 45,
255, 0, 55, 45};
// Gradient palette "GMT_drywet_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/gmt/tn/GMT_drywet.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 28 bytes of program space.
DEFINE_GRADIENT_PALETTE( GMT_drywet_gp ) {
0, 47, 30, 2,
42, 213,147, 24,
84, 103,219, 52,
127, 3,219,207,
170, 1, 48,214,
212, 1, 1,111,
255, 1, 7, 33};
// Gradient palette "ib15_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/ing/general/tn/ib15.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 24 bytes of program space.
DEFINE_GRADIENT_PALETTE( ib15_gp ) {
0, 113, 91,147,
72, 157, 88, 78,
89, 208, 85, 33,
107, 255, 29, 11,
141, 137, 31, 39,
255, 59, 33, 89};
// Gradient palette "Tertiary_01_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/vermillion/tn/Tertiary_01.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 20 bytes of program space.
DEFINE_GRADIENT_PALETTE( Tertiary_01_gp ) {
0, 0, 1,255,
63, 3, 68, 45,
127, 23,255, 0,
191, 100, 68, 1,
255, 255, 1, 4};
// Gradient palette "lava_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/neota/elem/tn/lava.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 52 bytes of program space.
DEFINE_GRADIENT_PALETTE( lava_gp ) {
0, 0, 0, 0,
46, 18, 0, 0,
96, 113, 0, 0,
108, 142, 3, 1,
119, 175, 17, 1,
146, 213, 44, 2,
174, 255, 82, 4,
188, 255,115, 4,
202, 255,156, 4,
218, 255,203, 4,
234, 255,255, 4,
244, 255,255, 71,
255, 255,255,255};
// Gradient palette "fierce_ice_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/neota/elem/tn/fierce-ice.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 28 bytes of program space.
DEFINE_GRADIENT_PALETTE( fierce_ice_gp ) {
0, 0, 0, 0,
59, 0, 9, 45,
119, 0, 38,255,
149, 3,100,255,
180, 23,199,255,
217, 100,235,255,
255, 255,255,255};
// Gradient palette "Colorfull_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/atmospheric/tn/Colorfull.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 44 bytes of program space.
DEFINE_GRADIENT_PALETTE( Colorfull_gp ) {
0, 10, 85, 5,
25, 29,109, 18,
60, 59,138, 42,
93, 83, 99, 52,
106, 110, 66, 64,
109, 123, 49, 65,
113, 139, 35, 66,
116, 192,117, 98,
124, 255,255,137,
168, 100,180,155,
255, 22,121,174};
// Gradient palette "Pink_Purple_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/atmospheric/tn/Pink_Purple.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 44 bytes of program space.
DEFINE_GRADIENT_PALETTE( Pink_Purple_gp ) {
0, 19, 2, 39,
25, 26, 4, 45,
51, 33, 6, 52,
76, 68, 62,125,
102, 118,187,240,
109, 163,215,247,
114, 217,244,255,
122, 159,149,221,
149, 113, 78,188,
183, 128, 57,155,
255, 146, 40,123};
// Gradient palette "Sunset_Real_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/atmospheric/tn/Sunset_Real.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 28 bytes of program space.
DEFINE_GRADIENT_PALETTE( Sunset_Real_gp ) {
0, 120, 0, 0,
22, 179, 22, 0,
51, 255,104, 0,
85, 167, 22, 18,
135, 100, 0,103,
198, 16, 0,130,
255, 0, 0,160};
// Gradient palette "Sunset_Yellow_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/atmospheric/tn/Sunset_Yellow.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 44 bytes of program space.
DEFINE_GRADIENT_PALETTE( Sunset_Yellow_gp ) {
0, 10, 62,123,
36, 56,130,103,
87, 153,225, 85,
100, 199,217, 68,
107, 255,207, 54,
115, 247,152, 57,
120, 239,107, 61,
128, 247,152, 57,
180, 255,207, 54,
223, 255,227, 48,
255, 255,248, 42};
// Gradient palette "Beech_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/atmospheric/tn/Beech.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 60 bytes of program space.
DEFINE_GRADIENT_PALETTE( Beech_gp ) {
0, 255,252,214,
12, 255,252,214,
22, 255,252,214,
26, 190,191,115,
28, 137,141, 52,
28, 112,255,205,
50, 51,246,214,
71, 17,235,226,
93, 2,193,199,
120, 0,156,174,
133, 1,101,115,
136, 1, 59, 71,
136, 7,131,170,
208, 1, 90,151,
255, 0, 56,133};
// Gradient palette "Another_Sunset_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/atmospheric/tn/Another_Sunset.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 32 bytes of program space.
DEFINE_GRADIENT_PALETTE( Another_Sunset_gp ) {
0, 110, 49, 11,
29, 55, 34, 10,
68, 22, 22, 9,
68, 239,124, 8,
97, 220,156, 27,
124, 203,193, 61,
178, 33, 53, 56,
255, 0, 1, 52};
// Gradient palette "es_autumn_19_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/es/autumn/tn/es_autumn_19.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 52 bytes of program space.
DEFINE_GRADIENT_PALETTE( es_autumn_19_gp ) {
0, 26, 1, 1,
51, 67, 4, 1,
84, 118, 14, 1,
104, 137,152, 52,
112, 113, 65, 1,
122, 133,149, 59,
124, 137,152, 52,
135, 113, 65, 1,
142, 139,154, 46,
163, 113, 13, 1,
204, 55, 3, 1,
249, 17, 1, 1,
255, 17, 1, 1};
// Gradient palette "BlacK_Blue_Magenta_White_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/basic/tn/BlacK_Blue_Magenta_White.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 28 bytes of program space.
DEFINE_GRADIENT_PALETTE( BlacK_Blue_Magenta_White_gp ) {
0, 0, 0, 0,
42, 0, 0, 45,
84, 0, 0,255,
127, 42, 0,255,
170, 255, 0,255,
212, 255, 55,255,
255, 255,255,255};
// Gradient palette "BlacK_Magenta_Red_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/basic/tn/BlacK_Magenta_Red.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 20 bytes of program space.
DEFINE_GRADIENT_PALETTE( BlacK_Magenta_Red_gp ) {
0, 0, 0, 0,
63, 42, 0, 45,
127, 255, 0,255,
191, 255, 0, 45,
255, 255, 0, 0};
// Gradient palette "BlacK_Red_Magenta_Yellow_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/basic/tn/BlacK_Red_Magenta_Yellow.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 28 bytes of program space.
DEFINE_GRADIENT_PALETTE( BlacK_Red_Magenta_Yellow_gp ) {
0, 0, 0, 0,
42, 42, 0, 0,
84, 255, 0, 0,
127, 255, 0, 45,
170, 255, 0,255,
212, 255, 55, 45,
255, 255,255, 0};
// Gradient palette "Blue_Cyan_Yellow_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/nd/basic/tn/Blue_Cyan_Yellow.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 20 bytes of program space.
DEFINE_GRADIENT_PALETTE( Blue_Cyan_Yellow_gp ) {
0, 0, 0,255,
63, 0, 55,255,
127, 0,255,255,
191, 42,255, 45,
255, 255,255, 0};
//Custom palette by Aircoookie
DEFINE_GRADIENT_PALETTE( Orange_Teal_gp ) {
0, 0,150, 92,
55, 0,150, 92,
200, 255, 72, 0,
255, 255, 72, 0};
//Custom palette by Aircoookie
DEFINE_GRADIENT_PALETTE( Tiamat_gp ) {
0, 1, 2, 14, //gc
33, 2, 5, 35, //gc from 47, 61,126
100, 13,135, 92, //gc from 88,242,247
120, 43,255,193, //gc from 135,255,253
140, 247, 7,249, //gc from 252, 69,253
160, 193, 17,208, //gc from 231, 96,237
180, 39,255,154, //gc from 130, 77,213
200, 4,213,236, //gc from 57,122,248
220, 39,252,135, //gc from 177,254,255
240, 193,213,253, //gc from 203,239,253
255, 255,249,255};
//Custom palette by Aircoookie
DEFINE_GRADIENT_PALETTE( April_Night_gp ) {
0, 1, 5, 45, //deep blue
10, 1, 5, 45,
25, 5,169,175, //light blue
40, 1, 5, 45,
61, 1, 5, 45,
76, 45,175, 31, //green
91, 1, 5, 45,
112, 1, 5, 45,
127, 249,150, 5, //yellow
143, 1, 5, 45,
162, 1, 5, 45,
178, 255, 92, 0, //pastel orange
193, 1, 5, 45,
214, 1, 5, 45,
229, 223, 45, 72, //pink
244, 1, 5, 45,
255, 1, 5, 45};
DEFINE_GRADIENT_PALETTE( Orangery_gp ) {
0, 255, 95, 23,
30, 255, 82, 0,
60, 223, 13, 8,
90, 144, 44, 2,
120, 255,110, 17,
150, 255, 69, 0,
180, 158, 13, 11,
210, 241, 82, 17,
255, 213, 37, 4};
//inspired by Mark Kriegsman https://gist.github.com/kriegsman/756ea6dcae8e30845b5a
DEFINE_GRADIENT_PALETTE( C9_gp ) {
0, 184, 4, 0, //red
60, 184, 4, 0,
65, 144, 44, 2, //amber
125, 144, 44, 2,
130, 4, 96, 2, //green
190, 4, 96, 2,
195, 7, 7, 88, //blue
255, 7, 7, 88};
DEFINE_GRADIENT_PALETTE( Sakura_gp ) {
0, 196, 19, 10,
65, 255, 69, 45,
130, 223, 45, 72,
195, 255, 82,103,
255, 223, 13, 17};
// Single array of defined cpt-city color palettes.
// This will let us programmatically choose one based on
// a number, rather than having to activate each explicitly
// by name every time.
// Since it is const, this array could also be moved
// into PROGMEM to save SRAM, but for simplicity of illustration
// we'll keep it in a regular SRAM array.
//
// This list of color palettes acts as a "playlist"; you can
// add or delete, or re-arrange as you wish.
const TProgmemRGBGradientPalettePtr gGradientPalettes[] = {
Sunset_Real_gp, //13-00 Sunset
es_rivendell_15_gp, //14-01 Rivendell
es_ocean_breeze_036_gp, //15-02 Breeze
rgi_15_gp, //16-03 Red & Blue
retro2_16_gp, //17-04 Yellowout
Analogous_1_gp, //18-05 Analogous
es_pinksplash_08_gp, //19-06 Splash
Sunset_Yellow_gp, //20-07 Pastel
Another_Sunset_gp, //21-08 Sunset2
Beech_gp, //22-09 Beech
es_vintage_01_gp, //23-10 Vintage
departure_gp, //24-11 Departure
es_landscape_64_gp, //25-12 Landscape
es_landscape_33_gp, //26-13 Beach
rainbowsherbet_gp, //27-14 Sherbet
gr65_hult_gp, //28-15 Hult
gr64_hult_gp, //29-16 Hult64
GMT_drywet_gp, //30-17 Drywet
ib_jul01_gp, //31-18 Jul
es_vintage_57_gp, //32-19 Grintage
ib15_gp, //33-20 Rewhi
Tertiary_01_gp, //34-21 Tertiary
lava_gp, //35-22 Fire
fierce_ice_gp, //36-23 Icefire
Colorfull_gp, //37-24 Cyane
Pink_Purple_gp, //38-25 Light Pink
es_autumn_19_gp, //39-26 Autumn
BlacK_Blue_Magenta_White_gp, //40-27 Magenta
BlacK_Magenta_Red_gp, //41-28 Magred
BlacK_Red_Magenta_Yellow_gp, //42-29 Yelmag
Blue_Cyan_Yellow_gp, //43-30 Yelblu
Orange_Teal_gp, //44-31 Orange & Teal
Tiamat_gp, //45-32 Tiamat
April_Night_gp, //46-33 April Night
Orangery_gp, //47-34 Orangery
C9_gp, //48-35 C9
Sakura_gp, //49-36 Sakura
};
// Count of how many cpt-city gradients are defined:
const uint8_t gGradientPaletteCount =
sizeof( gGradientPalettes) / sizeof( TProgmemRGBGradientPalettePtr );
#endif

View File

@@ -0,0 +1,877 @@
#include "AsyncMqttClient.hpp"
AsyncMqttClient::AsyncMqttClient()
: _connected(false)
, _connectPacketNotEnoughSpace(false)
, _disconnectFlagged(false)
, _tlsBadFingerprint(false)
, _lastClientActivity(0)
, _lastServerActivity(0)
, _lastPingRequestTime(0)
, _host(nullptr)
, _useIp(false)
#if ASYNC_TCP_SSL_ENABLED
, _secure(false)
#endif
, _port(0)
, _keepAlive(15)
, _cleanSession(true)
, _clientId(nullptr)
, _username(nullptr)
, _password(nullptr)
, _willTopic(nullptr)
, _willPayload(nullptr)
, _willPayloadLength(0)
, _willQos(0)
, _willRetain(false)
, _parsingInformation { .bufferState = AsyncMqttClientInternals::BufferState::NONE }
, _currentParsedPacket(nullptr)
, _remainingLengthBufferPosition(0)
, _nextPacketId(1) {
_client.onConnect([](void* obj, AsyncClient* c) { (static_cast<AsyncMqttClient*>(obj))->_onConnect(c); }, this);
_client.onDisconnect([](void* obj, AsyncClient* c) { (static_cast<AsyncMqttClient*>(obj))->_onDisconnect(c); }, this);
_client.onError([](void* obj, AsyncClient* c, int8_t error) { (static_cast<AsyncMqttClient*>(obj))->_onError(c, error); }, this);
_client.onTimeout([](void* obj, AsyncClient* c, uint32_t time) { (static_cast<AsyncMqttClient*>(obj))->_onTimeout(c, time); }, this);
_client.onAck([](void* obj, AsyncClient* c, size_t len, uint32_t time) { (static_cast<AsyncMqttClient*>(obj))->_onAck(c, len, time); }, this);
_client.onData([](void* obj, AsyncClient* c, void* data, size_t len) { (static_cast<AsyncMqttClient*>(obj))->_onData(c, static_cast<char*>(data), len); }, this);
_client.onPoll([](void* obj, AsyncClient* c) { (static_cast<AsyncMqttClient*>(obj))->_onPoll(c); }, this);
#ifdef ESP32
sprintf(_generatedClientId, "esp32%06x", ESP.getEfuseMac());
_xSemaphore = xSemaphoreCreateMutex();
#elif defined(ESP8266)
sprintf(_generatedClientId, "esp8266%06x", ESP.getChipId());
#endif
_clientId = _generatedClientId;
setMaxTopicLength(128);
}
AsyncMqttClient::~AsyncMqttClient() {
delete _currentParsedPacket;
delete[] _parsingInformation.topicBuffer;
#ifdef ESP32
vSemaphoreDelete(_xSemaphore);
#endif
}
AsyncMqttClient& AsyncMqttClient::setKeepAlive(uint16_t keepAlive) {
_keepAlive = keepAlive;
return *this;
}
AsyncMqttClient& AsyncMqttClient::setClientId(const char* clientId) {
_clientId = clientId;
return *this;
}
AsyncMqttClient& AsyncMqttClient::setCleanSession(bool cleanSession) {
_cleanSession = cleanSession;
return *this;
}
AsyncMqttClient& AsyncMqttClient::setMaxTopicLength(uint16_t maxTopicLength) {
_parsingInformation.maxTopicLength = maxTopicLength;
delete[] _parsingInformation.topicBuffer;
_parsingInformation.topicBuffer = new char[maxTopicLength + 1];
return *this;
}
AsyncMqttClient& AsyncMqttClient::setCredentials(const char* username, const char* password) {
_username = username;
_password = password;
return *this;
}
AsyncMqttClient& AsyncMqttClient::setWill(const char* topic, uint8_t qos, bool retain, const char* payload, size_t length) {
_willTopic = topic;
_willQos = qos;
_willRetain = retain;
_willPayload = payload;
_willPayloadLength = length;
return *this;
}
AsyncMqttClient& AsyncMqttClient::setServer(IPAddress ip, uint16_t port) {
_useIp = true;
_ip = ip;
_port = port;
return *this;
}
AsyncMqttClient& AsyncMqttClient::setServer(const char* host, uint16_t port) {
_useIp = false;
_host = host;
_port = port;
return *this;
}
#if ASYNC_TCP_SSL_ENABLED
AsyncMqttClient& AsyncMqttClient::setSecure(bool secure) {
_secure = secure;
return *this;
}
AsyncMqttClient& AsyncMqttClient::addServerFingerprint(const uint8_t* fingerprint) {
std::array<uint8_t, SHA1_SIZE> newFingerprint;
memcpy(newFingerprint.data(), fingerprint, SHA1_SIZE);
_secureServerFingerprints.push_back(newFingerprint);
return *this;
}
#endif
AsyncMqttClient& AsyncMqttClient::onConnect(AsyncMqttClientInternals::OnConnectUserCallback callback) {
_onConnectUserCallbacks.push_back(callback);
return *this;
}
AsyncMqttClient& AsyncMqttClient::onDisconnect(AsyncMqttClientInternals::OnDisconnectUserCallback callback) {
_onDisconnectUserCallbacks.push_back(callback);
return *this;
}
AsyncMqttClient& AsyncMqttClient::onSubscribe(AsyncMqttClientInternals::OnSubscribeUserCallback callback) {
_onSubscribeUserCallbacks.push_back(callback);
return *this;
}
AsyncMqttClient& AsyncMqttClient::onUnsubscribe(AsyncMqttClientInternals::OnUnsubscribeUserCallback callback) {
_onUnsubscribeUserCallbacks.push_back(callback);
return *this;
}
AsyncMqttClient& AsyncMqttClient::onMessage(AsyncMqttClientInternals::OnMessageUserCallback callback) {
_onMessageUserCallbacks.push_back(callback);
return *this;
}
AsyncMqttClient& AsyncMqttClient::onPublish(AsyncMqttClientInternals::OnPublishUserCallback callback) {
_onPublishUserCallbacks.push_back(callback);
return *this;
}
void AsyncMqttClient::_freeCurrentParsedPacket() {
delete _currentParsedPacket;
_currentParsedPacket = nullptr;
}
void AsyncMqttClient::_clear() {
_lastPingRequestTime = 0;
_connected = false;
_disconnectFlagged = false;
_connectPacketNotEnoughSpace = false;
_tlsBadFingerprint = false;
_freeCurrentParsedPacket();
_pendingPubRels.clear();
_pendingPubRels.shrink_to_fit();
_toSendAcks.clear();
_toSendAcks.shrink_to_fit();
_nextPacketId = 1;
_parsingInformation.bufferState = AsyncMqttClientInternals::BufferState::NONE;
}
/* TCP */
void AsyncMqttClient::_onConnect(AsyncClient* client) {
(void)client;
#if ASYNC_TCP_SSL_ENABLED
if (_secure && _secureServerFingerprints.size() > 0) {
SSL* clientSsl = _client.getSSL();
bool sslFoundFingerprint = false;
for (std::array<uint8_t, SHA1_SIZE> fingerprint : _secureServerFingerprints) {
if (ssl_match_fingerprint(clientSsl, fingerprint.data()) == SSL_OK) {
sslFoundFingerprint = true;
break;
}
}
if (!sslFoundFingerprint) {
_tlsBadFingerprint = true;
_client.close(true);
return;
}
}
#endif
char fixedHeader[5];
fixedHeader[0] = AsyncMqttClientInternals::PacketType.CONNECT;
fixedHeader[0] = fixedHeader[0] << 4;
fixedHeader[0] = fixedHeader[0] | AsyncMqttClientInternals::HeaderFlag.CONNECT_RESERVED;
uint16_t protocolNameLength = 4;
char protocolNameLengthBytes[2];
protocolNameLengthBytes[0] = protocolNameLength >> 8;
protocolNameLengthBytes[1] = protocolNameLength & 0xFF;
char protocolLevel[1];
protocolLevel[0] = 0x04;
char connectFlags[1];
connectFlags[0] = 0;
if (_cleanSession) connectFlags[0] |= AsyncMqttClientInternals::ConnectFlag.CLEAN_SESSION;
if (_username != nullptr) connectFlags[0] |= AsyncMqttClientInternals::ConnectFlag.USERNAME;
if (_password != nullptr) connectFlags[0] |= AsyncMqttClientInternals::ConnectFlag.PASSWORD;
if (_willTopic != nullptr) {
connectFlags[0] |= AsyncMqttClientInternals::ConnectFlag.WILL;
if (_willRetain) connectFlags[0] |= AsyncMqttClientInternals::ConnectFlag.WILL_RETAIN;
switch (_willQos) {
case 0:
connectFlags[0] |= AsyncMqttClientInternals::ConnectFlag.WILL_QOS0;
break;
case 1:
connectFlags[0] |= AsyncMqttClientInternals::ConnectFlag.WILL_QOS1;
break;
case 2:
connectFlags[0] |= AsyncMqttClientInternals::ConnectFlag.WILL_QOS2;
break;
}
}
char keepAliveBytes[2];
keepAliveBytes[0] = _keepAlive >> 8;
keepAliveBytes[1] = _keepAlive & 0xFF;
uint16_t clientIdLength = strlen(_clientId);
char clientIdLengthBytes[2];
clientIdLengthBytes[0] = clientIdLength >> 8;
clientIdLengthBytes[1] = clientIdLength & 0xFF;
// Optional fields
uint16_t willTopicLength = 0;
char willTopicLengthBytes[2];
uint16_t willPayloadLength = _willPayloadLength;
char willPayloadLengthBytes[2];
if (_willTopic != nullptr) {
willTopicLength = strlen(_willTopic);
willTopicLengthBytes[0] = willTopicLength >> 8;
willTopicLengthBytes[1] = willTopicLength & 0xFF;
if (_willPayload != nullptr && willPayloadLength == 0) willPayloadLength = strlen(_willPayload);
willPayloadLengthBytes[0] = willPayloadLength >> 8;
willPayloadLengthBytes[1] = willPayloadLength & 0xFF;
}
uint16_t usernameLength = 0;
char usernameLengthBytes[2];
if (_username != nullptr) {
usernameLength = strlen(_username);
usernameLengthBytes[0] = usernameLength >> 8;
usernameLengthBytes[1] = usernameLength & 0xFF;
}
uint16_t passwordLength = 0;
char passwordLengthBytes[2];
if (_password != nullptr) {
passwordLength = strlen(_password);
passwordLengthBytes[0] = passwordLength >> 8;
passwordLengthBytes[1] = passwordLength & 0xFF;
}
uint32_t remainingLength = 2 + protocolNameLength + 1 + 1 + 2 + 2 + clientIdLength; // always present
if (_willTopic != nullptr) remainingLength += 2 + willTopicLength + 2 + willPayloadLength;
if (_username != nullptr) remainingLength += 2 + usernameLength;
if (_password != nullptr) remainingLength += 2 + passwordLength;
uint8_t remainingLengthLength = AsyncMqttClientInternals::Helpers::encodeRemainingLength(remainingLength, fixedHeader + 1);
uint32_t neededSpace = 1 + remainingLengthLength;
neededSpace += 2;
neededSpace += protocolNameLength;
neededSpace += 1;
neededSpace += 1;
neededSpace += 2;
neededSpace += 2;
neededSpace += clientIdLength;
if (_willTopic != nullptr) {
neededSpace += 2;
neededSpace += willTopicLength;
neededSpace += 2;
if (_willPayload != nullptr) neededSpace += willPayloadLength;
}
if (_username != nullptr) {
neededSpace += 2;
neededSpace += usernameLength;
}
if (_password != nullptr) {
neededSpace += 2;
neededSpace += passwordLength;
}
SEMAPHORE_TAKE();
if (_client.space() < neededSpace) {
_connectPacketNotEnoughSpace = true;
_client.close(true);
SEMAPHORE_GIVE();
return;
}
_client.add(fixedHeader, 1 + remainingLengthLength);
_client.add(protocolNameLengthBytes, 2);
_client.add("MQTT", protocolNameLength);
_client.add(protocolLevel, 1);
_client.add(connectFlags, 1);
_client.add(keepAliveBytes, 2);
_client.add(clientIdLengthBytes, 2);
_client.add(_clientId, clientIdLength);
if (_willTopic != nullptr) {
_client.add(willTopicLengthBytes, 2);
_client.add(_willTopic, willTopicLength);
_client.add(willPayloadLengthBytes, 2);
if (_willPayload != nullptr) _client.add(_willPayload, willPayloadLength);
}
if (_username != nullptr) {
_client.add(usernameLengthBytes, 2);
_client.add(_username, usernameLength);
}
if (_password != nullptr) {
_client.add(passwordLengthBytes, 2);
_client.add(_password, passwordLength);
}
_client.send();
_lastClientActivity = millis();
SEMAPHORE_GIVE();
}
void AsyncMqttClient::_onDisconnect(AsyncClient* client) {
(void)client;
if (!_disconnectFlagged) {
AsyncMqttClientDisconnectReason reason;
if (_connectPacketNotEnoughSpace) {
reason = AsyncMqttClientDisconnectReason::ESP8266_NOT_ENOUGH_SPACE;
} else if (_tlsBadFingerprint) {
reason = AsyncMqttClientDisconnectReason::TLS_BAD_FINGERPRINT;
} else {
reason = AsyncMqttClientDisconnectReason::TCP_DISCONNECTED;
}
for (auto callback : _onDisconnectUserCallbacks) callback(reason);
}
_clear();
}
void AsyncMqttClient::_onError(AsyncClient* client, int8_t error) {
(void)client;
(void)error;
// _onDisconnect called anyway
}
void AsyncMqttClient::_onTimeout(AsyncClient* client, uint32_t time) {
(void)client;
(void)time;
// disconnection will be handled by ping/pong management
}
void AsyncMqttClient::_onAck(AsyncClient* client, size_t len, uint32_t time) {
(void)client;
(void)len;
(void)time;
}
void AsyncMqttClient::_onData(AsyncClient* client, char* data, size_t len) {
(void)client;
size_t currentBytePosition = 0;
char currentByte;
do {
switch (_parsingInformation.bufferState) {
case AsyncMqttClientInternals::BufferState::NONE:
currentByte = data[currentBytePosition++];
_parsingInformation.packetType = currentByte >> 4;
_parsingInformation.packetFlags = (currentByte << 4) >> 4;
_parsingInformation.bufferState = AsyncMqttClientInternals::BufferState::REMAINING_LENGTH;
_lastServerActivity = millis();
switch (_parsingInformation.packetType) {
case AsyncMqttClientInternals::PacketType.CONNACK:
_currentParsedPacket = new AsyncMqttClientInternals::ConnAckPacket(&_parsingInformation, std::bind(&AsyncMqttClient::_onConnAck, this, std::placeholders::_1, std::placeholders::_2));
break;
case AsyncMqttClientInternals::PacketType.PINGRESP:
_currentParsedPacket = new AsyncMqttClientInternals::PingRespPacket(&_parsingInformation, std::bind(&AsyncMqttClient::_onPingResp, this));
break;
case AsyncMqttClientInternals::PacketType.SUBACK:
_currentParsedPacket = new AsyncMqttClientInternals::SubAckPacket(&_parsingInformation, std::bind(&AsyncMqttClient::_onSubAck, this, std::placeholders::_1, std::placeholders::_2));
break;
case AsyncMqttClientInternals::PacketType.UNSUBACK:
_currentParsedPacket = new AsyncMqttClientInternals::UnsubAckPacket(&_parsingInformation, std::bind(&AsyncMqttClient::_onUnsubAck, this, std::placeholders::_1));
break;
case AsyncMqttClientInternals::PacketType.PUBLISH:
_currentParsedPacket = new AsyncMqttClientInternals::PublishPacket(&_parsingInformation, std::bind(&AsyncMqttClient::_onMessage, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, std::placeholders::_6, std::placeholders::_7, std::placeholders::_8, std::placeholders::_9), std::bind(&AsyncMqttClient::_onPublish, this, std::placeholders::_1, std::placeholders::_2));
break;
case AsyncMqttClientInternals::PacketType.PUBREL:
_currentParsedPacket = new AsyncMqttClientInternals::PubRelPacket(&_parsingInformation, std::bind(&AsyncMqttClient::_onPubRel, this, std::placeholders::_1));
break;
case AsyncMqttClientInternals::PacketType.PUBACK:
_currentParsedPacket = new AsyncMqttClientInternals::PubAckPacket(&_parsingInformation, std::bind(&AsyncMqttClient::_onPubAck, this, std::placeholders::_1));
break;
case AsyncMqttClientInternals::PacketType.PUBREC:
_currentParsedPacket = new AsyncMqttClientInternals::PubRecPacket(&_parsingInformation, std::bind(&AsyncMqttClient::_onPubRec, this, std::placeholders::_1));
break;
case AsyncMqttClientInternals::PacketType.PUBCOMP:
_currentParsedPacket = new AsyncMqttClientInternals::PubCompPacket(&_parsingInformation, std::bind(&AsyncMqttClient::_onPubComp, this, std::placeholders::_1));
break;
default:
break;
}
break;
case AsyncMqttClientInternals::BufferState::REMAINING_LENGTH:
currentByte = data[currentBytePosition++];
_remainingLengthBuffer[_remainingLengthBufferPosition++] = currentByte;
if (currentByte >> 7 == 0) {
_parsingInformation.remainingLength = AsyncMqttClientInternals::Helpers::decodeRemainingLength(_remainingLengthBuffer);
_remainingLengthBufferPosition = 0;
if (_parsingInformation.remainingLength > 0) {
_parsingInformation.bufferState = AsyncMqttClientInternals::BufferState::VARIABLE_HEADER;
} else {
// PINGRESP is a special case where it has no variable header, so the packet ends right here
_parsingInformation.bufferState = AsyncMqttClientInternals::BufferState::NONE;
_onPingResp();
}
}
break;
case AsyncMqttClientInternals::BufferState::VARIABLE_HEADER:
_currentParsedPacket->parseVariableHeader(data, len, &currentBytePosition);
break;
case AsyncMqttClientInternals::BufferState::PAYLOAD:
_currentParsedPacket->parsePayload(data, len, &currentBytePosition);
break;
default:
currentBytePosition = len;
}
} while (currentBytePosition != len);
}
void AsyncMqttClient::_onPoll(AsyncClient* client) {
if (!_connected) return;
// if there is too much time the client has sent a ping request without a response, disconnect client to avoid half open connections
if (_lastPingRequestTime != 0 && (millis() - _lastPingRequestTime) >= (_keepAlive * 1000 * 2)) {
disconnect();
return;
// send ping to ensure the server will receive at least one message inside keepalive window
} else if (_lastPingRequestTime == 0 && (millis() - _lastClientActivity) >= (_keepAlive * 1000 * 0.7)) {
_sendPing();
// send ping to verify if the server is still there (ensure this is not a half connection)
} else if (_connected && _lastPingRequestTime == 0 && (millis() - _lastServerActivity) >= (_keepAlive * 1000 * 0.7)) {
_sendPing();
}
// handle to send ack packets
_sendAcks();
// handle disconnect
if (_disconnectFlagged) {
_sendDisconnect();
}
}
/* MQTT */
void AsyncMqttClient::_onPingResp() {
_freeCurrentParsedPacket();
_lastPingRequestTime = 0;
}
void AsyncMqttClient::_onConnAck(bool sessionPresent, uint8_t connectReturnCode) {
(void)sessionPresent;
_freeCurrentParsedPacket();
if (connectReturnCode == 0) {
_connected = true;
for (auto callback : _onConnectUserCallbacks) callback(sessionPresent);
} else {
for (auto callback : _onDisconnectUserCallbacks) callback(static_cast<AsyncMqttClientDisconnectReason>(connectReturnCode));
_disconnectFlagged = true;
}
}
void AsyncMqttClient::_onSubAck(uint16_t packetId, char status) {
_freeCurrentParsedPacket();
for (auto callback : _onSubscribeUserCallbacks) callback(packetId, status);
}
void AsyncMqttClient::_onUnsubAck(uint16_t packetId) {
_freeCurrentParsedPacket();
for (auto callback : _onUnsubscribeUserCallbacks) callback(packetId);
}
void AsyncMqttClient::_onMessage(char* topic, char* payload, uint8_t qos, bool dup, bool retain, size_t len, size_t index, size_t total, uint16_t packetId) {
bool notifyPublish = true;
if (qos == 2) {
for (AsyncMqttClientInternals::PendingPubRel pendingPubRel : _pendingPubRels) {
if (pendingPubRel.packetId == packetId) {
notifyPublish = false;
break;
}
}
}
if (notifyPublish) {
AsyncMqttClientMessageProperties properties;
properties.qos = qos;
properties.dup = dup;
properties.retain = retain;
for (auto callback : _onMessageUserCallbacks) callback(topic, payload, properties, len, index, total);
}
}
void AsyncMqttClient::_onPublish(uint16_t packetId, uint8_t qos) {
AsyncMqttClientInternals::PendingAck pendingAck;
if (qos == 1) {
pendingAck.packetType = AsyncMqttClientInternals::PacketType.PUBACK;
pendingAck.headerFlag = AsyncMqttClientInternals::HeaderFlag.PUBACK_RESERVED;
pendingAck.packetId = packetId;
_toSendAcks.push_back(pendingAck);
} else if (qos == 2) {
pendingAck.packetType = AsyncMqttClientInternals::PacketType.PUBREC;
pendingAck.headerFlag = AsyncMqttClientInternals::HeaderFlag.PUBREC_RESERVED;
pendingAck.packetId = packetId;
_toSendAcks.push_back(pendingAck);
bool pubRelAwaiting = false;
for (AsyncMqttClientInternals::PendingPubRel pendingPubRel : _pendingPubRels) {
if (pendingPubRel.packetId == packetId) {
pubRelAwaiting = true;
break;
}
}
if (!pubRelAwaiting) {
AsyncMqttClientInternals::PendingPubRel pendingPubRel;
pendingPubRel.packetId = packetId;
_pendingPubRels.push_back(pendingPubRel);
}
_sendAcks();
}
_freeCurrentParsedPacket();
}
void AsyncMqttClient::_onPubRel(uint16_t packetId) {
_freeCurrentParsedPacket();
AsyncMqttClientInternals::PendingAck pendingAck;
pendingAck.packetType = AsyncMqttClientInternals::PacketType.PUBCOMP;
pendingAck.headerFlag = AsyncMqttClientInternals::HeaderFlag.PUBCOMP_RESERVED;
pendingAck.packetId = packetId;
_toSendAcks.push_back(pendingAck);
for (size_t i = 0; i < _pendingPubRels.size(); i++) {
if (_pendingPubRels[i].packetId == packetId) {
_pendingPubRels.erase(_pendingPubRels.begin() + i);
_pendingPubRels.shrink_to_fit();
}
}
_sendAcks();
}
void AsyncMqttClient::_onPubAck(uint16_t packetId) {
_freeCurrentParsedPacket();
for (auto callback : _onPublishUserCallbacks) callback(packetId);
}
void AsyncMqttClient::_onPubRec(uint16_t packetId) {
_freeCurrentParsedPacket();
AsyncMqttClientInternals::PendingAck pendingAck;
pendingAck.packetType = AsyncMqttClientInternals::PacketType.PUBREL;
pendingAck.headerFlag = AsyncMqttClientInternals::HeaderFlag.PUBREL_RESERVED;
pendingAck.packetId = packetId;
_toSendAcks.push_back(pendingAck);
_sendAcks();
}
void AsyncMqttClient::_onPubComp(uint16_t packetId) {
_freeCurrentParsedPacket();
for (auto callback : _onPublishUserCallbacks) callback(packetId);
}
bool AsyncMqttClient::_sendPing() {
char fixedHeader[2];
fixedHeader[0] = AsyncMqttClientInternals::PacketType.PINGREQ;
fixedHeader[0] = fixedHeader[0] << 4;
fixedHeader[0] = fixedHeader[0] | AsyncMqttClientInternals::HeaderFlag.PINGREQ_RESERVED;
fixedHeader[1] = 0;
size_t neededSpace = 2;
SEMAPHORE_TAKE(false);
if (_client.space() < neededSpace) { SEMAPHORE_GIVE(); return false; }
_client.add(fixedHeader, 2);
_client.send();
_lastClientActivity = millis();
_lastPingRequestTime = millis();
SEMAPHORE_GIVE();
return true;
}
void AsyncMqttClient::_sendAcks() {
uint8_t neededAckSpace = 2 + 2;
SEMAPHORE_TAKE();
for (size_t i = 0; i < _toSendAcks.size(); i++) {
if (_client.space() < neededAckSpace) break;
AsyncMqttClientInternals::PendingAck pendingAck = _toSendAcks[i];
char fixedHeader[2];
fixedHeader[0] = pendingAck.packetType;
fixedHeader[0] = fixedHeader[0] << 4;
fixedHeader[0] = fixedHeader[0] | pendingAck.headerFlag;
fixedHeader[1] = 2;
char packetIdBytes[2];
packetIdBytes[0] = pendingAck.packetId >> 8;
packetIdBytes[1] = pendingAck.packetId & 0xFF;
_client.add(fixedHeader, 2);
_client.add(packetIdBytes, 2);
_client.send();
_toSendAcks.erase(_toSendAcks.begin() + i);
_toSendAcks.shrink_to_fit();
_lastClientActivity = millis();
}
SEMAPHORE_GIVE();
}
bool AsyncMqttClient::_sendDisconnect() {
if (!_connected) return true;
const uint8_t neededSpace = 2;
SEMAPHORE_TAKE(false);
if (_client.space() < neededSpace) { SEMAPHORE_GIVE(); return false; }
char fixedHeader[2];
fixedHeader[0] = AsyncMqttClientInternals::PacketType.DISCONNECT;
fixedHeader[0] = fixedHeader[0] << 4;
fixedHeader[0] = fixedHeader[0] | AsyncMqttClientInternals::HeaderFlag.DISCONNECT_RESERVED;
fixedHeader[1] = 0;
_client.add(fixedHeader, 2);
_client.send();
_client.close(true);
_disconnectFlagged = false;
SEMAPHORE_GIVE();
return true;
}
uint16_t AsyncMqttClient::_getNextPacketId() {
uint16_t nextPacketId = _nextPacketId;
if (_nextPacketId == 65535) _nextPacketId = 0; // 0 is forbidden
_nextPacketId++;
return nextPacketId;
}
bool AsyncMqttClient::connected() const {
return _connected;
}
void AsyncMqttClient::connect() {
if (_connected) return;
#if ASYNC_TCP_SSL_ENABLED
if (_useIp) {
_client.connect(_ip, _port, _secure);
} else {
_client.connect(_host, _port, _secure);
}
#else
if (_useIp) {
_client.connect(_ip, _port);
} else {
_client.connect(_host, _port);
}
#endif
}
void AsyncMqttClient::disconnect(bool force) {
if (!_connected) return;
if (force) {
_client.close(true);
} else {
_disconnectFlagged = true;
_sendDisconnect();
}
}
uint16_t AsyncMqttClient::subscribe(const char* topic, uint8_t qos) {
if (!_connected) return 0;
char fixedHeader[5];
fixedHeader[0] = AsyncMqttClientInternals::PacketType.SUBSCRIBE;
fixedHeader[0] = fixedHeader[0] << 4;
fixedHeader[0] = fixedHeader[0] | AsyncMqttClientInternals::HeaderFlag.SUBSCRIBE_RESERVED;
uint16_t topicLength = strlen(topic);
char topicLengthBytes[2];
topicLengthBytes[0] = topicLength >> 8;
topicLengthBytes[1] = topicLength & 0xFF;
char qosByte[1];
qosByte[0] = qos;
uint8_t remainingLengthLength = AsyncMqttClientInternals::Helpers::encodeRemainingLength(2 + 2 + topicLength + 1, fixedHeader + 1);
size_t neededSpace = 0;
neededSpace += 1 + remainingLengthLength;
neededSpace += 2;
neededSpace += 2;
neededSpace += topicLength;
neededSpace += 1;
SEMAPHORE_TAKE(0);
if (_client.space() < neededSpace) { SEMAPHORE_GIVE(); return 0; }
uint16_t packetId = _getNextPacketId();
char packetIdBytes[2];
packetIdBytes[0] = packetId >> 8;
packetIdBytes[1] = packetId & 0xFF;
_client.add(fixedHeader, 1 + remainingLengthLength);
_client.add(packetIdBytes, 2);
_client.add(topicLengthBytes, 2);
_client.add(topic, topicLength);
_client.add(qosByte, 1);
_client.send();
_lastClientActivity = millis();
SEMAPHORE_GIVE();
return packetId;
}
uint16_t AsyncMqttClient::unsubscribe(const char* topic) {
if (!_connected) return 0;
char fixedHeader[5];
fixedHeader[0] = AsyncMqttClientInternals::PacketType.UNSUBSCRIBE;
fixedHeader[0] = fixedHeader[0] << 4;
fixedHeader[0] = fixedHeader[0] | AsyncMqttClientInternals::HeaderFlag.UNSUBSCRIBE_RESERVED;
uint16_t topicLength = strlen(topic);
char topicLengthBytes[2];
topicLengthBytes[0] = topicLength >> 8;
topicLengthBytes[1] = topicLength & 0xFF;
uint8_t remainingLengthLength = AsyncMqttClientInternals::Helpers::encodeRemainingLength(2 + 2 + topicLength, fixedHeader + 1);
size_t neededSpace = 0;
neededSpace += 1 + remainingLengthLength;
neededSpace += 2;
neededSpace += 2;
neededSpace += topicLength;
SEMAPHORE_TAKE(0);
if (_client.space() < neededSpace) { SEMAPHORE_GIVE(); return 0; }
uint16_t packetId = _getNextPacketId();
char packetIdBytes[2];
packetIdBytes[0] = packetId >> 8;
packetIdBytes[1] = packetId & 0xFF;
_client.add(fixedHeader, 1 + remainingLengthLength);
_client.add(packetIdBytes, 2);
_client.add(topicLengthBytes, 2);
_client.add(topic, topicLength);
_client.send();
_lastClientActivity = millis();
SEMAPHORE_GIVE();
return packetId;
}
uint16_t AsyncMqttClient::publish(const char* topic, uint8_t qos, bool retain, const char* payload, size_t length, bool dup, uint16_t message_id) {
if (!_connected) return 0;
char fixedHeader[5];
fixedHeader[0] = AsyncMqttClientInternals::PacketType.PUBLISH;
fixedHeader[0] = fixedHeader[0] << 4;
if (dup) fixedHeader[0] |= AsyncMqttClientInternals::HeaderFlag.PUBLISH_DUP;
if (retain) fixedHeader[0] |= AsyncMqttClientInternals::HeaderFlag.PUBLISH_RETAIN;
switch (qos) {
case 0:
fixedHeader[0] |= AsyncMqttClientInternals::HeaderFlag.PUBLISH_QOS0;
break;
case 1:
fixedHeader[0] |= AsyncMqttClientInternals::HeaderFlag.PUBLISH_QOS1;
break;
case 2:
fixedHeader[0] |= AsyncMqttClientInternals::HeaderFlag.PUBLISH_QOS2;
break;
}
uint16_t topicLength = strlen(topic);
char topicLengthBytes[2];
topicLengthBytes[0] = topicLength >> 8;
topicLengthBytes[1] = topicLength & 0xFF;
uint32_t payloadLength = length;
if (payload != nullptr && payloadLength == 0) payloadLength = strlen(payload);
uint32_t remainingLength = 2 + topicLength + payloadLength;
if (qos != 0) remainingLength += 2;
uint8_t remainingLengthLength = AsyncMqttClientInternals::Helpers::encodeRemainingLength(remainingLength, fixedHeader + 1);
size_t neededSpace = 0;
neededSpace += 1 + remainingLengthLength;
neededSpace += 2;
neededSpace += topicLength;
if (qos != 0) neededSpace += 2;
if (payload != nullptr) neededSpace += payloadLength;
SEMAPHORE_TAKE(0);
if (_client.space() < neededSpace) { SEMAPHORE_GIVE(); return 0; }
uint16_t packetId = 0;
char packetIdBytes[2];
if (qos != 0) {
if (dup && message_id > 0) {
packetId = message_id;
} else {
packetId = _getNextPacketId();
}
packetIdBytes[0] = packetId >> 8;
packetIdBytes[1] = packetId & 0xFF;
}
_client.add(fixedHeader, 1 + remainingLengthLength);
_client.add(topicLengthBytes, 2);
_client.add(topic, topicLength);
if (qos != 0) _client.add(packetIdBytes, 2);
if (payload != nullptr) _client.add(payload, payloadLength);
_client.send();
_lastClientActivity = millis();
SEMAPHORE_GIVE();
if (qos != 0) {
return packetId;
} else {
return 1;
}
}

View File

@@ -0,0 +1,6 @@
#ifndef SRC_ASYNCMQTTCLIENT_H_
#define SRC_ASYNCMQTTCLIENT_H_
#include "AsyncMqttClient.hpp"
#endif // SRC_ASYNCMQTTCLIENT_H_

View File

@@ -0,0 +1,166 @@
#pragma once
#include <functional>
#include <vector>
#include "Arduino.h"
#ifdef ESP32
#include <AsyncTCP.h>
#include <freertos/semphr.h>
#elif defined(ESP8266)
#include <ESPAsyncTCP.h>
#else
#error Platform not supported
#endif
#if ASYNC_TCP_SSL_ENABLED
#include <tcp_axtls.h>
#define SHA1_SIZE 20
#endif
#include "AsyncMqttClient/Flags.hpp"
#include "AsyncMqttClient/ParsingInformation.hpp"
#include "AsyncMqttClient/MessageProperties.hpp"
#include "AsyncMqttClient/Helpers.hpp"
#include "AsyncMqttClient/Callbacks.hpp"
#include "AsyncMqttClient/DisconnectReasons.hpp"
#include "AsyncMqttClient/Storage.hpp"
#include "AsyncMqttClient/Packets/Packet.hpp"
#include "AsyncMqttClient/Packets/ConnAckPacket.hpp"
#include "AsyncMqttClient/Packets/PingRespPacket.hpp"
#include "AsyncMqttClient/Packets/SubAckPacket.hpp"
#include "AsyncMqttClient/Packets/UnsubAckPacket.hpp"
#include "AsyncMqttClient/Packets/PublishPacket.hpp"
#include "AsyncMqttClient/Packets/PubRelPacket.hpp"
#include "AsyncMqttClient/Packets/PubAckPacket.hpp"
#include "AsyncMqttClient/Packets/PubRecPacket.hpp"
#include "AsyncMqttClient/Packets/PubCompPacket.hpp"
#if ESP32
#define SEMAPHORE_TAKE(X) if (xSemaphoreTake(_xSemaphore, 1000 / portTICK_PERIOD_MS) != pdTRUE) { return X; } // Waits max 1000ms
#define SEMAPHORE_GIVE() xSemaphoreGive(_xSemaphore);
#elif defined(ESP8266)
#define SEMAPHORE_TAKE(X) void()
#define SEMAPHORE_GIVE() void()
#endif
class AsyncMqttClient {
public:
AsyncMqttClient();
~AsyncMqttClient();
AsyncMqttClient& setKeepAlive(uint16_t keepAlive);
AsyncMqttClient& setClientId(const char* clientId);
AsyncMqttClient& setCleanSession(bool cleanSession);
AsyncMqttClient& setMaxTopicLength(uint16_t maxTopicLength);
AsyncMqttClient& setCredentials(const char* username, const char* password = nullptr);
AsyncMqttClient& setWill(const char* topic, uint8_t qos, bool retain, const char* payload = nullptr, size_t length = 0);
AsyncMqttClient& setServer(IPAddress ip, uint16_t port);
AsyncMqttClient& setServer(const char* host, uint16_t port);
#if ASYNC_TCP_SSL_ENABLED
AsyncMqttClient& setSecure(bool secure);
AsyncMqttClient& addServerFingerprint(const uint8_t* fingerprint);
#endif
AsyncMqttClient& onConnect(AsyncMqttClientInternals::OnConnectUserCallback callback);
AsyncMqttClient& onDisconnect(AsyncMqttClientInternals::OnDisconnectUserCallback callback);
AsyncMqttClient& onSubscribe(AsyncMqttClientInternals::OnSubscribeUserCallback callback);
AsyncMqttClient& onUnsubscribe(AsyncMqttClientInternals::OnUnsubscribeUserCallback callback);
AsyncMqttClient& onMessage(AsyncMqttClientInternals::OnMessageUserCallback callback);
AsyncMqttClient& onPublish(AsyncMqttClientInternals::OnPublishUserCallback callback);
bool connected() const;
void connect();
void disconnect(bool force = false);
uint16_t subscribe(const char* topic, uint8_t qos);
uint16_t unsubscribe(const char* topic);
uint16_t publish(const char* topic, uint8_t qos, bool retain, const char* payload = nullptr, size_t length = 0, bool dup = false, uint16_t message_id = 0);
private:
AsyncClient _client;
bool _connected;
bool _connectPacketNotEnoughSpace;
bool _disconnectFlagged;
bool _tlsBadFingerprint;
uint32_t _lastClientActivity;
uint32_t _lastServerActivity;
uint32_t _lastPingRequestTime;
char _generatedClientId[13 + 1]; // esp8266abc123
IPAddress _ip;
const char* _host;
bool _useIp;
#if ASYNC_TCP_SSL_ENABLED
bool _secure;
#endif
uint16_t _port;
uint16_t _keepAlive;
bool _cleanSession;
const char* _clientId;
const char* _username;
const char* _password;
const char* _willTopic;
const char* _willPayload;
uint16_t _willPayloadLength;
uint8_t _willQos;
bool _willRetain;
#if ASYNC_TCP_SSL_ENABLED
std::vector<std::array<uint8_t, SHA1_SIZE>> _secureServerFingerprints;
#endif
std::vector<AsyncMqttClientInternals::OnConnectUserCallback> _onConnectUserCallbacks;
std::vector<AsyncMqttClientInternals::OnDisconnectUserCallback> _onDisconnectUserCallbacks;
std::vector<AsyncMqttClientInternals::OnSubscribeUserCallback> _onSubscribeUserCallbacks;
std::vector<AsyncMqttClientInternals::OnUnsubscribeUserCallback> _onUnsubscribeUserCallbacks;
std::vector<AsyncMqttClientInternals::OnMessageUserCallback> _onMessageUserCallbacks;
std::vector<AsyncMqttClientInternals::OnPublishUserCallback> _onPublishUserCallbacks;
AsyncMqttClientInternals::ParsingInformation _parsingInformation;
AsyncMqttClientInternals::Packet* _currentParsedPacket;
uint8_t _remainingLengthBufferPosition;
char _remainingLengthBuffer[4];
uint16_t _nextPacketId;
std::vector<AsyncMqttClientInternals::PendingPubRel> _pendingPubRels;
std::vector<AsyncMqttClientInternals::PendingAck> _toSendAcks;
#ifdef ESP32
SemaphoreHandle_t _xSemaphore = nullptr;
#endif
void _clear();
void _freeCurrentParsedPacket();
// TCP
void _onConnect(AsyncClient* client);
void _onDisconnect(AsyncClient* client);
static void _onError(AsyncClient* client, int8_t error);
void _onTimeout(AsyncClient* client, uint32_t time);
static void _onAck(AsyncClient* client, size_t len, uint32_t time);
void _onData(AsyncClient* client, char* data, size_t len);
void _onPoll(AsyncClient* client);
// MQTT
void _onPingResp();
void _onConnAck(bool sessionPresent, uint8_t connectReturnCode);
void _onSubAck(uint16_t packetId, char status);
void _onUnsubAck(uint16_t packetId);
void _onMessage(char* topic, char* payload, uint8_t qos, bool dup, bool retain, size_t len, size_t index, size_t total, uint16_t packetId);
void _onPublish(uint16_t packetId, uint8_t qos);
void _onPubRel(uint16_t packetId);
void _onPubAck(uint16_t packetId);
void _onPubRec(uint16_t packetId);
void _onPubComp(uint16_t packetId);
bool _sendPing();
void _sendAcks();
bool _sendDisconnect();
uint16_t _getNextPacketId();
};

View File

@@ -0,0 +1,28 @@
#pragma once
#include <functional>
#include "DisconnectReasons.hpp"
#include "MessageProperties.hpp"
namespace AsyncMqttClientInternals {
// user callbacks
typedef std::function<void(bool sessionPresent)> OnConnectUserCallback;
typedef std::function<void(AsyncMqttClientDisconnectReason reason)> OnDisconnectUserCallback;
typedef std::function<void(uint16_t packetId, uint8_t qos)> OnSubscribeUserCallback;
typedef std::function<void(uint16_t packetId)> OnUnsubscribeUserCallback;
typedef std::function<void(char* topic, char* payload, AsyncMqttClientMessageProperties properties, size_t len, size_t index, size_t total)> OnMessageUserCallback;
typedef std::function<void(uint16_t packetId)> OnPublishUserCallback;
// internal callbacks
typedef std::function<void(bool sessionPresent, uint8_t connectReturnCode)> OnConnAckInternalCallback;
typedef std::function<void()> OnPingRespInternalCallback;
typedef std::function<void(uint16_t packetId, char status)> OnSubAckInternalCallback;
typedef std::function<void(uint16_t packetId)> OnUnsubAckInternalCallback;
typedef std::function<void(char* topic, char* payload, uint8_t qos, bool dup, bool retain, size_t len, size_t index, size_t total, uint16_t packetId)> OnMessageInternalCallback;
typedef std::function<void(uint16_t packetId, uint8_t qos)> OnPublishInternalCallback;
typedef std::function<void(uint16_t packetId)> OnPubRelInternalCallback;
typedef std::function<void(uint16_t packetId)> OnPubAckInternalCallback;
typedef std::function<void(uint16_t packetId)> OnPubRecInternalCallback;
typedef std::function<void(uint16_t packetId)> OnPubCompInternalCallback;
} // namespace AsyncMqttClientInternals

View File

@@ -0,0 +1,15 @@
#pragma once
enum class AsyncMqttClientDisconnectReason : int8_t {
TCP_DISCONNECTED = 0,
MQTT_UNACCEPTABLE_PROTOCOL_VERSION = 1,
MQTT_IDENTIFIER_REJECTED = 2,
MQTT_SERVER_UNAVAILABLE = 3,
MQTT_MALFORMED_CREDENTIALS = 4,
MQTT_NOT_AUTHORIZED = 5,
ESP8266_NOT_ENOUGH_SPACE = 6,
TLS_BAD_FINGERPRINT = 7
};

View File

@@ -0,0 +1,57 @@
#pragma once
namespace AsyncMqttClientInternals {
constexpr struct {
const uint8_t RESERVED = 0;
const uint8_t CONNECT = 1;
const uint8_t CONNACK = 2;
const uint8_t PUBLISH = 3;
const uint8_t PUBACK = 4;
const uint8_t PUBREC = 5;
const uint8_t PUBREL = 6;
const uint8_t PUBCOMP = 7;
const uint8_t SUBSCRIBE = 8;
const uint8_t SUBACK = 9;
const uint8_t UNSUBSCRIBE = 10;
const uint8_t UNSUBACK = 11;
const uint8_t PINGREQ = 12;
const uint8_t PINGRESP = 13;
const uint8_t DISCONNECT = 14;
const uint8_t RESERVED2 = 1;
} PacketType;
constexpr struct {
const uint8_t CONNECT_RESERVED = 0x00;
const uint8_t CONNACK_RESERVED = 0x00;
const uint8_t PUBLISH_DUP = 0x08;
const uint8_t PUBLISH_QOS0 = 0x00;
const uint8_t PUBLISH_QOS1 = 0x02;
const uint8_t PUBLISH_QOS2 = 0x04;
const uint8_t PUBLISH_QOSRESERVED = 0x06;
const uint8_t PUBLISH_RETAIN = 0x01;
const uint8_t PUBACK_RESERVED = 0x00;
const uint8_t PUBREC_RESERVED = 0x00;
const uint8_t PUBREL_RESERVED = 0x02;
const uint8_t PUBCOMP_RESERVED = 0x00;
const uint8_t SUBSCRIBE_RESERVED = 0x02;
const uint8_t SUBACK_RESERVED = 0x00;
const uint8_t UNSUBSCRIBE_RESERVED = 0x02;
const uint8_t UNSUBACK_RESERVED = 0x00;
const uint8_t PINGREQ_RESERVED = 0x00;
const uint8_t PINGRESP_RESERVED = 0x00;
const uint8_t DISCONNECT_RESERVED = 0x00;
const uint8_t RESERVED2_RESERVED = 0x00;
} HeaderFlag;
constexpr struct {
const uint8_t USERNAME = 0x80;
const uint8_t PASSWORD = 0x40;
const uint8_t WILL_RETAIN = 0x20;
const uint8_t WILL_QOS0 = 0x00;
const uint8_t WILL_QOS1 = 0x08;
const uint8_t WILL_QOS2 = 0x10;
const uint8_t WILL = 0x04;
const uint8_t CLEAN_SESSION = 0x02;
const uint8_t RESERVED = 0x00;
} ConnectFlag;
} // namespace AsyncMqttClientInternals

View File

@@ -0,0 +1,38 @@
#pragma once
namespace AsyncMqttClientInternals {
class Helpers {
public:
static uint32_t decodeRemainingLength(char* bytes) {
uint32_t multiplier = 1;
uint32_t value = 0;
uint8_t currentByte = 0;
uint8_t encodedByte;
do {
encodedByte = bytes[currentByte++];
value += (encodedByte & 127) * multiplier;
multiplier *= 128;
} while ((encodedByte & 128) != 0);
return value;
}
static uint8_t encodeRemainingLength(uint32_t remainingLength, char* destination) {
uint8_t currentByte = 0;
uint8_t bytesNeeded = 0;
do {
uint8_t encodedByte = remainingLength % 128;
remainingLength /= 128;
if (remainingLength > 0) {
encodedByte = encodedByte | 128;
}
destination[currentByte++] = encodedByte;
bytesNeeded++;
} while (remainingLength > 0);
return bytesNeeded;
}
};
} // namespace AsyncMqttClientInternals

View File

@@ -0,0 +1,7 @@
#pragma once
struct AsyncMqttClientMessageProperties {
uint8_t qos;
bool dup;
bool retain;
};

View File

@@ -0,0 +1,30 @@
#include "ConnAckPacket.hpp"
using AsyncMqttClientInternals::ConnAckPacket;
ConnAckPacket::ConnAckPacket(ParsingInformation* parsingInformation, OnConnAckInternalCallback callback)
: _parsingInformation(parsingInformation)
, _callback(callback)
, _bytePosition(0)
, _sessionPresent(false)
, _connectReturnCode(0) {
}
ConnAckPacket::~ConnAckPacket() {
}
void ConnAckPacket::parseVariableHeader(char* data, size_t len, size_t* currentBytePosition) {
char currentByte = data[(*currentBytePosition)++];
if (_bytePosition++ == 0) {
_sessionPresent = (currentByte << 7) >> 7;
} else {
_connectReturnCode = currentByte;
_parsingInformation->bufferState = BufferState::NONE;
_callback(_sessionPresent, _connectReturnCode);
}
}
void ConnAckPacket::parsePayload(char* data, size_t len, size_t* currentBytePosition) {
(void)data;
(void)currentBytePosition;
}

View File

@@ -0,0 +1,25 @@
#pragma once
#include "Arduino.h"
#include "Packet.hpp"
#include "../ParsingInformation.hpp"
#include "../Callbacks.hpp"
namespace AsyncMqttClientInternals {
class ConnAckPacket : public Packet {
public:
explicit ConnAckPacket(ParsingInformation* parsingInformation, OnConnAckInternalCallback callback);
~ConnAckPacket();
void parseVariableHeader(char* data, size_t len, size_t* currentBytePosition);
void parsePayload(char* data, size_t len, size_t* currentBytePosition);
private:
ParsingInformation* _parsingInformation;
OnConnAckInternalCallback _callback;
uint8_t _bytePosition;
bool _sessionPresent;
uint8_t _connectReturnCode;
};
} // namespace AsyncMqttClientInternals

View File

@@ -0,0 +1,11 @@
#pragma once
namespace AsyncMqttClientInternals {
class Packet {
public:
virtual ~Packet() {}
virtual void parseVariableHeader(char* data, size_t len, size_t* currentBytePosition) = 0;
virtual void parsePayload(char* data, size_t len, size_t* currentBytePosition) = 0;
};
} // namespace AsyncMqttClientInternals

View File

@@ -0,0 +1,21 @@
#include "PingRespPacket.hpp"
using AsyncMqttClientInternals::PingRespPacket;
PingRespPacket::PingRespPacket(ParsingInformation* parsingInformation, OnPingRespInternalCallback callback)
: _parsingInformation(parsingInformation)
, _callback(callback) {
}
PingRespPacket::~PingRespPacket() {
}
void PingRespPacket::parseVariableHeader(char* data, size_t len, size_t* currentBytePosition) {
(void)data;
(void)currentBytePosition;
}
void PingRespPacket::parsePayload(char* data, size_t len, size_t* currentBytePosition) {
(void)data;
(void)currentBytePosition;
}

View File

@@ -0,0 +1,21 @@
#pragma once
#include "Arduino.h"
#include "Packet.hpp"
#include "../ParsingInformation.hpp"
#include "../Callbacks.hpp"
namespace AsyncMqttClientInternals {
class PingRespPacket : public Packet {
public:
explicit PingRespPacket(ParsingInformation* parsingInformation, OnPingRespInternalCallback callback);
~PingRespPacket();
void parseVariableHeader(char* data, size_t len, size_t* currentBytePosition);
void parsePayload(char* data, size_t len, size_t* currentBytePosition);
private:
ParsingInformation* _parsingInformation;
OnPingRespInternalCallback _callback;
};
} // namespace AsyncMqttClientInternals

View File

@@ -0,0 +1,30 @@
#include "PubAckPacket.hpp"
using AsyncMqttClientInternals::PubAckPacket;
PubAckPacket::PubAckPacket(ParsingInformation* parsingInformation, OnPubAckInternalCallback callback)
: _parsingInformation(parsingInformation)
, _callback(callback)
, _bytePosition(0)
, _packetIdMsb(0)
, _packetId(0) {
}
PubAckPacket::~PubAckPacket() {
}
void PubAckPacket::parseVariableHeader(char* data, size_t len, size_t* currentBytePosition) {
char currentByte = data[(*currentBytePosition)++];
if (_bytePosition++ == 0) {
_packetIdMsb = currentByte;
} else {
_packetId = currentByte | _packetIdMsb << 8;
_parsingInformation->bufferState = BufferState::NONE;
_callback(_packetId);
}
}
void PubAckPacket::parsePayload(char* data, size_t len, size_t* currentBytePosition) {
(void)data;
(void)currentBytePosition;
}

View File

@@ -0,0 +1,25 @@
#pragma once
#include "Arduino.h"
#include "Packet.hpp"
#include "../ParsingInformation.hpp"
#include "../Callbacks.hpp"
namespace AsyncMqttClientInternals {
class PubAckPacket : public Packet {
public:
explicit PubAckPacket(ParsingInformation* parsingInformation, OnPubAckInternalCallback callback);
~PubAckPacket();
void parseVariableHeader(char* data, size_t len, size_t* currentBytePosition);
void parsePayload(char* data, size_t len, size_t* currentBytePosition);
private:
ParsingInformation* _parsingInformation;
OnPubAckInternalCallback _callback;
uint8_t _bytePosition;
char _packetIdMsb;
uint16_t _packetId;
};
} // namespace AsyncMqttClientInternals

View File

@@ -0,0 +1,30 @@
#include "PubCompPacket.hpp"
using AsyncMqttClientInternals::PubCompPacket;
PubCompPacket::PubCompPacket(ParsingInformation* parsingInformation, OnPubCompInternalCallback callback)
: _parsingInformation(parsingInformation)
, _callback(callback)
, _bytePosition(0)
, _packetIdMsb(0)
, _packetId(0) {
}
PubCompPacket::~PubCompPacket() {
}
void PubCompPacket::parseVariableHeader(char* data, size_t len, size_t* currentBytePosition) {
char currentByte = data[(*currentBytePosition)++];
if (_bytePosition++ == 0) {
_packetIdMsb = currentByte;
} else {
_packetId = currentByte | _packetIdMsb << 8;
_parsingInformation->bufferState = BufferState::NONE;
_callback(_packetId);
}
}
void PubCompPacket::parsePayload(char* data, size_t len, size_t* currentBytePosition) {
(void)data;
(void)currentBytePosition;
}

View File

@@ -0,0 +1,25 @@
#pragma once
#include "Arduino.h"
#include "Packet.hpp"
#include "../ParsingInformation.hpp"
#include "../Callbacks.hpp"
namespace AsyncMqttClientInternals {
class PubCompPacket : public Packet {
public:
explicit PubCompPacket(ParsingInformation* parsingInformation, OnPubCompInternalCallback callback);
~PubCompPacket();
void parseVariableHeader(char* data, size_t len, size_t* currentBytePosition);
void parsePayload(char* data, size_t len, size_t* currentBytePosition);
private:
ParsingInformation* _parsingInformation;
OnPubCompInternalCallback _callback;
uint8_t _bytePosition;
char _packetIdMsb;
uint16_t _packetId;
};
} // namespace AsyncMqttClientInternals

View File

@@ -0,0 +1,30 @@
#include "PubRecPacket.hpp"
using AsyncMqttClientInternals::PubRecPacket;
PubRecPacket::PubRecPacket(ParsingInformation* parsingInformation, OnPubRecInternalCallback callback)
: _parsingInformation(parsingInformation)
, _callback(callback)
, _bytePosition(0)
, _packetIdMsb(0)
, _packetId(0) {
}
PubRecPacket::~PubRecPacket() {
}
void PubRecPacket::parseVariableHeader(char* data, size_t len, size_t* currentBytePosition) {
char currentByte = data[(*currentBytePosition)++];
if (_bytePosition++ == 0) {
_packetIdMsb = currentByte;
} else {
_packetId = currentByte | _packetIdMsb << 8;
_parsingInformation->bufferState = BufferState::NONE;
_callback(_packetId);
}
}
void PubRecPacket::parsePayload(char* data, size_t len, size_t* currentBytePosition) {
(void)data;
(void)currentBytePosition;
}

View File

@@ -0,0 +1,25 @@
#pragma once
#include "Arduino.h"
#include "Packet.hpp"
#include "../ParsingInformation.hpp"
#include "../Callbacks.hpp"
namespace AsyncMqttClientInternals {
class PubRecPacket : public Packet {
public:
explicit PubRecPacket(ParsingInformation* parsingInformation, OnPubRecInternalCallback callback);
~PubRecPacket();
void parseVariableHeader(char* data, size_t len, size_t* currentBytePosition);
void parsePayload(char* data, size_t len, size_t* currentBytePosition);
private:
ParsingInformation* _parsingInformation;
OnPubRecInternalCallback _callback;
uint8_t _bytePosition;
char _packetIdMsb;
uint16_t _packetId;
};
} // namespace AsyncMqttClientInternals

View File

@@ -0,0 +1,30 @@
#include "PubRelPacket.hpp"
using AsyncMqttClientInternals::PubRelPacket;
PubRelPacket::PubRelPacket(ParsingInformation* parsingInformation, OnPubRelInternalCallback callback)
: _parsingInformation(parsingInformation)
, _callback(callback)
, _bytePosition(0)
, _packetIdMsb(0)
, _packetId(0) {
}
PubRelPacket::~PubRelPacket() {
}
void PubRelPacket::parseVariableHeader(char* data, size_t len, size_t* currentBytePosition) {
char currentByte = data[(*currentBytePosition)++];
if (_bytePosition++ == 0) {
_packetIdMsb = currentByte;
} else {
_packetId = currentByte | _packetIdMsb << 8;
_parsingInformation->bufferState = BufferState::NONE;
_callback(_packetId);
}
}
void PubRelPacket::parsePayload(char* data, size_t len, size_t* currentBytePosition) {
(void)data;
(void)currentBytePosition;
}

View File

@@ -0,0 +1,25 @@
#pragma once
#include "Arduino.h"
#include "Packet.hpp"
#include "../ParsingInformation.hpp"
#include "../Callbacks.hpp"
namespace AsyncMqttClientInternals {
class PubRelPacket : public Packet {
public:
explicit PubRelPacket(ParsingInformation* parsingInformation, OnPubRelInternalCallback callback);
~PubRelPacket();
void parseVariableHeader(char* data, size_t len, size_t* currentBytePosition);
void parsePayload(char* data, size_t len, size_t* currentBytePosition);
private:
ParsingInformation* _parsingInformation;
OnPubRelInternalCallback _callback;
uint8_t _bytePosition;
char _packetIdMsb;
uint16_t _packetId;
};
} // namespace AsyncMqttClientInternals

View File

@@ -0,0 +1,91 @@
#include "PublishPacket.hpp"
using AsyncMqttClientInternals::PublishPacket;
PublishPacket::PublishPacket(ParsingInformation* parsingInformation, OnMessageInternalCallback dataCallback, OnPublishInternalCallback completeCallback)
: _parsingInformation(parsingInformation)
, _dataCallback(dataCallback)
, _completeCallback(completeCallback)
, _dup(false)
, _qos(0)
, _retain(0)
, _bytePosition(0)
, _topicLengthMsb(0)
, _topicLength(0)
, _ignore(false)
, _packetIdMsb(0)
, _packetId(0)
, _payloadLength(0)
, _payloadBytesRead(0) {
_dup = _parsingInformation->packetFlags & HeaderFlag.PUBLISH_DUP;
_retain = _parsingInformation->packetFlags & HeaderFlag.PUBLISH_RETAIN;
char qosMasked = _parsingInformation->packetFlags & 0x06;
switch (qosMasked) {
case HeaderFlag.PUBLISH_QOS0:
_qos = 0;
break;
case HeaderFlag.PUBLISH_QOS1:
_qos = 1;
break;
case HeaderFlag.PUBLISH_QOS2:
_qos = 2;
break;
}
}
PublishPacket::~PublishPacket() {
}
void PublishPacket::parseVariableHeader(char* data, size_t len, size_t* currentBytePosition) {
char currentByte = data[(*currentBytePosition)++];
if (_bytePosition == 0) {
_topicLengthMsb = currentByte;
} else if (_bytePosition == 1) {
_topicLength = currentByte | _topicLengthMsb << 8;
if (_topicLength > _parsingInformation->maxTopicLength) {
_ignore = true;
} else {
_parsingInformation->topicBuffer[_topicLength] = '\0';
}
} else if (_bytePosition >= 2 && _bytePosition < 2 + _topicLength) {
// Starting from here, _ignore might be true
if (!_ignore) _parsingInformation->topicBuffer[_bytePosition - 2] = currentByte;
if (_bytePosition == 2 + _topicLength - 1 && _qos == 0) {
_preparePayloadHandling(_parsingInformation->remainingLength - (_bytePosition + 1));
return;
}
} else if (_bytePosition == 2 + _topicLength) {
_packetIdMsb = currentByte;
} else {
_packetId = currentByte | _packetIdMsb << 8;
_preparePayloadHandling(_parsingInformation->remainingLength - (_bytePosition + 1));
}
_bytePosition++;
}
void PublishPacket::_preparePayloadHandling(uint32_t payloadLength) {
_payloadLength = payloadLength;
if (payloadLength == 0) {
_parsingInformation->bufferState = BufferState::NONE;
if (!_ignore) {
_dataCallback(_parsingInformation->topicBuffer, nullptr, _qos, _dup, _retain, 0, 0, 0, _packetId);
_completeCallback(_packetId, _qos);
}
} else {
_parsingInformation->bufferState = BufferState::PAYLOAD;
}
}
void PublishPacket::parsePayload(char* data, size_t len, size_t* currentBytePosition) {
size_t remainToRead = len - (*currentBytePosition);
if (_payloadBytesRead + remainToRead > _payloadLength) remainToRead = _payloadLength - _payloadBytesRead;
if (!_ignore) _dataCallback(_parsingInformation->topicBuffer, data + (*currentBytePosition), _qos, _dup, _retain, remainToRead, _payloadBytesRead, _payloadLength, _packetId);
_payloadBytesRead += remainToRead;
(*currentBytePosition) += remainToRead;
if (_payloadBytesRead == _payloadLength) {
_parsingInformation->bufferState = BufferState::NONE;
if (!_ignore) _completeCallback(_packetId, _qos);
}
}

View File

@@ -0,0 +1,38 @@
#pragma once
#include "Arduino.h"
#include "Packet.hpp"
#include "../Flags.hpp"
#include "../ParsingInformation.hpp"
#include "../Callbacks.hpp"
namespace AsyncMqttClientInternals {
class PublishPacket : public Packet {
public:
explicit PublishPacket(ParsingInformation* parsingInformation, OnMessageInternalCallback dataCallback, OnPublishInternalCallback completeCallback);
~PublishPacket();
void parseVariableHeader(char* data, size_t len, size_t* currentBytePosition);
void parsePayload(char* data, size_t len, size_t* currentBytePosition);
private:
ParsingInformation* _parsingInformation;
OnMessageInternalCallback _dataCallback;
OnPublishInternalCallback _completeCallback;
void _preparePayloadHandling(uint32_t payloadLength);
bool _dup;
uint8_t _qos;
bool _retain;
uint8_t _bytePosition;
char _topicLengthMsb;
uint16_t _topicLength;
bool _ignore;
char _packetIdMsb;
uint16_t _packetId;
uint32_t _payloadLength;
uint32_t _payloadBytesRead;
};
} // namespace AsyncMqttClientInternals

View File

@@ -0,0 +1,46 @@
#include "SubAckPacket.hpp"
using AsyncMqttClientInternals::SubAckPacket;
SubAckPacket::SubAckPacket(ParsingInformation* parsingInformation, OnSubAckInternalCallback callback)
: _parsingInformation(parsingInformation)
, _callback(callback)
, _bytePosition(0)
, _packetIdMsb(0)
, _packetId(0) {
}
SubAckPacket::~SubAckPacket() {
}
void SubAckPacket::parseVariableHeader(char* data, size_t len, size_t* currentBytePosition) {
char currentByte = data[(*currentBytePosition)++];
if (_bytePosition++ == 0) {
_packetIdMsb = currentByte;
} else {
_packetId = currentByte | _packetIdMsb << 8;
_parsingInformation->bufferState = BufferState::PAYLOAD;
}
}
void SubAckPacket::parsePayload(char* data, size_t len, size_t* currentBytePosition) {
char status = data[(*currentBytePosition)++];
/* switch (status) {
case 0:
Serial.println("Success QoS 0");
break;
case 1:
Serial.println("Success QoS 1");
break;
case 2:
Serial.println("Success QoS 2");
break;
case 0x80:
Serial.println("Failure");
break;
} */
_parsingInformation->bufferState = BufferState::NONE;
_callback(_packetId, status);
}

View File

@@ -0,0 +1,25 @@
#pragma once
#include "Arduino.h"
#include "Packet.hpp"
#include "../ParsingInformation.hpp"
#include "../Callbacks.hpp"
namespace AsyncMqttClientInternals {
class SubAckPacket : public Packet {
public:
explicit SubAckPacket(ParsingInformation* parsingInformation, OnSubAckInternalCallback callback);
~SubAckPacket();
void parseVariableHeader(char* data, size_t len, size_t* currentBytePosition);
void parsePayload(char* data, size_t len, size_t* currentBytePosition);
private:
ParsingInformation* _parsingInformation;
OnSubAckInternalCallback _callback;
uint8_t _bytePosition;
char _packetIdMsb;
uint16_t _packetId;
};
} // namespace AsyncMqttClientInternals

View File

@@ -0,0 +1,30 @@
#include "UnsubAckPacket.hpp"
using AsyncMqttClientInternals::UnsubAckPacket;
UnsubAckPacket::UnsubAckPacket(ParsingInformation* parsingInformation, OnUnsubAckInternalCallback callback)
: _parsingInformation(parsingInformation)
, _callback(callback)
, _bytePosition(0)
, _packetIdMsb(0)
, _packetId(0) {
}
UnsubAckPacket::~UnsubAckPacket() {
}
void UnsubAckPacket::parseVariableHeader(char* data, size_t len, size_t* currentBytePosition) {
char currentByte = data[(*currentBytePosition)++];
if (_bytePosition++ == 0) {
_packetIdMsb = currentByte;
} else {
_packetId = currentByte | _packetIdMsb << 8;
_parsingInformation->bufferState = BufferState::NONE;
_callback(_packetId);
}
}
void UnsubAckPacket::parsePayload(char* data, size_t len, size_t* currentBytePosition) {
(void)data;
(void)currentBytePosition;
}

View File

@@ -0,0 +1,25 @@
#pragma once
#include "Arduino.h"
#include "Packet.hpp"
#include "../ParsingInformation.hpp"
#include "../Callbacks.hpp"
namespace AsyncMqttClientInternals {
class UnsubAckPacket : public Packet {
public:
explicit UnsubAckPacket(ParsingInformation* parsingInformation, OnUnsubAckInternalCallback callback);
~UnsubAckPacket();
void parseVariableHeader(char* data, size_t len, size_t* currentBytePosition);
void parsePayload(char* data, size_t len, size_t* currentBytePosition);
private:
ParsingInformation* _parsingInformation;
OnUnsubAckInternalCallback _callback;
uint8_t _bytePosition;
char _packetIdMsb;
uint16_t _packetId;
};
} // namespace AsyncMqttClientInternals

View File

@@ -0,0 +1,21 @@
#pragma once
namespace AsyncMqttClientInternals {
enum class BufferState : uint8_t {
NONE = 0,
REMAINING_LENGTH = 2,
VARIABLE_HEADER = 3,
PAYLOAD = 4
};
struct ParsingInformation {
BufferState bufferState;
uint16_t maxTopicLength;
char* topicBuffer;
uint8_t packetType;
uint16_t packetFlags;
uint32_t remainingLength;
};
} // namespace AsyncMqttClientInternals

View File

@@ -0,0 +1,13 @@
#pragma once
namespace AsyncMqttClientInternals {
struct PendingPubRel {
uint16_t packetId;
};
struct PendingAck {
uint8_t packetType;
uint8_t headerFlag;
uint16_t packetId;
};
} // namespace AsyncMqttClientInternals

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2015 Marvin Roger
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.

View File

@@ -0,0 +1,18 @@
Async MQTT client for ESP8266 and ESP32 (Github: https://github.com/marvinroger/async-mqtt-client)
=============================
[![Build Status](https://img.shields.io/travis/marvinroger/async-mqtt-client/master.svg?style=flat-square)](https://travis-ci.org/marvinroger/async-mqtt-client)
An Arduino for ESP8266 and ESP32 asynchronous [MQTT](http://mqtt.org/) client implementation, built on [me-no-dev/ESPAsyncTCP (ESP8266)](https://github.com/me-no-dev/ESPAsyncTCP) | [me-no-dev/AsyncTCP (ESP32)](https://github.com/me-no-dev/AsyncTCP) .
## Features
* Compliant with the 3.1.1 version of the protocol
* Fully asynchronous
* Subscribe at QoS 0, 1 and 2
* Publish at QoS 0, 1 and 2
* SSL/TLS support
* Available in the [PlatformIO registry](http://platformio.org/lib/show/346/AsyncMqttClient)
## Requirements, installation and usage
The project is documented in the [/docs folder](docs).

View File

@@ -0,0 +1,321 @@
/**
* @file BlynkApi.h
* @author Volodymyr Shymanskyy
* @license This project is released under the MIT License (MIT)
* @copyright Copyright (c) 2015 Volodymyr Shymanskyy
* @date Jan 2015
* @brief High-level functions
*
*/
#ifndef BlynkApi_h
#define BlynkApi_h
#include "BlynkConfig.h"
#include "BlynkDebug.h"
#include "BlynkParam.h"
#include "BlynkTimer.h"
#include "BlynkHandlers.h"
#include "BlynkProtocolDefs.h"
#if defined(BLYNK_EXPERIMENTAL)
#include <Blynk/BlynkEveryN.h>
#endif
/**
* Represents high-level functions of Blynk
*/
template <class Proto>
class BlynkApi
{
public:
BlynkApi() {
}
#ifdef DOXYGEN // These API here are only for the documentation
/**
* Connects to the server.
* Blocks until connected or timeout happens.
* May take less or more then timeout value.
*
* @param timeout Connection timeout
* @returns True if connected to the server
*/
bool connect(unsigned long timeout = BLYNK_TIMEOUT_MS*3);
/**
* Disconnects from the server.
* It will not try to reconnect, until connect() is called
*/
void disconnect();
/**
* @returns True if connected to the server
*/
bool connected();
/**
* Performs Blynk-related housekeeping
* and processes incoming commands
*
* @param available True if there is incoming data to process
* Only used when user manages connection manually.
*/
bool run(bool available = false);
#endif // DOXYGEN
/**
* Sends value to a Virtual Pin
*
* @param pin Virtual Pin number
* @param data Value to be sent
*/
template <typename... Args>
void virtualWrite(int pin, Args... values) {
char mem[BLYNK_MAX_SENDBYTES];
BlynkParam cmd(mem, 0, sizeof(mem));
cmd.add("vw");
cmd.add(pin);
cmd.add_multi(values...);
static_cast<Proto*>(this)->sendCmd(BLYNK_CMD_HARDWARE, 0, cmd.getBuffer(), cmd.getLength()-1);
}
/**
* Sends buffer to a Virtual Pin
*
* @param pin Virtual Pin number
* @param buff Data buffer
* @param len Length of data
*/
void virtualWriteBinary(int pin, const void* buff, size_t len) {
char mem[8];
BlynkParam cmd(mem, 0, sizeof(mem));
cmd.add("vw");
cmd.add(pin);
static_cast<Proto*>(this)->sendCmd(BLYNK_CMD_HARDWARE, 0, cmd.getBuffer(), cmd.getLength(), buff, len);
}
/**
* Sends BlynkParam to a Virtual Pin
*
* @param pin Virtual Pin number
* @param param
*/
void virtualWrite(int pin, const BlynkParam& param) {
virtualWriteBinary(pin, param.getBuffer(), param.getLength());
}
void virtualWrite(int pin, const BlynkParamAllocated& param) {
virtualWriteBinary(pin, param.getBuffer(), param.getLength());
}
/**
* Requests Server to re-send current values for all widgets.
*/
void syncAll() {
static_cast<Proto*>(this)->sendCmd(BLYNK_CMD_HARDWARE_SYNC);
}
/**
* Sends internal command
*/
template <typename... Args>
void sendInternal(Args... params) {
char mem[BLYNK_MAX_SENDBYTES];
BlynkParam cmd(mem, 0, sizeof(mem));
cmd.add_multi(params...);
static_cast<Proto*>(this)->sendCmd(BLYNK_CMD_INTERNAL, 0, cmd.getBuffer(), cmd.getLength()-1);
}
/**
* Requests App or Server to re-send current value of a Virtual Pin.
* This will probably cause user-defined BLYNK_WRITE handler to be called.
*
* @param pin Virtual Pin number
*/
template <typename... Args>
void syncVirtual(Args... pins) {
char mem[BLYNK_MAX_SENDBYTES];
BlynkParam cmd(mem, 0, sizeof(mem));
cmd.add("vr");
cmd.add_multi(pins...);
static_cast<Proto*>(this)->sendCmd(BLYNK_CMD_HARDWARE_SYNC, 0, cmd.getBuffer(), cmd.getLength()-1);
}
/**
* Tweets a message
*
* @param msg Text of the message
*/
template<typename T>
void tweet(const T& msg) {
char mem[BLYNK_MAX_SENDBYTES];
BlynkParam cmd(mem, 0, sizeof(mem));
cmd.add(msg);
static_cast<Proto*>(this)->sendCmd(BLYNK_CMD_TWEET, 0, cmd.getBuffer(), cmd.getLength()-1);
}
/**
* Sends a push notification to the App
*
* @param msg Text of the message
*/
template<typename T>
void notify(const T& msg) {
char mem[BLYNK_MAX_SENDBYTES];
BlynkParam cmd(mem, 0, sizeof(mem));
cmd.add(msg);
static_cast<Proto*>(this)->sendCmd(BLYNK_CMD_NOTIFY, 0, cmd.getBuffer(), cmd.getLength()-1);
}
/**
* Sends an SMS
*
* @param msg Text of the message
*/
template<typename T>
void sms(const T& msg) {
char mem[BLYNK_MAX_SENDBYTES];
BlynkParam cmd(mem, 0, sizeof(mem));
cmd.add(msg);
static_cast<Proto*>(this)->sendCmd(BLYNK_CMD_SMS, 0, cmd.getBuffer(), cmd.getLength()-1);
}
/**
* Sends an email message
*
* @param email Email to send to
* @param subject Subject of message
* @param msg Text of the message
*/
template <typename T1, typename T2>
void email(const char* email, const T1& subject, const T2& msg) {
char mem[BLYNK_MAX_SENDBYTES];
BlynkParam cmd(mem, 0, sizeof(mem));
cmd.add(email);
cmd.add(subject);
cmd.add(msg);
static_cast<Proto*>(this)->sendCmd(BLYNK_CMD_EMAIL, 0, cmd.getBuffer(), cmd.getLength()-1);
}
/**
* Sends an email message
*
* @param subject Subject of message
* @param msg Text of the message
*/
template <typename T1, typename T2>
void email(const T1& subject, const T2& msg) {
char mem[BLYNK_MAX_SENDBYTES];
BlynkParam cmd(mem, 0, sizeof(mem));
cmd.add(subject);
cmd.add(msg);
static_cast<Proto*>(this)->sendCmd(BLYNK_CMD_EMAIL, 0, cmd.getBuffer(), cmd.getLength()-1);
}
/**
* Sets property of a Widget
*
* @experimental
*
* @param pin Virtual Pin number
* @param property Property name ("label", "labels", "color", ...)
* @param value Property value
*/
template <typename T, typename... Args>
void setProperty(int pin, const T& property, Args... values) {
char mem[BLYNK_MAX_SENDBYTES];
BlynkParam cmd(mem, 0, sizeof(mem));
cmd.add(pin);
cmd.add(property);
cmd.add_multi(values...);
static_cast<Proto*>(this)->sendCmd(BLYNK_CMD_PROPERTY, 0, cmd.getBuffer(), cmd.getLength()-1);
}
template <typename T>
void setProperty(int pin, const T& property, const BlynkParam& param) {
char mem[32];
BlynkParam cmd(mem, 0, sizeof(mem));
cmd.add(pin);
cmd.add(property);
static_cast<Proto*>(this)->sendCmd(BLYNK_CMD_PROPERTY, 0, cmd.getBuffer(), cmd.getLength(), param.getBuffer(), param.getLength());
}
template <typename T>
void setProperty(int pin, const T& property, const BlynkParamAllocated& param) {
char mem[32];
BlynkParam cmd(mem, 0, sizeof(mem));
cmd.add(pin);
cmd.add(property);
static_cast<Proto*>(this)->sendCmd(BLYNK_CMD_PROPERTY, 0, cmd.getBuffer(), cmd.getLength(), param.getBuffer(), param.getLength());
}
template <typename NAME>
void logEvent(const NAME& event_name) {
char mem[BLYNK_MAX_SENDBYTES];
BlynkParam cmd(mem, 0, sizeof(mem));
cmd.add(event_name);
static_cast<Proto*>(this)->sendCmd(BLYNK_CMD_EVENT_LOG, 0, cmd.getBuffer(), cmd.getLength());
}
template <typename NAME, typename DESCR>
void logEvent(const NAME& event_name, const DESCR& description) {
char mem[BLYNK_MAX_SENDBYTES];
BlynkParam cmd(mem, 0, sizeof(mem));
cmd.add(event_name);
cmd.add(description);
static_cast<Proto*>(this)->sendCmd(BLYNK_CMD_EVENT_LOG, 0, cmd.getBuffer(), cmd.getLength());
}
#if defined(BLYNK_EXPERIMENTAL)
// Attention!
// Every function in this section may be changed, removed or renamed.
/**
* Refreshes value of a widget by running
* user-defined BLYNK_READ handler of a pin.
*
* @experimental
*
* @param pin Virtual Pin number
*/
void refresh(int pin) {
if (WidgetReadHandler handler = GetReadHandler(pin)) {
BlynkReq req = { 0, BLYNK_SUCCESS, (uint8_t)pin };
handler(req);
}
}
/**
* Delays for N milliseconds, handling server communication in background.
*
* @experimental
* @warning Should be used very carefully, especially on platforms with small RAM.
*
* @param ms Milliseconds to wait
*/
void delay(unsigned long ms) {
uint16_t start = (uint16_t)micros();
while (ms > 0) {
static_cast<Proto*>(this)->run();
#if !defined(BLYNK_NO_YIELD)
yield();
#endif
if (((uint16_t)micros() - start) >= 1000) {
ms--;
start += 1000;
}
}
}
#endif
protected:
void processCmd(const void* buff, size_t len);
void sendInfo();
};
#endif

View File

@@ -0,0 +1,199 @@
/**
* @file BlynkApiArduino.h
* @author Volodymyr Shymanskyy
* @license This project is released under the MIT License (MIT)
* @copyright Copyright (c) 2015 Volodymyr Shymanskyy
* @date Mar 2015
* @brief
*
*/
#ifndef BlynkApiArduino_h
#define BlynkApiArduino_h
#include "BlynkApi.h"
#include <Arduino.h>
#ifdef BLYNK_NO_INFO
template<class Proto>
BLYNK_FORCE_INLINE
void BlynkApi<Proto>::sendInfo() {}
#else
template<class Proto>
BLYNK_FORCE_INLINE
void BlynkApi<Proto>::sendInfo()
{
static const char profile[] BLYNK_PROGMEM = "blnkinf\0"
#ifdef BOARD_FIRMWARE_VERSION
BLYNK_PARAM_KV("ver" , BOARD_FIRMWARE_VERSION)
BLYNK_PARAM_KV("blynk" , BLYNK_VERSION)
#else
BLYNK_PARAM_KV("ver" , BLYNK_VERSION)
#endif
#ifdef BOARD_TEMPLATE_ID
BLYNK_PARAM_KV("tmpl" , BOARD_TEMPLATE_ID)
#endif
BLYNK_PARAM_KV("h-beat" , BLYNK_TOSTRING(BLYNK_HEARTBEAT))
BLYNK_PARAM_KV("buff-in", BLYNK_TOSTRING(BLYNK_MAX_READBYTES))
#ifdef BLYNK_INFO_DEVICE
BLYNK_PARAM_KV("dev" , BLYNK_INFO_DEVICE)
#endif
#ifdef BLYNK_INFO_CPU
BLYNK_PARAM_KV("cpu" , BLYNK_INFO_CPU)
#endif
#ifdef BLYNK_INFO_CONNECTION
BLYNK_PARAM_KV("con" , BLYNK_INFO_CONNECTION)
#endif
BLYNK_PARAM_KV("build" , __DATE__ " " __TIME__)
"\0"
;
const size_t profile_len = sizeof(profile)-8-2;
#ifdef BLYNK_HAS_PROGMEM
char mem[profile_len];
memcpy_P(mem, profile+8, profile_len);
static_cast<Proto*>(this)->sendCmd(BLYNK_CMD_INTERNAL, 0, mem, profile_len);
#else
static_cast<Proto*>(this)->sendCmd(BLYNK_CMD_INTERNAL, 0, profile+8, profile_len);
#endif
return;
}
#endif
// Check if analog pins can be referenced by name on this device
#if defined(analogInputToDigitalPin)
#define BLYNK_DECODE_PIN(it) (((it).asStr()[0] == 'A') ? analogInputToDigitalPin(atoi((it).asStr()+1)) : (it).asInt())
#else
#define BLYNK_DECODE_PIN(it) ((it).asInt())
#if defined(BLYNK_DEBUG_ALL)
#pragma message "analogInputToDigitalPin not defined"
#endif
#endif
template<class Proto>
BLYNK_FORCE_INLINE
void BlynkApi<Proto>::processCmd(const void* buff, size_t len)
{
BlynkParam param((void*)buff, len);
BlynkParam::iterator it = param.begin();
if (it >= param.end())
return;
const char* cmd = it.asStr();
uint16_t cmd16;
memcpy(&cmd16, cmd, sizeof(cmd16));
if (++it >= param.end())
return;
uint8_t pin = BLYNK_DECODE_PIN(it);
switch(cmd16) {
#ifndef BLYNK_NO_BUILTIN
case BLYNK_HW_PM: {
while (it < param.end()) {
pin = BLYNK_DECODE_PIN(it);
++it;
if (!strcmp(it.asStr(), "in")) {
pinMode(pin, INPUT);
} else if (!strcmp(it.asStr(), "out") || !strcmp(it.asStr(), "pwm")) {
pinMode(pin, OUTPUT);
#ifdef INPUT_PULLUP
} else if (!strcmp(it.asStr(), "pu")) {
pinMode(pin, INPUT_PULLUP);
#endif
#ifdef INPUT_PULLDOWN
} else if (!strcmp(it.asStr(), "pd")) {
pinMode(pin, INPUT_PULLDOWN);
#endif
} else {
#ifdef BLYNK_DEBUG
BLYNK_LOG4(BLYNK_F("Invalid pin "), pin, BLYNK_F(" mode "), it.asStr());
#endif
}
++it;
}
} break;
case BLYNK_HW_DR: {
char mem[16];
BlynkParam rsp(mem, 0, sizeof(mem));
rsp.add("dw");
rsp.add(pin);
rsp.add(digitalRead(pin));
static_cast<Proto*>(this)->sendCmd(BLYNK_CMD_HARDWARE, 0, rsp.getBuffer(), rsp.getLength()-1);
} break;
case BLYNK_HW_DW: {
// Should be 1 parameter (value)
if (++it >= param.end())
return;
#ifdef ESP8266
// Disable PWM...
analogWrite(pin, 0);
#endif
#ifndef BLYNK_MINIMIZE_PINMODE_USAGE
pinMode(pin, OUTPUT);
#endif
digitalWrite(pin, it.asInt() ? HIGH : LOW);
} break;
case BLYNK_HW_AR: {
char mem[16];
BlynkParam rsp(mem, 0, sizeof(mem));
rsp.add("aw");
rsp.add(pin);
rsp.add(analogRead(pin));
static_cast<Proto*>(this)->sendCmd(BLYNK_CMD_HARDWARE, 0, rsp.getBuffer(), rsp.getLength()-1);
} break;
// TODO: Remove workaround for ESP32
#if !defined(ESP32)
case BLYNK_HW_AW: {
// Should be 1 parameter (value)
if (++it >= param.end())
return;
#ifndef BLYNK_MINIMIZE_PINMODE_USAGE
pinMode(pin, OUTPUT);
#endif
analogWrite(pin, it.asInt());
} break;
#endif // TODO: Remove workaround for ESP32
#endif
case BLYNK_HW_VR: {
BlynkReq req = { pin };
WidgetReadHandler handler = GetReadHandler(pin);
if (handler && (handler != BlynkWidgetRead)) {
handler(req);
} else {
BlynkWidgetReadDefault(req);
}
} break;
case BLYNK_HW_VW: {
++it;
char* start = (char*)it.asStr();
BlynkParam param2(start, len - (start - (char*)buff));
BlynkReq req = { pin };
WidgetWriteHandler handler = GetWriteHandler(pin);
if (handler && (handler != BlynkWidgetWrite)) {
handler(req, param2);
} else {
BlynkWidgetWriteDefault(req, param2);
}
} break;
default:
BLYNK_LOG2(BLYNK_F("Invalid HW cmd: "), cmd);
static_cast<Proto*>(this)->sendCmd(BLYNK_CMD_RESPONSE, static_cast<Proto*>(this)->msgIdOutOverride, NULL, BLYNK_ILLEGAL_COMMAND);
}
}
#endif

View File

@@ -0,0 +1,128 @@
/**
* @file BlynkParam.h
* @author Volodymyr Shymanskyy
* @license This project is released under the MIT License (MIT)
* @copyright Copyright (c) 2015 Volodymyr Shymanskyy
* @date Jan 2015
* @brief
*
*/
#ifndef BlynkArduinoClient_h
#define BlynkArduinoClient_h
#include "BlynkApiArduino.h"
#include "BlynkDebug.h"
#include <Client.h>
#if defined(ESP8266) && !defined(BLYNK_NO_YIELD)
#define YIELD_FIX() BLYNK_RUN_YIELD();
#else
#define YIELD_FIX()
#endif
template <typename Client>
class BlynkArduinoClientGen
{
public:
BlynkArduinoClientGen(Client& c)
: client(NULL), domain(NULL), port(0), isConn(false)
{
setClient(&c);
}
BlynkArduinoClientGen()
: client(NULL), domain(NULL), port(0), isConn(false)
{}
void setClient(Client* c) {
client = c;
client->setTimeout(BLYNK_TIMEOUT_MS);
}
void begin(IPAddress a, uint16_t p) {
domain = NULL;
port = p;
addr = a;
}
void begin(const char* d, uint16_t p) {
domain = d;
port = p;
}
bool connect() {
if (domain) {
BLYNK_LOG4(BLYNK_F("Connecting to "), domain, ':', port);
isConn = (1 == client->connect(domain, port));
return isConn;
} else { //if (uint32_t(addr) != 0) {
BLYNK_LOG_IP("Connecting to ", addr);
isConn = (1 == client->connect(addr, port));
return isConn;
}
return false;
}
void disconnect() { isConn = false; client->stop(); }
#ifdef BLYNK_ENC28J60_FIX
size_t read(void* buf, size_t len) {
while (client->available() < len) { BLYNK_RUN_YIELD(); }
return client->read((uint8_t*)buf, len);
}
#else
size_t read(void* buf, size_t len) {
size_t res = client->readBytes((char*)buf, len);
YIELD_FIX();
return res;
}
#endif
#ifdef BLYNK_RETRY_SEND
size_t write(const void* buf, size_t len) {
size_t sent = 0;
int retry = 0;
while (sent < len && ++retry < 10) {
size_t w = client->write((const uint8_t*)buf+sent, len-sent);
if (w != 0 && w != -1) {
sent += w;
} else {
BlynkDelay(50);
#if defined(BLYNK_DEBUG) && defined(BLYNK_PRINT)
BLYNK_PRINT_TIME();
BLYNK_PRINT.print(BLYNK_F("Retry "));
BLYNK_PRINT.print(retry);
BLYNK_PRINT.print(BLYNK_F(" send: "));
BLYNK_PRINT.print(sent);
BLYNK_PRINT.print('/');
BLYNK_PRINT.println(len);
#endif
}
}
return sent;
}
#else
size_t write(const void* buf, size_t len) {
YIELD_FIX();
size_t res = client->write((const uint8_t*)buf, len);
YIELD_FIX();
return res;
}
#endif
bool connected() { YIELD_FIX(); return isConn && client->connected(); }
int available() { YIELD_FIX(); return client->available(); }
protected:
Client* client;
IPAddress addr;
const char* domain;
uint16_t port;
bool isConn;
};
typedef BlynkArduinoClientGen<Client> BlynkArduinoClient;
#endif

View File

@@ -0,0 +1,95 @@
/**
* @file BlynkConfig.h
* @author Volodymyr Shymanskyy
* @license This project is released under the MIT License (MIT)
* @copyright Copyright (c) 2015 Volodymyr Shymanskyy
* @date Jan 2015
* @brief Configuration of different aspects of library
*
*/
#ifndef BlynkConfig_h
#define BlynkConfig_h
#include "BlynkDetectDevice.h"
/***************************************************
* Change these settings to match your need
***************************************************/
#define BLYNK_DEFAULT_DOMAIN "blynk-cloud.com"
#define BLYNK_DEFAULT_PORT 80
#define BLYNK_DEFAULT_PORT_SSL 8441
/***************************************************
* Professional settings
***************************************************/
// Library version.
#define BLYNK_VERSION "0.5.3"
// Heartbeat period in seconds.
#ifndef BLYNK_HEARTBEAT
#define BLYNK_HEARTBEAT 10
#endif
// Network timeout in milliseconds.
#ifndef BLYNK_TIMEOUT_MS
#define BLYNK_TIMEOUT_MS 2000UL
#endif
// Limit the amount of outgoing commands per second.
#ifndef BLYNK_MSG_LIMIT
#define BLYNK_MSG_LIMIT 15
#endif
// Limit the incoming command length.
#ifndef BLYNK_MAX_READBYTES
#define BLYNK_MAX_READBYTES 256
#endif
// Limit the outgoing command length.
#ifndef BLYNK_MAX_SENDBYTES
#define BLYNK_MAX_SENDBYTES 128
#endif
// Uncomment to use Let's Encrypt Root CA
//#define BLYNK_SSL_USE_LETSENCRYPT
// Uncomment to disable built-in analog and digital operations.
//#define BLYNK_NO_BUILTIN
// Uncomment to disable providing info about device to the server.
//#define BLYNK_NO_INFO
// Uncomment to enable debug prints.
//#define BLYNK_DEBUG
// Uncomment to force-enable 128 virtual pins
//#define BLYNK_USE_128_VPINS
// Uncomment to disable fancy logo
//#define BLYNK_NO_FANCY_LOGO
// Uncomment to enable 3D fancy logo
//#define BLYNK_FANCY_LOGO_3D
// Uncomment to enable experimental functions.
//#define BLYNK_EXPERIMENTAL
// Uncomment to disable all float/double usage
//#define BLYNK_NO_FLOAT
// Uncomment to switch to direct-connect mode
//#define BLYNK_USE_DIRECT_CONNECT
// Uncomment to append command body to header (uses more RAM)
//#define BLYNK_SEND_ATOMIC
// Split whole command into chunks (in bytes)
//#define BLYNK_SEND_CHUNK 64
// Wait after sending each chunk (in milliseconds)
//#define BLYNK_SEND_THROTTLE 10
#endif

View File

@@ -0,0 +1,173 @@
/**
* @file BlynkDateTime.h
* @author Volodymyr Shymanskyy
* @license This project is released under the MIT License (MIT)
* @copyright Copyright (c) 2016 Volodymyr Shymanskyy
* @date Aug 2016
* @brief DateTime implementation
*
*/
#ifndef BlynkDateTime_h
#define BlynkDateTime_h
typedef long blynk_time_t;
struct blynk_tm *blynk_gmtime_r(const blynk_time_t *time, struct blynk_tm *tm);
blynk_time_t blynk_mk_gmtime(struct blynk_tm *tm);
struct blynk_tm {
int8_t tm_sec;
int8_t tm_min;
int8_t tm_hour;
int8_t tm_mday;
int8_t tm_wday;
int8_t tm_mon;
int16_t tm_year;
int16_t tm_yday;
int16_t tm_isdst;
};
class BlynkTime {
public:
static const uint32_t MAX_TIME = 86400L;
BlynkTime() : mTime(-1) {}
BlynkTime(const BlynkTime& t) : mTime(t.mTime) {}
BlynkTime(long seconds) : mTime(seconds % MAX_TIME) {}
BlynkTime(int hour, int minute, int second)
{
mTime = (hour * 3600 + minute * 60 + second) % MAX_TIME;
}
int second() const { return mTime % 60; }
int minute() const { return (mTime / 60) % 60; }
int hour() const { return mTime / 3600; }
int hour12() const {
int h = hour();
if (h == 0)
return 12; // 12 midnight
else if (h > 12)
return h - 12;
return h;
}
bool isAM() const { return !isPM(); }
bool isPM() const { return (hour() >= 12); }
void adjustSeconds(int sec) {
if (isValid()) {
mTime = (mTime + sec) % MAX_TIME;
}
}
blynk_time_t getUnixOffset() const { return mTime; }
bool isValid() const { return mTime < MAX_TIME; }
operator bool() const { return isValid(); }
bool operator == (const BlynkTime& t) const { return mTime == t.mTime; }
bool operator >= (const BlynkTime& t) const { return mTime >= t.mTime; }
bool operator <= (const BlynkTime& t) const { return mTime <= t.mTime; }
bool operator > (const BlynkTime& t) const { return mTime > t.mTime; }
bool operator < (const BlynkTime& t) const { return mTime < t.mTime; }
private:
uint32_t mTime;
};
class BlynkDateTime {
public:
BlynkDateTime() : mTime(0) {}
BlynkDateTime(const BlynkDateTime& t)
{
mTime = t.mTime;
blynk_gmtime_r(&mTime, &mTm);
}
BlynkDateTime(blynk_time_t t)
{
mTime = t;
blynk_gmtime_r(&mTime, &mTm);
}
BlynkDateTime(int hour, int minute, int second, int day, int month, int year)
{
mTm.tm_hour = hour;
mTm.tm_min = minute;
mTm.tm_sec = second;
mTm.tm_mday = day;
mTm.tm_mon = month - 1;
mTm.tm_year = year - 1900;
mTm.tm_isdst = 0;
mTime = blynk_mk_gmtime(&mTm);
}
int second() const { return mTm.tm_sec; }
int minute() const { return mTm.tm_min; }
int hour() const { return mTm.tm_hour; }
int day() const { return mTm.tm_mday; }
int month() const { return 1 + mTm.tm_mon; }
int year() const { return 1900 + mTm.tm_year; }
int day_of_year() const { return 1 + mTm.tm_yday; }
int day_of_week() const { return mTm.tm_wday == 0 ? 7 : mTm.tm_wday; }
/*int weak_of_year() const {
int julian = day_of_year();
int dow = day_of_week();
int dowJan1 = BlynkDateTime(0,0,0, 1,1,year()).day_of_week();
int weekNum = ((julian + 6) / 7);
if (dow < dowJan1)
++weekNum;
return (weekNum);
}*/
int hour12() const {
int h = hour();
if (h == 0)
return 12; // 12 midnight
else if (h > 12)
return h - 12;
return h;
}
bool isAM() const { return !isPM(); }
bool isPM() const { return (hour() >= 12); }
void adjustSeconds(int sec) {
if (isValid()) {
mTime += sec;
blynk_gmtime_r(&mTime, &mTm);
}
}
//tm& getTm() { return mTm; }
blynk_time_t getUnix() const { return mTime; }
bool isValid() const { return mTime != 0; }
operator bool() const { return isValid(); }
bool operator == (const BlynkDateTime& t) const { return mTime == t.mTime; }
bool operator >= (const BlynkDateTime& t) const { return mTime >= t.mTime; }
bool operator <= (const BlynkDateTime& t) const { return mTime <= t.mTime; }
bool operator > (const BlynkDateTime& t) const { return mTime > t.mTime; }
bool operator < (const BlynkDateTime& t) const { return mTime < t.mTime; }
private:
blynk_tm mTm;
blynk_time_t mTime;
};
#endif

View File

@@ -0,0 +1,278 @@
/**
* @file BlynkDebug.cpp
* @author Volodymyr Shymanskyy
* @license This project is released under the MIT License (MIT)
* @copyright Copyright (c) 2015 Volodymyr Shymanskyy
* @date Jan 2015
* @brief Debug utilities for Arduino
*/
#include "BlynkDebug.h"
#if defined(ARDUINO) && defined(__AVR__) && defined(BLYNK_USE_AVR_WDT)
#include <Arduino.h>
#include <avr/wdt.h>
BLYNK_CONSTRUCTOR
static void BlynkSystemInit()
{
MCUSR = 0;
wdt_disable();
}
void BlynkReset()
{
wdt_enable(WDTO_15MS);
delay(50);
void(*resetFunc)(void) = 0;
resetFunc();
for(;;) {} // To make compiler happy
}
size_t BlynkFreeRam()
{
extern int __heap_start, *__brkval;
int v;
return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
}
#define _BLYNK_USE_DEFAULT_MILLIS
#define _BLYNK_USE_DEFAULT_DELAY
#elif defined(ARDUINO) && defined(__AVR__)
#include <Arduino.h>
void BlynkReset()
{
void(*resetFunc)(void) = 0;
resetFunc();
for(;;) {}
}
size_t BlynkFreeRam()
{
extern int __heap_start, *__brkval;
int v;
return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
}
#define _BLYNK_USE_DEFAULT_MILLIS
#define _BLYNK_USE_DEFAULT_DELAY
#elif defined(ARDUINO) && defined(ESP8266)
#include <Arduino.h>
size_t BlynkFreeRam()
{
return ESP.getFreeHeap();
}
void BlynkReset()
{
ESP.restart();
for(;;) {}
}
#define _BLYNK_USE_DEFAULT_MILLIS
#define _BLYNK_USE_DEFAULT_DELAY
#elif defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_SAM)
#include <Arduino.h>
size_t BlynkFreeRam()
{
return 0;
}
void BlynkReset()
{
NVIC_SystemReset();
for(;;) {}
}
#define _BLYNK_USE_DEFAULT_MILLIS
#define _BLYNK_USE_DEFAULT_DELAY
#elif defined (ARDUINO_ARCH_ARC32)
millis_time_t BlynkMillis()
{
// TODO: Remove workaround for Intel Curie
// https://forum.arduino.cc/index.php?topic=391836.0
noInterrupts();
uint64_t t = millis();
interrupts();
return t;
}
#define _BLYNK_USE_DEFAULT_FREE_RAM
#define _BLYNK_USE_DEFAULT_RESET
#define _BLYNK_USE_DEFAULT_DELAY
#elif defined(ARDUINO) && (defined(__STM32F1__) || defined(__STM32F3__))
#include <Arduino.h>
#include <libmaple/nvic.h>
void BlynkReset()
{
nvic_sys_reset();
for(;;) {}
}
#define _BLYNK_USE_DEFAULT_FREE_RAM
#define _BLYNK_USE_DEFAULT_MILLIS
#define _BLYNK_USE_DEFAULT_DELAY
#elif defined (PARTICLE) || defined(SPARK)
#include "application.h"
void BlynkReset()
{
System.reset();
for(;;) {} // To make compiler happy
}
#define _BLYNK_USE_DEFAULT_FREE_RAM
#define _BLYNK_USE_DEFAULT_MILLIS
#define _BLYNK_USE_DEFAULT_DELAY
#elif defined(__MBED__)
#include "mbed.h"
static Timer blynk_millis_timer;
static Ticker blynk_waker;
static
void blynk_wake() {
//pc.puts("(...)");
}
BLYNK_CONSTRUCTOR
static void BlynkSystemInit()
{
blynk_waker.attach(&blynk_wake, 2.0);
blynk_millis_timer.start();
}
void BlynkDelay(millis_time_t ms)
{
wait_ms(ms);
}
millis_time_t BlynkMillis()
{
return blynk_millis_timer.read_ms();
}
#define _BLYNK_USE_DEFAULT_FREE_RAM
#define _BLYNK_USE_DEFAULT_RESET
#elif defined(LINUX) && defined(RASPBERRY)
#include <stdlib.h>
#include <wiringPi.h>
BLYNK_CONSTRUCTOR
static void BlynkSystemInit()
{
wiringPiSetupGpio();
}
void BlynkReset()
{
exit(1);
for(;;) {} // To make compiler happy
}
#define _BLYNK_USE_DEFAULT_FREE_RAM
#define _BLYNK_USE_DEFAULT_MILLIS
#define _BLYNK_USE_DEFAULT_DELAY
#elif defined(LINUX)
#define _POSIX_C_SOURCE 200809L
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
static millis_time_t blynk_startup_time = 0;
BLYNK_CONSTRUCTOR
static void BlynkSystemInit()
{
blynk_startup_time = BlynkMillis();
}
void BlynkReset()
{
exit(1);
for(;;) {} // To make compiler happy
}
void BlynkDelay(millis_time_t ms)
{
usleep(ms * 1000);
}
millis_time_t BlynkMillis()
{
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts );
return ( ts.tv_sec * 1000 + ts.tv_nsec / 1000000L ) - blynk_startup_time;
}
#define _BLYNK_USE_DEFAULT_FREE_RAM
#else
#if defined(BLYNK_DEBUG_ALL)
#warning "Need to implement board-specific utilities"
#endif
#define _BLYNK_USE_DEFAULT_FREE_RAM
#define _BLYNK_USE_DEFAULT_RESET
#define _BLYNK_USE_DEFAULT_MILLIS
#define _BLYNK_USE_DEFAULT_DELAY
#endif
#ifdef _BLYNK_USE_DEFAULT_DELAY
void BlynkDelay(millis_time_t ms)
{
return delay(ms);
}
#endif
#ifdef _BLYNK_USE_DEFAULT_MILLIS
millis_time_t BlynkMillis()
{
return millis();
}
#endif
#ifdef _BLYNK_USE_DEFAULT_FREE_RAM
size_t BlynkFreeRam()
{
return 0;
}
#endif
#ifdef _BLYNK_USE_DEFAULT_RESET
void BlynkReset()
{
for(;;) {} // To make compiler happy
}
#endif
void BlynkFatal()
{
BlynkDelay(10000L);
BlynkReset();
}

View File

@@ -0,0 +1,305 @@
/**
* @file BlynkDebug.h
* @author Volodymyr Shymanskyy
* @license This project is released under the MIT License (MIT)
* @copyright Copyright (c) 2015 Volodymyr Shymanskyy
* @date Jan 2015
* @brief Debug utilities
*
*/
#ifndef BlynkDebug_h
#define BlynkDebug_h
#include "BlynkConfig.h"
#include <stddef.h>
#ifdef ESP8266
extern "C" {
#include "ets_sys.h"
#include "os_type.h"
#include "mem.h"
}
#else
#include <inttypes.h>
#endif
#if defined(ARDUINO_ARCH_ARC32)
typedef uint64_t millis_time_t;
#else
typedef uint32_t millis_time_t;
#endif
void BlynkDelay(millis_time_t ms);
millis_time_t BlynkMillis();
size_t BlynkFreeRam();
void BlynkReset() BLYNK_NORETURN;
void BlynkFatal() BLYNK_NORETURN;
#if defined(SPARK) || defined(PARTICLE)
#include "application.h"
#endif
#if defined(ARDUINO)
#if ARDUINO >= 100
#include <Arduino.h>
#else
#include <WProgram.h>
#endif
#endif
#if defined(LINUX)
#if defined(RASPBERRY)
#include <wiringPi.h>
#endif
#endif
#if !defined(BLYNK_RUN_YIELD)
#if defined(BLYNK_NO_YIELD)
#define BLYNK_RUN_YIELD() {}
#elif defined(SPARK) || defined(PARTICLE)
#define BLYNK_RUN_YIELD() { Particle.process(); }
#elif !defined(ARDUINO) || (ARDUINO < 151)
#define BLYNK_RUN_YIELD() {}
#else
#define BLYNK_RUN_YIELD() { BlynkDelay(0); }
#endif
#endif
#if defined(__AVR__)
#include <avr/pgmspace.h>
#define BLYNK_HAS_PROGMEM
#define BLYNK_PROGMEM PROGMEM
#define BLYNK_F(s) F(s)
#define BLYNK_PSTR(s) PSTR(s)
#else
#define BLYNK_PROGMEM
#define BLYNK_F(s) s
#define BLYNK_PSTR(s) s
#endif
#ifdef ARDUINO_AVR_DIGISPARK
typedef fstr_t __FlashStringHelper;
#endif
#if defined(BLYNK_DEBUG_ALL) && !(__cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__))
#warning "Compiler features not enabled -> please contact yor board vendor to enable c++0x"
#endif
// Diagnostic defines
#define BLYNK_FATAL(msg) { BLYNK_LOG1(msg); BlynkFatal(); }
#define BLYNK_LOG_RAM() { BLYNK_LOG2(BLYNK_F("Free RAM: "), BlynkFreeRam()); }
#define BLYNK_LOG_FN() BLYNK_LOG3(BLYNK_F(__FUNCTION__), '@', __LINE__);
#define BLYNK_LOG_TROUBLE(t) BLYNK_LOG2(BLYNK_F("Trouble detected: http://docs.blynk.cc/#troubleshooting-"), t)
#ifndef BLYNK_PRINT
#undef BLYNK_DEBUG
#endif
#ifdef BLYNK_DEBUG_ALL
#define BLYNK_DEBUG
#endif
#ifdef BLYNK_PRINT
#if defined(ARDUINO) || defined(SPARK) || defined(PARTICLE)
#if defined(ARDUINO_ARCH_ARC32)
// This will cause error - on purpose
#define BLYNK_LOG(msg, ...) BLYNK_LOG_UNAVAILABLE(msg, ##__VA_ARGS__)
#else
#define BLYNK_LOG(msg, ...) blynk_dbg_print(BLYNK_PSTR(msg), ##__VA_ARGS__)
#endif
#define BLYNK_LOG1(p1) { BLYNK_LOG_TIME(); BLYNK_PRINT.println(p1); }
#define BLYNK_LOG2(p1,p2) { BLYNK_LOG_TIME(); BLYNK_PRINT.print(p1); BLYNK_PRINT.println(p2); }
#define BLYNK_LOG3(p1,p2,p3) { BLYNK_LOG_TIME(); BLYNK_PRINT.print(p1); BLYNK_PRINT.print(p2); BLYNK_PRINT.println(p3); }
#define BLYNK_LOG4(p1,p2,p3,p4) { BLYNK_LOG_TIME(); BLYNK_PRINT.print(p1); BLYNK_PRINT.print(p2); BLYNK_PRINT.print(p3); BLYNK_PRINT.println(p4); }
#define BLYNK_LOG6(p1,p2,p3,p4,p5,p6) { BLYNK_LOG_TIME(); BLYNK_PRINT.print(p1); BLYNK_PRINT.print(p2); BLYNK_PRINT.print(p3); BLYNK_PRINT.print(p4); BLYNK_PRINT.print(p5); BLYNK_PRINT.println(p6); }
#define BLYNK_LOG_IP(msg, ip) { BLYNK_LOG_TIME(); BLYNK_PRINT.print(BLYNK_F(msg)); \
BLYNK_PRINT.print(ip[0]); BLYNK_PRINT.print('.'); \
BLYNK_PRINT.print(ip[1]); BLYNK_PRINT.print('.'); \
BLYNK_PRINT.print(ip[2]); BLYNK_PRINT.print('.'); \
BLYNK_PRINT.println(ip[3]); }
#define BLYNK_LOG_IP_REV(msg, ip) { BLYNK_LOG_TIME(); BLYNK_PRINT.print(BLYNK_F(msg)); \
BLYNK_PRINT.print(ip[3]); BLYNK_PRINT.print('.'); \
BLYNK_PRINT.print(ip[2]); BLYNK_PRINT.print('.'); \
BLYNK_PRINT.print(ip[1]); BLYNK_PRINT.print('.'); \
BLYNK_PRINT.println(ip[0]); }
static
void BLYNK_LOG_TIME() {
BLYNK_PRINT.print('[');
BLYNK_PRINT.print(BlynkMillis());
BLYNK_PRINT.print(BLYNK_F("] "));
}
#ifdef BLYNK_DEBUG
#include <ctype.h>
#define BLYNK_DBG_BREAK() { for(;;); }
#define BLYNK_ASSERT(expr) { if(!(expr)) { BLYNK_LOG2(BLYNK_F("Assertion failed: "), BLYNK_F(#expr)); BLYNK_DBG_BREAK() } }
static
void BLYNK_DBG_DUMP(const char* msg, const void* addr, size_t len) {
if (len) {
BLYNK_LOG_TIME();
BLYNK_PRINT.print(msg);
int l2 = len;
const uint8_t* octets = (const uint8_t*)addr;
bool prev_print = true;
while (l2--) {
const uint8_t c = *octets++ & 0xFF;
if (c >= 32 && c < 127) {
if (!prev_print) { BLYNK_PRINT.print(']'); }
BLYNK_PRINT.print((char)c);
prev_print = true;
} else {
BLYNK_PRINT.print(prev_print?'[':'|');
if (c < 0x10) { BLYNK_PRINT.print('0'); }
BLYNK_PRINT.print(c, HEX);
prev_print = false;
}
}
if (!prev_print) {
BLYNK_PRINT.print(']');
}
BLYNK_PRINT.println();
}
}
#endif
#if !defined(ARDUINO_ARCH_ARC32)
#include <stdio.h>
#include <stdarg.h>
BLYNK_UNUSED
void blynk_dbg_print(const char* BLYNK_PROGMEM fmt, ...)
{
va_list ap;
va_start(ap, fmt);
char buff[128];
BLYNK_PRINT.print('[');
BLYNK_PRINT.print(BlynkMillis());
BLYNK_PRINT.print(BLYNK_F("] "));
#if defined(__AVR__)
vsnprintf_P(buff, sizeof(buff), fmt, ap);
#else
vsnprintf(buff, sizeof(buff), fmt, ap);
#endif
BLYNK_PRINT.println(buff);
va_end(ap);
}
#endif // ARDUINO_ARCH_ARC32
#elif defined(__MBED__)
#define BLYNK_LOG(msg, ...) { BLYNK_PRINT.printf("[%ld] " msg "\n", BlynkMillis(), ##__VA_ARGS__); }
#define BLYNK_LOG1(p1) { BLYNK_LOG(p1);}
#define BLYNK_LOG2(p1,p2) { BLYNK_LOG(p1,p2);}
#define BLYNK_LOG3(p1,p2,p3) { BLYNK_LOG(p1,p2,p3);}
#define BLYNK_LOG4(p1,p2,p3,p4) { BLYNK_LOG(p1,p2,p3,p4);}
#define BLYNK_LOG6(p1,p2,p3,p4,p5,p6) { BLYNK_LOG(p1,p2,p3,p4,p5,p6);}
#define BLYNK_LOG_TIME() BLYNK_PRINT.printf("[%ld]", BlynkMillis());
#ifdef BLYNK_DEBUG
#define BLYNK_DBG_BREAK() raise(SIGTRAP);
#define BLYNK_ASSERT(expr) assert(expr)
static
void BLYNK_DBG_DUMP(const char* msg, const void* addr, size_t len) {
BLYNK_LOG_TIME();
BLYNK_PRINT.printf(msg);
int l2 = len;
const uint8_t* octets = (const uint8_t*)addr;
bool prev_print = true;
while (l2--) {
const uint8_t c = *octets++ & 0xFF;
if (c >= 32 && c < 127) {
if (!prev_print) { BLYNK_PRINT.putc(']'); }
BLYNK_PRINT.putc((char)c);
prev_print = true;
} else {
BLYNK_PRINT.putc(prev_print?'[':'|');
BLYNK_PRINT.printf("%02x", c);
prev_print = false;
}
}
BLYNK_PRINT.printf("%s\n", prev_print?"":"]");
}
#endif
#elif defined(LINUX)
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <signal.h>
#include <iostream>
using namespace std;
#define BLYNK_LOG(msg, ...) { fprintf(BLYNK_PRINT, "[%ld] " msg "\n", BlynkMillis(), ##__VA_ARGS__); }
#define BLYNK_LOG1(p1) { BLYNK_LOG_TIME(); cout << p1 << endl; }
#define BLYNK_LOG2(p1,p2) { BLYNK_LOG_TIME(); cout << p1 << p2 << endl; }
#define BLYNK_LOG3(p1,p2,p3) { BLYNK_LOG_TIME(); cout << p1 << p2 << p3 << endl; }
#define BLYNK_LOG4(p1,p2,p3,p4) { BLYNK_LOG_TIME(); cout << p1 << p2 << p3 << p4 << endl; }
#define BLYNK_LOG6(p1,p2,p3,p4,p5,p6) { BLYNK_LOG_TIME(); cout << p1 << p2 << p3 << p4 << p5 << p6 << endl; }
#define BLYNK_LOG_TIME() cout << '[' << BlynkMillis() << "] ";
#ifdef BLYNK_DEBUG
#define BLYNK_DBG_BREAK() raise(SIGTRAP);
#define BLYNK_ASSERT(expr) assert(expr)
static
void BLYNK_DBG_DUMP(const char* msg, const void* addr, size_t len) {
BLYNK_LOG_TIME();
fprintf(BLYNK_PRINT, "%s", msg);
int l2 = len;
const uint8_t* octets = (const uint8_t*)addr;
bool prev_print = true;
while (l2--) {
const uint8_t c = *octets++ & 0xFF;
if (c >= 32 && c < 127) {
if (!prev_print) { fputc(']', BLYNK_PRINT); }
fputc((char)c, BLYNK_PRINT);
prev_print = true;
} else {
fputc(prev_print?'[':'|', BLYNK_PRINT);
fprintf(BLYNK_PRINT, "%02x", c);
prev_print = false;
}
}
fprintf(BLYNK_PRINT, "%s\n", prev_print?"":"]");
}
#endif
#else
#warning "Cannot detect platform"
#endif
#endif
#ifndef BLYNK_LOG
#define BLYNK_LOG(...)
#define BLYNK_LOG1(p1)
#define BLYNK_LOG2(p1,p2)
#define BLYNK_LOG3(p1,p2,p3)
#define BLYNK_LOG4(p1,p2,p3,p4)
#define BLYNK_LOG6(p1,p2,p3,p4,p5,p6)
#define BLYNK_LOG_IP(msg, ip)
#define BLYNK_LOG_IP_REV(msg, ip)
#endif
#ifndef BLYNK_DBG_BREAK
#define BLYNK_DBG_BREAK()
#define BLYNK_ASSERT(expr)
#define BLYNK_DBG_DUMP(msg, addr, len)
#endif
#endif

View File

@@ -0,0 +1,268 @@
/**
* @file BlynkDetectDevice.h
* @author Volodymyr Shymanskyy
* @license This project is released under the MIT License (MIT)
* @copyright Copyright (c) 2016 Volodymyr Shymanskyy
* @date May 2016
* @brief
*
*/
#ifndef BlynkDetectDevice_h
#define BlynkDetectDevice_h
// General defines
#define BLYNK_NEWLINE "\r\n"
#define BLYNK_CONCAT(a, b) a ## b
#define BLYNK_CONCAT2(a, b) BLYNK_CONCAT(a, b)
#define BLYNK_STRINGIFY(x) #x
#define BLYNK_TOSTRING(x) BLYNK_STRINGIFY(x)
#define BLYNK_COUNT_OF(x) ((sizeof(x)/sizeof(0[x])) / ((size_t)(!(sizeof(x) % sizeof(0[x])))))
#define BLYNK_ATTR_PACKED __attribute__ ((__packed__))
#define BLYNK_NORETURN __attribute__ ((noreturn))
#define BLYNK_UNUSED __attribute__((__unused__))
#define BLYNK_DEPRECATED __attribute__ ((deprecated))
#define BLYNK_CONSTRUCTOR __attribute__((constructor))
// Causes problems on some platforms
#define BLYNK_FORCE_INLINE inline //__attribute__((always_inline))
#ifndef BLYNK_INFO_CPU
#if defined(__AVR_ATmega168__)
#define BLYNK_INFO_CPU "ATmega168"
#endif
#endif
#ifndef BLYNK_INFO_DEVICE
#if defined(ENERGIA)
#define BLYNK_NO_YIELD
#define BLYNK_USE_128_VPINS
#if defined(ENERGIA_ARCH_MSP430)
#define BLYNK_INFO_DEVICE "LaunchPad MSP430"
#define BLYNK_INFO_CPU "MSP430"
#define BLYNK_NO_FLOAT
#elif defined(ENERGIA_ARCH_MSP432)
#define BLYNK_INFO_DEVICE "LaunchPad MSP432"
#define BLYNK_INFO_CPU "MSP432"
#elif defined(ENERGIA_ARCH_TIVAC)
#define BLYNK_INFO_DEVICE "LaunchPad"
#elif defined(ENERGIA_ARCH_CC3200EMT) || defined(ENERGIA_ARCH_CC3200)
#define BLYNK_INFO_CONNECTION "CC3200"
#define BLYNK_SEND_CHUNK 64
#define BLYNK_BUFFERS_SIZE 1024
#if defined(ENERGIA_CC3200_LAUNCHXL) //TODO: This is a bug in Energia IDE
#define BLYNK_INFO_DEVICE "CC3200 LaunchXL"
#elif defined(ENERGIA_RedBearLab_CC3200)
#define BLYNK_INFO_DEVICE "RBL CC3200"
#elif defined(ENERGIA_RedBearLab_WiFiMini)
#define BLYNK_INFO_DEVICE "RBL WiFi Mini"
#elif defined(ENERGIA_RedBearLab_WiFiMicro)
#define BLYNK_INFO_DEVICE "RBL WiFi Micro"
#endif
#elif defined(ENERGIA_ARCH_CC3220EMT) || defined(ENERGIA_ARCH_CC3220)
#define BLYNK_INFO_CONNECTION "CC3220"
#define BLYNK_SEND_CHUNK 64
#define BLYNK_BUFFERS_SIZE 1024
#define BLYNK_USE_INTERNAL_DTOSTRF
#define BLYNK_INFO_DEVICE "CC3220"
#define BLYNK_INFO_CPU "CC3220"
#endif
#if !defined(BLYNK_INFO_DEVICE)
#define BLYNK_INFO_DEVICE "Energia"
#endif
#elif defined(LINUX)
#define BLYNK_INFO_DEVICE "Linux"
#define BLYNK_USE_128_VPINS
#define BLYNK_BUFFERS_SIZE 4096
#elif defined(SPARK) || defined(PARTICLE)
#define BLYNK_USE_128_VPINS
#define BLYNK_BUFFERS_SIZE 1024
#if PLATFORM_ID==0
#define BLYNK_INFO_DEVICE "Particle Core"
#undef BLYNK_BUFFERS_SIZE // Use default on Core
#elif PLATFORM_ID==6
#define BLYNK_INFO_DEVICE "Particle Photon"
#elif PLATFORM_ID==8
#define BLYNK_INFO_DEVICE "Particle P1"
#elif PLATFORM_ID==9
#define BLYNK_INFO_DEVICE "Particle Ethernet"
#elif PLATFORM_ID==10
#define BLYNK_INFO_DEVICE "Particle Electron"
#elif PLATFORM_ID==31
#define BLYNK_INFO_DEVICE "Particle RPi"
#elif PLATFORM_ID==82
#define BLYNK_INFO_DEVICE "Digistump Oak"
#elif PLATFORM_ID==88
#define BLYNK_INFO_DEVICE "RedBear Duo"
#elif PLATFORM_ID==103
#define BLYNK_INFO_DEVICE "Bluz"
#else
#if defined(BLYNK_DEBUG_ALL)
#warning "Cannot detect board type"
#endif
#define BLYNK_INFO_DEVICE "Particle"
#endif
#elif defined(__MBED__)
#define BLYNK_INFO_DEVICE "MBED"
#define BLYNK_USE_128_VPINS
#define BLYNK_BUFFERS_SIZE 512
#define noInterrupts() __disable_irq()
#define interrupts() __enable_irq()
#elif defined(ARDUINO) && defined(MPIDE)
#define BLYNK_NO_YIELD
#if defined(_BOARD_UNO_)
#define BLYNK_INFO_DEVICE "chipKIT Uno32"
#else
#define BLYNK_INFO_DEVICE "chipKIT"
#endif
#elif defined(ARDUINO) && defined(ARDUINO_AMEBA)
#if defined(BOARD_RTL8710)
#define BLYNK_INFO_DEVICE "RTL8710"
#define BLYNK_USE_128_VPINS
#define BLYNK_BUFFERS_SIZE 1024
#elif defined(BOARD_RTL8711AM)
#define BLYNK_INFO_DEVICE "RTL8711AM"
#define BLYNK_USE_128_VPINS
#define BLYNK_BUFFERS_SIZE 1024
#elif defined(BOARD_RTL8195A)
#define BLYNK_INFO_DEVICE "RTL8195A"
#define BLYNK_USE_128_VPINS
#define BLYNK_BUFFERS_SIZE 1024
#else
#define BLYNK_INFO_DEVICE "Ameba"
#endif
#elif defined(ARDUINO) && defined(TEENSYDUINO)
#if defined(__MK66FX1M0__)
#define BLYNK_INFO_DEVICE "Teensy 3.6"
#define BLYNK_USE_128_VPINS
#define BLYNK_BUFFERS_SIZE 1024
#elif defined(__MK64FX512__)
#define BLYNK_INFO_DEVICE "Teensy 3.5"
#define BLYNK_USE_128_VPINS
#define BLYNK_BUFFERS_SIZE 1024
#elif defined(__MK20DX256__)
#define BLYNK_INFO_DEVICE "Teensy 3.2/3.1"
#define BLYNK_USE_128_VPINS
#define BLYNK_BUFFERS_SIZE 1024
#elif defined(__MK20DX128__)
#define BLYNK_INFO_DEVICE "Teensy 3.0"
#define BLYNK_USE_128_VPINS
#define BLYNK_BUFFERS_SIZE 1024
#elif defined(__MKL26Z64__)
#define BLYNK_INFO_DEVICE "Teensy LC"
#define BLYNK_BUFFERS_SIZE 512
#elif defined(ARDUINO_ARCH_AVR)
#define BLYNK_INFO_DEVICE "Teensy 2.0"
#else
#define BLYNK_INFO_DEVICE "Teensy"
#endif
#elif defined(ARDUINO)
#if defined(ARDUINO_ARCH_SAMD) || defined(ESP32) || defined(ESP8266)
#define BLYNK_USE_128_VPINS
#define BLYNK_BUFFERS_SIZE 1024
#endif
/* Arduino AVR */
#if defined(ARDUINO_AVR_NANO)
#define BLYNK_INFO_DEVICE "Arduino Nano"
/* ESP8266 */
#elif defined(ARDUINO_ESP8266_ESP01)
#define BLYNK_INFO_DEVICE "ESP8266"
#elif defined(ARDUINO_ESP8266_ESP12)
#define BLYNK_INFO_DEVICE "ESP-12"
#elif defined(ARDUINO_ESP8266_NODEMCU)
#define BLYNK_INFO_DEVICE "NodeMCU"
#elif defined(ARDUINO_ESP8266_THING)
#define BLYNK_INFO_DEVICE "Esp Thing"
#elif defined(ARDUINO_ESP8266_THING_DEV)
#define BLYNK_INFO_DEVICE "Esp Thing Dev"
/* ESP32 */
#elif defined(ARDUINO_ESP32_DEV)
#define BLYNK_INFO_DEVICE "ESP32"
#elif defined(ARDUINO_ESP320)
#define BLYNK_INFO_DEVICE "SweetPeas ESP320"
#elif defined(ARDUINO_NANO32)
#define BLYNK_INFO_DEVICE "ESP32 Nano32"
#elif defined(ARDUINO_LoLin32)
#define BLYNK_INFO_DEVICE "LoLin32"
#elif defined(ARDUINO_ESPea32)
#define BLYNK_INFO_DEVICE "ESPea32"
#elif defined(ARDUINO_QUANTUM)
#define BLYNK_INFO_DEVICE "Noduino Quantum"
#else
#if defined(BLYNK_DEBUG_ALL)
#warning "Cannot detect board type"
#endif
#define BLYNK_INFO_DEVICE "Arduino"
#endif
#elif defined(TI_CC3220)
#define BLYNK_INFO_DEVICE "TI CC3220"
#define BLYNK_USE_128_VPINS
#define BLYNK_BUFFERS_SIZE 1024
#define BLYNK_USE_INTERNAL_DTOSTRF
#else
#define BLYNK_INFO_DEVICE "Custom platform"
#endif
#if !defined(BLYNK_MAX_READBYTES) && defined(BLYNK_BUFFERS_SIZE)
#define BLYNK_MAX_READBYTES BLYNK_BUFFERS_SIZE
#endif
#if !defined(BLYNK_MAX_SENDBYTES) && defined(BLYNK_BUFFERS_SIZE)
#define BLYNK_MAX_SENDBYTES BLYNK_BUFFERS_SIZE
#endif
// Print diagnostics
#if defined(BLYNK_DEBUG_ALL)
#if defined(BLYNK_INFO_DEVICE)
#pragma message ("BLYNK_INFO_DEVICE=" BLYNK_TOSTRING(BLYNK_INFO_DEVICE))
#endif
#if defined(BLYNK_INFO_CPU)
#pragma message ("BLYNK_INFO_CPU=" BLYNK_TOSTRING(BLYNK_INFO_CPU))
#endif
#if defined(BLYNK_BUFFERS_SIZE)
#pragma message ("BLYNK_BUFFERS_SIZE=" BLYNK_TOSTRING(BLYNK_BUFFERS_SIZE))
#endif
#endif
#endif
#endif

View File

@@ -0,0 +1,69 @@
#ifndef BLYNKEVERYN_H
#define BLYNKEVERYN_H
#include "BlynkDebug.h"
millis_time_t blynk_count_millis() {
const millis_time_t ms = BlynkMillis();
return ms;
}
uint16_t blynk_count_seconds16() {
const millis_time_t ms = BlynkMillis();
return (ms / 1000);
}
uint16_t blynk_count_minutes16()
{
const millis_time_t ms = BlynkMillis();
return (ms / (60000L)) & 0xFFFF;
}
uint8_t blynk_count_hours8()
{
const millis_time_t ms = BlynkMillis();
return (ms / (3600000L)) & 0xFF;
}
template<typename T, T (*timeGetter)()>
class BlynkPeriodic {
public:
T mPrev;
T mPeriod;
BlynkPeriodic() { reset(); mPeriod = 1; };
BlynkPeriodic(T period) { reset(); setPeriod(period); };
void setPeriod( T period) { mPeriod = period; };
T getTime() { return (T)(timeGetter()); };
T getPeriod() { return mPeriod; };
T getElapsed() { return getTime() - mPrev; }
T getRemaining() { return mPeriod - getElapsed(); }
T getLastTriggerTime() { return mPrev; }
bool ready() {
bool isReady = (getElapsed() >= mPeriod);
if( isReady ) { reset(); }
return isReady;
}
void reset() { mPrev = getTime(); };
void trigger() { mPrev = getTime() - mPeriod; };
operator bool() { return ready(); }
};
typedef BlynkPeriodic<millis_time_t,blynk_count_millis> BlynkEveryNMillis;
typedef BlynkPeriodic<uint16_t,blynk_count_seconds16> BlynkEveryNSeconds;
typedef BlynkPeriodic<uint16_t,blynk_count_minutes16> BlynkEveryNMinutes;
typedef BlynkPeriodic<uint8_t,blynk_count_hours8> BlynkEveryNHours;
#define BLYNK_EVERY_N_MILLIS_I(NAME,N) static BlynkEveryNMillis NAME(N); if(NAME)
#define BLYNK_EVERY_N_SECONDS_I(NAME,N) static BlynkEveryNSeconds NAME(N); if(NAME)
#define BLYNK_EVERY_N_MINUTES_I(NAME,N) static BlynkEveryNMinutes NAME(N); if(NAME)
#define BLYNK_EVERY_N_HOURS_I(NAME,N) static BlynkEveryNHours NAME(N); if(NAME)
#define BLYNK_EVERY_N_MILLIS(N) BLYNK_EVERY_N_MILLIS_I(BLYNK_CONCAT2(PER, __COUNTER__),N)
#define BLYNK_EVERY_N_SECONDS(N) BLYNK_EVERY_N_SECONDS_I(BLYNK_CONCAT2(PER, __COUNTER__),N)
#define BLYNK_EVERY_N_MINUTES(N) BLYNK_EVERY_N_MINUTES_I(BLYNK_CONCAT2(PER, __COUNTER__),N)
#define BLYNK_EVERY_N_HOURS(N) BLYNK_EVERY_N_HOURS_I(BLYNK_CONCAT2(PER, __COUNTER__),N)
#endif

View File

@@ -0,0 +1,158 @@
/**
* @file BlynkFifo.h
* @author Volodymyr Shymanskyy
* @license This project is released under the MIT License (MIT)
* @copyright Copyright (c) 2015 Volodymyr Shymanskyy
* @date Feb 2015
* @brief FIFO implementation
*
*/
#ifndef BlynkFifo_h
#define BlynkFifo_h
#include "BlynkUtility.h"
template <class T, unsigned N>
class BlynkFifo
{
public:
BlynkFifo()
{
clear();
}
void clear()
{
_r = 0;
_w = 0;
}
~BlynkFifo(void)
{}
// writing thread/context API
//-------------------------------------------------------------
bool writeable(void)
{
return free() > 0;
}
int free(void)
{
int s = _r - _w;
if (s <= 0)
s += N;
return s - 1;
}
T put(const T& c)
{
int i = _w;
int j = i;
i = _inc(i);
while (i == _r) // = !writeable()
/* nothing / just wait */;
_b[j] = c;
_w = i;
return c;
}
int put(const T* p, int n, bool blocking = false)
{
int c = n;
while (c)
{
int f;
while ((f = free()) == 0) // wait for space
{
if (!blocking) return n - c; // no more space and not blocking
/* nothing / just wait */;
}
// check free space
if (c < f) f = c;
int w = _w;
int m = N - w;
// check wrap
if (f > m) f = m;
memcpy(&_b[w], p, f);
_w = _inc(w, f);
c -= f;
p += f;
}
return n - c;
}
// reading thread/context API
// --------------------------------------------------------
bool readable(void)
{
return (_r != _w);
}
size_t size(void)
{
int s = _w - _r;
if (s < 0)
s += N;
return s;
}
T get(void)
{
int r = _r;
while (r == _w) // = !readable()
/* nothing / just wait */;
T t = _b[r];
_r = _inc(r);
return t;
}
T peek(void)
{
int r = _r;
while (r == _w);
return _b[r];
}
int get(T* p, int n, bool blocking = false)
{
int c = n;
while (c)
{
int f;
for (;;) // wait for data
{
f = size();
if (f) break; // free space
if (!blocking) return n - c; // no space and not blocking
/* nothing / just wait */;
}
// check available data
if (c < f) f = c;
int r = _r;
int m = N - r;
// check wrap
if (f > m) f = m;
memcpy(p, &_b[r], f);
_r = _inc(r, f);
c -= f;
p += f;
}
return n - c;
}
private:
int _inc(int i, int n = 1)
{
return (i + n) % N;
}
T _b[N];
volatile int _w;
volatile int _r;
};
#endif

View File

@@ -0,0 +1,402 @@
/**
* @file BlynkHandlers.cpp
* @author Volodymyr Shymanskyy
* @license This project is released under the MIT License (MIT)
* @copyright Copyright (c) 2015 Volodymyr Shymanskyy
* @date Jan 2015
* @brief Virtual pin utilities
*/
#include "BlynkConfig.h"
#include "BlynkHandlers.h"
#include "BlynkDebug.h"
void BlynkNoOpCbk()
{}
void BlynkWidgetRead(BlynkReq BLYNK_UNUSED &request)
{
BLYNK_LOG2(BLYNK_F("No handler for reading from pin "), request.pin);
}
void BlynkWidgetWrite(BlynkReq BLYNK_UNUSED &request, const BlynkParam BLYNK_UNUSED &param)
{
BLYNK_LOG2(BLYNK_F("No handler for writing to pin "), request.pin);
}
#define BLYNK_ON_READ_IMPL(pin) void BlynkWidgetRead ## pin (BlynkReq BLYNK_UNUSED &req) \
__attribute__((weak, alias("BlynkWidgetRead")))
#define BLYNK_ON_WRITE_IMPL(pin) void BlynkWidgetWrite ## pin (BlynkReq BLYNK_UNUSED &req, const BlynkParam BLYNK_UNUSED &param) \
__attribute__((weak, alias("BlynkWidgetWrite")))
BLYNK_CONNECTED() __attribute__((weak, alias("BlynkNoOpCbk")));
BLYNK_DISCONNECTED() __attribute__((weak, alias("BlynkNoOpCbk")));
// Internal Virtual Pins
BLYNK_ON_WRITE_IMPL(InternalPinACON);
BLYNK_ON_WRITE_IMPL(InternalPinADIS);
BLYNK_ON_WRITE_IMPL(InternalPinRTC);
BLYNK_ON_WRITE_IMPL(InternalPinOTA);
// Regular Virtual Pins
BLYNK_ON_READ_IMPL(Default);
BLYNK_ON_WRITE_IMPL(Default);
BLYNK_ON_READ_IMPL(0 );
BLYNK_ON_READ_IMPL(1 );
BLYNK_ON_READ_IMPL(2 );
BLYNK_ON_READ_IMPL(3 );
BLYNK_ON_READ_IMPL(4 );
BLYNK_ON_READ_IMPL(5 );
BLYNK_ON_READ_IMPL(6 );
BLYNK_ON_READ_IMPL(7 );
BLYNK_ON_READ_IMPL(8 );
BLYNK_ON_READ_IMPL(9 );
BLYNK_ON_READ_IMPL(10);
BLYNK_ON_READ_IMPL(11);
BLYNK_ON_READ_IMPL(12);
BLYNK_ON_READ_IMPL(13);
BLYNK_ON_READ_IMPL(14);
BLYNK_ON_READ_IMPL(15);
BLYNK_ON_READ_IMPL(16);
BLYNK_ON_READ_IMPL(17);
BLYNK_ON_READ_IMPL(18);
BLYNK_ON_READ_IMPL(19);
BLYNK_ON_READ_IMPL(20);
BLYNK_ON_READ_IMPL(21);
BLYNK_ON_READ_IMPL(22);
BLYNK_ON_READ_IMPL(23);
BLYNK_ON_READ_IMPL(24);
BLYNK_ON_READ_IMPL(25);
BLYNK_ON_READ_IMPL(26);
BLYNK_ON_READ_IMPL(27);
BLYNK_ON_READ_IMPL(28);
BLYNK_ON_READ_IMPL(29);
BLYNK_ON_READ_IMPL(30);
BLYNK_ON_READ_IMPL(31);
#ifdef BLYNK_USE_128_VPINS
BLYNK_ON_READ_IMPL(32);
BLYNK_ON_READ_IMPL(33);
BLYNK_ON_READ_IMPL(34);
BLYNK_ON_READ_IMPL(35);
BLYNK_ON_READ_IMPL(36);
BLYNK_ON_READ_IMPL(37);
BLYNK_ON_READ_IMPL(38);
BLYNK_ON_READ_IMPL(39);
BLYNK_ON_READ_IMPL(40);
BLYNK_ON_READ_IMPL(41);
BLYNK_ON_READ_IMPL(42);
BLYNK_ON_READ_IMPL(43);
BLYNK_ON_READ_IMPL(44);
BLYNK_ON_READ_IMPL(45);
BLYNK_ON_READ_IMPL(46);
BLYNK_ON_READ_IMPL(47);
BLYNK_ON_READ_IMPL(48);
BLYNK_ON_READ_IMPL(49);
BLYNK_ON_READ_IMPL(50);
BLYNK_ON_READ_IMPL(51);
BLYNK_ON_READ_IMPL(52);
BLYNK_ON_READ_IMPL(53);
BLYNK_ON_READ_IMPL(54);
BLYNK_ON_READ_IMPL(55);
BLYNK_ON_READ_IMPL(56);
BLYNK_ON_READ_IMPL(57);
BLYNK_ON_READ_IMPL(58);
BLYNK_ON_READ_IMPL(59);
BLYNK_ON_READ_IMPL(60);
BLYNK_ON_READ_IMPL(61);
BLYNK_ON_READ_IMPL(62);
BLYNK_ON_READ_IMPL(63);
BLYNK_ON_READ_IMPL(64);
BLYNK_ON_READ_IMPL(65);
BLYNK_ON_READ_IMPL(66);
BLYNK_ON_READ_IMPL(67);
BLYNK_ON_READ_IMPL(68);
BLYNK_ON_READ_IMPL(69);
BLYNK_ON_READ_IMPL(70);
BLYNK_ON_READ_IMPL(71);
BLYNK_ON_READ_IMPL(72);
BLYNK_ON_READ_IMPL(73);
BLYNK_ON_READ_IMPL(74);
BLYNK_ON_READ_IMPL(75);
BLYNK_ON_READ_IMPL(76);
BLYNK_ON_READ_IMPL(77);
BLYNK_ON_READ_IMPL(78);
BLYNK_ON_READ_IMPL(79);
BLYNK_ON_READ_IMPL(80);
BLYNK_ON_READ_IMPL(81);
BLYNK_ON_READ_IMPL(82);
BLYNK_ON_READ_IMPL(83);
BLYNK_ON_READ_IMPL(84);
BLYNK_ON_READ_IMPL(85);
BLYNK_ON_READ_IMPL(86);
BLYNK_ON_READ_IMPL(87);
BLYNK_ON_READ_IMPL(88);
BLYNK_ON_READ_IMPL(89);
BLYNK_ON_READ_IMPL(90);
BLYNK_ON_READ_IMPL(91);
BLYNK_ON_READ_IMPL(92);
BLYNK_ON_READ_IMPL(93);
BLYNK_ON_READ_IMPL(94);
BLYNK_ON_READ_IMPL(95);
BLYNK_ON_READ_IMPL(96);
BLYNK_ON_READ_IMPL(97);
BLYNK_ON_READ_IMPL(98);
BLYNK_ON_READ_IMPL(99);
BLYNK_ON_READ_IMPL(100);
BLYNK_ON_READ_IMPL(101);
BLYNK_ON_READ_IMPL(102);
BLYNK_ON_READ_IMPL(103);
BLYNK_ON_READ_IMPL(104);
BLYNK_ON_READ_IMPL(105);
BLYNK_ON_READ_IMPL(106);
BLYNK_ON_READ_IMPL(107);
BLYNK_ON_READ_IMPL(108);
BLYNK_ON_READ_IMPL(109);
BLYNK_ON_READ_IMPL(110);
BLYNK_ON_READ_IMPL(111);
BLYNK_ON_READ_IMPL(112);
BLYNK_ON_READ_IMPL(113);
BLYNK_ON_READ_IMPL(114);
BLYNK_ON_READ_IMPL(115);
BLYNK_ON_READ_IMPL(116);
BLYNK_ON_READ_IMPL(117);
BLYNK_ON_READ_IMPL(118);
BLYNK_ON_READ_IMPL(119);
BLYNK_ON_READ_IMPL(120);
BLYNK_ON_READ_IMPL(121);
BLYNK_ON_READ_IMPL(122);
BLYNK_ON_READ_IMPL(123);
BLYNK_ON_READ_IMPL(124);
BLYNK_ON_READ_IMPL(125);
BLYNK_ON_READ_IMPL(126);
BLYNK_ON_READ_IMPL(127);
#endif
BLYNK_ON_WRITE_IMPL(0 );
BLYNK_ON_WRITE_IMPL(1 );
BLYNK_ON_WRITE_IMPL(2 );
BLYNK_ON_WRITE_IMPL(3 );
BLYNK_ON_WRITE_IMPL(4 );
BLYNK_ON_WRITE_IMPL(5 );
BLYNK_ON_WRITE_IMPL(6 );
BLYNK_ON_WRITE_IMPL(7 );
BLYNK_ON_WRITE_IMPL(8 );
BLYNK_ON_WRITE_IMPL(9 );
BLYNK_ON_WRITE_IMPL(10);
BLYNK_ON_WRITE_IMPL(11);
BLYNK_ON_WRITE_IMPL(12);
BLYNK_ON_WRITE_IMPL(13);
BLYNK_ON_WRITE_IMPL(14);
BLYNK_ON_WRITE_IMPL(15);
BLYNK_ON_WRITE_IMPL(16);
BLYNK_ON_WRITE_IMPL(17);
BLYNK_ON_WRITE_IMPL(18);
BLYNK_ON_WRITE_IMPL(19);
BLYNK_ON_WRITE_IMPL(20);
BLYNK_ON_WRITE_IMPL(21);
BLYNK_ON_WRITE_IMPL(22);
BLYNK_ON_WRITE_IMPL(23);
BLYNK_ON_WRITE_IMPL(24);
BLYNK_ON_WRITE_IMPL(25);
BLYNK_ON_WRITE_IMPL(26);
BLYNK_ON_WRITE_IMPL(27);
BLYNK_ON_WRITE_IMPL(28);
BLYNK_ON_WRITE_IMPL(29);
BLYNK_ON_WRITE_IMPL(30);
BLYNK_ON_WRITE_IMPL(31);
#ifdef BLYNK_USE_128_VPINS
BLYNK_ON_WRITE_IMPL(32);
BLYNK_ON_WRITE_IMPL(33);
BLYNK_ON_WRITE_IMPL(34);
BLYNK_ON_WRITE_IMPL(35);
BLYNK_ON_WRITE_IMPL(36);
BLYNK_ON_WRITE_IMPL(37);
BLYNK_ON_WRITE_IMPL(38);
BLYNK_ON_WRITE_IMPL(39);
BLYNK_ON_WRITE_IMPL(40);
BLYNK_ON_WRITE_IMPL(41);
BLYNK_ON_WRITE_IMPL(42);
BLYNK_ON_WRITE_IMPL(43);
BLYNK_ON_WRITE_IMPL(44);
BLYNK_ON_WRITE_IMPL(45);
BLYNK_ON_WRITE_IMPL(46);
BLYNK_ON_WRITE_IMPL(47);
BLYNK_ON_WRITE_IMPL(48);
BLYNK_ON_WRITE_IMPL(49);
BLYNK_ON_WRITE_IMPL(50);
BLYNK_ON_WRITE_IMPL(51);
BLYNK_ON_WRITE_IMPL(52);
BLYNK_ON_WRITE_IMPL(53);
BLYNK_ON_WRITE_IMPL(54);
BLYNK_ON_WRITE_IMPL(55);
BLYNK_ON_WRITE_IMPL(56);
BLYNK_ON_WRITE_IMPL(57);
BLYNK_ON_WRITE_IMPL(58);
BLYNK_ON_WRITE_IMPL(59);
BLYNK_ON_WRITE_IMPL(60);
BLYNK_ON_WRITE_IMPL(61);
BLYNK_ON_WRITE_IMPL(62);
BLYNK_ON_WRITE_IMPL(63);
BLYNK_ON_WRITE_IMPL(64);
BLYNK_ON_WRITE_IMPL(65);
BLYNK_ON_WRITE_IMPL(66);
BLYNK_ON_WRITE_IMPL(67);
BLYNK_ON_WRITE_IMPL(68);
BLYNK_ON_WRITE_IMPL(69);
BLYNK_ON_WRITE_IMPL(70);
BLYNK_ON_WRITE_IMPL(71);
BLYNK_ON_WRITE_IMPL(72);
BLYNK_ON_WRITE_IMPL(73);
BLYNK_ON_WRITE_IMPL(74);
BLYNK_ON_WRITE_IMPL(75);
BLYNK_ON_WRITE_IMPL(76);
BLYNK_ON_WRITE_IMPL(77);
BLYNK_ON_WRITE_IMPL(78);
BLYNK_ON_WRITE_IMPL(79);
BLYNK_ON_WRITE_IMPL(80);
BLYNK_ON_WRITE_IMPL(81);
BLYNK_ON_WRITE_IMPL(82);
BLYNK_ON_WRITE_IMPL(83);
BLYNK_ON_WRITE_IMPL(84);
BLYNK_ON_WRITE_IMPL(85);
BLYNK_ON_WRITE_IMPL(86);
BLYNK_ON_WRITE_IMPL(87);
BLYNK_ON_WRITE_IMPL(88);
BLYNK_ON_WRITE_IMPL(89);
BLYNK_ON_WRITE_IMPL(90);
BLYNK_ON_WRITE_IMPL(91);
BLYNK_ON_WRITE_IMPL(92);
BLYNK_ON_WRITE_IMPL(93);
BLYNK_ON_WRITE_IMPL(94);
BLYNK_ON_WRITE_IMPL(95);
BLYNK_ON_WRITE_IMPL(96);
BLYNK_ON_WRITE_IMPL(97);
BLYNK_ON_WRITE_IMPL(98);
BLYNK_ON_WRITE_IMPL(99);
BLYNK_ON_WRITE_IMPL(100);
BLYNK_ON_WRITE_IMPL(101);
BLYNK_ON_WRITE_IMPL(102);
BLYNK_ON_WRITE_IMPL(103);
BLYNK_ON_WRITE_IMPL(104);
BLYNK_ON_WRITE_IMPL(105);
BLYNK_ON_WRITE_IMPL(106);
BLYNK_ON_WRITE_IMPL(107);
BLYNK_ON_WRITE_IMPL(108);
BLYNK_ON_WRITE_IMPL(109);
BLYNK_ON_WRITE_IMPL(110);
BLYNK_ON_WRITE_IMPL(111);
BLYNK_ON_WRITE_IMPL(112);
BLYNK_ON_WRITE_IMPL(113);
BLYNK_ON_WRITE_IMPL(114);
BLYNK_ON_WRITE_IMPL(115);
BLYNK_ON_WRITE_IMPL(116);
BLYNK_ON_WRITE_IMPL(117);
BLYNK_ON_WRITE_IMPL(118);
BLYNK_ON_WRITE_IMPL(119);
BLYNK_ON_WRITE_IMPL(120);
BLYNK_ON_WRITE_IMPL(121);
BLYNK_ON_WRITE_IMPL(122);
BLYNK_ON_WRITE_IMPL(123);
BLYNK_ON_WRITE_IMPL(124);
BLYNK_ON_WRITE_IMPL(125);
BLYNK_ON_WRITE_IMPL(126);
BLYNK_ON_WRITE_IMPL(127);
#endif
static const WidgetReadHandler BlynkReadHandlerVector[] BLYNK_PROGMEM = {
BlynkWidgetRead0, BlynkWidgetRead1, BlynkWidgetRead2, BlynkWidgetRead3,
BlynkWidgetRead4, BlynkWidgetRead5, BlynkWidgetRead6, BlynkWidgetRead7,
BlynkWidgetRead8, BlynkWidgetRead9, BlynkWidgetRead10, BlynkWidgetRead11,
BlynkWidgetRead12, BlynkWidgetRead13, BlynkWidgetRead14, BlynkWidgetRead15,
BlynkWidgetRead16, BlynkWidgetRead17, BlynkWidgetRead18, BlynkWidgetRead19,
BlynkWidgetRead20, BlynkWidgetRead21, BlynkWidgetRead22, BlynkWidgetRead23,
BlynkWidgetRead24, BlynkWidgetRead25, BlynkWidgetRead26, BlynkWidgetRead27,
BlynkWidgetRead28, BlynkWidgetRead29, BlynkWidgetRead30, BlynkWidgetRead31,
#ifdef BLYNK_USE_128_VPINS
BlynkWidgetRead32, BlynkWidgetRead33, BlynkWidgetRead34, BlynkWidgetRead35,
BlynkWidgetRead36, BlynkWidgetRead37, BlynkWidgetRead38, BlynkWidgetRead39,
BlynkWidgetRead40, BlynkWidgetRead41, BlynkWidgetRead42, BlynkWidgetRead43,
BlynkWidgetRead44, BlynkWidgetRead45, BlynkWidgetRead46, BlynkWidgetRead47,
BlynkWidgetRead48, BlynkWidgetRead49, BlynkWidgetRead50, BlynkWidgetRead51,
BlynkWidgetRead52, BlynkWidgetRead53, BlynkWidgetRead54, BlynkWidgetRead55,
BlynkWidgetRead56, BlynkWidgetRead57, BlynkWidgetRead58, BlynkWidgetRead59,
BlynkWidgetRead60, BlynkWidgetRead61, BlynkWidgetRead62, BlynkWidgetRead63,
BlynkWidgetRead64, BlynkWidgetRead65, BlynkWidgetRead66, BlynkWidgetRead67,
BlynkWidgetRead68, BlynkWidgetRead69, BlynkWidgetRead70, BlynkWidgetRead71,
BlynkWidgetRead72, BlynkWidgetRead73, BlynkWidgetRead74, BlynkWidgetRead75,
BlynkWidgetRead76, BlynkWidgetRead77, BlynkWidgetRead78, BlynkWidgetRead79,
BlynkWidgetRead80, BlynkWidgetRead81, BlynkWidgetRead82, BlynkWidgetRead83,
BlynkWidgetRead84, BlynkWidgetRead85, BlynkWidgetRead86, BlynkWidgetRead87,
BlynkWidgetRead88, BlynkWidgetRead89, BlynkWidgetRead90, BlynkWidgetRead91,
BlynkWidgetRead92, BlynkWidgetRead93, BlynkWidgetRead94, BlynkWidgetRead95,
BlynkWidgetRead96, BlynkWidgetRead97, BlynkWidgetRead98, BlynkWidgetRead99,
BlynkWidgetRead100, BlynkWidgetRead101, BlynkWidgetRead102, BlynkWidgetRead103,
BlynkWidgetRead104, BlynkWidgetRead105, BlynkWidgetRead106, BlynkWidgetRead107,
BlynkWidgetRead108, BlynkWidgetRead109, BlynkWidgetRead110, BlynkWidgetRead111,
BlynkWidgetRead112, BlynkWidgetRead113, BlynkWidgetRead114, BlynkWidgetRead115,
BlynkWidgetRead116, BlynkWidgetRead117, BlynkWidgetRead118, BlynkWidgetRead119,
BlynkWidgetRead120, BlynkWidgetRead121, BlynkWidgetRead122, BlynkWidgetRead123,
BlynkWidgetRead124, BlynkWidgetRead125, BlynkWidgetRead126, BlynkWidgetRead127,
#endif
};
static const WidgetWriteHandler BlynkWriteHandlerVector[] BLYNK_PROGMEM = {
BlynkWidgetWrite0, BlynkWidgetWrite1, BlynkWidgetWrite2, BlynkWidgetWrite3,
BlynkWidgetWrite4, BlynkWidgetWrite5, BlynkWidgetWrite6, BlynkWidgetWrite7,
BlynkWidgetWrite8, BlynkWidgetWrite9, BlynkWidgetWrite10, BlynkWidgetWrite11,
BlynkWidgetWrite12, BlynkWidgetWrite13, BlynkWidgetWrite14, BlynkWidgetWrite15,
BlynkWidgetWrite16, BlynkWidgetWrite17, BlynkWidgetWrite18, BlynkWidgetWrite19,
BlynkWidgetWrite20, BlynkWidgetWrite21, BlynkWidgetWrite22, BlynkWidgetWrite23,
BlynkWidgetWrite24, BlynkWidgetWrite25, BlynkWidgetWrite26, BlynkWidgetWrite27,
BlynkWidgetWrite28, BlynkWidgetWrite29, BlynkWidgetWrite30, BlynkWidgetWrite31,
#ifdef BLYNK_USE_128_VPINS
BlynkWidgetWrite32, BlynkWidgetWrite33, BlynkWidgetWrite34, BlynkWidgetWrite35,
BlynkWidgetWrite36, BlynkWidgetWrite37, BlynkWidgetWrite38, BlynkWidgetWrite39,
BlynkWidgetWrite40, BlynkWidgetWrite41, BlynkWidgetWrite42, BlynkWidgetWrite43,
BlynkWidgetWrite44, BlynkWidgetWrite45, BlynkWidgetWrite46, BlynkWidgetWrite47,
BlynkWidgetWrite48, BlynkWidgetWrite49, BlynkWidgetWrite50, BlynkWidgetWrite51,
BlynkWidgetWrite52, BlynkWidgetWrite53, BlynkWidgetWrite54, BlynkWidgetWrite55,
BlynkWidgetWrite56, BlynkWidgetWrite57, BlynkWidgetWrite58, BlynkWidgetWrite59,
BlynkWidgetWrite60, BlynkWidgetWrite61, BlynkWidgetWrite62, BlynkWidgetWrite63,
BlynkWidgetWrite64, BlynkWidgetWrite65, BlynkWidgetWrite66, BlynkWidgetWrite67,
BlynkWidgetWrite68, BlynkWidgetWrite69, BlynkWidgetWrite70, BlynkWidgetWrite71,
BlynkWidgetWrite72, BlynkWidgetWrite73, BlynkWidgetWrite74, BlynkWidgetWrite75,
BlynkWidgetWrite76, BlynkWidgetWrite77, BlynkWidgetWrite78, BlynkWidgetWrite79,
BlynkWidgetWrite80, BlynkWidgetWrite81, BlynkWidgetWrite82, BlynkWidgetWrite83,
BlynkWidgetWrite84, BlynkWidgetWrite85, BlynkWidgetWrite86, BlynkWidgetWrite87,
BlynkWidgetWrite88, BlynkWidgetWrite89, BlynkWidgetWrite90, BlynkWidgetWrite91,
BlynkWidgetWrite92, BlynkWidgetWrite93, BlynkWidgetWrite94, BlynkWidgetWrite95,
BlynkWidgetWrite96, BlynkWidgetWrite97, BlynkWidgetWrite98, BlynkWidgetWrite99,
BlynkWidgetWrite100, BlynkWidgetWrite101, BlynkWidgetWrite102, BlynkWidgetWrite103,
BlynkWidgetWrite104, BlynkWidgetWrite105, BlynkWidgetWrite106, BlynkWidgetWrite107,
BlynkWidgetWrite108, BlynkWidgetWrite109, BlynkWidgetWrite110, BlynkWidgetWrite111,
BlynkWidgetWrite112, BlynkWidgetWrite113, BlynkWidgetWrite114, BlynkWidgetWrite115,
BlynkWidgetWrite116, BlynkWidgetWrite117, BlynkWidgetWrite118, BlynkWidgetWrite119,
BlynkWidgetWrite120, BlynkWidgetWrite121, BlynkWidgetWrite122, BlynkWidgetWrite123,
BlynkWidgetWrite124, BlynkWidgetWrite125, BlynkWidgetWrite126, BlynkWidgetWrite127,
#endif
};
WidgetReadHandler GetReadHandler(uint8_t pin)
{
if (pin >= BLYNK_COUNT_OF(BlynkReadHandlerVector))
return NULL;
#ifdef BLYNK_HAS_PROGMEM
return (WidgetReadHandler)pgm_read_word(&BlynkReadHandlerVector[pin]);
#else
return BlynkReadHandlerVector[pin];
#endif
}
WidgetWriteHandler GetWriteHandler(uint8_t pin)
{
if (pin >= BLYNK_COUNT_OF(BlynkWriteHandlerVector))
return NULL;
#ifdef BLYNK_HAS_PROGMEM
return (WidgetWriteHandler)pgm_read_word(&BlynkWriteHandlerVector[pin]);
#else
return BlynkWriteHandlerVector[pin];
#endif
}

View File

@@ -0,0 +1,511 @@
/**
* @file BlynkHandlers.h
* @author Volodymyr Shymanskyy
* @license This project is released under the MIT License (MIT)
* @copyright Copyright (c) 2015 Volodymyr Shymanskyy
* @date Jan 2015
* @brief Handlers for virtual pin operations
*
*/
#ifndef BlynkHandlers_h
#define BlynkHandlers_h
#include "BlynkConfig.h"
#include "BlynkParam.h"
// Helper macro
#define V0 0
#define V1 1
#define V2 2
#define V3 3
#define V4 4
#define V5 5
#define V6 6
#define V7 7
#define V8 8
#define V9 9
#define V10 10
#define V11 11
#define V12 12
#define V13 13
#define V14 14
#define V15 15
#define V16 16
#define V17 17
#define V18 18
#define V19 19
#define V20 20
#define V21 21
#define V22 22
#define V23 23
#define V24 24
#define V25 25
#define V26 26
#define V27 27
#define V28 28
#define V29 29
#define V30 30
#define V31 31
#ifdef BLYNK_USE_128_VPINS
#define V32 32
#define V33 33
#define V34 34
#define V35 35
#define V36 36
#define V37 37
#define V38 38
#define V39 39
#define V40 40
#define V41 41
#define V42 42
#define V43 43
#define V44 44
#define V45 45
#define V46 46
#define V47 47
#define V48 48
#define V49 49
#define V50 50
#define V51 51
#define V52 52
#define V53 53
#define V54 54
#define V55 55
#define V56 56
#define V57 57
#define V58 58
#define V59 59
#define V60 60
#define V61 61
#define V62 62
#define V63 63
#define V64 64
#define V65 65
#define V66 66
#define V67 67
#define V68 68
#define V69 69
#define V70 70
#define V71 71
#define V72 72
#define V73 73
#define V74 74
#define V75 75
#define V76 76
#define V77 77
#define V78 78
#define V79 79
#define V80 80
#define V81 81
#define V82 82
#define V83 83
#define V84 84
#define V85 85
#define V86 86
#define V87 87
#define V88 88
#define V89 89
#define V90 90
#define V91 91
#define V92 92
#define V93 93
#define V94 94
#define V95 95
#define V96 96
#define V97 97
#define V98 98
#define V99 99
#define V100 100
#define V101 101
#define V102 102
#define V103 103
#define V104 104
#define V105 105
#define V106 106
#define V107 107
#define V108 108
#define V109 109
#define V110 110
#define V111 111
#define V112 112
#define V113 113
#define V114 114
#define V115 115
#define V116 116
#define V117 117
#define V118 118
#define V119 119
#define V120 120
#define V121 121
#define V122 122
#define V123 123
#define V124 124
#define V125 125
#define V126 126
#define V127 127
#endif
// Initial syntax:
#define BLYNK_WRITE_2(pin) \
void BlynkWidgetWrite ## pin (BlynkReq BLYNK_UNUSED &request, const BlynkParam BLYNK_UNUSED &param)
#define BLYNK_READ_2(pin) \
void BlynkWidgetRead ## pin (BlynkReq BLYNK_UNUSED &request)
#define BLYNK_WRITE_DEFAULT() BLYNK_WRITE_2(Default)
#define BLYNK_READ_DEFAULT() BLYNK_READ_2(Default)
#define BLYNK_WRITE(pin) BLYNK_WRITE_2(pin)
#define BLYNK_READ(pin) BLYNK_READ_2(pin)
// New, more readable syntax:
#define BLYNK_IN_2(pin) \
void BlynkWidgetWrite ## pin (BlynkReq BLYNK_UNUSED &request, const BlynkParam BLYNK_UNUSED &getValue)
#define BLYNK_OUT_2(pin) \
void BlynkWidgetRead ## pin (BlynkReq BLYNK_UNUSED &request)
#define BLYNK_INPUT_DEFAULT() BLYNK_IN_2(Default)
#define BLYNK_OUTPUT_DEFAULT() BLYNK_OUT_2(Default)
#define BLYNK_INPUT(pin) BLYNK_IN_2(pin)
#define BLYNK_OUTPUT(pin) BLYNK_OUT_2(pin)
// Additional handlers
#define BLYNK_CONNECTED() void BlynkOnConnected()
#define BLYNK_DISCONNECTED() void BlynkOnDisconnected()
// Advanced functions
#define BLYNK_VAR_INT(name, pin) \
int name; \
BLYNK_WRITE(pin) { name = param.asInt(); } \
BLYNK_READ(pin) { Blynk.virtualWrite(pin, name); }
#define BLYNK_VAR_LONG(name, pin) \
long name; \
BLYNK_WRITE(pin) { name = param.asLong(); } \
BLYNK_READ(pin) { Blynk.virtualWrite(pin, name); }
#ifndef BLYNK_NO_FLOAT
#define BLYNK_VAR_DOUBLE(name, pin) \
double name; \
BLYNK_WRITE(pin) { name = param.asDouble(); } \
BLYNK_READ(pin) { Blynk.virtualWrite(pin, name); }
#endif
#ifdef ARDUINO
#define BLYNK_VAR_STRING(name, pin) \
String name; \
BLYNK_WRITE(pin) { name = param.asStr(); } \
BLYNK_READ(pin) { Blynk.virtualWrite(pin, name); }
#endif
// Default read/write handlers (you can redefine them in your code)
#ifdef __cplusplus
extern "C" {
#endif
struct BlynkReq
{
uint8_t pin;
};
typedef void (*WidgetReadHandler)(BlynkReq BLYNK_UNUSED &request);
typedef void (*WidgetWriteHandler)(BlynkReq BLYNK_UNUSED &request, const BlynkParam BLYNK_UNUSED &param);
WidgetReadHandler GetReadHandler(uint8_t pin);
WidgetWriteHandler GetWriteHandler(uint8_t pin);
// Declare placeholders
BLYNK_READ();
BLYNK_WRITE();
void BlynkNoOpCbk();
// Declare all pin handlers (you can redefine them in your code)
BLYNK_CONNECTED();
BLYNK_DISCONNECTED();
// Internal Virtual Pins
BLYNK_WRITE(InternalPinACON);
BLYNK_WRITE(InternalPinADIS);
BLYNK_WRITE(InternalPinRTC);
BLYNK_WRITE(InternalPinOTA);
// Aliases
#define BLYNK_APP_CONNECTED() BLYNK_WRITE(InternalPinACON)
#define BLYNK_APP_DISCONNECTED() BLYNK_WRITE(InternalPinADIS)
// Regular Virtual Pins
BLYNK_READ_DEFAULT();
BLYNK_WRITE_DEFAULT();
BLYNK_READ(0 );
BLYNK_READ(1 );
BLYNK_READ(2 );
BLYNK_READ(3 );
BLYNK_READ(4 );
BLYNK_READ(5 );
BLYNK_READ(6 );
BLYNK_READ(7 );
BLYNK_READ(8 );
BLYNK_READ(9 );
BLYNK_READ(10);
BLYNK_READ(11);
BLYNK_READ(12);
BLYNK_READ(13);
BLYNK_READ(14);
BLYNK_READ(15);
BLYNK_READ(16);
BLYNK_READ(17);
BLYNK_READ(18);
BLYNK_READ(19);
BLYNK_READ(20);
BLYNK_READ(21);
BLYNK_READ(22);
BLYNK_READ(23);
BLYNK_READ(24);
BLYNK_READ(25);
BLYNK_READ(26);
BLYNK_READ(27);
BLYNK_READ(28);
BLYNK_READ(29);
BLYNK_READ(30);
BLYNK_READ(31);
#ifdef BLYNK_USE_128_VPINS
BLYNK_READ(32);
BLYNK_READ(33);
BLYNK_READ(34);
BLYNK_READ(35);
BLYNK_READ(36);
BLYNK_READ(37);
BLYNK_READ(38);
BLYNK_READ(39);
BLYNK_READ(40);
BLYNK_READ(41);
BLYNK_READ(42);
BLYNK_READ(43);
BLYNK_READ(44);
BLYNK_READ(45);
BLYNK_READ(46);
BLYNK_READ(47);
BLYNK_READ(48);
BLYNK_READ(49);
BLYNK_READ(50);
BLYNK_READ(51);
BLYNK_READ(52);
BLYNK_READ(53);
BLYNK_READ(54);
BLYNK_READ(55);
BLYNK_READ(56);
BLYNK_READ(57);
BLYNK_READ(58);
BLYNK_READ(59);
BLYNK_READ(60);
BLYNK_READ(61);
BLYNK_READ(62);
BLYNK_READ(63);
BLYNK_READ(64);
BLYNK_READ(65);
BLYNK_READ(66);
BLYNK_READ(67);
BLYNK_READ(68);
BLYNK_READ(69);
BLYNK_READ(70);
BLYNK_READ(71);
BLYNK_READ(72);
BLYNK_READ(73);
BLYNK_READ(74);
BLYNK_READ(75);
BLYNK_READ(76);
BLYNK_READ(77);
BLYNK_READ(78);
BLYNK_READ(79);
BLYNK_READ(80);
BLYNK_READ(81);
BLYNK_READ(82);
BLYNK_READ(83);
BLYNK_READ(84);
BLYNK_READ(85);
BLYNK_READ(86);
BLYNK_READ(87);
BLYNK_READ(88);
BLYNK_READ(89);
BLYNK_READ(90);
BLYNK_READ(91);
BLYNK_READ(92);
BLYNK_READ(93);
BLYNK_READ(94);
BLYNK_READ(95);
BLYNK_READ(96);
BLYNK_READ(97);
BLYNK_READ(98);
BLYNK_READ(99);
BLYNK_READ(100);
BLYNK_READ(101);
BLYNK_READ(102);
BLYNK_READ(103);
BLYNK_READ(104);
BLYNK_READ(105);
BLYNK_READ(106);
BLYNK_READ(107);
BLYNK_READ(108);
BLYNK_READ(109);
BLYNK_READ(110);
BLYNK_READ(111);
BLYNK_READ(112);
BLYNK_READ(113);
BLYNK_READ(114);
BLYNK_READ(115);
BLYNK_READ(116);
BLYNK_READ(117);
BLYNK_READ(118);
BLYNK_READ(119);
BLYNK_READ(120);
BLYNK_READ(121);
BLYNK_READ(122);
BLYNK_READ(123);
BLYNK_READ(124);
BLYNK_READ(125);
BLYNK_READ(126);
BLYNK_READ(127);
#endif
BLYNK_WRITE(0 );
BLYNK_WRITE(1 );
BLYNK_WRITE(2 );
BLYNK_WRITE(3 );
BLYNK_WRITE(4 );
BLYNK_WRITE(5 );
BLYNK_WRITE(6 );
BLYNK_WRITE(7 );
BLYNK_WRITE(8 );
BLYNK_WRITE(9 );
BLYNK_WRITE(10);
BLYNK_WRITE(11);
BLYNK_WRITE(12);
BLYNK_WRITE(13);
BLYNK_WRITE(14);
BLYNK_WRITE(15);
BLYNK_WRITE(16);
BLYNK_WRITE(17);
BLYNK_WRITE(18);
BLYNK_WRITE(19);
BLYNK_WRITE(20);
BLYNK_WRITE(21);
BLYNK_WRITE(22);
BLYNK_WRITE(23);
BLYNK_WRITE(24);
BLYNK_WRITE(25);
BLYNK_WRITE(26);
BLYNK_WRITE(27);
BLYNK_WRITE(28);
BLYNK_WRITE(29);
BLYNK_WRITE(30);
BLYNK_WRITE(31);
#ifdef BLYNK_USE_128_VPINS
BLYNK_WRITE(32);
BLYNK_WRITE(33);
BLYNK_WRITE(34);
BLYNK_WRITE(35);
BLYNK_WRITE(36);
BLYNK_WRITE(37);
BLYNK_WRITE(38);
BLYNK_WRITE(39);
BLYNK_WRITE(40);
BLYNK_WRITE(41);
BLYNK_WRITE(42);
BLYNK_WRITE(43);
BLYNK_WRITE(44);
BLYNK_WRITE(45);
BLYNK_WRITE(46);
BLYNK_WRITE(47);
BLYNK_WRITE(48);
BLYNK_WRITE(49);
BLYNK_WRITE(50);
BLYNK_WRITE(51);
BLYNK_WRITE(52);
BLYNK_WRITE(53);
BLYNK_WRITE(54);
BLYNK_WRITE(55);
BLYNK_WRITE(56);
BLYNK_WRITE(57);
BLYNK_WRITE(58);
BLYNK_WRITE(59);
BLYNK_WRITE(60);
BLYNK_WRITE(61);
BLYNK_WRITE(62);
BLYNK_WRITE(63);
BLYNK_WRITE(64);
BLYNK_WRITE(65);
BLYNK_WRITE(66);
BLYNK_WRITE(67);
BLYNK_WRITE(68);
BLYNK_WRITE(69);
BLYNK_WRITE(70);
BLYNK_WRITE(71);
BLYNK_WRITE(72);
BLYNK_WRITE(73);
BLYNK_WRITE(74);
BLYNK_WRITE(75);
BLYNK_WRITE(76);
BLYNK_WRITE(77);
BLYNK_WRITE(78);
BLYNK_WRITE(79);
BLYNK_WRITE(80);
BLYNK_WRITE(81);
BLYNK_WRITE(82);
BLYNK_WRITE(83);
BLYNK_WRITE(84);
BLYNK_WRITE(85);
BLYNK_WRITE(86);
BLYNK_WRITE(87);
BLYNK_WRITE(88);
BLYNK_WRITE(89);
BLYNK_WRITE(90);
BLYNK_WRITE(91);
BLYNK_WRITE(92);
BLYNK_WRITE(93);
BLYNK_WRITE(94);
BLYNK_WRITE(95);
BLYNK_WRITE(96);
BLYNK_WRITE(97);
BLYNK_WRITE(98);
BLYNK_WRITE(99);
BLYNK_WRITE(100);
BLYNK_WRITE(101);
BLYNK_WRITE(102);
BLYNK_WRITE(103);
BLYNK_WRITE(104);
BLYNK_WRITE(105);
BLYNK_WRITE(106);
BLYNK_WRITE(107);
BLYNK_WRITE(108);
BLYNK_WRITE(109);
BLYNK_WRITE(110);
BLYNK_WRITE(111);
BLYNK_WRITE(112);
BLYNK_WRITE(113);
BLYNK_WRITE(114);
BLYNK_WRITE(115);
BLYNK_WRITE(116);
BLYNK_WRITE(117);
BLYNK_WRITE(118);
BLYNK_WRITE(119);
BLYNK_WRITE(120);
BLYNK_WRITE(121);
BLYNK_WRITE(122);
BLYNK_WRITE(123);
BLYNK_WRITE(124);
BLYNK_WRITE(125);
BLYNK_WRITE(126);
BLYNK_WRITE(127);
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,379 @@
/**
* @file BlynkParam.h
* @author Volodymyr Shymanskyy
* @license This project is released under the MIT License (MIT)
* @copyright Copyright (c) 2015 Volodymyr Shymanskyy
* @date Jan 2015
* @brief Container for handler parameters
*
*/
#ifndef BlynkParam_h
#define BlynkParam_h
#include <string.h>
#include <stdlib.h>
#include "BlynkConfig.h"
#include "BlynkDebug.h"
#define BLYNK_PARAM_KV(k, v) k "\0" v "\0"
class BlynkParam
{
public:
class iterator
{
public:
iterator(const char* c, const char* l) : ptr(c), limit(l) {}
static iterator invalid() { return iterator(NULL, NULL); }
operator const char* () const { return asStr(); }
operator int () const { return asInt(); }
const char* asStr() const { return ptr; }
const char* asString() const { return ptr; }
int asInt() const { if(!isValid()) return 0; return atoi(ptr); }
long asLong() const { if(!isValid()) return 0; return atol(ptr); }
//long long asLongLong() const { return atoll(ptr); }
#ifndef BLYNK_NO_FLOAT
double asDouble() const { if(!isValid()) return 0; return atof(ptr); }
float asFloat() const { if(!isValid()) return 0; return atof(ptr); }
#endif
bool isValid() const { return ptr != NULL && ptr < limit; }
bool isEmpty() const { if(!isValid()) return true; return *ptr == '\0'; }
bool operator < (const iterator& it) const { return ptr < it.ptr; }
bool operator >= (const iterator& it) const { return ptr >= it.ptr; }
iterator& operator ++() {
if(isValid()) {
ptr += strlen(ptr) + 1;
}
return *this;
}
private:
const char* ptr;
const char* limit;
};
public:
explicit
BlynkParam(void* addr, size_t length)
: buff((char*)addr), len(length), buff_size(length)
{}
explicit
BlynkParam(void* addr, size_t length, size_t buffsize)
: buff((char*)addr), len(length), buff_size(buffsize)
{}
const char* asStr() const { return buff; }
const char* asString() const { return buff; }
int asInt() const { return atoi(buff); }
long asLong() const { return atol(buff); }
//long long asLongLong() const { return atoll(buff); }
#ifndef BLYNK_NO_FLOAT
double asDouble() const { return atof(buff); }
float asFloat() const { return atof(buff); }
#endif
bool isEmpty() const { return *buff == '\0'; }
iterator begin() const { return iterator(buff, buff+len); }
iterator end() const { return iterator(buff+len, buff+len); }
iterator operator[](int index) const;
iterator operator[](const char* key) const;
void* getBuffer() const { return (void*)buff; }
size_t getLength() const { return len; }
// Modification
void add(int value);
void add(unsigned int value);
void add(long value);
void add(unsigned long value);
void add(long long value);
void add(unsigned long long value);
#ifndef BLYNK_NO_FLOAT
void add(float value);
void add(double value);
#endif
void add(const char* str);
void add(const void* b, size_t l);
#if defined(ARDUINO) || defined(SPARK) || defined(PARTICLE)
void add(const String& str);
#if defined(BLYNK_HAS_PROGMEM)
void add(const __FlashStringHelper* str);
#endif
#endif
template<typename T, typename... Args>
void add_multi(T last) {
add(last);
}
template<typename T, typename... Args>
void add_multi(T head, Args... tail) {
add(head);
add_multi(tail...);
}
template <typename TV>
void add_key(const char* key, const TV& val) {
add(key);
add(val);
}
protected:
char* buff;
size_t len;
size_t buff_size;
};
class BlynkParamAllocated
: public BlynkParam
{
public:
BlynkParamAllocated(size_t size)
: BlynkParam(malloc(size), 0, size)
{}
~BlynkParamAllocated() {
free(buff);
}
};
inline
BlynkParam::iterator BlynkParam::operator[](int index) const
{
const iterator e = end();
for (iterator it = begin(); it < e; ++it) {
if (!index--) {
return it;
}
}
return iterator::invalid();
}
inline
BlynkParam::iterator BlynkParam::operator[](const char* key) const
{
const iterator e = end();
for (iterator it = begin(); it < e; ++it) {
if (!strcmp(it.asStr(), key)) {
return ++it;
}
++it;
if (it >= e) break;
}
return iterator::invalid();
}
inline
void BlynkParam::add(const void* b, size_t l)
{
if (len + l > buff_size)
return;
memcpy(buff+len, b, l);
len += l;
}
inline
void BlynkParam::add(const char* str)
{
if (str == NULL) {
buff[len++] = '\0';
return;
}
add(str, strlen(str)+1);
}
#if defined(ARDUINO) || defined(SPARK) || defined(PARTICLE)
inline
void BlynkParam::add(const String& str)
{
#if defined(ARDUINO_AVR_DIGISPARK) \
|| defined(__ARDUINO_X86__) \
|| defined(__RFduino__)
size_t len = str.length()+1;
char buff[len];
const_cast<String&>(str).toCharArray(buff, len);
add(buff, len);
#else
add(str.c_str());
#endif
}
#if defined(BLYNK_HAS_PROGMEM)
inline
void BlynkParam::add(const __FlashStringHelper* ifsh)
{
PGM_P p = reinterpret_cast<PGM_P>(ifsh);
size_t l = strlen_P(p) + 1;
if (len + l > buff_size)
return;
memcpy_P(buff+len, p, l);
len += l;
buff[len] = '\0';
}
#endif
#endif
#if defined(__AVR__) || defined (ARDUINO_ARCH_ARC32)
#include <stdlib.h>
inline
void BlynkParam::add(int value)
{
char str[2 + 8 * sizeof(value)];
itoa(value, str, 10);
add(str);
}
inline
void BlynkParam::add(unsigned int value)
{
char str[1 + 8 * sizeof(value)];
utoa(value, str, 10);
add(str);
}
inline
void BlynkParam::add(long value)
{
char str[2 + 8 * sizeof(value)];
ltoa(value, str, 10);
add(str);
}
inline
void BlynkParam::add(unsigned long value)
{
char str[1 + 8 * sizeof(value)];
ultoa(value, str, 10);
add(str);
}
inline
void BlynkParam::add(long long value) // TODO: this currently adds just a long
{
char str[2 + 8 * sizeof(value)];
ltoa(value, str, 10);
add(str);
}
inline
void BlynkParam::add(unsigned long long value) // TODO: this currently adds just a long
{
char str[1 + 8 * sizeof(value)];
ultoa(value, str, 10);
add(str);
}
#ifndef BLYNK_NO_FLOAT
inline
void BlynkParam::add(float value)
{
char str[33];
dtostrf(value, 5, 3, str);
add(str);
}
inline
void BlynkParam::add(double value)
{
char str[33];
dtostrf(value, 5, 7, str);
add(str);
}
#endif
#else
#include <stdio.h>
inline
void BlynkParam::add(int value)
{
len += snprintf(buff+len, buff_size-len, "%i", value)+1;
}
inline
void BlynkParam::add(unsigned int value)
{
len += snprintf(buff+len, buff_size-len, "%u", value)+1;
}
inline
void BlynkParam::add(long value)
{
len += snprintf(buff+len, buff_size-len, "%li", value)+1;
}
inline
void BlynkParam::add(unsigned long value)
{
len += snprintf(buff+len, buff_size-len, "%lu", value)+1;
}
inline
void BlynkParam::add(long long value)
{
len += snprintf(buff+len, buff_size-len, "%lli", value)+1;
}
inline
void BlynkParam::add(unsigned long long value)
{
len += snprintf(buff+len, buff_size-len, "%llu", value)+1;
}
#ifndef BLYNK_NO_FLOAT
#if defined(BLYNK_USE_INTERNAL_DTOSTRF)
extern char* dtostrf_internal(double number, signed char width, unsigned char prec, char *s);
inline
void BlynkParam::add(float value)
{
char str[33];
dtostrf_internal(value, 5, 3, str);
add(str);
}
inline
void BlynkParam::add(double value)
{
char str[33];
dtostrf_internal(value, 5, 7, str);
add(str);
}
#else
inline
void BlynkParam::add(float value)
{
len += snprintf(buff+len, buff_size-len, "%2.3f", value)+1;
}
inline
void BlynkParam::add(double value)
{
len += snprintf(buff+len, buff_size-len, "%2.7f", value)+1;
}
#endif
#endif
#endif
#endif

View File

@@ -0,0 +1,535 @@
/**
* @file BlynkProtocol.h
* @author Volodymyr Shymanskyy
* @license This project is released under the MIT License (MIT)
* @copyright Copyright (c) 2015 Volodymyr Shymanskyy
* @date Jan 2015
* @brief Blynk protocol implementation
*
*/
#ifndef BlynkProtocol_h
#define BlynkProtocol_h
#include <string.h>
#include <stdlib.h>
#include "BlynkDebug.h"
#include "BlynkProtocolDefs.h"
#include "BlynkApi.h"
#include "BlynkUtility.h"
template <class Transp>
class BlynkProtocol
: public BlynkApi< BlynkProtocol<Transp> >
{
friend class BlynkApi< BlynkProtocol<Transp> >;
public:
enum BlynkState {
CONNECTING,
CONNECTED,
DISCONNECTED,
};
BlynkProtocol(Transp& transp)
: conn(transp)
, authkey(NULL)
, redir_serv(NULL)
, lastActivityIn(0)
, lastActivityOut(0)
, lastHeartbeat(0)
, msgIdOut(0)
, msgIdOutOverride(0)
, nesting(0)
, state(CONNECTING)
{}
bool connected() { return state == CONNECTED; }
bool connect(uint32_t timeout = BLYNK_TIMEOUT_MS*3) {
conn.disconnect();
state = CONNECTING;
millis_time_t started = BlynkMillis();
while ((state != CONNECTED) &&
(BlynkMillis() - started < timeout))
{
run();
}
return state == CONNECTED;
}
void disconnect() {
conn.disconnect();
state = DISCONNECTED;
BLYNK_LOG1(BLYNK_F("Disconnected"));
}
bool run(bool avail = false);
// TODO: Fixme
void startSession() {
conn.connect();
state = CONNECTING;
msgIdOut = 0;
lastHeartbeat = lastActivityIn = lastActivityOut = (BlynkMillis() - 5000UL);
}
void sendCmd(uint8_t cmd, uint16_t id = 0, const void* data = NULL, size_t length = 0, const void* data2 = NULL, size_t length2 = 0);
private:
void internalReconnect() {
state = CONNECTING;
conn.disconnect();
BlynkOnDisconnected();
}
int readHeader(BlynkHeader& hdr);
uint16_t getNextMsgId();
protected:
void begin(const char* auth) {
this->authkey = auth;
lastHeartbeat = lastActivityIn = lastActivityOut = (BlynkMillis() - 5000UL);
#if defined(BLYNK_NO_FANCY_LOGO)
BLYNK_LOG1(BLYNK_F("Blynk v" BLYNK_VERSION " on " BLYNK_INFO_DEVICE));
#else
BLYNK_LOG1(BLYNK_F(BLYNK_NEWLINE
" ___ __ __" BLYNK_NEWLINE
" / _ )/ /_ _____ / /__" BLYNK_NEWLINE
" / _ / / // / _ \\/ '_/" BLYNK_NEWLINE
" /____/_/\\_, /_//_/_/\\_\\" BLYNK_NEWLINE
" /___/ v" BLYNK_VERSION " on " BLYNK_INFO_DEVICE BLYNK_NEWLINE
BLYNK_NEWLINE
" Give Blynk a Github star! => https://github.com/blynkkk/blynk-library" BLYNK_NEWLINE
));
#endif
}
bool processInput(void);
Transp& conn;
private:
const char* authkey;
char* redir_serv;
millis_time_t lastActivityIn;
millis_time_t lastActivityOut;
union {
millis_time_t lastHeartbeat;
millis_time_t lastLogin;
};
uint16_t msgIdOut;
uint16_t msgIdOutOverride;
uint8_t nesting;
protected:
BlynkState state;
};
template <class Transp>
bool BlynkProtocol<Transp>::run(bool avail)
{
BLYNK_RUN_YIELD();
if (state == DISCONNECTED) {
return false;
}
// Detect nesting
BlynkHelperAutoInc guard(nesting);
if (msgIdOutOverride || nesting > 2) {
//BLYNK_LOG1(BLYNK_F("Nested run() skipped"));
return true;
}
if (conn.connected()) {
while (avail || conn.available() > 0) {
//BLYNK_LOG2(BLYNK_F("Available: "), conn.available());
//const unsigned long t = micros();
if (!processInput()) {
conn.disconnect();
// TODO: Only when in direct mode?
#ifdef BLYNK_USE_DIRECT_CONNECT
state = CONNECTING;
#endif
BlynkOnDisconnected();
return false;
}
avail = false;
//BLYNK_LOG2(BLYNK_F("Proc time: "), micros() - t);
}
}
const millis_time_t t = BlynkMillis();
// Update connection status after running commands
const bool tconn = conn.connected();
if (state == CONNECTED) {
if (!tconn) {
lastHeartbeat = t;
internalReconnect();
return false;
}
if (t - lastActivityIn > (1000UL * BLYNK_HEARTBEAT + BLYNK_TIMEOUT_MS*3)) {
#ifdef BLYNK_DEBUG
BLYNK_LOG6(BLYNK_F("Heartbeat timeout: "), t, BLYNK_F(", "), lastActivityIn, BLYNK_F(", "), lastHeartbeat);
#else
BLYNK_LOG1(BLYNK_F("Heartbeat timeout"));
#endif
internalReconnect();
return false;
} else if ((t - lastActivityIn > 1000UL * BLYNK_HEARTBEAT ||
t - lastActivityOut > 1000UL * BLYNK_HEARTBEAT) &&
t - lastHeartbeat > BLYNK_TIMEOUT_MS)
{
// Send ping if we didn't either send or receive something
// for BLYNK_HEARTBEAT seconds
sendCmd(BLYNK_CMD_PING);
lastHeartbeat = t;
}
} else if (state == CONNECTING) {
#ifdef BLYNK_USE_DIRECT_CONNECT
if (!tconn)
conn.connect();
#else
if (tconn && (t - lastLogin > BLYNK_TIMEOUT_MS)) {
BLYNK_LOG1(BLYNK_F("Login timeout"));
conn.disconnect();
state = CONNECTING;
return false;
} else if (!tconn && (t - lastLogin > 5000UL)) {
conn.disconnect();
if (!conn.connect()) {
lastLogin = t;
return false;
}
msgIdOut = 1;
sendCmd(BLYNK_CMD_LOGIN, 1, authkey, strlen(authkey));
lastLogin = lastActivityOut;
return true;
}
#endif
}
return true;
}
template <class Transp>
BLYNK_FORCE_INLINE
bool BlynkProtocol<Transp>::processInput(void)
{
BlynkHeader hdr;
const int ret = readHeader(hdr);
if (ret == 0) {
return true; // Considered OK (no data on input)
}
if (ret < 0 || hdr.msg_id == 0) {
#ifdef BLYNK_DEBUG
BLYNK_LOG2(BLYNK_F("Bad hdr len: "), ret);
#endif
return false;
}
if (hdr.type == BLYNK_CMD_RESPONSE) {
lastActivityIn = BlynkMillis();
#ifndef BLYNK_USE_DIRECT_CONNECT
if (state == CONNECTING && (1 == hdr.msg_id)) {
switch (hdr.length) {
case BLYNK_SUCCESS:
case BLYNK_ALREADY_REGISTERED:
BLYNK_LOG3(BLYNK_F("Ready (ping: "), lastActivityIn-lastHeartbeat, BLYNK_F("ms)."));
lastHeartbeat = lastActivityIn;
state = CONNECTED;
#ifdef BLYNK_DEBUG
if (size_t ram = BlynkFreeRam()) {
BLYNK_LOG2(BLYNK_F("Free RAM: "), ram);
}
#endif
this->sendInfo();
BLYNK_RUN_YIELD();
BlynkOnConnected();
return true;
case BLYNK_INVALID_TOKEN:
BLYNK_LOG1(BLYNK_F("Invalid auth token"));
break;
default:
BLYNK_LOG2(BLYNK_F("Connect failed. code: "), hdr.length);
}
return false;
}
if (BLYNK_NOT_AUTHENTICATED == hdr.length) {
return false;
}
#endif
// TODO: return code may indicate App presence
return true;
}
if (hdr.length > BLYNK_MAX_READBYTES) {
BLYNK_LOG2(BLYNK_F("Packet too big: "), hdr.length);
// TODO: Flush
internalReconnect();
return true;
}
uint8_t inputBuffer[hdr.length+1]; // Add 1 to zero-terminate
if (hdr.length != conn.read(inputBuffer, hdr.length)) {
#ifdef BLYNK_DEBUG
BLYNK_LOG1(BLYNK_F("Can't read body"));
#endif
return false;
}
inputBuffer[hdr.length] = '\0';
BLYNK_DBG_DUMP(">", inputBuffer, hdr.length);
lastActivityIn = BlynkMillis();
switch (hdr.type)
{
case BLYNK_CMD_LOGIN: {
#ifdef BLYNK_USE_DIRECT_CONNECT
if (strncmp(authkey, (char*)inputBuffer, 32)) {
BLYNK_LOG1(BLYNK_F("Invalid token"));
sendCmd(BLYNK_CMD_RESPONSE, hdr.msg_id, NULL, BLYNK_INVALID_TOKEN);
break;
}
#endif
if (state == CONNECTING) {
BLYNK_LOG1(BLYNK_F("Ready"));
state = CONNECTED;
#ifdef BLYNK_DEBUG
if (size_t ram = BlynkFreeRam()) {
BLYNK_LOG2(BLYNK_F("Free RAM: "), ram);
}
#endif
this->sendInfo();
BLYNK_RUN_YIELD();
BlynkOnConnected();
}
sendCmd(BLYNK_CMD_RESPONSE, hdr.msg_id, NULL, BLYNK_SUCCESS);
} break;
case BLYNK_CMD_PING: {
sendCmd(BLYNK_CMD_RESPONSE, hdr.msg_id, NULL, BLYNK_SUCCESS);
} break;
case BLYNK_CMD_REDIRECT: {
if (!redir_serv) {
redir_serv = (char*)malloc(32);
}
BlynkParam param(inputBuffer, hdr.length);
uint16_t redir_port = BLYNK_DEFAULT_PORT; // TODO: Fixit
BlynkParam::iterator it = param.begin();
if (it >= param.end())
return false;
strncpy(redir_serv, it.asStr(), 32);
if (++it < param.end())
redir_port = it.asLong();
BLYNK_LOG4(BLYNK_F("Redirecting to "), redir_serv, ':', redir_port);
conn.disconnect();
conn.begin(redir_serv, redir_port);
state = CONNECTING;
lastHeartbeat = lastActivityIn = lastActivityOut = (BlynkMillis() - 5000UL);
} break;
case BLYNK_CMD_HARDWARE:
case BLYNK_CMD_BRIDGE: {
msgIdOutOverride = hdr.msg_id;
this->processCmd(inputBuffer, hdr.length);
msgIdOutOverride = 0;
} break;
case BLYNK_CMD_INTERNAL: {
BlynkReq req = { 0 };
BlynkParam param(inputBuffer, hdr.length);
BlynkParam::iterator it = param.begin();
if (it >= param.end())
return true;
uint32_t cmd32;
memcpy(&cmd32, it.asStr(), sizeof(cmd32));
++it;
char* start = (char*)(it).asStr();
unsigned length = hdr.length - (start - (char*)inputBuffer);
BlynkParam param2(start, length);
switch (cmd32) {
case BLYNK_INT_RTC: BlynkWidgetWriteInternalPinRTC(req, param2); break;
case BLYNK_INT_OTA: BlynkWidgetWriteInternalPinOTA(req, param2); break;
case BLYNK_INT_ACON: BlynkWidgetWriteInternalPinACON(req, param2); break;
case BLYNK_INT_ADIS: BlynkWidgetWriteInternalPinADIS(req, param2); break;
#ifdef BLYNK_DEBUG
default: BLYNK_LOG2(BLYNK_F("Invalid internal cmd:"), param.asStr());
#endif
}
} break;
case BLYNK_CMD_DEBUG_PRINT: {
if (hdr.length) {
BLYNK_LOG2(BLYNK_F("Server: "), (char*)inputBuffer);
}
} break;
default: {
#ifdef BLYNK_DEBUG
BLYNK_LOG2(BLYNK_F("Invalid header type: "), hdr.type);
#endif
// TODO: Flush
internalReconnect();
} break;
}
return true;
}
template <class Transp>
int BlynkProtocol<Transp>::readHeader(BlynkHeader& hdr)
{
size_t rlen = conn.read(&hdr, sizeof(hdr));
if (rlen == 0) {
return 0;
}
if (sizeof(hdr) != rlen) {
return -1;
}
BLYNK_DBG_DUMP(">", &hdr, sizeof(BlynkHeader));
hdr.msg_id = ntohs(hdr.msg_id);
hdr.length = ntohs(hdr.length);
return rlen;
}
#ifndef BLYNK_SEND_THROTTLE
#define BLYNK_SEND_THROTTLE 0
#endif
#ifndef BLYNK_SEND_CHUNK
#define BLYNK_SEND_CHUNK 1024 // Just a big number
#endif
template <class Transp>
void BlynkProtocol<Transp>::sendCmd(uint8_t cmd, uint16_t id, const void* data, size_t length, const void* data2, size_t length2)
{
if (!conn.connected() || (cmd != BLYNK_CMD_RESPONSE && cmd != BLYNK_CMD_PING && cmd != BLYNK_CMD_LOGIN && state != CONNECTED) ) {
#ifdef BLYNK_DEBUG_ALL
BLYNK_LOG2(BLYNK_F("Cmd skipped:"), cmd);
#endif
return;
}
if (0 == id) {
id = getNextMsgId();
}
#if defined(BLYNK_MSG_LIMIT) && BLYNK_MSG_LIMIT > 0
if (cmd >= BLYNK_CMD_TWEET && cmd <= BLYNK_CMD_HARDWARE) {
const millis_time_t allowed_time = BlynkMax(lastActivityOut, lastActivityIn) + 1000/BLYNK_MSG_LIMIT;
int32_t wait_time = allowed_time - BlynkMillis();
if (wait_time >= 0) {
#ifdef BLYNK_DEBUG_ALL
BLYNK_LOG2(BLYNK_F("Waiting:"), wait_time);
#endif
while (wait_time >= 0) {
run();
wait_time = allowed_time - BlynkMillis();
}
} else if (nesting == 0) {
run();
}
}
#endif
const size_t full_length = (sizeof(BlynkHeader)) +
(data ? length : 0) +
(data2 ? length2 : 0);
#if defined(BLYNK_SEND_ATOMIC) || defined(ESP8266) || defined(ESP32) || defined(SPARK) || defined(PARTICLE) || defined(ENERGIA)
// Those have more RAM and like single write at a time...
uint8_t buff[full_length];
BlynkHeader* hdr = (BlynkHeader*)buff;
hdr->type = cmd;
hdr->msg_id = htons(id);
hdr->length = htons(length+length2);
size_t pos = sizeof(BlynkHeader);
if (data && length) {
memcpy(buff + pos, data, length);
pos += length;
}
if (data2 && length2) {
memcpy(buff + pos, data2, length2);
}
size_t wlen = 0;
while (wlen < full_length) {
const size_t chunk = BlynkMin(size_t(BLYNK_SEND_CHUNK), full_length - wlen);
BLYNK_DBG_DUMP("<", buff + wlen, chunk);
const size_t w = conn.write(buff + wlen, chunk);
BlynkDelay(BLYNK_SEND_THROTTLE);
if (w == 0) {
#ifdef BLYNK_DEBUG
BLYNK_LOG1(BLYNK_F("Cmd error"));
#endif
conn.disconnect();
state = CONNECTING;
BlynkOnDisconnected();
return;
}
wlen += w;
}
#else
BlynkHeader hdr;
hdr.type = cmd;
hdr.msg_id = htons(id);
hdr.length = htons(length+length2);
BLYNK_DBG_DUMP("<", &hdr, sizeof(hdr));
size_t wlen = conn.write(&hdr, sizeof(hdr));
BlynkDelay(BLYNK_SEND_THROTTLE);
if (cmd != BLYNK_CMD_RESPONSE) {
if (length) {
BLYNK_DBG_DUMP("<", data, length);
wlen += conn.write(data, length);
BlynkDelay(BLYNK_SEND_THROTTLE);
}
if (length2) {
BLYNK_DBG_DUMP("<", data2, length2);
wlen += conn.write(data2, length2);
BlynkDelay(BLYNK_SEND_THROTTLE);
}
}
#endif
if (wlen != full_length) {
#ifdef BLYNK_DEBUG
BLYNK_LOG4(BLYNK_F("Sent "), wlen, '/', full_length);
#endif
internalReconnect();
return;
}
lastActivityOut = BlynkMillis();
}
template <class Transp>
uint16_t BlynkProtocol<Transp>::getNextMsgId()
{
if (msgIdOutOverride != 0)
return msgIdOutOverride;
if (++msgIdOut == 0)
msgIdOut = 1;
return msgIdOut;
}
#endif

View File

@@ -0,0 +1,138 @@
/**
* @file BlynkProtocolDefs.h
* @author Volodymyr Shymanskyy
* @license This project is released under the MIT License (MIT)
* @copyright Copyright (c) 2015 Volodymyr Shymanskyy
* @date Jan 2015
* @brief Blynk protocol definitions
*
*/
#ifndef BlynkProtocolDefs_h
#define BlynkProtocolDefs_h
enum BlynkCmd
{
BLYNK_CMD_RESPONSE = 0,
BLYNK_CMD_REGISTER = 1,
BLYNK_CMD_LOGIN = 2,
BLYNK_CMD_SAVE_PROF = 3,
BLYNK_CMD_LOAD_PROF = 4,
BLYNK_CMD_GET_TOKEN = 5,
BLYNK_CMD_PING = 6,
BLYNK_CMD_ACTIVATE = 7,
BLYNK_CMD_DEACTIVATE = 8,
BLYNK_CMD_REFRESH = 9,
BLYNK_CMD_GET_GRAPH_DATA = 10,
BLYNK_CMD_GET_GRAPH_DATA_RESPONSE = 11,
BLYNK_CMD_TWEET = 12,
BLYNK_CMD_EMAIL = 13,
BLYNK_CMD_NOTIFY = 14,
BLYNK_CMD_BRIDGE = 15,
BLYNK_CMD_HARDWARE_SYNC = 16,
BLYNK_CMD_INTERNAL = 17,
BLYNK_CMD_SMS = 18,
BLYNK_CMD_PROPERTY = 19,
BLYNK_CMD_HARDWARE = 20,
BLYNK_CMD_CREATE_DASH = 21,
BLYNK_CMD_SAVE_DASH = 22,
BLYNK_CMD_DELETE_DASH = 23,
BLYNK_CMD_LOAD_PROF_GZ = 24,
BLYNK_CMD_SYNC = 25,
BLYNK_CMD_SHARING = 26,
BLYNK_CMD_ADD_PUSH_TOKEN = 27,
//sharing commands
BLYNK_CMD_GET_SHARED_DASH = 29,
BLYNK_CMD_GET_SHARE_TOKEN = 30,
BLYNK_CMD_REFRESH_SHARE_TOKEN = 31,
BLYNK_CMD_SHARE_LOGIN = 32,
BLYNK_CMD_REDIRECT = 41,
BLYNK_CMD_DEBUG_PRINT = 55,
BLYNK_CMD_EVENT_LOG = 64
};
enum BlynkStatus
{
BLYNK_SUCCESS = 200,
BLYNK_QUOTA_LIMIT_EXCEPTION = 1,
BLYNK_ILLEGAL_COMMAND = 2,
BLYNK_NOT_REGISTERED = 3,
BLYNK_ALREADY_REGISTERED = 4,
BLYNK_NOT_AUTHENTICATED = 5,
BLYNK_NOT_ALLOWED = 6,
BLYNK_DEVICE_NOT_IN_NETWORK = 7,
BLYNK_NO_ACTIVE_DASHBOARD = 8,
BLYNK_INVALID_TOKEN = 9,
BLYNK_ILLEGAL_COMMAND_BODY = 11,
BLYNK_GET_GRAPH_DATA_EXCEPTION = 12,
BLYNK_NO_DATA_EXCEPTION = 17,
BLYNK_DEVICE_WENT_OFFLINE = 18,
BLYNK_SERVER_EXCEPTION = 19,
BLYNK_NTF_INVALID_BODY = 13,
BLYNK_NTF_NOT_AUTHORIZED = 14,
BLYNK_NTF_ECXEPTION = 15,
BLYNK_TIMEOUT = 16,
BLYNK_NOT_SUPPORTED_VERSION = 20,
BLYNK_ENERGY_LIMIT = 21
};
struct BlynkHeader
{
uint8_t type;
uint16_t msg_id;
uint16_t length;
}
BLYNK_ATTR_PACKED;
#if !defined(htons) && (defined(ARDUINO) || defined(ESP8266) || defined(PARTICLE) || defined(__MBED__))
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
#define htons(x) ( ((x)<<8) | (((x)>>8)&0xFF) )
#define htonl(x) ( ((x)<<24 & 0xFF000000UL) | \
((x)<< 8 & 0x00FF0000UL) | \
((x)>> 8 & 0x0000FF00UL) | \
((x)>>24 & 0x000000FFUL) )
#define ntohs(x) htons(x)
#define ntohl(x) htonl(x)
#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
#define htons(x) (x)
#define htonl(x) (x)
#define ntohs(x) (x)
#define ntohl(x) (x)
#else
#error byte order problem
#endif
#endif
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
#define BLYNK_STR_16(a,b) ((uint16_t(a) << 0) | (uint16_t(b) << 8))
#define BLYNK_STR_32(a,b,c,d) ((uint32_t(a) << 0) | (uint32_t(b) << 8) | (uint32_t(c) << 16) | (uint32_t(d) << 24))
#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
#define BLYNK_STR_16(a,b) ((uint16_t(b) << 0) | (uint16_t(a) << 8))
#define BLYNK_STR_32(a,b,c,d) ((uint32_t(d) << 0) | (uint32_t(c) << 8) | (uint32_t(b) << 16) | (uint32_t(a) << 24))
#else
#error byte order problem
#endif
#define BLYNK_HW_PM BLYNK_STR_16('p','m')
#define BLYNK_HW_DW BLYNK_STR_16('d','w')
#define BLYNK_HW_DR BLYNK_STR_16('d','r')
#define BLYNK_HW_AW BLYNK_STR_16('a','w')
#define BLYNK_HW_AR BLYNK_STR_16('a','r')
#define BLYNK_HW_VW BLYNK_STR_16('v','w')
#define BLYNK_HW_VR BLYNK_STR_16('v','r')
#define BLYNK_INT_RTC BLYNK_STR_32('r','t','c',0)
#define BLYNK_INT_OTA BLYNK_STR_32('o','t','a',0)
#define BLYNK_INT_ACON BLYNK_STR_32('a','c','o','n')
#define BLYNK_INT_ADIS BLYNK_STR_32('a','d','i','s')
#endif

View File

@@ -0,0 +1,47 @@
class BlynkStackOnly
{
protected:
BlynkStackOnly() {}
~BlynkStackOnly() {}
private:
/// @brief Declared as private to prevent usage of dynamic memory
void* operator new(size_t size);
/// @brief Declared as private to prevent usage of dynamic memory
void operator delete(void *p);
};
class BlynkNonCopyable
{
protected:
BlynkNonCopyable(){}
~BlynkNonCopyable(){}
private:
/// @brief Declared as private to prevent usage of copy constructor
BlynkNonCopyable(const BlynkNonCopyable&);
/// @brief Declared as private to prevent usage of assignment operator
BlynkNonCopyable& operator=(const BlynkNonCopyable&);
};
template<typename T>
class BlynkSingleton
: public BlynkNonCopyable
{
public:
/** @brief Returns the instance of the singleton type
When called for the first time, the singleton instance will be
created. All subsequent calls will return a reference to the
previously created instance.
@return The singleton instance
*/
static T* instance()
{
static T instance;
return &instance;
}
protected:
BlynkSingleton() {}
~BlynkSingleton() {}
};

View File

@@ -0,0 +1,291 @@
/*
* SimpleTimer.cpp
*
* SimpleTimer - A timer library for Arduino.
* Author: mromani@ottotecnica.com
* Copyright (c) 2010 OTTOTECNICA Italy
*
* Callback function parameters added & compiler warnings
* removed by Bill Knight <billk@rosw.com> 20March2017
*
* 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 "BlynkTimer.h"
#include <string.h>
// Select time function:
//static inline unsigned long elapsed() { return micros(); }
static inline unsigned long elapsed() { return BlynkMillis(); }
SimpleTimer::SimpleTimer()
: numTimers (-1)
{
}
void SimpleTimer::init() {
unsigned long current_millis = elapsed();
for (int i = 0; i < MAX_TIMERS; i++) {
memset(&timer[i], 0, sizeof (timer_t));
timer[i].prev_millis = current_millis;
}
numTimers = 0;
}
void SimpleTimer::run() {
int i;
unsigned long current_millis;
// get current time
current_millis = elapsed();
for (i = 0; i < MAX_TIMERS; i++) {
timer[i].toBeCalled = DEFCALL_DONTRUN;
// no callback == no timer, i.e. jump over empty slots
if (timer[i].callback != NULL) {
// is it time to process this timer ?
// see http://arduino.cc/forum/index.php/topic,124048.msg932592.html#msg932592
if ((current_millis - timer[i].prev_millis) >= timer[i].delay) {
unsigned long skipTimes = (current_millis - timer[i].prev_millis) / timer[i].delay;
// update time
timer[i].prev_millis += timer[i].delay * skipTimes;
// check if the timer callback has to be executed
if (timer[i].enabled) {
// "run forever" timers must always be executed
if (timer[i].maxNumRuns == RUN_FOREVER) {
timer[i].toBeCalled = DEFCALL_RUNONLY;
}
// other timers get executed the specified number of times
else if (timer[i].numRuns < timer[i].maxNumRuns) {
timer[i].toBeCalled = DEFCALL_RUNONLY;
timer[i].numRuns++;
// after the last run, delete the timer
if (timer[i].numRuns >= timer[i].maxNumRuns) {
timer[i].toBeCalled = DEFCALL_RUNANDDEL;
}
}
}
}
}
}
for (i = 0; i < MAX_TIMERS; i++) {
if (timer[i].toBeCalled == DEFCALL_DONTRUN)
continue;
if (timer[i].hasParam)
(*(timer_callback_p)timer[i].callback)(timer[i].param);
else
(*(timer_callback)timer[i].callback)();
if (timer[i].toBeCalled == DEFCALL_RUNANDDEL)
deleteTimer(i);
}
}
// find the first available slot
// return -1 if none found
int SimpleTimer::findFirstFreeSlot() {
// all slots are used
if (numTimers >= MAX_TIMERS) {
return -1;
}
// return the first slot with no callback (i.e. free)
for (int i = 0; i < MAX_TIMERS; i++) {
if (timer[i].callback == NULL) {
return i;
}
}
// no free slots found
return -1;
}
int SimpleTimer::setupTimer(unsigned long d, void* f, void* p, bool h, unsigned n) {
int freeTimer;
if (numTimers < 0) {
init();
}
freeTimer = findFirstFreeSlot();
if (freeTimer < 0) {
return -1;
}
if (f == NULL) {
return -1;
}
timer[freeTimer].delay = d;
timer[freeTimer].callback = f;
timer[freeTimer].param = p;
timer[freeTimer].hasParam = h;
timer[freeTimer].maxNumRuns = n;
timer[freeTimer].enabled = true;
timer[freeTimer].prev_millis = elapsed();
numTimers++;
return freeTimer;
}
int SimpleTimer::setTimer(unsigned long d, timer_callback f, unsigned n) {
return setupTimer(d, (void *)f, NULL, false, n);
}
int SimpleTimer::setTimer(unsigned long d, timer_callback_p f, void* p, unsigned n) {
return setupTimer(d, (void *)f, p, true, n);
}
int SimpleTimer::setInterval(unsigned long d, timer_callback f) {
return setupTimer(d, (void *)f, NULL, false, RUN_FOREVER);
}
int SimpleTimer::setInterval(unsigned long d, timer_callback_p f, void* p) {
return setupTimer(d, (void *)f, p, true, RUN_FOREVER);
}
int SimpleTimer::setTimeout(unsigned long d, timer_callback f) {
return setupTimer(d, (void *)f, NULL, false, RUN_ONCE);
}
int SimpleTimer::setTimeout(unsigned long d, timer_callback_p f, void* p) {
return setupTimer(d, (void *)f, p, true, RUN_ONCE);
}
bool SimpleTimer::changeInterval(unsigned numTimer, unsigned long d) {
if (numTimer >= MAX_TIMERS) {
return false;
}
// Updates interval of existing specified timer
if (timer[numTimer].callback != NULL) {
timer[numTimer].delay = d;
timer[numTimer].prev_millis = elapsed();
return true;
}
// false return for non-used numTimer, no callback
return false;
}
void SimpleTimer::deleteTimer(unsigned timerId) {
if (timerId >= MAX_TIMERS) {
return;
}
// nothing to delete if no timers are in use
if (numTimers == 0) {
return;
}
// don't decrease the number of timers if the
// specified slot is already empty
if (timer[timerId].callback != NULL) {
memset(&timer[timerId], 0, sizeof (timer_t));
timer[timerId].prev_millis = elapsed();
// update number of timers
numTimers--;
}
}
// function contributed by code@rowansimms.com
void SimpleTimer::restartTimer(unsigned numTimer) {
if (numTimer >= MAX_TIMERS) {
return;
}
timer[numTimer].prev_millis = elapsed();
}
bool SimpleTimer::isEnabled(unsigned numTimer) {
if (numTimer >= MAX_TIMERS) {
return false;
}
return timer[numTimer].enabled;
}
void SimpleTimer::enable(unsigned numTimer) {
if (numTimer >= MAX_TIMERS) {
return;
}
timer[numTimer].enabled = true;
}
void SimpleTimer::disable(unsigned numTimer) {
if (numTimer >= MAX_TIMERS) {
return;
}
timer[numTimer].enabled = false;
}
void SimpleTimer::enableAll() {
// Enable all timers with a callback assigned (used)
for (int i = 0; i < MAX_TIMERS; i++) {
if (timer[i].callback != NULL && timer[i].numRuns == RUN_FOREVER) {
timer[i].enabled = true;
}
}
}
void SimpleTimer::disableAll() {
// Disable all timers with a callback assigned (used)
for (int i = 0; i < MAX_TIMERS; i++) {
if (timer[i].callback != NULL && timer[i].numRuns == RUN_FOREVER) {
timer[i].enabled = false;
}
}
}
void SimpleTimer::toggle(unsigned numTimer) {
if (numTimer >= MAX_TIMERS) {
return;
}
timer[numTimer].enabled = !timer[numTimer].enabled;
}
unsigned SimpleTimer::getNumTimers() {
return numTimers;
}

View File

@@ -0,0 +1,155 @@
/*
* SimpleTimer.h
*
* SimpleTimer - A timer library for Arduino.
* Author: mromani@ottotecnica.com
* Copyright (c) 2010 OTTOTECNICA Italy
*
* Modifications by Bill Knight <billk@rosw.com> 18March2017
*
* 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 BLYNKTIMER_H
#define BLYNKTIMER_H
#include "BlynkDebug.h"
// Replace SimpleTimer
#define SIMPLETIMER_H
#define SimpleTimer BlynkTimer
typedef void (*timer_callback)(void);
typedef void (*timer_callback_p)(void *);
class SimpleTimer {
public:
// maximum number of timers
const static int MAX_TIMERS = 16;
// setTimer() constants
const static int RUN_FOREVER = 0;
const static int RUN_ONCE = 1;
// constructor
SimpleTimer();
void init();
// this function must be called inside loop()
void run();
// Timer will call function 'f' every 'd' milliseconds forever
// returns the timer number (numTimer) on success or
// -1 on failure (f == NULL) or no free timers
int setInterval(unsigned long d, timer_callback f);
// Timer will call function 'f' with parameter 'p' every 'd' milliseconds forever
// returns the timer number (numTimer) on success or
// -1 on failure (f == NULL) or no free timers
int setInterval(unsigned long d, timer_callback_p f, void* p);
// Timer will call function 'f' after 'd' milliseconds one time
// returns the timer number (numTimer) on success or
// -1 on failure (f == NULL) or no free timers
int setTimeout(unsigned long d, timer_callback f);
// Timer will call function 'f' with parameter 'p' after 'd' milliseconds one time
// returns the timer number (numTimer) on success or
// -1 on failure (f == NULL) or no free timers
int setTimeout(unsigned long d, timer_callback_p f, void* p);
// Timer will call function 'f' every 'd' milliseconds 'n' times
// returns the timer number (numTimer) on success or
// -1 on failure (f == NULL) or no free timers
int setTimer(unsigned long d, timer_callback f, unsigned n);
// Timer will call function 'f' with parameter 'p' every 'd' milliseconds 'n' times
// returns the timer number (numTimer) on success or
// -1 on failure (f == NULL) or no free timers
int setTimer(unsigned long d, timer_callback_p f, void* p, unsigned n);
// updates interval of the specified timer
bool changeInterval(unsigned numTimer, unsigned long d);
// destroy the specified timer
void deleteTimer(unsigned numTimer);
// restart the specified timer
void restartTimer(unsigned numTimer);
// returns true if the specified timer is enabled
bool isEnabled(unsigned numTimer);
// enables the specified timer
void enable(unsigned numTimer);
// disables the specified timer
void disable(unsigned numTimer);
// enables all timers
void enableAll();
// disables all timers
void disableAll();
// enables the specified timer if it's currently disabled,
// and vice-versa
void toggle(unsigned numTimer);
// returns the number of used timers
unsigned getNumTimers();
// returns the number of available timers
unsigned getNumAvailableTimers() { return MAX_TIMERS - numTimers; };
private:
// deferred call constants
const static int DEFCALL_DONTRUN = 0; // don't call the callback function
const static int DEFCALL_RUNONLY = 1; // call the callback function but don't delete the timer
const static int DEFCALL_RUNANDDEL = 2; // call the callback function and delete the timer
// low level function to initialize and enable a new timer
// returns the timer number (numTimer) on success or
// -1 on failure (f == NULL) or no free timers
int setupTimer(unsigned long d, void* f, void* p, bool h, unsigned n);
// find the first available slot
int findFirstFreeSlot();
typedef struct {
unsigned long prev_millis; // value returned by the millis() function in the previous run() call
void* callback; // pointer to the callback function
void* param; // function parameter
bool hasParam; // true if callback takes a parameter
unsigned long delay; // delay value
unsigned maxNumRuns; // number of runs to be executed
unsigned numRuns; // number of executed runs
bool enabled; // true if enabled
unsigned toBeCalled; // deferred function call (sort of) - N.B.: only used in run()
} timer_t;
timer_t timer[MAX_TIMERS];
// actual number of timers in use (-1 means uninitialized)
int numTimers;
};
#endif

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