mirror of
https://github.com/anklimov/lighthub
synced 2025-12-06 19:59:50 +03:00
Compare commits
96 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e4cf5a45a5 | |||
| 56a0360823 | |||
| 9d15f7ad9b | |||
| f650b830d7 | |||
| 7b9c474c19 | |||
| 08f251bc63 | |||
| ff6816b2e1 | |||
| c7bed971ba | |||
| d1d62515b6 | |||
| 054ac6a206 | |||
| d5e9686ca9 | |||
| 504280ca84 | |||
| 24bf7316a9 | |||
| 75b08441f7 | |||
| e0a6ac9ff0 | |||
| 9e9a3c6e7e | |||
| cc96e4697e | |||
| 7dd48f78d4 | |||
| 602a997757 | |||
| d0537484c5 | |||
| cacd9eab27 | |||
| 5a06d221c8 | |||
| 0044b741ac | |||
| 951d0d4383 | |||
| 8a3980272e | |||
| b02edbda5e | |||
| f57d47dc2b | |||
| a3e0e70aec | |||
| c947c8bb4c | |||
| 23167b4f1c | |||
| b779fd0fac | |||
| 86b19d081d | |||
| 26e8fed4e1 | |||
| 78e1562b48 | |||
| 9ce0a84208 | |||
| 99b2456f82 | |||
| 9cd0d924bb | |||
| 0841c2b06f | |||
| 9356fa70c5 | |||
| 77701e541c | |||
| c8561c8071 | |||
| d7fda3b89e | |||
| 8ddd8f1313 | |||
| 668f0118b0 | |||
| a80509af34 | |||
| 8a649272e0 | |||
| 8699f496d6 | |||
| 0d3b260bd5 | |||
| d2915e9ad9 | |||
| 0fbf9f0849 | |||
| 88d9c262af | |||
| 7c9d9d171b | |||
| e487db022a | |||
| 9b413cd9bb | |||
| 862f4bc0d3 | |||
| 9a0cff1f63 | |||
| 21c09b2588 | |||
| f900f897b7 | |||
| 3fae70bd61 | |||
| 206355b3ec | |||
| 4b1be34561 | |||
| 549bd6527c | |||
| 90965aad85 | |||
| a001bd9e35 | |||
| 209cba2352 | |||
| 1e06556fe5 | |||
| 94810689c2 | |||
| 64588b6c5a | |||
| fa1127190c | |||
| fb64394571 | |||
| a24e56e941 | |||
| 91a3aeb206 | |||
| cc0a679613 | |||
| 5c4b1512bb | |||
| c78891a423 | |||
| 088a4b0397 | |||
| 5540b6ae4d | |||
| bb318d6a96 | |||
| 07349f3586 | |||
| 6c0c3ce77e | |||
| 4efe3af7bb | |||
| 8aec09fe76 | |||
| 1919d3c210 | |||
| ea67d46810 | |||
| e6f8e3f9d0 | |||
| 3542ba1a6a | |||
| 719908d7ff | |||
| d7e4181377 | |||
| 1214e306ea | |||
| ae868f42d6 | |||
| a19ee7bc51 | |||
| 21b93f4065 | |||
| 902b2768fb | |||
| dff2f43e41 | |||
| 3b1f1e7b9e | |||
| 5a99efa0c2 |
22
.gitignore
vendored
22
.gitignore
vendored
@@ -6,12 +6,16 @@
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
CMakeListsPrivate.txt
|
CMakeListsPrivate.txt
|
||||||
custom-build-flags/*
|
custom-build-flags/*
|
||||||
build_flags_due.sh
|
custom-build-flags/build_flags_due
|
||||||
build_flags_esp32.sh
|
custom-build-flags/build_flags_esp32
|
||||||
build_flags_esp8266.sh
|
custom-build-flags/build_flags_esp8266
|
||||||
build_flags_stm32.sh
|
custom-build-flags/build_flags_stm32
|
||||||
build_flags_due-5500.sh
|
custom-build-flags/build_flags_due-5500
|
||||||
build_flags_mega2560.sh
|
custom-build-flags/build_flags_mega2560
|
||||||
build_flags_mega2560-net.sh
|
custom-build-flags/build_flags_mega2560-net
|
||||||
build_flags_controllino.sh
|
custom-build-flags/build_flags_controllino
|
||||||
build_flags_nrf52840.sh
|
custom-build-flags/build_flags_nrf52840
|
||||||
|
.vscode/*
|
||||||
|
.vscode/.browse.c_cpp.db
|
||||||
|
.vscode/c_cpp_properties.json
|
||||||
|
.vscode/launch.json
|
||||||
|
|||||||
BIN
.vscode/.browse.c_cpp.db
vendored
BIN
.vscode/.browse.c_cpp.db
vendored
Binary file not shown.
4
.vscode/arduino.json
vendored
4
.vscode/arduino.json
vendored
@@ -1,4 +0,0 @@
|
|||||||
{
|
|
||||||
"board": "arduino:sam:arduino_due_x",
|
|
||||||
"port": "/dev/cu.usbmodem1411"
|
|
||||||
}
|
|
||||||
108
.vscode/c_cpp_properties.json
vendored
108
.vscode/c_cpp_properties.json
vendored
@@ -1,108 +0,0 @@
|
|||||||
{
|
|
||||||
"!!! WARNING !!!": "PLEASE DO NOT MODIFY THIS FILE! USE https://docs.platformio.org/page/projectconf/section_env_build.html#build-flags",
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"name": "Mac",
|
|
||||||
"macFrameworkPath": [],
|
|
||||||
"includePath": [
|
|
||||||
"/Users/andrey/Library/Arduino15/packages/arduino/tools/**",
|
|
||||||
"/Users/andrey/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/**",
|
|
||||||
"/Users/andrey/.platformio/packages/framework-arduinosam/cores/sam",
|
|
||||||
"/Users/andrey/.platformio/packages/framework-arduinosam/system/sam/libsam",
|
|
||||||
"/Users/andrey/.platformio/packages/framework-arduinosam/system/sam/CMSIS/CMSIS/Include",
|
|
||||||
"/Users/andrey/.platformio/packages/framework-arduinosam/system/sam/CMSIS/Device/ATMEL",
|
|
||||||
"/Users/andrey/.platformio/packages/framework-arduinosam/variants/arduino_due_x",
|
|
||||||
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/Adafruit Unified Sensor_ID31",
|
|
||||||
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/ArduinoHttpClient/src",
|
|
||||||
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/Artnet",
|
|
||||||
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/CmdArduino",
|
|
||||||
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/DHT sensor library_ID19",
|
|
||||||
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/DS2482_OneWire",
|
|
||||||
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/DallasTemperature",
|
|
||||||
"/Users/andrey/.platformio/packages/framework-arduinosam/libraries/__cores__/sam/Wire/src",
|
|
||||||
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/DmxDue",
|
|
||||||
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/DueFlashStorage/src",
|
|
||||||
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/Ethernet2/src",
|
|
||||||
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/FastLED_ID126",
|
|
||||||
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/ModbusMaster/src",
|
|
||||||
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/PrintEx/src",
|
|
||||||
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/PubSubClient/src",
|
|
||||||
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/SD_ID161",
|
|
||||||
"/Users/andrey/.platformio/packages/framework-arduinosam/libraries/__cores__/sam/SPI/src",
|
|
||||||
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/SdFat_ID322/src",
|
|
||||||
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/Streaming_ID560",
|
|
||||||
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/Syslog/src",
|
|
||||||
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/aJson",
|
|
||||||
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/Ethernet2_ID261/src",
|
|
||||||
"/Users/andrey/.platformio/packages/framework-arduinosam/libraries/__cores__/sam/HID/src",
|
|
||||||
"/Users/andrey/.platformio/packages/tool-unity",
|
|
||||||
"/Users/andrey/Documents/Arduino/lighthub/include",
|
|
||||||
"/Users/andrey/Documents/Arduino/lighthub/lighthub",
|
|
||||||
""
|
|
||||||
],
|
|
||||||
"browse": {
|
|
||||||
"limitSymbolsToIncludedHeaders": true,
|
|
||||||
"databaseFilename": "${workspaceRoot}/.vscode/.browse.c_cpp.db",
|
|
||||||
"path": [
|
|
||||||
"/Users/andrey/.platformio/packages/framework-arduinosam/cores/sam",
|
|
||||||
"/Users/andrey/.platformio/packages/framework-arduinosam/system/sam/libsam",
|
|
||||||
"/Users/andrey/.platformio/packages/framework-arduinosam/system/sam/CMSIS/CMSIS/Include",
|
|
||||||
"/Users/andrey/.platformio/packages/framework-arduinosam/system/sam/CMSIS/Device/ATMEL",
|
|
||||||
"/Users/andrey/.platformio/packages/framework-arduinosam/variants/arduino_due_x",
|
|
||||||
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/Adafruit Unified Sensor_ID31",
|
|
||||||
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/ArduinoHttpClient/src",
|
|
||||||
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/Artnet",
|
|
||||||
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/CmdArduino",
|
|
||||||
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/DHT sensor library_ID19",
|
|
||||||
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/DS2482_OneWire",
|
|
||||||
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/DallasTemperature",
|
|
||||||
"/Users/andrey/.platformio/packages/framework-arduinosam/libraries/__cores__/sam/Wire/src",
|
|
||||||
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/DmxDue",
|
|
||||||
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/DueFlashStorage/src",
|
|
||||||
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/Ethernet2/src",
|
|
||||||
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/FastLED_ID126",
|
|
||||||
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/ModbusMaster/src",
|
|
||||||
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/PrintEx/src",
|
|
||||||
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/PubSubClient/src",
|
|
||||||
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/SD_ID161",
|
|
||||||
"/Users/andrey/.platformio/packages/framework-arduinosam/libraries/__cores__/sam/SPI/src",
|
|
||||||
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/SdFat_ID322/src",
|
|
||||||
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/Streaming_ID560",
|
|
||||||
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/Syslog/src",
|
|
||||||
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/aJson",
|
|
||||||
"/Users/andrey/Documents/Arduino/lighthub/.piolibdeps/Ethernet2_ID261/src",
|
|
||||||
"/Users/andrey/.platformio/packages/framework-arduinosam/libraries/__cores__/sam/HID/src",
|
|
||||||
"/Users/andrey/.platformio/packages/tool-unity",
|
|
||||||
"/Users/andrey/Documents/Arduino/lighthub/include",
|
|
||||||
"/Users/andrey/Documents/Arduino/lighthub/lighthub",
|
|
||||||
""
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"defines": [
|
|
||||||
"PLATFORMIO=40000",
|
|
||||||
"__SAM3X8E__",
|
|
||||||
"ARDUINO_ARCH_SAM",
|
|
||||||
"ARDUINO_SAM_DUE",
|
|
||||||
"Wiz5500",
|
|
||||||
"ARTNET_ENABLE",
|
|
||||||
"F_CPU=84000000L",
|
|
||||||
"USBCON",
|
|
||||||
"ARDUINO=10805",
|
|
||||||
"USB_VID=0x2341",
|
|
||||||
"USB_PID=0x003E",
|
|
||||||
"USB_PRODUCT=\"Arduino Due\"",
|
|
||||||
"USB_MANUFACTURER=\"Arduino\"",
|
|
||||||
"printf=iprintf",
|
|
||||||
""
|
|
||||||
],
|
|
||||||
"intelliSenseMode": "clang-x64",
|
|
||||||
"cStandard": "c11",
|
|
||||||
"cppStandard": "c++11",
|
|
||||||
"compilerPath": "/Users/andrey/.platformio/packages/toolchain-gccarmnoneeabi@1.40804.0/bin/arm-none-eabi-gcc -mthumb -mcpu=cortex-m3",
|
|
||||||
"forcedInclude": [
|
|
||||||
"/Users/andrey/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/cores/arduino/Arduino.h"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"version": 4
|
|
||||||
}
|
|
||||||
7
.vscode/extensions.json
vendored
7
.vscode/extensions.json
vendored
@@ -1,7 +0,0 @@
|
|||||||
{
|
|
||||||
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
|
||||||
// for the documentation about the extensions.json format
|
|
||||||
"recommendations": [
|
|
||||||
"platformio.platformio-ide"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
34
.vscode/launch.json
vendored
34
.vscode/launch.json
vendored
@@ -1,34 +0,0 @@
|
|||||||
// AUTOMATICALLY GENERATED FILE. PLEASE DO NOT MODIFY IT MANUALLY
|
|
||||||
|
|
||||||
// PIO Unified Debugger
|
|
||||||
//
|
|
||||||
// Documentation: https://docs.platformio.org/page/plus/debugging.html
|
|
||||||
// Configuration: https://docs.platformio.org/page/projectconf/section_env_debug.html
|
|
||||||
|
|
||||||
{
|
|
||||||
"version": "0.2.0",
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"type": "platformio-debug",
|
|
||||||
"request": "launch",
|
|
||||||
"name": "PIO Debug",
|
|
||||||
"executable": "/Users/andrey/Documents/Arduino/lighthub/.pioenvs/due-5500/firmware.elf",
|
|
||||||
"toolchainBinDir": "/Users/andrey/.platformio/packages/toolchain-gccarmnoneeabi@1.40804.0/bin",
|
|
||||||
"svdPath": "/Users/andrey/.platformio/platforms/atmelsam/misc/svd/ATSAM3X8E.svd",
|
|
||||||
"preLaunchTask": {
|
|
||||||
"type": "PlatformIO",
|
|
||||||
"task": "Pre-Debug"
|
|
||||||
},
|
|
||||||
"internalConsoleOptions": "openOnSessionStart"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "platformio-debug",
|
|
||||||
"request": "launch",
|
|
||||||
"name": "PIO Debug (skip Pre-Debug)",
|
|
||||||
"executable": "/Users/andrey/Documents/Arduino/lighthub/.pioenvs/due-5500/firmware.elf",
|
|
||||||
"toolchainBinDir": "/Users/andrey/.platformio/packages/toolchain-gccarmnoneeabi@1.40804.0/bin",
|
|
||||||
"svdPath": "/Users/andrey/.platformio/platforms/atmelsam/misc/svd/ATSAM3X8E.svd",
|
|
||||||
"internalConsoleOptions": "openOnSessionStart"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
6
.vscode/settings.json
vendored
6
.vscode/settings.json
vendored
@@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"terminal.integrated.env.osx": {
|
|
||||||
"PATH": "/Users/andrey/.platformio/penv/bin:/Users/andrey/.platformio/penv:/usr/local/opt/ruby/bin:/usr/local/opt/python@2/bin:/opt/local/sbin:/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Applications/Wireshark.app/Contents/MacOS",
|
|
||||||
"PLATFORMIO_CALLER": "vscode"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
2
build-flags/build_flags_controllino
Normal file
2
build-flags/build_flags_controllino
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
-DCONTROLLINO
|
||||||
|
-DCUSTOM_FIRMWARE_MAC=de:ad:be:ef:fe:07
|
||||||
1
build-flags/build_flags_due-5100
Normal file
1
build-flags/build_flags_due-5100
Normal file
@@ -0,0 +1 @@
|
|||||||
|
#NO special flags
|
||||||
3
build-flags/build_flags_due-5500
Normal file
3
build-flags/build_flags_due-5500
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
-DWiz5500
|
||||||
|
-DARTNET_ENABLE
|
||||||
|
-DDMX_SMOOTH
|
||||||
9
build-flags/build_flags_esp32-wifi
Normal file
9
build-flags/build_flags_esp32-wifi
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
-DDMX_DISABLE
|
||||||
|
-DMODBUS_DISABLE
|
||||||
|
-DOWIRE_DISABLE
|
||||||
|
-DDHT_DISABLE
|
||||||
|
-DCOUNTER_DISABLE
|
||||||
|
-DSPILED_DISABLE
|
||||||
|
-DAC_DISABLE
|
||||||
|
#-DM5STACK
|
||||||
|
-DOTA
|
||||||
4
build-flags/build_flags_esp8266-wifi
Normal file
4
build-flags/build_flags_esp8266-wifi
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
-DMODBUS_DISABLE
|
||||||
|
#-DCOUNTER_DISABLE
|
||||||
|
-DOTA
|
||||||
|
-std=gnu++11
|
||||||
6
build-flags/build_flags_lighthub21
Normal file
6
build-flags/build_flags_lighthub21
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
-DWiz5500
|
||||||
|
-DW5500_CS_PIN=53
|
||||||
|
-DARTNET_ENABLE
|
||||||
|
-DDMX_SMOOTH
|
||||||
|
-DMODBUS_DIMMER_PARAM=SERIAL_8N1
|
||||||
|
-DMODBUS_SERIAL_BAUD=9600
|
||||||
8
build-flags/build_flags_m5stack
Normal file
8
build-flags/build_flags_m5stack
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
-DDMX_DISABLE
|
||||||
|
-DMODBUS_DISABLE
|
||||||
|
-DOWIRE_DISABLE
|
||||||
|
-DDHT_DISABLE
|
||||||
|
-DCOUNTER_DISABLE
|
||||||
|
-DSPILED_DISABLE
|
||||||
|
-DAC_DISABLE
|
||||||
|
-DM5STACK
|
||||||
2
build-flags/build_flags_mega2560-5100
Normal file
2
build-flags/build_flags_mega2560-5100
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
-DMODBUS_DIMMER_PARAM=SERIAL_8E1
|
||||||
|
-DAVR_DMXOUT_PIN=18
|
||||||
3
build-flags/build_flags_mega2560-5500
Normal file
3
build-flags/build_flags_mega2560-5500
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
-DWiz5500
|
||||||
|
-DMODBUS_DIMMER_PARAM=SERIAL_8E1
|
||||||
|
-DAVR_DMXOUT_PIN=18
|
||||||
2
build-flags/build_flags_mega2560-slim-5100
Normal file
2
build-flags/build_flags_mega2560-slim-5100
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
-DMODBUS_DIMMER_PARAM=SERIAL_8E1
|
||||||
|
-DAVR_DMXOUT_PIN=18
|
||||||
11
build-flags/build_flags_nrf52840-5500
Normal file
11
build-flags/build_flags_nrf52840-5500
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
-DWiz5500
|
||||||
|
#-DW5500_CS_PIN=10
|
||||||
|
-DDMX_DISABLE
|
||||||
|
-DMODBUS_DISABLE
|
||||||
|
#-DOWIRE_DISABLE
|
||||||
|
-std=gnu++11
|
||||||
|
-DWIFI_MANAGER_DISABLE
|
||||||
|
-DCOUNTER_DISABLE
|
||||||
|
-DCSSHDC_DISABLE
|
||||||
|
-DSPILED_DISABLE
|
||||||
|
-DAC_DISABLE
|
||||||
9
build-flags/build_flags_stm32-enc2860
Normal file
9
build-flags/build_flags_stm32-enc2860
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
-DDMX_DISABLE
|
||||||
|
-DMODBUS_DISABLE
|
||||||
|
-DOWIRE_DISABLE
|
||||||
|
-DDHT_DISABLE
|
||||||
|
-DCOUNTER_DISABLE
|
||||||
|
-DNO_HOMIE
|
||||||
|
-DCSSHDC_DISABLE
|
||||||
|
-DSPILED_DISABLE
|
||||||
|
-DAC_DISABLE
|
||||||
33
build-flags/build_flags_template
Normal file
33
build-flags/build_flags_template
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
|
||||||
|
# usage:
|
||||||
|
# first make your own copy of template
|
||||||
|
# cp build_flags_template build_flags_ENVNAME
|
||||||
|
# then edit, change or comment something
|
||||||
|
# place to custom-build-flags dir if you would like have your own private settings
|
||||||
|
# -DMY_CONFIG_SERVER=lazyhome.ru
|
||||||
|
# -DWATCH_DOG_TICKER_DISABLE
|
||||||
|
# -DUSE_1W_PIN=12
|
||||||
|
# -DSD_CARD_INSERTED
|
||||||
|
# -DSERIAL_BAUD=115200
|
||||||
|
# -DWiz5500
|
||||||
|
# -DDISABLE_FREERAM_PRINT
|
||||||
|
# -DCUSTOM_FIRMWARE_MAC=de:ad:be:ef:fe:ff
|
||||||
|
# -DDMX_DISABLE
|
||||||
|
# -DMODBUS_DISABLE
|
||||||
|
# -DOWIRE_DISABLE
|
||||||
|
# -DAVR_DMXOUT_PIN=18
|
||||||
|
# -DLAN_INIT_DELAY=2000
|
||||||
|
# -DCONTROLLINO
|
||||||
|
# -DESP_WIFI_AP=MYAP
|
||||||
|
# -DESP_WIFI_PWD=MYPWD
|
||||||
|
# -DWIFI_MANAGER_DISABLE
|
||||||
|
# -DRESET_PIN=5
|
||||||
|
# -DDHCP_RETRY_INTERVAL=60000
|
||||||
|
# -DRESTART_LAN_ON_MQTT_ERRORS
|
||||||
|
# -DW5500_CS_PIN=53
|
||||||
|
# -DSYSLOG_ENABLE
|
||||||
|
# -DDEVICE_NAME=MYDEVICE
|
||||||
|
# -DDHT_DISABLE
|
||||||
|
# -DCOUNTER_DISABLE
|
||||||
|
# -DWITH_PRINTEX_LIB
|
||||||
|
# -DCSSHDC_DISABLE
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
#! /bin/bash
|
|
||||||
# usage:
|
|
||||||
# first make your own copy of template
|
|
||||||
# cp build_flags_template.sh build_flags_ENVNAME.sh
|
|
||||||
# then edit, change or comment something
|
|
||||||
export FLAGS="-DMY_CONFIG_SERVER=lazyhome.ru"
|
|
||||||
#export FLAGS="$FLAGS -DWATCH_DOG_TICKER_DISABLE"
|
|
||||||
#export FLAGS="$FLAGS -DUSE_1W_PIN=12"
|
|
||||||
#export FLAGS="$FLAGS -DSD_CARD_INSERTED"
|
|
||||||
export FLAGS="$FLAGS -DSERIAL_BAUD=115200"
|
|
||||||
#export FLAGS="$FLAGS -DWiz5500"
|
|
||||||
#export FLAGS="$FLAGS -DDISABLE_FREERAM_PRINT"
|
|
||||||
export FLAGS="$FLAGS -DCUSTOM_FIRMWARE_MAC=de:ad:be:ef:fe:fe"
|
|
||||||
# export FLAGS="$FLAGS -DDMX_DISABLE"
|
|
||||||
# export FLAGS="$FLAGS -DARTNET_ENABLE"
|
|
||||||
# export FLAGS="$FLAGS -DMODBUS_DISABLE"
|
|
||||||
# export FLAGS="$FLAGS -DOWIRE_DISABLE"
|
|
||||||
# export FLAGS="$FLAGS -DAVR_DMXOUT_PIN=18"
|
|
||||||
# export FLAGS="$FLAGS -DLAN_INIT_DELAY=2000"
|
|
||||||
# export FLAGS="$FLAGS -DCONTROLLINO"
|
|
||||||
# export FLAGS="$FLAGS -DESP_WIFI_AP=MYAP"
|
|
||||||
# export FLAGS="$FLAGS -DESP_WIFI_PWD=MYPWD"
|
|
||||||
# export FLAGS="$FLAGS -DWIFI_MANAGER_DISABLE"
|
|
||||||
export FLAGS="$FLAGS -DDHT_DISABLE"
|
|
||||||
# export FLAGS="$FLAGS -DRESET_PIN=5"
|
|
||||||
# export FLAGS="$FLAGS -DDHCP_RETRY_INTERVAL=60000"
|
|
||||||
# export FLAGS="$FLAGS -DRESTART_LAN_ON_MQTT_ERRORS"
|
|
||||||
# export FLAGS="$FLAGS -DW5500_CS_PIN=53"
|
|
||||||
export FLAGS="$FLAGS -DPIO_SRC_REV="$(git log --pretty=format:%h_%ad -1 --date=short)
|
|
||||||
echo $FLAGS
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
#! /bin/bash
|
|
||||||
export FLAGS="$FLAGS -DCONTROLLINO"
|
|
||||||
export FLAGS="$FLAGS -DCUSTOM_FIRMWARE_MAC=de:ad:be:ef:fe:07"
|
|
||||||
export FLAGS="$FLAGS -DPIO_SRC_REV="$(git log --pretty=format:%h_%ad -1 --date=short)
|
|
||||||
CUSTOM_BUILD_FLAGS_FILE=custom-build-flags/build_flags_controllino.sh
|
|
||||||
if [ -f $CUSTOM_BUILD_FLAGS_FILE ]; then
|
|
||||||
source $CUSTOM_BUILD_FLAGS_FILE
|
|
||||||
fi
|
|
||||||
echo $FLAGS
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
#! /bin/bash
|
|
||||||
export FLAGS="$FLAGS -DWiz5500"
|
|
||||||
export FLAGS="$FLAGS -DARTNET_ENABLE"
|
|
||||||
export FLAGS="$FLAGS -DPIO_SRC_REV="$(git log --pretty=format:%h_%ad -1 --date=short)
|
|
||||||
CUSTOM_BUILD_FLAGS_FILE=custom-build-flags/build_flags_due-5500.sh
|
|
||||||
if [ -f $CUSTOM_BUILD_FLAGS_FILE ]; then
|
|
||||||
source $CUSTOM_BUILD_FLAGS_FILE
|
|
||||||
fi
|
|
||||||
echo $FLAGS
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
#! /bin/bash
|
|
||||||
export FLAGS="$FLAGS -DPIO_SRC_REV="$(git log --pretty=format:%h_%ad -1 --date=short)
|
|
||||||
CUSTOM_BUILD_FLAGS_FILE=custom-build-flags/build_flags_due.sh
|
|
||||||
if [ -f $CUSTOM_BUILD_FLAGS_FILE ]; then
|
|
||||||
source $CUSTOM_BUILD_FLAGS_FILE
|
|
||||||
fi
|
|
||||||
echo $FLAGS
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
#! /bin/bash
|
|
||||||
export FLAGS="$FLAGS -DPIO_SRC_REV="$(git log --pretty=format:%h_%ad -1 --date=short)
|
|
||||||
export FLAGS="$FLAGS -DDMX_DISABLE"
|
|
||||||
export FLAGS="$FLAGS -DMODBUS_DISABLE"
|
|
||||||
export FLAGS="$FLAGS -DOWIRE_DISABLE"
|
|
||||||
export FLAGS="$FLAGS -DDHT_DISABLE"
|
|
||||||
export FLAGS="$FLAGS -DCOUNTER_DISABLE"
|
|
||||||
#export FLAGS="$FLAGS -DM5STACK"
|
|
||||||
#export FLAGS="$FLAGS -std=gnu++11"
|
|
||||||
CUSTOM_BUILD_FLAGS_FILE=custom-build-flags/build_flags_esp32.sh
|
|
||||||
if [ -f $CUSTOM_BUILD_FLAGS_FILE ]; then
|
|
||||||
source $CUSTOM_BUILD_FLAGS_FILE
|
|
||||||
fi
|
|
||||||
echo $FLAGS
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
#! /bin/bash
|
|
||||||
export FLAGS="$FLAGS -DMODBUS_DISABLE"
|
|
||||||
#export FLAGS="$FLAGS -DCOUNTER_DISABLE"
|
|
||||||
export FLAGS="$FLAGS -DPIO_SRC_REV="$(git log --pretty=format:%h_%ad -1 --date=short)
|
|
||||||
CUSTOM_BUILD_FLAGS_FILE=custom-build-flags/build_flags_esp8266.sh
|
|
||||||
if [ -f $CUSTOM_BUILD_FLAGS_FILE ]; then
|
|
||||||
source $CUSTOM_BUILD_FLAGS_FILE
|
|
||||||
fi
|
|
||||||
echo $FLAGS
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
#! /bin/bash
|
|
||||||
export FLAGS="$FLAGS -DWiz5500"
|
|
||||||
export FLAGS="$FLAGS -DW5500_CS_PIN=53"
|
|
||||||
export FLAGS="$FLAGS -DARTNET_ENABLE"
|
|
||||||
export FLAGS="$FLAGS -DPIO_SRC_REV="$(git log --pretty=format:%h_%ad -1 --date=short)
|
|
||||||
CUSTOM_BUILD_FLAGS_FILE=custom-build-flags/build_flags_due-5500.sh
|
|
||||||
if [ -f $CUSTOM_BUILD_FLAGS_FILE ]; then
|
|
||||||
source $CUSTOM_BUILD_FLAGS_FILE
|
|
||||||
fi
|
|
||||||
echo $FLAGS
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
#! /bin/bash
|
|
||||||
CUSTOM_BUILD_FLAGS_FILE="custom-build-flags/build_flags_mega2560.sh"
|
|
||||||
export FLAGS="$FLAGS -DPIO_SRC_REV="$(git log --pretty=format:%h_%ad -1 --date=short)
|
|
||||||
export FLAGS="$FLAGS -DWiz5500"
|
|
||||||
#TODO: make one file for all envs
|
|
||||||
if [ -f $CUSTOM_BUILD_FLAGS_FILE ]; then
|
|
||||||
source $CUSTOM_BUILD_FLAGS_FILE
|
|
||||||
fi
|
|
||||||
echo $FLAGS
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
#! /bin/bash
|
|
||||||
CUSTOM_BUILD_FLAGS_FILE="custom-build-flags/build_flags_mega2560-slim.sh"
|
|
||||||
export FLAGS="$FLAGS -DPIO_SRC_REV="$(git log --pretty=format:%h_%ad -1 --date=short)
|
|
||||||
#TODO: make one file for all envs
|
|
||||||
if [ -f $CUSTOM_BUILD_FLAGS_FILE ]; then
|
|
||||||
source $CUSTOM_BUILD_FLAGS_FILE
|
|
||||||
fi
|
|
||||||
echo $FLAGS
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
#! /bin/bash
|
|
||||||
CUSTOM_BUILD_FLAGS_FILE=custom-build-flags/build_flags_mega2560.sh
|
|
||||||
export FLAGS="$FLAGS -DPIO_SRC_REV="$(git log --pretty=format:%h_%ad -1 --date=short)
|
|
||||||
if [ -f $CUSTOM_BUILD_FLAGS_FILE ]; then
|
|
||||||
source $CUSTOM_BUILD_FLAGS_FILE
|
|
||||||
fi
|
|
||||||
echo $FLAGS
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
#! /bin/bash
|
|
||||||
export FLAGS="$FLAGS -DWiz5500"
|
|
||||||
#export FLAGS="$FLAGS -DW5500_CS_PIN=10"
|
|
||||||
export FLAGS="$FLAGS -DPIO_SRC_REV="$(git log --pretty=format:%h_%ad -1 --date=short)
|
|
||||||
export FLAGS="$FLAGS -DDMX_DISABLE"
|
|
||||||
export FLAGS="$FLAGS -DMODBUS_DISABLE"
|
|
||||||
#export FLAGS="$FLAGS -DOWIRE_DISABLE"
|
|
||||||
export FLAGS="$FLAGS -std=gnu++11"
|
|
||||||
export FLAGS="$FLAGS -DWIFI_MANAGER_DISABLE"
|
|
||||||
export FLAGS="$FLAGS -DCOUNTER_DISABLE"
|
|
||||||
export FLAGS="$FLAGS -DCSSHDC_DISABLE"
|
|
||||||
|
|
||||||
CUSTOM_BUILD_FLAGS_FILE=custom-build-flags/build_flags_nrf52840.sh
|
|
||||||
if [ -f $CUSTOM_BUILD_FLAGS_FILE ]; then
|
|
||||||
source $CUSTOM_BUILD_FLAGS_FILE
|
|
||||||
fi
|
|
||||||
echo $FLAGS
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
#! /bin/bash
|
|
||||||
CUSTOM_BUILD_FLAGS_FILE=custom-build-flags/build_flags_stm32.sh
|
|
||||||
export FLAGS="$FLAGS -DPIO_SRC_REV="$(git log --pretty=format:%h_%ad -1 --date=short)
|
|
||||||
export FLAGS="$FLAGS -DDMX_DISABLE"
|
|
||||||
export FLAGS="$FLAGS -DMODBUS_DISABLE"
|
|
||||||
export FLAGS="$FLAGS -DOWIRE_DISABLE"
|
|
||||||
export FLAGS="$FLAGS -DDHT_DISABLE"
|
|
||||||
export FLAGS="$FLAGS -DCOUNTER_DISABLE"
|
|
||||||
export FLAGS="$FLAGS -DNO_HOMIE"
|
|
||||||
export FLAGS="$FLAGS -DCSSHDC_DISABLE"
|
|
||||||
if [ -f $CUSTOM_BUILD_FLAGS_FILE ]; then
|
|
||||||
source $CUSTOM_BUILD_FLAGS_FILE
|
|
||||||
fi
|
|
||||||
echo $FLAGS
|
|
||||||
273
compiled/DUE_16u2_reflash/16u2.hex
Normal file
273
compiled/DUE_16u2_reflash/16u2.hex
Normal file
@@ -0,0 +1,273 @@
|
|||||||
|
:10000000A7C00000C0C00000BEC00000BCC000000F
|
||||||
|
:10001000BAC00000B8C00000B6C00000B4C0000004
|
||||||
|
:10002000B2C00000B0C00000AEC00000C1C40000FB
|
||||||
|
:1000300085C40000A8C00000A6C00000A4C0000045
|
||||||
|
:10004000A2C00000A0C000009EC000009CC0000034
|
||||||
|
:100050009AC0000098C0000096C0000021C10000B6
|
||||||
|
:1000600092C0000090C000008EC000008CC0000054
|
||||||
|
:100070008AC0000088C0000086C0000084C0000064
|
||||||
|
:1000800082C0000080C000007EC000007CC0000074
|
||||||
|
:100090007AC0000078C000001201100102000008C0
|
||||||
|
:1000A00041233D0001000102DC0109023E00020182
|
||||||
|
:1000B00000C0320904000001020201000524000111
|
||||||
|
:1000C0001004240206052406000107058203080027
|
||||||
|
:1000D000FF09040100020A000000070504024000B5
|
||||||
|
:1000E00001070583024000010403090432034100B3
|
||||||
|
:1000F00072006400750069006E006F002000280027
|
||||||
|
:100100007700770077002E006100720064007500B0
|
||||||
|
:1001100069006E006F002E0063006300290000007C
|
||||||
|
:100120002E03410072006400750069006E006F00CC
|
||||||
|
:1001300020004400750065002000500072006F0030
|
||||||
|
:1001400067002E00200050006F0072007400000055
|
||||||
|
:1001500011241FBECFEFD2E0DEBFCDBF11E0A0E083
|
||||||
|
:10016000B1E0E4EDF0E102C005900D92A831B107D5
|
||||||
|
:10017000D9F712E0A8E1B1E001C01D92A833B107A0
|
||||||
|
:10018000E1F72BD1A5C73CCF9C01DC01AE57BF4F97
|
||||||
|
:10019000ED91FC91119741911196FC93EE9380584B
|
||||||
|
:1001A0009F4FE817F90711F42D933C939FB7F894EC
|
||||||
|
:1001B000F901EC57FF4F8081815080839FBF842FCE
|
||||||
|
:1001C0000895882311F03F9A01C03F9847980895F9
|
||||||
|
:1001D000882311F046980895469A0895DF92EF9289
|
||||||
|
:1001E000FF920F931F93FC018489813019F08230B4
|
||||||
|
:1001F00019F404C010E303C010E001C010E28389C9
|
||||||
|
:10020000823009F418608589873031F0883031F008
|
||||||
|
:10021000863029F4126003C0146001C01660109289
|
||||||
|
:10022000C9001092C8001092CA000785F088E188C2
|
||||||
|
:10023000D288202F3F2D4E2D5D2D10921E01203B88
|
||||||
|
:1002400084E0380780E0480780E0580719F481E02F
|
||||||
|
:1002500080931E01CA01B90122E030E040E050E085
|
||||||
|
:100260001CD720583B47414E5F4FCA01B901202F90
|
||||||
|
:100270003F2D4E2D5D2DEFD6215030403093CD00D7
|
||||||
|
:100280002093CC001093CA0082E08093C80088E9D4
|
||||||
|
:100290008093C9001F910F91FF90EF90DF90089518
|
||||||
|
:1002A0001F920F920FB60F9211242F938F939F934B
|
||||||
|
:1002B000EF93FF939091CE008EB38430F1F4E091F0
|
||||||
|
:1002C000A201F091A3019083E091A201F091A3011A
|
||||||
|
:1002D000CF0101969093A3018093A201825A91408D
|
||||||
|
:1002E00021F482E291E0928381839FB7F894809118
|
||||||
|
:1002F000A6018F5F8093A6019FBFFF91EF919F9111
|
||||||
|
:100300008F912F910F900FBE0F901F901895FC01A9
|
||||||
|
:1003100040911A0140931B0180911C0180931D01A3
|
||||||
|
:100320008585282F30E02170307020931A01858553
|
||||||
|
:1003300090E096958795817080931C0180911E01B5
|
||||||
|
:10034000882339F088E790E0909319018093180191
|
||||||
|
:100350000895442341F4222331F082E390E0909306
|
||||||
|
:10036000190180931801089580E091E00AC680E0A9
|
||||||
|
:1003700091E0BDC584B7877F84BF88E10FB6F8944C
|
||||||
|
:1003800080936000109260000FBE81E01ADF16BCFF
|
||||||
|
:1003900083E085BD86B58831E8F315BC16BC80E0E6
|
||||||
|
:1003A00010DF469A3E9A87E690E09093CD008093C6
|
||||||
|
:1003B000CC0086E08093CA001092C80088E1809348
|
||||||
|
:1003C000C900539A5A9A8AB180638AB98BB1806303
|
||||||
|
:1003D0008BB9A9D284E085BD08950F931F93CF9365
|
||||||
|
:1003E000DF93C8DF2FB7F89487EA91E09093280253
|
||||||
|
:1003F0008093270290932A02809329022FBF2FB760
|
||||||
|
:10040000F89482E291E09093A3018093A2019093EB
|
||||||
|
:10041000A5018093A4012FBF7894C7EAD1E003E03F
|
||||||
|
:100420008FB7F89490912B028FBF903809F180E03C
|
||||||
|
:1004300091E0D3D497FD1CC0E0912702F0912802EF
|
||||||
|
:100440008083E0912702F0912802CF0101969093DA
|
||||||
|
:100450002802809327028752924011F4D283C183ED
|
||||||
|
:100460009FB7F89480912B028F5F80932B029FBFE0
|
||||||
|
:100470008FB7F8941091A6018FBFA89903C01136C9
|
||||||
|
:1004800008F456C0A89A8091A601882361F05D986F
|
||||||
|
:1004900000931F0108C082E291E076DE682F80E0C1
|
||||||
|
:1004A00091E001D511501123B1F780911F018823EC
|
||||||
|
:1004B00051F080911F01815080931F0180911F0195
|
||||||
|
:1004C000882309F45D9A80912001882351F080915E
|
||||||
|
:1004D000200181508093200180912001882309F41C
|
||||||
|
:1004E0005C9A809118019091190118161906E4F48C
|
||||||
|
:1004F000CC97CD9710F481E001C080E069DE809157
|
||||||
|
:100500001801909119010197C29710F481E001C080
|
||||||
|
:1005100080E057DE80911801909119010197909326
|
||||||
|
:1005200019018093180104C080E052DE80E049DEAA
|
||||||
|
:100530008FB7F89490912B028FBF992369F087EAC7
|
||||||
|
:1005400091E022DE982F8091C80085FFFCCF909328
|
||||||
|
:10055000CE005C980093200180E091E095D42AD4ED
|
||||||
|
:100560005FCFDA01923049F0933061F09130F9F4C5
|
||||||
|
:10057000E8E9F0E022E130E01EC0EAEAF0E02EE334
|
||||||
|
:1005800030E019C0813049F0813018F0823079F4C0
|
||||||
|
:1005900008C0E8EEF0E0849107C0ECEEF0E0849152
|
||||||
|
:1005A00003C0E0E2F1E08491282F30E004C0E0E0F5
|
||||||
|
:1005B000F0E020E030E0ED93FC93C901089528E0DD
|
||||||
|
:1005C00030E040E003C04F5F220F331F2817390788
|
||||||
|
:1005D000D0F3842F8295807F08958093E9008091E5
|
||||||
|
:1005E000EB0081608093EB001092ED006093EC00D3
|
||||||
|
:1005F0004093ED008091EE00881F8827881F0895A2
|
||||||
|
:100600001092F40090E09093E9001092F0001092A4
|
||||||
|
:10061000E8001092ED008091EB008E7F8093EB005C
|
||||||
|
:100620009F5F953081F708958091300288238CF484
|
||||||
|
:1006300003C08EB38823B1F08091E80082FFF9CF28
|
||||||
|
:100640008091E8008B778093E80008958EB388232B
|
||||||
|
:1006500049F08091E80080FFF9CF8091E8008E7723
|
||||||
|
:100660008093E800089594E68091EC0080FF05C037
|
||||||
|
:100670008091E80080FF05C023C08091E80082FDE2
|
||||||
|
:100680001FC08EB3882311F482E008958EB38530A5
|
||||||
|
:1006900011F483E008958091EB0085FF02C081E0B2
|
||||||
|
:1006A00008958091E10082FFDFCF8091E1008B7F90
|
||||||
|
:1006B0008093E100992311F484E008959150D4CF00
|
||||||
|
:1006C00080E008959C014091360250913702461710
|
||||||
|
:1006D000570718F4F90120E038C06115710511F0D1
|
||||||
|
:1006E000AB01F8CF8091E8008E778093E80040E07E
|
||||||
|
:1006F00050E0F0CF8091E80083FF02C081E00895D0
|
||||||
|
:100700008091E80082FD2DC08EB3882381F18EB3E5
|
||||||
|
:10071000853079F18091E80080FF17C09091F20058
|
||||||
|
:1007200006C081918093F100415050409F5F411578
|
||||||
|
:10073000510511F09830A8F320E0983009F421E039
|
||||||
|
:100740008091E8008E778093E8004115510591F67D
|
||||||
|
:10075000222381F606C08EB3882349F08EB38530FC
|
||||||
|
:1007600041F08091E80082FFF6CF80E0089582E0BA
|
||||||
|
:10077000089583E008959C0140913602509137021C
|
||||||
|
:100780004617570710F490E03BC06115710511F052
|
||||||
|
:10079000AB01F9CF8091E8008E778093E80040E0CC
|
||||||
|
:1007A00050E0F1CF8091E80083FF02C081E008951E
|
||||||
|
:1007B0008091E80082FD30C08EB3882399F18EB31A
|
||||||
|
:1007C000853091F18091E80080FF1AC08091F2009D
|
||||||
|
:1007D00009C0F9012F5F3F4FE491E093F1004150D0
|
||||||
|
:1007E00050408F5F4115510511F0883090F390E033
|
||||||
|
:1007F000883009F491E08091E8008E778093E800DA
|
||||||
|
:100800004115510579F6992369F606C08EB3882300
|
||||||
|
:1008100049F08EB3853041F08091E80082FFF6CF39
|
||||||
|
:1008200080E0089582E0089583E008959C016115B9
|
||||||
|
:10083000710529F48091E8008B778093E800F90135
|
||||||
|
:1008400020C08091E80083FF02C081E008958EB34C
|
||||||
|
:10085000882339F18EB3853031F18091E80082FF31
|
||||||
|
:10086000F0CF06C08091F10081936150704021F07B
|
||||||
|
:100870008091F2008823B1F78091E8008B77809314
|
||||||
|
:10088000E80061157105E9F606C08EB3882349F0CA
|
||||||
|
:100890008EB3853041F08091E80080FFF6CF80E094
|
||||||
|
:1008A000089582E0089583E0089542D044D01EBAAE
|
||||||
|
:1008B00010922E0210922D0210922C0284E089BD1B
|
||||||
|
:1008C00089B5826089BD09B400FEFDCF8091D80052
|
||||||
|
:1008D000982F9F779093D80080688093D80080915C
|
||||||
|
:1008E00063008E7F809363008091D8008F7D80931A
|
||||||
|
:1008F000D8008091E0008E7F8093E0008091E1003D
|
||||||
|
:100900008E7F8093E1008091E20081608093E2001D
|
||||||
|
:100910008091E100877F8093E1008091E200886010
|
||||||
|
:100920008093E2000895C1DF81E080932F02089553
|
||||||
|
:100930001092E20008951092E10008951F920F9224
|
||||||
|
:100940000FB60F9211241F932F933F934F935F93F2
|
||||||
|
:100950006F937F938F939F93AF93BF93EF93FF9387
|
||||||
|
:10096000E9EEF0E0108117701082E0EFF0E0808196
|
||||||
|
:10097000877F80837894C3D0F894A9EEB0E01C926E
|
||||||
|
:10098000E0EFF0E08081886080831C93FF91EF911D
|
||||||
|
:10099000BF91AF919F918F917F916F915F914F9197
|
||||||
|
:1009A0003F912F911F910F900FBE0F901F901895A0
|
||||||
|
:1009B0001F920F920FB60F9211242F933F934F93D4
|
||||||
|
:1009C0005F936F937F938F939F93AF93BF93EF93B7
|
||||||
|
:1009D000FF938091E10080FF1BC08091E20080FFC7
|
||||||
|
:1009E00017C08091E1008E7F8093E1008091E2004A
|
||||||
|
:1009F0008E7F8093E2008091E20080618093E2002C
|
||||||
|
:100A00008091D80080628093D80019BC1EBAD1D1E1
|
||||||
|
:100A10008091E10084FF29C08091E20084FF25C01D
|
||||||
|
:100A200084E089BD89B5826089BD09B400FEFDCF2F
|
||||||
|
:100A30008091D8008F7D8093D8008091E1008F7ED7
|
||||||
|
:100A40008093E1008091E2008F7E8093E2008091AC
|
||||||
|
:100A5000E20081608093E20080912E02882311F4ED
|
||||||
|
:100A600081E001C084E08EBBA4D18091E10083FFCE
|
||||||
|
:100A700027C08091E20083FF23C08091E100877F3F
|
||||||
|
:100A80008093E10082E08EBB10922E028091E10003
|
||||||
|
:100A90008E7F8093E1008091E2008E7F8093E20060
|
||||||
|
:100AA0008091E20080618093E200AADD80E060E056
|
||||||
|
:100AB00042E093DD8091F00088608093F00079D16E
|
||||||
|
:100AC0008091E10082FF0AC08091E20082FF06C0AF
|
||||||
|
:100AD0008091E1008B7F8093E1006BD1FF91EF91DA
|
||||||
|
:100AE000BF91AF919F918F917F916F915F914F9146
|
||||||
|
:100AF0003F912F910F900FBE0F901F9018951F934D
|
||||||
|
:100B0000DF93CF93CDB7DEB7AC970FB6F894DEBFC7
|
||||||
|
:100B10000FBECDBFE0E3F2E08091F100819322E0CF
|
||||||
|
:100B2000E833F207C9F78091300230913102353055
|
||||||
|
:100B300009F487C0363040F43130C9F1313070F0FB
|
||||||
|
:100B4000333009F01DC133C0383009F4EFC03930FB
|
||||||
|
:100B500009F4FEC0363009F013C192C0803821F08C
|
||||||
|
:100B6000823809F00DC108C090912C0280912D02AD
|
||||||
|
:100B7000882399F0926011C080913402877080932D
|
||||||
|
:100B8000E9008091EB0090E025E0969587952A9505
|
||||||
|
:100B9000E1F7982F91701092E9008091E800877F2B
|
||||||
|
:100BA0008093E8009093F1001092F100CAC088236E
|
||||||
|
:100BB00019F0823009F0E4C090E08F7190700097D6
|
||||||
|
:100BC00021F0029709F0DDC00CC080913202813023
|
||||||
|
:100BD00009F0D7C010922D02333069F580932D02B1
|
||||||
|
:100BE0002AC080913202882331F520913402277087
|
||||||
|
:100BF00009F4C7C02093E9008091EB0080FFC1C0D9
|
||||||
|
:100C0000333021F48091EB00806213C08091EB00BF
|
||||||
|
:100C100080618093EB0081E090E002C0880F991F13
|
||||||
|
:100C20002A95E2F78093EA001092EA008091EB00A7
|
||||||
|
:100C300088608093EB001092E9008091E800877F44
|
||||||
|
:100C400083C0882309F09CC0109132028091E80093
|
||||||
|
:100C5000877F8093E800E8DC04C08EB3882309F422
|
||||||
|
:100C600090C08091E80080FFF8CF812F8F7711F43A
|
||||||
|
:100C700092E001C093E09EBB80688093E30081C056
|
||||||
|
:100C80008058823008F07CC080913202909133020B
|
||||||
|
:100C900023E08C3D920799F55FB7F894DE01159635
|
||||||
|
:100CA0004EE020E030E061E2E42FF0E06093570096
|
||||||
|
:100CB000849120FF03C082958F704F5F982F9F70A3
|
||||||
|
:100CC000892F805D8A3308F0895F8C9311961C927E
|
||||||
|
:100CD00011972F5F3F4F12962431310529F75FBFDF
|
||||||
|
:100CE0008AE28B8383E08C838091E800877F809306
|
||||||
|
:100CF000E800CE0103966AE270E0E4DC11C0609186
|
||||||
|
:100D00003402AE014F5F5F4F2CDCBC010097C9F18C
|
||||||
|
:100D10008091E800877F8093E80089819A812BDDAC
|
||||||
|
:100D20008091E8008B778093E8002BC0803841F5F4
|
||||||
|
:100D30008091E800877F8093E80080912E02809365
|
||||||
|
:100D4000F1008091E8008E778093E8006DDC19C097
|
||||||
|
:100D50008823B1F490913202923098F48091E800A7
|
||||||
|
:100D6000877F8093E80090932E025EDC80912E02B4
|
||||||
|
:100D7000882311F483E001C084E08EBBF8DA01C05F
|
||||||
|
:100D8000F3DA8091E80083FF0AC08091EB00806273
|
||||||
|
:100D90008093EB008091E800877F8093E800AC9619
|
||||||
|
:100DA0000FB6F894DEBF0FBECDBFCF91DF911F917C
|
||||||
|
:100DB000089508951F938EB3882361F01091E90080
|
||||||
|
:100DC0001092E9008091E80083FF01C098DE17705F
|
||||||
|
:100DD0001093E9001F9108950895FC018EB38430AB
|
||||||
|
:100DE00021F587859089A189B2890097A105B10570
|
||||||
|
:100DF000E1F085818093E9008091E80082FF15C0D1
|
||||||
|
:100E00008091F200882319F42FEF3FEF04C0809106
|
||||||
|
:100E1000F100282F30E08091F200882341F4809186
|
||||||
|
:100E2000E8008B778093E80002C02FEF3FEFC90105
|
||||||
|
:100E30000895FC018EB3843011F587859089A189CE
|
||||||
|
:100E4000B2890097A105B105D1F081818093E900B5
|
||||||
|
:100E50008091F2008823A9F09091E8008091E80049
|
||||||
|
:100E60008E778093E80095FD0CC0FDDB982F8823DA
|
||||||
|
:100E700049F48091E8008E778093E80003C092E007
|
||||||
|
:100E800001C090E0892F0895FC018EB3843051F4A5
|
||||||
|
:100E900087859089A189B2890097A105B10511F0D4
|
||||||
|
:100EA000CF01C7CF08951F93FC01162F8EB3843056
|
||||||
|
:100EB000D9F487859089A189B2890097A105B105E8
|
||||||
|
:100EC00099F081818093E9008091E80085FD08C058
|
||||||
|
:100ED0008091E8008E778093E800C5DB882329F4B1
|
||||||
|
:100EE0001093F10080E001C082E01F9108950F93FC
|
||||||
|
:100EF0001F93CF93DF93EC010D96FC0189E0DF0196
|
||||||
|
:100F00001D928A95E9F72A813B8109818C8188238A
|
||||||
|
:100F100011F410E001C014E0C90151DB182B12607C
|
||||||
|
:100F2000802F61E8412F59DB882329F12E813F81F1
|
||||||
|
:100F30000D818885882311F410E001C014E0C901F7
|
||||||
|
:100F40003EDB182B1260802F60E8412F46DB8823A0
|
||||||
|
:100F500091F02A853B8509858C85882311F410E062
|
||||||
|
:100F600001C014E0C9012BDB182B1260802F61EC4B
|
||||||
|
:100F7000412F33DB01C080E0DF91CF911F910F91B2
|
||||||
|
:100F80000895CF93DF93EC018091E80083FF60C068
|
||||||
|
:100F9000888190E02091340230913502281739077A
|
||||||
|
:100FA00009F056C080913102813261F0823220F422
|
||||||
|
:100FB000803209F04DC019C0823269F1833209F0E4
|
||||||
|
:100FC00047C038C080913002813A09F041C0809119
|
||||||
|
:100FD000E800877F8093E800CE010F9667E070E01D
|
||||||
|
:100FE00071DB8091E8008B7713C0809130028132F1
|
||||||
|
:100FF00079F58091E800877F8093E800CE010F9615
|
||||||
|
:1010000067E070E013DCCE01E9D88091E8008E77CC
|
||||||
|
:101010008093E8001DC0809130028132C9F4809134
|
||||||
|
:10102000E800877F8093E800809132028D87CE01AF
|
||||||
|
:101030006ED90DC080913002813251F48091E80068
|
||||||
|
:10104000877F8093E800CE0160913202C5DEECDA42
|
||||||
|
:10105000DF91CF910895A1E21A2EAA1BBB1BFD01BF
|
||||||
|
:101060000DC0AA1FBB1FEE1FFF1FA217B307E40787
|
||||||
|
:10107000F50720F0A21BB30BE40BF50B661F771FDF
|
||||||
|
:10108000881F991F1A9469F76095709580959095BF
|
||||||
|
:101090009B01AC01BD01CF01089597FB092E0526E8
|
||||||
|
:1010A0000ED057FD04D0D7DF0AD0001C38F450957D
|
||||||
|
:1010B0004095309521953F4F4F4F5F4F0895F6F77C
|
||||||
|
:1010C00090958095709561957F4F8F4F9F4F0895B4
|
||||||
|
:0410D000F894FFCFC2
|
||||||
|
:1010D400000340000004400000020800000000007B
|
||||||
|
:0810E4000000000000001400F0
|
||||||
|
:00000001FF
|
||||||
2
compiled/DUE_16u2_reflash/reflash16u2DUE.sh
Normal file → Executable file
2
compiled/DUE_16u2_reflash/reflash16u2DUE.sh
Normal file → Executable file
@@ -1 +1 @@
|
|||||||
../tools/mac/tool-avrdude/avrdude -C ../tools/mac/tool-avrdude/avrdude.conf -c arduino -P /dev/cu.usbmodem1411 -b 19200 -p m16u2 -vvv -U flash:w:16u2.hex:i
|
../tools/mac/tool-avrdude/avrdude -C ../tools/mac/tool-avrdude/avrdude.conf -c arduino -P /dev/cu.usbmodem14101 -b 19200 -p m16u2 -vvv -U flash:w:16u2.hex:i
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
@@ -1,3 +1,3 @@
|
|||||||
export PORT=cu.usbmodem1411
|
export PORT=cu.usbmodem14201
|
||||||
echo . | stty -f /dev/$PORT speed 1200
|
echo . | stty -f /dev/$PORT speed 1200
|
||||||
../tools/mac/tool-bossac/bossac -U false -p $PORT -i -e -w -v -b firmware.bin -R
|
../tools/mac/tool-bossac/bossac -U false -p $PORT -i -e -w -v -b firmware.bin -R
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -1,12 +1,12 @@
|
|||||||
cp ../.pioenvs/controllino/firmware.hex controllino
|
cp ../.pio/build/controllino/firmware.hex controllino
|
||||||
cp ../.pioenvs/m5stack/firmware.bin m5stack
|
cp ../.pio/build/m5stack/firmware.bin m5stack
|
||||||
cp ../.pioenvs/mega2560slim-5100/firmware.hex mega2560slim-5100
|
cp ../.pio/build/mega2560slim-5100/firmware.hex mega2560slim-5100
|
||||||
cp ../.pioenvs/due-5100/firmware.bin due-5100
|
cp ../.pio/build/due-5100/firmware.bin due-5100
|
||||||
cp ../.pioenvs/mega2560-5100/firmware.hex mega2560-5100
|
cp ../.pio/build/mega2560-5100/firmware.hex mega2560-5100
|
||||||
cp ../.pioenvs/due-5500/firmware.bin due-5500
|
cp ../.pio/build/due-5500/firmware.bin due-5500
|
||||||
cp ../.pioenvs/nrf52840-5500/firmware.hex nrf52840-5500
|
cp ../.pio/build/nrf52840-5500/firmware.hex nrf52840-5500
|
||||||
cp ../.pioenvs/esp32-wifi/firmware.bin esp32-wifi
|
cp ../.pio/build/esp32-wifi/firmware.bin esp32-wifi
|
||||||
cp ../.pioenvs/stm32-enc2860/firmware.bin stm32-enc2860
|
cp ../.pio/build/stm32-enc2860/firmware.bin stm32-enc2860
|
||||||
cp ../.pioenvs/esp8266-wifi/firmware.bin esp8266-wifi
|
cp ../.pio/build/esp8266-wifi/firmware.bin esp8266-wifi
|
||||||
cp ../.pioenvs/lighthub21/firmware.bin lighthub21
|
cp ../.pio/build/lighthub21/firmware.bin lighthub21
|
||||||
cp ../.pioenvs/mega2560-5500/firmware.hex mega2560-5500
|
cp ../.pio/build/mega2560-5500/firmware.hex mega2560-5500
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
#! /bin/bash
|
|
||||||
# usage:
|
|
||||||
# first make your own copy of template
|
|
||||||
# cp build_flags_template.sh my_build_flags.sh
|
|
||||||
# then edit, change or comment something
|
|
||||||
# nano my_build_flags.sh
|
|
||||||
# and source it
|
|
||||||
# source my_build_flags.sh
|
|
||||||
#export FLAGS="$FLAGS -DMY_CONFIG_SERVER=lighthub.elistech.ru"
|
|
||||||
#export FLAGS="$FLAGS -DWATCH_DOG_TICKER_DISABLE"
|
|
||||||
#export FLAGS="$FLAGS -DUSE_1W_PIN=12"
|
|
||||||
#export FLAGS="$FLAGS -DSD_CARD_INSERTED"
|
|
||||||
export FLAGS="$FLAGS -DSERIAL_BAUD=115200"
|
|
||||||
# export FLAGS="$FLAGS -DWiz5500"
|
|
||||||
export FLAGS="$FLAGS -DDISABLE_FREERAM_PRINT"
|
|
||||||
export FLAGS="$FLAGS -DCUSTOM_FIRMWARE_MAC=C2:3E:1f:03:1B:1E"
|
|
||||||
# export FLAGS="$FLAGS -DDMX_DISABLE"
|
|
||||||
# export FLAGS="$FLAGS -DMODBUS_DISABLE"
|
|
||||||
# export FLAGS="$FLAGS -DOWIRE_DISABLE"
|
|
||||||
#export FLAGS="$FLAGS -DAVR_DMXOUT_PIN=18"
|
|
||||||
#export FLAGS="$FLAGS -DCONTROLLINO"
|
|
||||||
# export FLAGS="$FLAGS -DRESET_PIN=8"
|
|
||||||
# export FLAGS="$FLAGS -DLAN_INIT_DELAY=2000"
|
|
||||||
# export FLAGS="$FLAGS -DESP_WIFI_AP=vent"
|
|
||||||
# export FLAGS="$FLAGS -DESP_WIFI_PWD=kk007remont"
|
|
||||||
# export FLAGS="$FLAGS -DSYSLOG_ENABLE"
|
|
||||||
export FLAGS="$FLAGS -DDEVICE_NAME=kk007_mega2560"
|
|
||||||
export FLAGS="$FLAGS -DCOUNTER_DISABLE"
|
|
||||||
export FLAGS="$FLAGS -DDHT_DISABLE"
|
|
||||||
#export FLAGS="$FLAGS -DWITH_DOMOTICZ"
|
|
||||||
#export FLAGS="$FLAGS -DWITH_PRINTEX_LIB"
|
|
||||||
export FLAGS="$FLAGS -DPIO_SRC_REV="$(git log --pretty=format:%h_%ad -1 --date=short)
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
#! /bin/bash
|
|
||||||
# usage:
|
|
||||||
# first make your own copy of template
|
|
||||||
# cp build_flags_template.sh build_flags_ENVNAME.sh
|
|
||||||
# then edit, change or comment something
|
|
||||||
#export FLAGS="$FLAGS -DMY_CONFIG_SERVER=lazyhome.ru"
|
|
||||||
export FLAGS="$FLAGS -DWATCH_DOG_TICKER_DISABLE"
|
|
||||||
#export FLAGS="$FLAGS -DUSE_1W_PIN=12"
|
|
||||||
#export FLAGS="$FLAGS -DSD_CARD_INSERTED"
|
|
||||||
#export FLAGS="$FLAGS -DSERIAL_BAUD=115200"
|
|
||||||
#export FLAGS="$FLAGS -DWiz5500"
|
|
||||||
export FLAGS="$FLAGS -DDISABLE_FREERAM_PRINT"
|
|
||||||
#export FLAGS="$FLAGS -DCUSTOM_FIRMWARE_MAC=de:ad:be:ef:fe:ff"
|
|
||||||
#export FLAGS="$FLAGS -DDMX_DISABLE"
|
|
||||||
#export FLAGS="$FLAGS -DMODBUS_DISABLE"
|
|
||||||
#export FLAGS="$FLAGS -DOWIRE_DISABLE"
|
|
||||||
# export FLAGS="$FLAGS -DAVR_DMXOUT_PIN=18"
|
|
||||||
# export FLAGS="$FLAGS -DLAN_INIT_DELAY=2000"
|
|
||||||
# export FLAGS="$FLAGS -DCONTROLLINO"
|
|
||||||
# export FLAGS="$FLAGS -DWIFI_MANAGER_DISABLE"
|
|
||||||
# export FLAGS="$FLAGS -DRESET_PIN=5"
|
|
||||||
# export FLAGS="$FLAGS -DDHCP_RETRY_INTERVAL=60000"
|
|
||||||
# export FLAGS="$FLAGS -DRESTART_LAN_ON_MQTT_ERRORS"
|
|
||||||
# export FLAGS="$FLAGS -DW5500_CS_PIN=53"
|
|
||||||
#export FLAGS="$FLAGS -std=gnu++11"
|
|
||||||
#export FLAGS="$FLAGS -DDEVICE_NAME=MYDEVICE"
|
|
||||||
#export FLAGS="$FLAGS -DDHT_COUNTER_DISABLE"
|
|
||||||
#export FLAGS="$FLAGS -DWITH_PRINTEX_LIB"
|
|
||||||
#export FLAGS="$FLAGS -DPIO_SRC_REV="$(git log --pretty=format:%h_%ad -1 --date=short)
|
|
||||||
echo $FLAGS
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
#! /bin/bash
|
|
||||||
# usage:
|
|
||||||
# first make your own copy of template
|
|
||||||
# cp build_flags_template.sh build_flags_ENVNAME.sh
|
|
||||||
# then edit, change or comment something
|
|
||||||
# export FLAGS="$FLAGS -DMY_CONFIG_SERVER=lazyhome.ru"
|
|
||||||
# export FLAGS="$FLAGS -DWATCH_DOG_TICKER_DISABLE"
|
|
||||||
# export FLAGS="$FLAGS -DUSE_1W_PIN=12"
|
|
||||||
# export FLAGS="$FLAGS -DSD_CARD_INSERTED"
|
|
||||||
# export FLAGS="$FLAGS -DSERIAL_BAUD=115200"
|
|
||||||
# export FLAGS="$FLAGS -DWiz5500"
|
|
||||||
# export FLAGS="$FLAGS -DDISABLE_FREERAM_PRINT"
|
|
||||||
# export FLAGS="$FLAGS -DCUSTOM_FIRMWARE_MAC=de:ad:be:ef:fe:ff"
|
|
||||||
# export FLAGS="$FLAGS -DDMX_DISABLE"
|
|
||||||
# export FLAGS="$FLAGS -DMODBUS_DISABLE"
|
|
||||||
# export FLAGS="$FLAGS -DOWIRE_DISABLE"
|
|
||||||
# export FLAGS="$FLAGS -DAVR_DMXOUT_PIN=18"
|
|
||||||
# export FLAGS="$FLAGS -DLAN_INIT_DELAY=2000"
|
|
||||||
# export FLAGS="$FLAGS -DCONTROLLINO"
|
|
||||||
# export FLAGS="$FLAGS -DESP_WIFI_AP=MYAP"
|
|
||||||
# export FLAGS="$FLAGS -DESP_WIFI_PWD=MYPWD"
|
|
||||||
# export FLAGS="$FLAGS -DWIFI_MANAGER_DISABLE"
|
|
||||||
# export FLAGS="$FLAGS -DRESET_PIN=5"
|
|
||||||
# export FLAGS="$FLAGS -DDHCP_RETRY_INTERVAL=60000"
|
|
||||||
# export FLAGS="$FLAGS -DRESTART_LAN_ON_MQTT_ERRORS"
|
|
||||||
# export FLAGS="$FLAGS -DW5500_CS_PIN=53"
|
|
||||||
# export FLAGS="$FLAGS -DSYSLOG_ENABLE"
|
|
||||||
# export FLAGS="$FLAGS -DDEVICE_NAME=MYDEVICE"
|
|
||||||
# export FLAGS="$FLAGS -DDHT_DISABLE"
|
|
||||||
# export FLAGS="$FLAGS -DCOUNTER_DISABLE"
|
|
||||||
# export FLAGS="$FLAGS -DWITH_PRINTEX_LIB"
|
|
||||||
# export FLAGS="$FLAGS -DPIO_SRC_REV="$(git log --pretty=format:%h_%ad -1 --date=short)
|
|
||||||
# export FLAGS="$FLAGS -DCSSHDC_DISABLE"
|
|
||||||
echo $FLAGS
|
|
||||||
31
get_build_flags.py
Normal file
31
get_build_flags.py
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import print_function
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
print(sys.argv[1:], file=sys.stderr)
|
||||||
|
#print("build_flags_"+sys.argv[1:][0])
|
||||||
|
try:
|
||||||
|
file = open("build-flags/build_flags_"+sys.argv[1:][0])
|
||||||
|
except IOError as e:
|
||||||
|
print(u'No build flags file ', file=sys.stderr)
|
||||||
|
else:
|
||||||
|
with file:
|
||||||
|
for line in file.readlines():
|
||||||
|
if not line.startswith('#'):
|
||||||
|
print (line)
|
||||||
|
file.close()
|
||||||
|
|
||||||
|
try:
|
||||||
|
file = open("custom-build-flags/build_flags_"+sys.argv[1:][0])
|
||||||
|
except IOError as e:
|
||||||
|
print(u'No custom build flags file ', file=sys.stderr)
|
||||||
|
else:
|
||||||
|
with file:
|
||||||
|
for line in file.readlines():
|
||||||
|
if not line.startswith('#'):
|
||||||
|
print (line)
|
||||||
|
file.close()
|
||||||
|
|
||||||
|
sys.stdout.write("-DPIO_SRC_REV=")
|
||||||
|
sys.stdout.flush()
|
||||||
|
os.system("git log --pretty=format:%h_%ad -1 --date=short")
|
||||||
42
lighthub/abstractch.cpp
Normal file
42
lighthub/abstractch.cpp
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
|
||||||
|
#include "abstractch.h"
|
||||||
|
#include <PubSubClient.h>
|
||||||
|
#include "utils.h"
|
||||||
|
#include <aJSON.h>
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
extern lan_status lanStatus;
|
||||||
|
extern PubSubClient mqttClient;
|
||||||
|
extern int8_t ethernetIdleCount;
|
||||||
|
|
||||||
|
int abstractCh::publishTopic(const char* topic, long value, const char* subtopic)
|
||||||
|
{
|
||||||
|
char valstr[16];
|
||||||
|
printUlongValueToStr(valstr, value);
|
||||||
|
return publishTopic(topic, valstr,subtopic);
|
||||||
|
};
|
||||||
|
|
||||||
|
int abstractCh::publishTopic(const char* topic, float value, const char* subtopic)
|
||||||
|
{
|
||||||
|
char valstr[16];
|
||||||
|
printFloatValueToStr(value, valstr);
|
||||||
|
return publishTopic(topic, valstr,subtopic);
|
||||||
|
};
|
||||||
|
|
||||||
|
int abstractCh::publishTopic(const char* topic, const char * value, const char* subtopic)
|
||||||
|
{
|
||||||
|
char addrstr[MQTT_TOPIC_LENGTH];
|
||||||
|
|
||||||
|
if (topic)
|
||||||
|
{
|
||||||
|
strncpy(addrstr,topic,sizeof(addrstr));
|
||||||
|
if (!strchr(addrstr,'/')) setTopic(addrstr,sizeof(addrstr),T_OUT,topic);
|
||||||
|
strncat(addrstr,subtopic,sizeof(addrstr));
|
||||||
|
if (mqttClient.connected() && lanStatus == OPERATION && !ethernetIdleCount)
|
||||||
|
{
|
||||||
|
mqttClient.publish(addrstr, value, true);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
23
lighthub/abstractch.h
Normal file
23
lighthub/abstractch.h
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "Arduino.h"
|
||||||
|
|
||||||
|
#define CST_UNKNOWN 0
|
||||||
|
#define CST_INITIALIZED 1
|
||||||
|
|
||||||
|
class abstractCh {
|
||||||
|
public:
|
||||||
|
abstractCh(){};
|
||||||
|
virtual ~abstractCh(){};
|
||||||
|
virtual int Poll(short cause) = 0;
|
||||||
|
virtual int Setup() =0; //Should initialize hardware and reserve resources
|
||||||
|
virtual int Anounce () {return 0;};
|
||||||
|
virtual int Stop() {return 0;}; //Should free resources
|
||||||
|
virtual int Status() {return CST_UNKNOWN;}
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual int publishTopic(const char* topic, long value, const char* subtopic = NULL);
|
||||||
|
virtual int publishTopic(const char* topic, float value, const char* subtopic = NULL );
|
||||||
|
virtual int publishTopic(const char* topic, const char * value, const char* subtopic = NULL);
|
||||||
|
//friend Input;
|
||||||
|
};
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
|
|
||||||
#include "abstractin.h"
|
#include "abstractin.h"
|
||||||
|
#include "abstractch.h"
|
||||||
#include <PubSubClient.h>
|
#include <PubSubClient.h>
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include <aJSON.h>
|
#include <aJSON.h>
|
||||||
@@ -9,36 +10,28 @@
|
|||||||
extern lan_status lanStatus;
|
extern lan_status lanStatus;
|
||||||
extern PubSubClient mqttClient;
|
extern PubSubClient mqttClient;
|
||||||
|
|
||||||
int abstractIn::publish(long value, char* subtopic)
|
int abstractIn::publish(long value, const char* subtopic)
|
||||||
{
|
{
|
||||||
char valstr[16];
|
char valstr[16];
|
||||||
printUlongValueToStr(valstr, value);
|
printUlongValueToStr(valstr, value);
|
||||||
return publish(valstr,subtopic);
|
return publish(valstr,subtopic);
|
||||||
};
|
};
|
||||||
|
|
||||||
int abstractIn::publish(float value, char* subtopic)
|
int abstractIn::publish(float value, const char* subtopic)
|
||||||
{
|
{
|
||||||
char valstr[16];
|
char valstr[16];
|
||||||
printFloatValueToStr(value, valstr);
|
printFloatValueToStr(value, valstr);
|
||||||
return publish(valstr,subtopic);
|
return publish(valstr,subtopic);
|
||||||
};
|
};
|
||||||
|
|
||||||
int abstractIn::publish(char * value, char* subtopic)
|
int abstractIn::publish(char * value, const char* subtopic)
|
||||||
{
|
{
|
||||||
char addrstr[MQTT_TOPIC_LENGTH];
|
|
||||||
if (in)
|
if (in)
|
||||||
{
|
{
|
||||||
aJsonObject *emit = aJson.getObjectItem(in->inputObj, "emit");
|
aJsonObject *emit = aJson.getObjectItem(in->inputObj, "emit");
|
||||||
if (emit)
|
if (emit && emit->type == aJson_String)
|
||||||
{
|
{
|
||||||
strncpy(addrstr,emit->valuestring,sizeof(addrstr));
|
return publishTopic(emit->valuestring,value,subtopic);
|
||||||
if (!strchr(addrstr,'/')) setTopic(addrstr,sizeof(addrstr),T_OUT,emit->valuestring);
|
|
||||||
strncat(addrstr,subtopic,sizeof(addrstr));
|
|
||||||
if (mqttClient.connected() && lanStatus == OPERATION)
|
|
||||||
{
|
|
||||||
mqttClient.publish(addrstr, value, true);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -1,17 +1,16 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
|
#include "abstractch.h"
|
||||||
|
|
||||||
class Input;
|
class Input;
|
||||||
class abstractIn {
|
class abstractIn : public abstractCh{
|
||||||
public:
|
public:
|
||||||
abstractIn(Input * _in){in=_in;};
|
abstractIn(Input * _in):abstractCh(){in=_in;};
|
||||||
virtual int Setup(int addr) = 0;
|
|
||||||
virtual int Poll() = 0;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Input * in;
|
Input * in;
|
||||||
int publish(long value, char* subtopic = NULL);
|
int publish(long value, const char* subtopic = NULL);
|
||||||
int publish(float value, char* subtopic = NULL );
|
int publish(float value, const char* subtopic = NULL );
|
||||||
int publish(char * value, char* subtopic = NULL);
|
int publish(char * value, const char* subtopic = NULL);
|
||||||
friend Input;
|
friend Input;
|
||||||
};
|
};
|
||||||
|
|||||||
15
lighthub/abstractout.h
Normal file
15
lighthub/abstractout.h
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "Arduino.h"
|
||||||
|
#include "abstractch.h"
|
||||||
|
|
||||||
|
class Item;
|
||||||
|
class abstractOut : public abstractCh{
|
||||||
|
public:
|
||||||
|
abstractOut(Item * _item):abstractCh(){item=_item;};
|
||||||
|
virtual int Ctrl(short cmd, short n=0, int * Parameters=NULL, boolean send=true, int suffixCode=0, char* subItem=NULL) =0;
|
||||||
|
virtual int isActive(){return 0;};
|
||||||
|
virtual int getDefaultOnVal(){return 100;};
|
||||||
|
virtual int getChanType(){return 0;}
|
||||||
|
protected:
|
||||||
|
Item * item;
|
||||||
|
};
|
||||||
23
lighthub/bright.cpp
Normal file
23
lighthub/bright.cpp
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
#include "bright.h"
|
||||||
|
|
||||||
|
uint8_t getBright(uint8_t percent)
|
||||||
|
{
|
||||||
|
int index = map(percent,0,100,0,255);
|
||||||
|
if (index>255) index=255;
|
||||||
|
return getBright255(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t getBright255(uint8_t percent)
|
||||||
|
{
|
||||||
|
#ifdef BRIGHT_LINEAR
|
||||||
|
return percent;
|
||||||
|
#else
|
||||||
|
int val = stepvar[index];
|
||||||
|
if (val>255) val=255;
|
||||||
|
Serial.print(F("Bright:"));
|
||||||
|
Serial.print(percent);
|
||||||
|
Serial.print(F("->"));
|
||||||
|
Serial.println(val);
|
||||||
|
return val;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
105
lighthub/bright.h
Normal file
105
lighthub/bright.h
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <Arduino.h>
|
||||||
|
#define BRIGHT_LINEAR
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef BRIGHT_LOG
|
||||||
|
const uint8_t stepvar[] PROGMEM =
|
||||||
|
{
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
// 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||||
|
0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||||
|
0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||||
|
0x01, 0x02, 0x02, 0x02, 0x02, 0x02,
|
||||||
|
0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
|
||||||
|
0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
|
||||||
|
0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
|
||||||
|
0x02, 0x03, 0x03, 0x03, 0x03, 0x03,
|
||||||
|
0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
|
||||||
|
0x03, 0x03, 0x03, 0x03, 0x04, 0x04,
|
||||||
|
0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
|
||||||
|
0x04, 0x04, 0x04, 0x04, 0x05, 0x05,
|
||||||
|
0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
|
||||||
|
0x05, 0x06, 0x06, 0x06, 0x06, 0x06,
|
||||||
|
0x06, 0x06, 0x06, 0x07, 0x07, 0x07,
|
||||||
|
0x07, 0x07, 0x07, 0x08, 0x08, 0x08,
|
||||||
|
0x08, 0x08, 0x08, 0x09, 0x09, 0x09,
|
||||||
|
0x09, 0x09, 0x0A, 0x0A, 0x0A, 0x0A,
|
||||||
|
0x0A, 0x0B, 0x0B, 0x0B, 0x0B, 0x0C,
|
||||||
|
0x0C, 0x0C, 0x0C, 0x0D, 0x0D, 0x0D,
|
||||||
|
0x0E, 0x0E, 0x0E, 0x0E, 0x0F, 0x0F,
|
||||||
|
0x0F, 0x10, 0x10, 0x10, 0x11, 0x11,
|
||||||
|
0x12, 0x12, 0x12, 0x13, 0x13, 0x14,
|
||||||
|
0x14, 0x14, 0x15, 0x15, 0x16, 0x16,
|
||||||
|
0x17, 0x17, 0x18, 0x18, 0x19, 0x19,
|
||||||
|
0x1A, 0x1B, 0x1B, 0x1C, 0x1C, 0x1D,
|
||||||
|
0x1E, 0x1E, 0x1F, 0x20, 0x20, 0x21,
|
||||||
|
0x22, 0x23, 0x23, 0x24, 0x25, 0x26,
|
||||||
|
0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B,
|
||||||
|
0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31,
|
||||||
|
0x32, 0x33, 0x34, 0x35, 0x37, 0x38,
|
||||||
|
0x39, 0x3A, 0x3B, 0x3D, 0x3E, 0x3F,
|
||||||
|
0x41, 0x42, 0x44, 0x45, 0x47, 0x48,
|
||||||
|
0x4A, 0x4C, 0x4D, 0x4F, 0x51, 0x52,
|
||||||
|
0x54, 0x56, 0x58, 0x5A, 0x5C, 0x5E,
|
||||||
|
0x60, 0x62, 0x64, 0x66, 0x69, 0x6B,
|
||||||
|
0x6D, 0x70, 0x72, 0x75, 0x77, 0x7A,
|
||||||
|
0x7C, 0x7F, 0x82, 0x85, 0x88, 0x8B,
|
||||||
|
0x8E, 0x91, 0x94, 0x97, 0x9B, 0x9E,
|
||||||
|
0xA2, 0xA5, 0xA9, 0xAC, 0xB0, 0xB4,
|
||||||
|
0xB8, 0xBC, 0xC0, 0xC4, 0xC9, 0xCD,
|
||||||
|
0xD2, 0xD6, 0xDB, 0xE0, 0xE5, 0xEA,
|
||||||
|
0xEF, 0xF4, 0xF9, 0xFF};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef BRIGHT_STEP
|
||||||
|
const uint8_t stepvar[] PROGMEM =
|
||||||
|
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x01, 0x01, 0x01,
|
||||||
|
0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||||
|
0x01, 0x01, 0x01, 0x01, 0x01, 0x02,
|
||||||
|
0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
|
||||||
|
0x02, 0x02, 0x03, 0x03, 0x03, 0x03,
|
||||||
|
0x03, 0x03, 0x04, 0x04, 0x04, 0x04,
|
||||||
|
0x04, 0x04, 0x05, 0x05, 0x05, 0x05,
|
||||||
|
0x06, 0x06, 0x06, 0x06, 0x07, 0x07,
|
||||||
|
0x07, 0x07, 0x08, 0x08, 0x08, 0x08,
|
||||||
|
0x09, 0x09, 0x09, 0x0A, 0x0A, 0x0A,
|
||||||
|
0x0B, 0x0B, 0x0C, 0x0C, 0x0C, 0x0D,
|
||||||
|
0x0D, 0x0E, 0x0E, 0x0E, 0x0F, 0x0F,
|
||||||
|
0x10, 0x10, 0x11, 0x11, 0x12, 0x12,
|
||||||
|
0x13, 0x13, 0x14, 0x14, 0x15, 0x16,
|
||||||
|
0x16, 0x17, 0x17, 0x18, 0x19, 0x19,
|
||||||
|
0x1A, 0x1B, 0x1B, 0x1C, 0x1D, 0x1D,
|
||||||
|
0x1E, 0x1F, 0x20, 0x20, 0x21, 0x22,
|
||||||
|
0x23, 0x23, 0x24, 0x25, 0x26, 0x27,
|
||||||
|
0x28, 0x29, 0x29, 0x2A, 0x2B, 0x2C,
|
||||||
|
0x2D, 0x2E, 0x2F, 0x30, 0x31, 0x32,
|
||||||
|
0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
|
||||||
|
0x39, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
|
||||||
|
0x40, 0x42, 0x43, 0x44, 0x45, 0x47,
|
||||||
|
0x48, 0x49, 0x4B, 0x4C, 0x4D, 0x4F,
|
||||||
|
0x50, 0x51, 0x53, 0x54, 0x56, 0x57,
|
||||||
|
0x59, 0x5A, 0x5C, 0x5D, 0x5F, 0x60,
|
||||||
|
0x62, 0x64, 0x65, 0x67, 0x68, 0x6A,
|
||||||
|
0x6C, 0x6E, 0x6F, 0x71, 0x73, 0x75,
|
||||||
|
0x76, 0x78, 0x7A, 0x7C, 0x7E, 0x80,
|
||||||
|
0x82, 0x84, 0x85, 0x87, 0x89, 0x8B,
|
||||||
|
0x8E, 0x90, 0x92, 0x94, 0x96, 0x98,
|
||||||
|
0x9A, 0x9C, 0x9E, 0xA1, 0xA3, 0xA5,
|
||||||
|
0xA7, 0xAA, 0xAC, 0xAE, 0xB1, 0xB3,
|
||||||
|
0xB6, 0xB8, 0xBA, 0xBD, 0xBF, 0xC2,
|
||||||
|
0xC4, 0xC7, 0xCA, 0xCC, 0xCF, 0xD1,
|
||||||
|
0xD4, 0xD7, 0xD9, 0xDC, 0xDF, 0xE2,
|
||||||
|
0xE5, 0xE7, 0xEA, 0xED, 0xF0, 0xF3,
|
||||||
|
0xF6, 0xF9, 0xFC, 0xFF};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
uint8_t getBright(uint8_t percent);
|
||||||
|
uint8_t getBright255(uint8_t percent);
|
||||||
@@ -21,6 +21,7 @@ e-mail anklimov@gmail.com
|
|||||||
//#include <DmxSimple.h>
|
//#include <DmxSimple.h>
|
||||||
//#include <DMXSerial.h>
|
//#include <DMXSerial.h>
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
|
#include "item.h"
|
||||||
|
|
||||||
#ifdef _dmxin
|
#ifdef _dmxin
|
||||||
#if defined(ARDUINO_ARCH_AVR)
|
#if defined(ARDUINO_ARCH_AVR)
|
||||||
@@ -35,6 +36,13 @@ DMXESPSerial dmxout;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint8_t * DMXin = NULL;
|
uint8_t * DMXin = NULL;
|
||||||
|
|
||||||
|
#ifdef DMX_SMOOTH
|
||||||
|
uint8_t * DMXinterimBuf = NULL;
|
||||||
|
uint16_t DMXOUT_Channels=0;
|
||||||
|
uint32_t checkTimestamp=0L;
|
||||||
|
#endif
|
||||||
|
|
||||||
int D_State=0;
|
int D_State=0;
|
||||||
|
|
||||||
unsigned long D_checkT=0;
|
unsigned long D_checkT=0;
|
||||||
@@ -61,16 +69,16 @@ int itemCtrl2(char* name,int r,int g, int b, int w)
|
|||||||
short itemaddr = aJson.getArrayItem(itemArr,1)->valueint;
|
short itemaddr = aJson.getArrayItem(itemArr,1)->valueint;
|
||||||
switch (itemtype){
|
switch (itemtype){
|
||||||
#ifdef _dmxout
|
#ifdef _dmxout
|
||||||
case 0: //Dimmed light
|
case CH_DIMMER: //Dimmed light
|
||||||
|
|
||||||
DmxWrite(itemaddr, w);
|
DmxWrite(itemaddr, w);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case 1: //Colour RGBW
|
case CH_RGBW: //Colour RGBW
|
||||||
DmxWrite(itemaddr+3, w);
|
DmxWrite(itemaddr+3, w);
|
||||||
|
|
||||||
case 2: // RGB
|
case CH_RGB: // RGB
|
||||||
{
|
{
|
||||||
|
|
||||||
DmxWrite(itemaddr, r);
|
DmxWrite(itemaddr, r);
|
||||||
@@ -79,13 +87,13 @@ int itemCtrl2(char* name,int r,int g, int b, int w)
|
|||||||
|
|
||||||
break; }
|
break; }
|
||||||
#endif
|
#endif
|
||||||
case 7: //Group
|
case CH_GROUP: //Group
|
||||||
aJsonObject *groupArr= aJson.getArrayItem(itemArr, 1);
|
aJsonObject *groupArr= aJson.getArrayItem(itemArr, 1);
|
||||||
if (groupArr && (groupArr->type==aJson_Array))
|
if (groupArr && (groupArr->type==aJson_Array))
|
||||||
{ aJsonObject *i =groupArr->child;
|
{ aJsonObject *i =groupArr->child;
|
||||||
while (i)
|
while (i)
|
||||||
{ //Serial.println(i->valuestring);
|
{ //Serial.println(i->valuestring);
|
||||||
itemCtrl2(i->valuestring,r,g,b,w);
|
if (i->type == aJson_String) itemCtrl2(i->valuestring,r,g,b,w);
|
||||||
i=i->next;}
|
i=i->next;}
|
||||||
}
|
}
|
||||||
} //itemtype
|
} //itemtype
|
||||||
@@ -100,7 +108,9 @@ void DMXImmediateUpdate(short tch,short r, short g, short b, short w) {
|
|||||||
if (dmxArr && (dmxArr->type==aJson_Array))
|
if (dmxArr && (dmxArr->type==aJson_Array))
|
||||||
|
|
||||||
{
|
{
|
||||||
char* itemname = aJson.getArrayItem(dmxArr,tch)->valuestring;
|
aJsonObject *DMXch = aJson.getArrayItem(dmxArr,tch);
|
||||||
|
char* itemname = NULL;
|
||||||
|
if (DMXch->type == aJson_String) itemname=DMXch->valuestring;
|
||||||
if (itemname) itemCtrl2(itemname,r,g,b,w);
|
if (itemname) itemCtrl2(itemname,r,g,b,w);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -112,7 +122,6 @@ void DMXSemiImmediateUpdate(short tch,short trh, int val)
|
|||||||
|
|
||||||
void DMXput(void)
|
void DMXput(void)
|
||||||
{
|
{
|
||||||
int t;
|
|
||||||
for (short tch=0; tch<=3 ; tch++)
|
for (short tch=0; tch<=3 ; tch++)
|
||||||
{
|
{
|
||||||
short base = tch*4;
|
short base = tch*4;
|
||||||
@@ -160,6 +169,7 @@ for (short tch=0; tch<=3 ; tch++)
|
|||||||
{
|
{
|
||||||
// CHSV hsv;
|
// CHSV hsv;
|
||||||
// CRGB rgb;
|
// CRGB rgb;
|
||||||
|
DMXOUT_propagate();
|
||||||
#if defined(_dmxin)
|
#if defined(_dmxin)
|
||||||
|
|
||||||
short t,tch;
|
short t,tch;
|
||||||
@@ -191,7 +201,7 @@ for (int i=1; i<17; i++) {Serial.print(dmxin.read(i));Serial.print(";");}
|
|||||||
void onDmxFrame(uint16_t universe, uint16_t length, uint8_t sequence, uint8_t* data, IPAddress remoteIP)
|
void onDmxFrame(uint16_t universe, uint16_t length, uint8_t sequence, uint8_t* data, IPAddress remoteIP)
|
||||||
{
|
{
|
||||||
#ifdef _dmxout
|
#ifdef _dmxout
|
||||||
for (int i = 0 ; i < length && i<MAX_CHANNELS ; i++)
|
for (unsigned int i = 0 ; i < length && i<MAX_CHANNELS ; i++)
|
||||||
{
|
{
|
||||||
DmxWrite(i+1,data[i]);
|
DmxWrite(i+1,data[i]);
|
||||||
}
|
}
|
||||||
@@ -249,8 +259,42 @@ dmxout.setTxMaxChannels(channels);
|
|||||||
#ifndef DMX_DISABLE
|
#ifndef DMX_DISABLE
|
||||||
for (int i=1;i<=channels;i++) DmxWrite(i,0);
|
for (int i=1;i<=channels;i++) DmxWrite(i,0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef DMX_SMOOTH
|
||||||
|
if (DMXinterimBuf) delete DMXinterimBuf;
|
||||||
|
DMXinterimBuf = new uint8_t [channels];
|
||||||
|
DMXOUT_Channels=channels;
|
||||||
|
for (int i=1;i<=channels;i++) DMXinterimBuf[i]=0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DMXOUT_propagate()
|
||||||
|
{
|
||||||
|
#ifdef DMX_SMOOTH
|
||||||
|
uint32_t now = millis();
|
||||||
|
if (now<checkTimestamp) return;
|
||||||
|
|
||||||
|
for(int i=1;i<=DMXOUT_Channels;i++)
|
||||||
|
{
|
||||||
|
uint8_t currLevel=dmxout.getTx(i);
|
||||||
|
uint16_t delta = currLevel-DMXinterimBuf[i-1];
|
||||||
|
if (delta)
|
||||||
|
{
|
||||||
|
uint16_t step = abs(delta) >> 4;
|
||||||
|
if (!step) step=1;
|
||||||
|
|
||||||
|
if (delta<0)
|
||||||
|
DmxWrite2(i,currLevel+step);
|
||||||
|
|
||||||
|
if (delta>0)
|
||||||
|
DmxWrite2(i,currLevel-step);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
checkTimestamp=now+DMX_SMOOTH_DELAY;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ArtnetSetup()
|
void ArtnetSetup()
|
||||||
{
|
{
|
||||||
#ifdef _artnet
|
#ifdef _artnet
|
||||||
@@ -259,3 +303,12 @@ void ArtnetSetup()
|
|||||||
if (artnet) artnet->setArtDmxCallback(onDmxFrame);
|
if (artnet) artnet->setArtDmxCallback(onDmxFrame);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DmxWriteBuf(uint16_t chan,uint8_t val)
|
||||||
|
{
|
||||||
|
#ifdef DMX_SMOOTH
|
||||||
|
if (chan && chan<=DMXOUT_Channels)
|
||||||
|
DMXinterimBuf[chan-1] = val;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|||||||
@@ -32,6 +32,35 @@ e-mail anklimov@gmail.com
|
|||||||
|
|
||||||
#if defined(_dmxout)
|
#if defined(_dmxout)
|
||||||
|
|
||||||
|
#if defined DMX_SMOOTH
|
||||||
|
|
||||||
|
#if defined(ARDUINO_ARCH_AVR)
|
||||||
|
#include <DmxSimple.h>
|
||||||
|
#define DmxWrite DmxSimple.write
|
||||||
|
//#define DmxWrite DmxWriteBuf
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(ESP8266)
|
||||||
|
#include <ESPDMX.h>
|
||||||
|
extern DMXESPSerial dmxout;
|
||||||
|
#define DmxWrite dmxout.write
|
||||||
|
//#define DmxWrite DmxWriteBuf
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(ARDUINO_ARCH_ESP32)
|
||||||
|
#include <ESPDMX.h>
|
||||||
|
extern DMXESPSerial dmxout;
|
||||||
|
#define DmxWrite dmxout.write
|
||||||
|
//#define DmxWrite DmxWriteBuf
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__SAM3X8E__)
|
||||||
|
#include <DmxDue.h>
|
||||||
|
#define DmxWrite2 dmxout.write
|
||||||
|
#define DmxWrite DmxWriteBuf
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#else
|
||||||
#if defined(ARDUINO_ARCH_AVR)
|
#if defined(ARDUINO_ARCH_AVR)
|
||||||
#include <DmxSimple.h>
|
#include <DmxSimple.h>
|
||||||
#define DmxWrite DmxSimple.write
|
#define DmxWrite DmxSimple.write
|
||||||
@@ -52,6 +81,8 @@ extern DMXESPSerial dmxout;
|
|||||||
#if defined(__SAM3X8E__)
|
#if defined(__SAM3X8E__)
|
||||||
#include <DmxDue.h>
|
#include <DmxDue.h>
|
||||||
#define DmxWrite dmxout.write
|
#define DmxWrite dmxout.write
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -78,3 +109,5 @@ void ArtnetSetup();
|
|||||||
void DMXCheck(void);
|
void DMXCheck(void);
|
||||||
int itemCtrl2(char* name,int r,int g, int b, int w);
|
int itemCtrl2(char* name,int r,int g, int b, int w);
|
||||||
void ArtnetSetup();
|
void ArtnetSetup();
|
||||||
|
void DmxWriteBuf(uint16_t chan,uint8_t val);
|
||||||
|
void DMXOUT_propagate();
|
||||||
|
|||||||
@@ -1,38 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
const char state_P[] PROGMEM = "$state";
|
|
||||||
const char disconnected_P[] PROGMEM = "disconnected";
|
|
||||||
const char ready_P[] PROGMEM = "ready";
|
|
||||||
|
|
||||||
const char homie_P[] PROGMEM = "$homie";
|
|
||||||
const char homiever_P[] PROGMEM = "2.1.0";
|
|
||||||
|
|
||||||
const char name_P[] PROGMEM = "$name";
|
|
||||||
const char nameval_P[] PROGMEM = "LightHub ";
|
|
||||||
|
|
||||||
const char nodes_P[] PROGMEM = "$nodes";
|
|
||||||
const char localip_P[] PROGMEM = "$localip";
|
|
||||||
const char mac_P[] PROGMEM = "$mac";
|
|
||||||
const char fwname_P[] PROGMEM = "$fw/name";
|
|
||||||
const char fwversion_P[] PROGMEM = "$fw/version";
|
|
||||||
const char implementation_P[] PROGMEM = "$implementation";
|
|
||||||
const char interval_P[] PROGMEM = "$stats/interval";
|
|
||||||
const char color_P[] PROGMEM = "color";
|
|
||||||
|
|
||||||
const char datatype_P[] PROGMEM = "$datatype";
|
|
||||||
|
|
||||||
const char float_P[] PROGMEM = "float";
|
|
||||||
const char hsv_P[] PROGMEM = "hsv";
|
|
||||||
const char int_P[] PROGMEM = "integer";
|
|
||||||
const char enum_P[] PROGMEM = "enum";
|
|
||||||
const char format_P[] PROGMEM = "$format";
|
|
||||||
const char true_P[] PROGMEM = "true";
|
|
||||||
const char false_P[] PROGMEM = "false";
|
|
||||||
|
|
||||||
const char enumformat_P[] PROGMEM = "ON,OFF,HALT,REST,XON,XOFF,TOGGLE";
|
|
||||||
const char intformat_P[] PROGMEM = "0-100";
|
|
||||||
|
|
||||||
const char stats_P[] PROGMEM = "$stats";
|
|
||||||
const char statsval_P[] PROGMEM = "uptime,freeheap";
|
|
||||||
const char uptime_P[] PROGMEM = "uptime";
|
|
||||||
const char freeheap_P[] PROGMEM = "freeheap";
|
|
||||||
@@ -34,6 +34,7 @@ e-mail anklimov@gmail.com
|
|||||||
extern PubSubClient mqttClient;
|
extern PubSubClient mqttClient;
|
||||||
extern aJsonObject *root;
|
extern aJsonObject *root;
|
||||||
extern int8_t ethernetIdleCount;
|
extern int8_t ethernetIdleCount;
|
||||||
|
extern int8_t configLocked;
|
||||||
|
|
||||||
#if !defined(DHT_DISABLE) || !defined(COUNTER_DISABLE)
|
#if !defined(DHT_DISABLE) || !defined(COUNTER_DISABLE)
|
||||||
static volatile unsigned long nextPollMillisValue[5];
|
static volatile unsigned long nextPollMillisValue[5];
|
||||||
@@ -113,24 +114,69 @@ void Input::Parse()
|
|||||||
void Input::setup()
|
void Input::setup()
|
||||||
{
|
{
|
||||||
if (!isValid() || (!root)) return;
|
if (!isValid() || (!root)) return;
|
||||||
|
/*
|
||||||
#ifndef CSSHDC_DISABLE
|
#ifndef CSSHDC_DISABLE
|
||||||
if (inType == IN_CCS811)
|
if (inType == IN_CCS811)
|
||||||
{
|
{
|
||||||
in_ccs811 ccs811(this);
|
in_ccs811 ccs811(this);
|
||||||
ccs811.Setup(pin);
|
ccs811.Setup();
|
||||||
}
|
}
|
||||||
else if (inType == IN_HDC1080)
|
else if (inType == IN_HDC1080)
|
||||||
{
|
{
|
||||||
in_hdc1080 hdc1080(this);
|
in_hdc1080 hdc1080(this);
|
||||||
hdc1080.Setup(pin);
|
hdc1080.Setup();
|
||||||
}
|
}
|
||||||
// TODO rest types setup
|
// TODO rest types setup
|
||||||
#endif
|
#endif
|
||||||
|
*/
|
||||||
|
store->aslong=0;
|
||||||
|
uint8_t inputPinMode = INPUT; //if IN_ACTIVE_HIGH
|
||||||
|
switch (inType)
|
||||||
|
{
|
||||||
|
case IN_PUSH_ON:
|
||||||
|
case IN_PUSH_TOGGLE :
|
||||||
|
inputPinMode = INPUT_PULLUP;
|
||||||
|
|
||||||
|
case IN_PUSH_ON | IN_ACTIVE_HIGH:
|
||||||
|
case IN_PUSH_TOGGLE | IN_ACTIVE_HIGH:
|
||||||
|
pinMode(pin, inputPinMode);
|
||||||
|
|
||||||
|
store->state=IS_IDLE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IN_ANALOG:
|
||||||
|
inputPinMode = INPUT_PULLUP;
|
||||||
|
|
||||||
|
case IN_ANALOG | IN_ACTIVE_HIGH:
|
||||||
|
pinMode(pin, inputPinMode);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IN_DHT22:
|
||||||
|
case IN_COUNTER:
|
||||||
|
case IN_UPTIME:
|
||||||
|
break;
|
||||||
|
|
||||||
|
#ifndef CSSHDC_DISABLE
|
||||||
|
case IN_CCS811:
|
||||||
|
{
|
||||||
|
in_ccs811 ccs811(this);
|
||||||
|
ccs811.Setup();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IN_HDC1080:
|
||||||
|
{
|
||||||
|
in_hdc1080 hdc1080(this);
|
||||||
|
hdc1080.Setup();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
} //switch
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int Input::poll(short cause) {
|
int Input::Poll(short cause) {
|
||||||
|
|
||||||
if (!isValid()) return -1;
|
if (!isValid()) return -1;
|
||||||
#ifndef CSSHDC_DISABLE
|
#ifndef CSSHDC_DISABLE
|
||||||
@@ -140,17 +186,18 @@ if (!isValid()) return -1;
|
|||||||
|
|
||||||
switch (cause) {
|
switch (cause) {
|
||||||
case CHECK_INPUT: //Fast polling
|
case CHECK_INPUT: //Fast polling
|
||||||
|
case CHECK_INTERRUPT: //Realtime polling
|
||||||
switch (inType)
|
switch (inType)
|
||||||
{
|
{
|
||||||
case IN_PUSH_ON:
|
case IN_PUSH_ON:
|
||||||
case IN_PUSH_ON | IN_ACTIVE_HIGH:
|
case IN_PUSH_ON | IN_ACTIVE_HIGH:
|
||||||
case IN_PUSH_TOGGLE :
|
case IN_PUSH_TOGGLE :
|
||||||
case IN_PUSH_TOGGLE | IN_ACTIVE_HIGH:
|
case IN_PUSH_TOGGLE | IN_ACTIVE_HIGH:
|
||||||
contactPoll();
|
contactPoll(cause);
|
||||||
break;
|
break;
|
||||||
case IN_ANALOG:
|
case IN_ANALOG:
|
||||||
case IN_ANALOG | IN_ACTIVE_HIGH:
|
case IN_ANALOG | IN_ACTIVE_HIGH:
|
||||||
analogPoll();
|
analogPoll(cause);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// No fast polling
|
// No fast polling
|
||||||
@@ -167,10 +214,10 @@ switch (cause) {
|
|||||||
{
|
{
|
||||||
#ifndef CSSHDC_DISABLE
|
#ifndef CSSHDC_DISABLE
|
||||||
case IN_CCS811:
|
case IN_CCS811:
|
||||||
_ccs811.Poll();
|
_ccs811.Poll(POLLING_SLOW);
|
||||||
break;
|
break;
|
||||||
case IN_HDC1080:
|
case IN_HDC1080:
|
||||||
_hdc1080.Poll();
|
_hdc1080.Poll(POLLING_SLOW);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
#ifndef DHT_DISABLE
|
#ifndef DHT_DISABLE
|
||||||
@@ -188,6 +235,7 @@ switch (cause) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef COUNTER_DISABLE
|
#ifndef COUNTER_DISABLE
|
||||||
@@ -221,16 +269,16 @@ void Input::counterPoll() {
|
|||||||
debugSerial<<F("IN:")<<(pin)<<F(" Counter type. val=")<<counterValue;
|
debugSerial<<F("IN:")<<(pin)<<F(" Counter type. val=")<<counterValue;
|
||||||
|
|
||||||
aJsonObject *emit = aJson.getObjectItem(inputObj, "emit");
|
aJsonObject *emit = aJson.getObjectItem(inputObj, "emit");
|
||||||
if (emit) {
|
if (emit && emit->type == aJson_String) {
|
||||||
char valstr[10];
|
char valstr[10];
|
||||||
char addrstr[MQTT_TOPIC_LENGTH];
|
char addrstr[MQTT_TOPIC_LENGTH];
|
||||||
strncpy(addrstr,emit->valuestring,sizeof(addrstr));
|
strncpy(addrstr,emit->valuestring,sizeof(addrstr));
|
||||||
if (!strchr(addrstr,'/')) setTopic(addrstr,sizeof(addrstr),T_OUT,emit->valuestring);
|
if (!strchr(addrstr,'/')) setTopic(addrstr,sizeof(addrstr),T_OUT,emit->valuestring);
|
||||||
sprintf(valstr, "%d", counterValue);
|
sprintf(valstr, "%ld", counterValue);
|
||||||
if (mqttClient.connected() && !ethernetIdleCount)
|
if (mqttClient.connected() && !ethernetIdleCount)
|
||||||
mqttClient.publish(addrstr, valstr);
|
mqttClient.publish(addrstr, valstr);
|
||||||
setNextPollTime(millis() + DHT_POLL_DELAY_DEFAULT);
|
setNextPollTime(millis() + DHT_POLL_DELAY_DEFAULT);
|
||||||
debugSerial<<F(" NextPollMillis=")<<nextPollTime();
|
// debugSerial<<F(" NextPollMillis=")<<nextPollTime();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
debugSerial<<F(" No emit data!");
|
debugSerial<<F(" No emit data!");
|
||||||
@@ -280,7 +328,7 @@ void Input::uptimePoll() {
|
|||||||
if (nextPollTime() > millis())
|
if (nextPollTime() > millis())
|
||||||
return;
|
return;
|
||||||
aJsonObject *emit = aJson.getObjectItem(inputObj, "emit");
|
aJsonObject *emit = aJson.getObjectItem(inputObj, "emit");
|
||||||
if (emit) {
|
if (emit && emit->type == aJson_String) {
|
||||||
#ifdef WITH_DOMOTICZ
|
#ifdef WITH_DOMOTICZ
|
||||||
if(getIdxField()){
|
if(getIdxField()){
|
||||||
publishDataToDomoticz(DHT_POLL_DELAY_DEFAULT, emit, "{\"idx\":%s,\"svalue\":\"%d\"}", getIdxField(), millis());
|
publishDataToDomoticz(DHT_POLL_DELAY_DEFAULT, emit, "{\"idx\":%s,\"svalue\":\"%d\"}", getIdxField(), millis());
|
||||||
@@ -375,9 +423,9 @@ void Input::dht22Poll() {
|
|||||||
#endif
|
#endif
|
||||||
aJsonObject *emit = aJson.getObjectItem(inputObj, "emit");
|
aJsonObject *emit = aJson.getObjectItem(inputObj, "emit");
|
||||||
aJsonObject *item = aJson.getObjectItem(inputObj, "item");
|
aJsonObject *item = aJson.getObjectItem(inputObj, "item");
|
||||||
if (item) thermoSetCurTemp(item->valuestring, temp);
|
if (item && item->type == aJson_String) thermoSetCurTemp(item->valuestring, temp);
|
||||||
debugSerial << F("IN:") << pin << F(" DHT22 type. T=") << temp << F("°C H=") << humidity << F("%")<<endl;
|
debugSerial << F("IN:") << pin << F(" DHT22 type. T=") << temp << F("°C H=") << humidity << F("%")<<endl;
|
||||||
if (emit && temp && humidity && temp == temp && humidity == humidity) {
|
if (emit && emit->type == aJson_String && temp && humidity && temp == temp && humidity == humidity) {
|
||||||
char addrstr[MQTT_TOPIC_LENGTH] = "";
|
char addrstr[MQTT_TOPIC_LENGTH] = "";
|
||||||
#ifdef WITH_DOMOTICZ
|
#ifdef WITH_DOMOTICZ
|
||||||
if(getIdxField()){
|
if(getIdxField()){
|
||||||
@@ -399,97 +447,443 @@ void Input::dht22Poll() {
|
|||||||
mqttClient.publish(addrstr, valstr);
|
mqttClient.publish(addrstr, valstr);
|
||||||
|
|
||||||
setNextPollTime(millis() + DHT_POLL_DELAY_DEFAULT);
|
setNextPollTime(millis() + DHT_POLL_DELAY_DEFAULT);
|
||||||
debugSerial << F(" NextPollMillis=") << nextPollTime() << endl;
|
// debugSerial << F(" NextPollMillis=") << nextPollTime() << endl;
|
||||||
} else
|
} else
|
||||||
setNextPollTime(millis() + DHT_POLL_DELAY_DEFAULT / 3);
|
setNextPollTime(millis() + DHT_POLL_DELAY_DEFAULT / 3);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void Input::contactPoll() {
|
bool Input::executeCommand(aJsonObject* cmd, int8_t toggle, char* defCmd)
|
||||||
boolean currentInputState;
|
{
|
||||||
|
if (!cmd) return false;
|
||||||
|
|
||||||
|
switch (cmd->type)
|
||||||
|
{
|
||||||
|
case aJson_String: //legacy - no action
|
||||||
|
break;
|
||||||
|
case aJson_Array: //array - recursive iterate
|
||||||
|
{
|
||||||
|
configLocked++;
|
||||||
|
aJsonObject * command = cmd->child;
|
||||||
|
while (command)
|
||||||
|
{
|
||||||
|
executeCommand(command,toggle,defCmd);
|
||||||
|
command = command->next;
|
||||||
|
}
|
||||||
|
configLocked--;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case aJson_Object:
|
||||||
|
{
|
||||||
|
aJsonObject *item = aJson.getObjectItem(cmd, "item");
|
||||||
|
aJsonObject *icmd = aJson.getObjectItem(cmd, "icmd");
|
||||||
|
aJsonObject *irev = aJson.getObjectItem(cmd, "irev");
|
||||||
|
aJsonObject *ecmd = aJson.getObjectItem(cmd, "ecmd");
|
||||||
|
aJsonObject *erev = aJson.getObjectItem(cmd, "erev");
|
||||||
|
aJsonObject *emit = aJson.getObjectItem(cmd, "emit");
|
||||||
|
|
||||||
|
char * itemCommand;
|
||||||
|
if (irev && toggle && irev->type == aJson_String) itemCommand = irev->valuestring;
|
||||||
|
else if(icmd && icmd->type == aJson_String) itemCommand = icmd->valuestring;
|
||||||
|
else itemCommand = defCmd;
|
||||||
|
|
||||||
|
char * emitCommand;
|
||||||
|
if (erev && toggle && erev->type == aJson_String) emitCommand = erev->valuestring;
|
||||||
|
else if(ecmd && ecmd->type == aJson_String) emitCommand = ecmd->valuestring;
|
||||||
|
else emitCommand = defCmd;
|
||||||
|
|
||||||
|
debugSerial << F("IN:") << (pin) << F(" : ") <<endl;
|
||||||
|
if (item) debugSerial << item->valuestring<< F(" -> ")<<itemCommand<<endl;
|
||||||
|
if (emit) debugSerial << emit->valuestring<< F(" -> ")<<emitCommand<<endl;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (emit && emitCommand && emit->type == aJson_String) {
|
||||||
/*
|
/*
|
||||||
#if defined(ARDUINO_ARCH_STM32)
|
TODO implement
|
||||||
WiringPinMode inputPinMode;
|
#ifdef WITH_DOMOTICZ
|
||||||
#endif
|
if (getIdxField())
|
||||||
|
{ (newValue) ? publishDataToDomoticz(0, emit, "{\"command\":\"switchlight\",\"idx\":%s,\"switchcmd\":\"On\"}",
|
||||||
#if defined(__SAM3X8E__)||defined(ARDUINO_ARCH_AVR)||defined(ARDUINO_ARCH_ESP8266)||defined(ARDUINO_ARCH_ESP32)
|
: publishDataToDomoticz(0,emit,"{\"command\":\"switchlight\",\"idx\":%s,\"switchcmd\":\"Off\"}",getIdxField()); getIdxField())
|
||||||
|
: publishDataToDomoticz(0, emit,
|
||||||
|
"{\"command\":\"switchlight\",\"idx\":%s,\"switchcmd\":\"Off\"}",
|
||||||
|
getIdxField());
|
||||||
|
} else
|
||||||
#endif
|
#endif
|
||||||
*/
|
*/
|
||||||
uint32_t inputPinMode;
|
|
||||||
uint8_t inputOnLevel;
|
{
|
||||||
if (inType & IN_ACTIVE_HIGH) {
|
char addrstr[MQTT_TOPIC_LENGTH];
|
||||||
inputOnLevel = HIGH;
|
strncpy(addrstr,emit->valuestring,sizeof(addrstr));
|
||||||
inputPinMode = INPUT;
|
if (mqttClient.connected() && !ethernetIdleCount)
|
||||||
} else {
|
{
|
||||||
inputOnLevel = LOW;
|
if (!strchr(addrstr,'/')) setTopic(addrstr,sizeof(addrstr),T_OUT,emit->valuestring);
|
||||||
inputPinMode = INPUT_PULLUP;
|
mqttClient.publish(addrstr, emitCommand , true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // emit
|
||||||
|
if (item && itemCommand && item->type == aJson_String) {
|
||||||
|
//debugSerial <<F("Controlled item:")<< item->valuestring <<endl;
|
||||||
|
Item it(item->valuestring);
|
||||||
|
if (it.isValid()) it.Ctrl(itemCommand, true);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
} //switch type
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Polling via timed interrupt with CHECK_INTERRUPT cause
|
||||||
|
bool Input::changeState(uint8_t newState, short cause)
|
||||||
|
{
|
||||||
|
if (!inputObj || !store) return false;
|
||||||
|
|
||||||
|
if (newState == IS_REQSTATE)
|
||||||
|
if (store->delayedState && cause != CHECK_INTERRUPT)
|
||||||
|
{
|
||||||
|
// Requested delayed change State and safe moment
|
||||||
|
newState=store->reqState; //Retrieve requested state
|
||||||
|
debugSerial<<F("Pended state retrieved:")<<newState;
|
||||||
|
|
||||||
}
|
}
|
||||||
pinMode(pin, inputPinMode);
|
else return true; // No pended State
|
||||||
|
else if (store->delayedState)
|
||||||
|
return false; //State changing is postponed already (( giving up
|
||||||
|
|
||||||
|
aJsonObject *cmd = NULL;
|
||||||
|
int8_t toggle=0;
|
||||||
|
if (newState!=store->state) debugSerial<<F("#")<<pin<<F(" ")<<store->state<<F("->") <<newState<<endl;
|
||||||
|
switch (newState)
|
||||||
|
{
|
||||||
|
case IS_IDLE:
|
||||||
|
switch (store->state)
|
||||||
|
{
|
||||||
|
case IS_RELEASED: //click
|
||||||
|
cmd = aJson.getObjectItem(inputObj, "click");
|
||||||
|
toggle=store->toggle1;
|
||||||
|
break;
|
||||||
|
case IS_RELEASED2: //doubleclick
|
||||||
|
cmd = aJson.getObjectItem(inputObj, "dclick");
|
||||||
|
toggle=store->toggle2;
|
||||||
|
break;
|
||||||
|
case IS_PRESSED3: //tripple click
|
||||||
|
cmd = aJson.getObjectItem(inputObj, "tclick");
|
||||||
|
toggle=store->toggle3;
|
||||||
|
break;
|
||||||
|
case IS_WAITPRESS: //do nothing
|
||||||
|
break;
|
||||||
|
default: //rcmd
|
||||||
|
cmd = aJson.getObjectItem(inputObj, "rcmd");
|
||||||
|
;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case IS_PRESSED: //scmd
|
||||||
|
cmd = aJson.getObjectItem(inputObj, "scmd");
|
||||||
|
toggle=store->toggle1;
|
||||||
|
store->toggle1 = !store->toggle1;
|
||||||
|
break;
|
||||||
|
case IS_PRESSED2: //scmd2
|
||||||
|
cmd = aJson.getObjectItem(inputObj, "scmd2");
|
||||||
|
toggle=store->toggle2;
|
||||||
|
store->toggle2 = !store->toggle2;
|
||||||
|
break;
|
||||||
|
case IS_PRESSED3: //scmd3
|
||||||
|
cmd = aJson.getObjectItem(inputObj, "scmd3");
|
||||||
|
toggle=store->toggle3;
|
||||||
|
store->toggle3 = !store->toggle3;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IS_RELEASED: //rcmd
|
||||||
|
case IS_WAITPRESS:
|
||||||
|
case IS_RELEASED2:
|
||||||
|
cmd = aJson.getObjectItem(inputObj, "rcmd");
|
||||||
|
// toggle=state->toggle1;
|
||||||
|
|
||||||
|
break;
|
||||||
|
case IS_LONG: //lcmd
|
||||||
|
cmd = aJson.getObjectItem(inputObj, "lcmd");
|
||||||
|
toggle=store->toggle1;
|
||||||
|
break;
|
||||||
|
case IS_REPEAT: //rpcmd
|
||||||
|
cmd = aJson.getObjectItem(inputObj, "rpcmd");
|
||||||
|
toggle=store->toggle1;
|
||||||
|
break;
|
||||||
|
case IS_LONG2: //lcmd2
|
||||||
|
cmd = aJson.getObjectItem(inputObj, "lcmd2");
|
||||||
|
toggle=store->toggle2;
|
||||||
|
break;
|
||||||
|
case IS_REPEAT2: //rpcmd2
|
||||||
|
cmd = aJson.getObjectItem(inputObj, "rpcmd2");
|
||||||
|
toggle=store->toggle2;
|
||||||
|
break;
|
||||||
|
case IS_LONG3: //lcmd3
|
||||||
|
cmd = aJson.getObjectItem(inputObj, "lcmd3");
|
||||||
|
toggle=store->toggle3;
|
||||||
|
break;
|
||||||
|
case IS_REPEAT3: //rpcmd3
|
||||||
|
cmd = aJson.getObjectItem(inputObj, "rpcmd3");
|
||||||
|
toggle=store->toggle3;
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
if (!cmd)
|
||||||
|
{
|
||||||
|
store->state=newState;
|
||||||
|
return true; //nothing to do
|
||||||
|
}
|
||||||
|
if (cause != CHECK_INTERRUPT)
|
||||||
|
{
|
||||||
|
store->state=newState;
|
||||||
|
executeCommand(cmd,toggle);
|
||||||
|
//Executed
|
||||||
|
store->delayedState=false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//Postpone actual execution
|
||||||
|
store->reqState=store->state;
|
||||||
|
store->delayedState=true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Input::contactPoll(short cause) {
|
||||||
|
boolean currentInputState;
|
||||||
|
if (!store) return;
|
||||||
|
|
||||||
|
changeState(IS_REQSTATE,cause); //Check for postponed states transitions
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t inputOnLevel;
|
||||||
|
if (inType & IN_ACTIVE_HIGH) inputOnLevel = HIGH;
|
||||||
|
else inputOnLevel = LOW;
|
||||||
|
|
||||||
|
|
||||||
currentInputState = (digitalRead(pin) == inputOnLevel);
|
currentInputState = (digitalRead(pin) == inputOnLevel);
|
||||||
if (currentInputState != store->currentValue) // value changed
|
|
||||||
|
switch (store->state) //Timer based transitions
|
||||||
|
{
|
||||||
|
case IS_PRESSED:
|
||||||
|
if (isTimeOver(store->timestamp16,millis() & 0xFFFF,T_LONG,0xFFFF))
|
||||||
|
{
|
||||||
|
if (!aJson.getObjectItem(inputObj, "lcmd") && !aJson.getObjectItem(inputObj, "rpcmd")) changeState(IS_WAITRELEASE, cause);
|
||||||
|
else changeState(IS_LONG, cause);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IS_LONG:
|
||||||
|
if (isTimeOver(store->timestamp16,millis() & 0xFFFF,T_RPT,0xFFFF))
|
||||||
|
{
|
||||||
|
changeState(IS_REPEAT, cause);
|
||||||
|
store->timestamp16 = millis() & 0xFFFF;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IS_REPEAT:
|
||||||
|
if (isTimeOver(store->timestamp16,millis() & 0xFFFF,T_RPT_PULSE,0xFFFF))
|
||||||
|
{
|
||||||
|
changeState(IS_REPEAT, cause);
|
||||||
|
store->timestamp16 = millis() & 0xFFFF;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IS_PRESSED2:
|
||||||
|
if (isTimeOver(store->timestamp16,millis() & 0xFFFF,T_LONG,0xFFFF))
|
||||||
|
{
|
||||||
|
if (!aJson.getObjectItem(inputObj, "lcmd2") && !aJson.getObjectItem(inputObj, "rpcmd2")) changeState(IS_WAITRELEASE, cause);
|
||||||
|
else changeState(IS_LONG2, cause);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IS_LONG2:
|
||||||
|
if (isTimeOver(store->timestamp16,millis() & 0xFFFF,T_RPT,0xFFFF))
|
||||||
|
{
|
||||||
|
changeState(IS_REPEAT2, cause);
|
||||||
|
store->timestamp16 = millis() & 0xFFFF;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IS_REPEAT2:
|
||||||
|
if (isTimeOver(store->timestamp16,millis() & 0xFFFF,T_RPT_PULSE,0xFFFF))
|
||||||
|
{
|
||||||
|
changeState(IS_REPEAT2, cause);
|
||||||
|
store->timestamp16 = millis() & 0xFFFF;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IS_PRESSED3:
|
||||||
|
if (isTimeOver(store->timestamp16,millis() & 0xFFFF,T_LONG,0xFFFF))
|
||||||
|
{
|
||||||
|
if (!aJson.getObjectItem(inputObj, "lcmd3") && !aJson.getObjectItem(inputObj, "rpcmd3")) //No longpress handlers
|
||||||
|
{
|
||||||
|
if (aJson.getObjectItem(inputObj, "scmd3")) changeState(IS_WAITRELEASE, cause); //was used
|
||||||
|
else changeState(IS_PRESSED2, cause); // completely empty trippleClick section - fallback to first click handler
|
||||||
|
}
|
||||||
|
else changeState(IS_LONG3, cause);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IS_LONG3:
|
||||||
|
if (isTimeOver(store->timestamp16,millis() & 0xFFFF,T_RPT,0xFFFF))
|
||||||
|
{
|
||||||
|
changeState(IS_REPEAT3, cause);
|
||||||
|
store->timestamp16 = millis() & 0xFFFF;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IS_REPEAT3:
|
||||||
|
if (isTimeOver(store->timestamp16,millis() & 0xFFFF,T_RPT_PULSE,0xFFFF))
|
||||||
|
{
|
||||||
|
changeState(IS_REPEAT3, cause);
|
||||||
|
store->timestamp16 = millis() & 0xFFFF;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IS_RELEASED:
|
||||||
|
case IS_RELEASED2:
|
||||||
|
case IS_WAITPRESS:
|
||||||
|
|
||||||
|
|
||||||
|
if (isTimeOver(store->timestamp16,millis() & 0xFFFF,T_IDLE,0xFFFF)) changeState(IS_IDLE, cause);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentInputState != store->lastValue) // value changed
|
||||||
{
|
{
|
||||||
if (store->bounce) store->bounce = store->bounce - 1;
|
if (store->bounce) store->bounce = store->bounce - 1;
|
||||||
else //confirmed change
|
else //confirmed change
|
||||||
{
|
{
|
||||||
if (inType & IN_PUSH_TOGGLE) {
|
store->timestamp16 = millis() & 0xFFFF; //Saving timestamp of changing
|
||||||
|
|
||||||
|
if (inType & IN_PUSH_TOGGLE) { //To refactore
|
||||||
if (currentInputState) { //react on leading edge only (change from 0 to 1)
|
if (currentInputState) { //react on leading edge only (change from 0 to 1)
|
||||||
store->logicState = !store->logicState;
|
//store->logicState = !store->logicState;
|
||||||
onContactChanged(store->logicState);
|
store->lastValue = currentInputState;
|
||||||
|
onContactChanged(store->toggle1);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
|
||||||
|
{
|
||||||
|
onContactChanged(currentInputState); //Legacy input - to remove later
|
||||||
|
|
||||||
|
bool res = true;
|
||||||
|
if (currentInputState) //Button pressed state transitions
|
||||||
|
|
||||||
|
switch (store->state)
|
||||||
|
{
|
||||||
|
case IS_IDLE:
|
||||||
|
res = changeState(IS_PRESSED, cause);
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IS_RELEASED:
|
||||||
|
case IS_WAITPRESS:
|
||||||
|
res = changeState(IS_PRESSED2, cause);
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IS_RELEASED2:
|
||||||
|
|
||||||
|
res = changeState(IS_PRESSED3, cause);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
switch (store->state) //Button released state transitions
|
||||||
|
{
|
||||||
|
case IS_PRESSED:
|
||||||
|
|
||||||
|
res = changeState(IS_RELEASED, cause);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IS_LONG:
|
||||||
|
case IS_REPEAT:
|
||||||
|
case IS_WAITRELEASE:
|
||||||
|
res = changeState(IS_WAITPRESS, cause);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IS_PRESSED2:
|
||||||
|
res = changeState(IS_RELEASED2, cause);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IS_LONG2:
|
||||||
|
case IS_REPEAT2:
|
||||||
|
case IS_LONG3:
|
||||||
|
case IS_REPEAT3:
|
||||||
|
case IS_PRESSED3:
|
||||||
|
res = changeState(IS_IDLE, cause);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (res) { //State changed or postponed
|
||||||
|
// store->logicState = currentInputState;
|
||||||
|
store->lastValue = currentInputState;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
store->logicState = currentInputState;
|
|
||||||
onContactChanged(currentInputState);
|
|
||||||
}
|
}
|
||||||
store->currentValue = currentInputState;
|
// store->currentValue = currentInputState;
|
||||||
}
|
}
|
||||||
} else // no change
|
} else // no change
|
||||||
store->bounce = SAME_STATE_ATTEMPTS;
|
store->bounce = SAME_STATE_ATTEMPTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Input::analogPoll() {
|
|
||||||
int16_t mappedInputVal;
|
void Input::analogPoll(short cause) {
|
||||||
|
int16_t inputVal;
|
||||||
|
int32_t mappedInputVal; // 10x inputVal
|
||||||
aJsonObject *inputMap = aJson.getObjectItem(inputObj, "map");
|
aJsonObject *inputMap = aJson.getObjectItem(inputObj, "map");
|
||||||
short Noize = ANALOG_NOIZE;
|
int16_t Noize = ANALOG_NOIZE;
|
||||||
short simple = 0;
|
short simple = 0;
|
||||||
|
// uint32_t inputPinMode;
|
||||||
|
int max=1024*10;
|
||||||
|
int min=0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
#if defined(ARDUINO_ARCH_STM32)
|
|
||||||
WiringPinMode inputPinMode;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#if defined(__SAM3X8E__)||defined(ARDUINO_ARCH_AVR)||defined(ARDUINO_ARCH_ESP8266)||defined(ARDUINO_ARCH_ESP32)
|
|
||||||
#endif */
|
|
||||||
uint32_t inputPinMode;
|
|
||||||
if (inType & IN_ACTIVE_HIGH) {
|
if (inType & IN_ACTIVE_HIGH) {
|
||||||
inputPinMode = INPUT;
|
inputPinMode = INPUT;
|
||||||
} else {
|
} else {
|
||||||
inputPinMode = INPUT_PULLUP;
|
inputPinMode = INPUT_PULLUP;
|
||||||
}
|
}
|
||||||
|
|
||||||
pinMode(pin, inputPinMode);
|
pinMode(pin, inputPinMode);
|
||||||
mappedInputVal = analogRead(pin);
|
*/
|
||||||
|
inputVal = analogRead(pin);
|
||||||
// Mapping
|
// Mapping
|
||||||
if (inputMap && inputMap->type == aJson_Array)
|
if (inputMap && inputMap->type == aJson_Array)
|
||||||
{
|
{
|
||||||
int max=1024;
|
|
||||||
if (aJson.getArraySize(inputMap)>=4)
|
if (aJson.getArraySize(inputMap)>=4)
|
||||||
mappedInputVal = map (mappedInputVal,
|
mappedInputVal = map (inputVal,
|
||||||
aJson.getArrayItem(inputMap, 0)->valueint,
|
aJson.getArrayItem(inputMap, 0)->valueint,
|
||||||
aJson.getArrayItem(inputMap, 1)->valueint,
|
aJson.getArrayItem(inputMap, 1)->valueint,
|
||||||
aJson.getArrayItem(inputMap, 2)->valueint,
|
min=aJson.getArrayItem(inputMap, 2)->valueint*10,
|
||||||
max=aJson.getArrayItem(inputMap, 3)->valueint);
|
max=aJson.getArrayItem(inputMap, 3)->valueint*10);
|
||||||
|
else mappedInputVal = inputVal*10;
|
||||||
|
|
||||||
if (aJson.getArraySize(inputMap)==5) Noize = aJson.getArrayItem(inputMap, 4)->valueint;
|
if (aJson.getArraySize(inputMap)==5) Noize = aJson.getArrayItem(inputMap, 4)->valueint;
|
||||||
if (mappedInputVal>max) mappedInputVal=max;
|
|
||||||
|
if (mappedInputVal>max)
|
||||||
|
{
|
||||||
|
mappedInputVal = max;
|
||||||
|
inputVal = 1023;
|
||||||
|
}
|
||||||
|
if (mappedInputVal<min) {
|
||||||
|
mappedInputVal = min;
|
||||||
|
inputVal = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (aJson.getArraySize(inputMap)==2)
|
if (aJson.getArraySize(inputMap)==2)
|
||||||
{
|
{
|
||||||
simple = 1;
|
simple = 1;
|
||||||
if (mappedInputVal < aJson.getArrayItem(inputMap, 0)->valueint) mappedInputVal = 0;
|
if (inputVal < aJson.getArrayItem(inputMap, 0)->valueint) mappedInputVal = 0;
|
||||||
else if (mappedInputVal > aJson.getArrayItem(inputMap, 1)->valueint) mappedInputVal = 1;
|
else if (inputVal > aJson.getArrayItem(inputMap, 1)->valueint) mappedInputVal = 1;
|
||||||
else return;
|
else return;
|
||||||
}
|
}
|
||||||
}
|
} else mappedInputVal = inputVal*10; //No mapping arguments
|
||||||
|
|
||||||
if (simple) {
|
if (simple) {
|
||||||
if (mappedInputVal != store->currentValue)
|
if (mappedInputVal != store->currentValue)
|
||||||
{
|
{
|
||||||
@@ -497,29 +891,34 @@ void Input::analogPoll() {
|
|||||||
store->currentValue = mappedInputVal;
|
store->currentValue = mappedInputVal;
|
||||||
}}
|
}}
|
||||||
else
|
else
|
||||||
if (abs(mappedInputVal - store->currentValue)>Noize) // value changed >ANALOG_NOIZE
|
{
|
||||||
|
//if (abs(mappedInputVal - store->currentValue)>Noize || mappedInputVal == min || mappedInputVal ==max) // value changed >ANALOG_NOIZE
|
||||||
|
if (abs(inputVal - store->currentValue)>Noize ) // value changed >ANALOG_NOIZE
|
||||||
store->bounce = 0;
|
store->bounce = 0;
|
||||||
else // no change
|
else // no change
|
||||||
if (store->bounce<ANALOG_STATE_ATTEMPTS) store->bounce ++;
|
if (store->bounce<ANALOG_STATE_ATTEMPTS) store->bounce ++;
|
||||||
|
|
||||||
if (store->bounce<ANALOG_STATE_ATTEMPTS-1 && (mappedInputVal != store->currentValue)) //confirmed change
|
if ((store->bounce<ANALOG_STATE_ATTEMPTS-1 || mappedInputVal == min || mappedInputVal ==max )&& (inputVal != store->currentValue))//confirmed change
|
||||||
{
|
{
|
||||||
onAnalogChanged(mappedInputVal);
|
onAnalogChanged(mappedInputVal/10.);
|
||||||
store->currentValue = mappedInputVal;
|
// store->currentValue = mappedInputVal;
|
||||||
|
store->currentValue = inputVal;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Input::onContactChanged(int newValue) {
|
void Input::onContactChanged(int newValue) {
|
||||||
debugSerial << F("IN:") << (pin) << F("=") << newValue << endl;
|
|
||||||
aJsonObject *item = aJson.getObjectItem(inputObj, "item");
|
aJsonObject *item = aJson.getObjectItem(inputObj, "item");
|
||||||
|
aJsonObject *emit = aJson.getObjectItem(inputObj, "emit");
|
||||||
|
if (!item && !emit) return;
|
||||||
aJsonObject *scmd = aJson.getObjectItem(inputObj, "scmd");
|
aJsonObject *scmd = aJson.getObjectItem(inputObj, "scmd");
|
||||||
aJsonObject *rcmd = aJson.getObjectItem(inputObj, "rcmd");
|
aJsonObject *rcmd = aJson.getObjectItem(inputObj, "rcmd");
|
||||||
aJsonObject *emit = aJson.getObjectItem(inputObj, "emit");
|
debugSerial << F("LEGACY IN:") << (pin) << F("=") << newValue << endl;
|
||||||
if (emit) {
|
if (emit && emit->type == aJson_String) {
|
||||||
#ifdef WITH_DOMOTICZ
|
#ifdef WITH_DOMOTICZ
|
||||||
if (getIdxField())
|
if (getIdxField())
|
||||||
{ (newValue) ? publishDataToDomoticz(0, emit, "{\"command\":\"switchlight\",\"idx\":%s,\"switchcmd\":\"On\"}",
|
{ (newValue) ? publishDataToDomoticz(0, emit, "{\"command\":\"switchlight\",\"idx\":%s,\"switchcmd\":\"On\"}",
|
||||||
@@ -536,26 +935,26 @@ if (mqttClient.connected() && !ethernetIdleCount)
|
|||||||
{
|
{
|
||||||
if (!strchr(addrstr,'/')) setTopic(addrstr,sizeof(addrstr),T_OUT,emit->valuestring);
|
if (!strchr(addrstr,'/')) setTopic(addrstr,sizeof(addrstr),T_OUT,emit->valuestring);
|
||||||
if (newValue) { //send set command
|
if (newValue) { //send set command
|
||||||
if (!scmd) mqttClient.publish(addrstr, "ON", true);
|
if (!scmd || scmd->type != aJson_String) mqttClient.publish(addrstr, "ON", true);
|
||||||
else if (strlen(scmd->valuestring))
|
else if (strlen(scmd->valuestring))
|
||||||
mqttClient.publish(addrstr, scmd->valuestring, true);
|
mqttClient.publish(addrstr, scmd->valuestring, true);
|
||||||
} else { //send reset command
|
} else { //send reset command
|
||||||
if (!rcmd) mqttClient.publish(addrstr, "OFF", true);
|
if (!rcmd || rcmd->type == aJson_String) mqttClient.publish(addrstr, "OFF", true);
|
||||||
else if (strlen(rcmd->valuestring))mqttClient.publish(addrstr, rcmd->valuestring, true);
|
else if (strlen(rcmd->valuestring))mqttClient.publish(addrstr, rcmd->valuestring, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // emit
|
} // emit
|
||||||
if (item) {
|
if (item && item->type == aJson_String) {
|
||||||
//debugSerial <<F("Controlled item:")<< item->valuestring <<endl;
|
//debugSerial <<F("Controlled item:")<< item->valuestring <<endl;
|
||||||
Item it(item->valuestring);
|
Item it(item->valuestring);
|
||||||
if (it.isValid()) {
|
if (it.isValid()) {
|
||||||
if (newValue) { //send set command
|
if (newValue) { //send set command
|
||||||
if (!scmd) it.Ctrl(CMD_ON, 0, NULL, true);
|
if (!scmd || scmd->type != aJson_String) it.Ctrl(CMD_ON, 0, NULL, true);
|
||||||
else if (strlen(scmd->valuestring))
|
else if (strlen(scmd->valuestring))
|
||||||
it.Ctrl(scmd->valuestring, true);
|
it.Ctrl(scmd->valuestring, true);
|
||||||
} else { //send reset command
|
} else { //send reset command
|
||||||
if (!rcmd) it.Ctrl(CMD_OFF, 0, NULL, true);
|
if (!rcmd || rcmd->type != aJson_String) it.Ctrl(CMD_OFF, 0, NULL, true);
|
||||||
else if (strlen(rcmd->valuestring))
|
else if (strlen(rcmd->valuestring))
|
||||||
it.Ctrl(rcmd->valuestring, true);
|
it.Ctrl(rcmd->valuestring, true);
|
||||||
}
|
}
|
||||||
@@ -563,13 +962,13 @@ if (!strchr(addrstr,'/')) setTopic(addrstr,sizeof(addrstr),T_OUT,emit->valuestri
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Input::onAnalogChanged(int newValue) {
|
void Input::onAnalogChanged(float newValue) {
|
||||||
debugSerial << F("IN:") << (pin) << F("=") << newValue << endl;
|
debugSerial << F("IN:") << (pin) << F("=") << newValue << endl;
|
||||||
aJsonObject *item = aJson.getObjectItem(inputObj, "item");
|
aJsonObject *item = aJson.getObjectItem(inputObj, "item");
|
||||||
aJsonObject *emit = aJson.getObjectItem(inputObj, "emit");
|
aJsonObject *emit = aJson.getObjectItem(inputObj, "emit");
|
||||||
|
|
||||||
|
|
||||||
if (emit) {
|
if (emit && emit->type == aJson_String) {
|
||||||
|
|
||||||
//#ifdef WITH_DOMOTICZ
|
//#ifdef WITH_DOMOTICZ
|
||||||
// if (getIdxField()) {
|
// if (getIdxField()) {
|
||||||
@@ -581,15 +980,17 @@ void Input::onAnalogChanged(int newValue) {
|
|||||||
strncpy(addrstr,emit->valuestring,sizeof(addrstr));
|
strncpy(addrstr,emit->valuestring,sizeof(addrstr));
|
||||||
if (!strchr(addrstr,'/')) setTopic(addrstr,sizeof(addrstr),T_OUT,emit->valuestring);
|
if (!strchr(addrstr,'/')) setTopic(addrstr,sizeof(addrstr),T_OUT,emit->valuestring);
|
||||||
char strVal[16];
|
char strVal[16];
|
||||||
itoa(newValue,strVal,10);
|
//itoa(newValue,strVal,10);
|
||||||
|
printFloatValueToStr(newValue, strVal);
|
||||||
if (mqttClient.connected() && !ethernetIdleCount)
|
if (mqttClient.connected() && !ethernetIdleCount)
|
||||||
mqttClient.publish(addrstr, strVal, true);
|
mqttClient.publish(addrstr, strVal, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item) {
|
if (item && item->type == aJson_String) {
|
||||||
|
int intNewValue = round(newValue);
|
||||||
Item it(item->valuestring);
|
Item it(item->valuestring);
|
||||||
if (it.isValid()) {
|
if (it.isValid()) {
|
||||||
it.Ctrl(0, 1, &newValue, true);
|
it.Ctrl(0, 1, &intNewValue, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -598,6 +999,8 @@ void Input::onAnalogChanged(int newValue) {
|
|||||||
bool Input::publishDataToDomoticz(int pollTimeIncrement, aJsonObject *emit, const char *format, ...)
|
bool Input::publishDataToDomoticz(int pollTimeIncrement, aJsonObject *emit, const char *format, ...)
|
||||||
{
|
{
|
||||||
#ifdef WITH_DOMOTICZ
|
#ifdef WITH_DOMOTICZ
|
||||||
|
if (emit && emit->type == aJson_String)
|
||||||
|
{
|
||||||
debugSerial << F("\nDomoticz valstr:");
|
debugSerial << F("\nDomoticz valstr:");
|
||||||
char valstr[50];
|
char valstr[50];
|
||||||
va_list args;
|
va_list args;
|
||||||
@@ -609,7 +1012,8 @@ bool Input::publishDataToDomoticz(int pollTimeIncrement, aJsonObject *emit, cons
|
|||||||
mqttClient.publish(emit->valuestring, valstr);
|
mqttClient.publish(emit->valuestring, valstr);
|
||||||
if (pollTimeIncrement)
|
if (pollTimeIncrement)
|
||||||
setNextPollTime(millis() + pollTimeIncrement);
|
setNextPollTime(millis() + pollTimeIncrement);
|
||||||
debugSerial << F(" NextPollMillis=") << nextPollTime() << endl;
|
// debugSerial << F(" NextPollMillis=") << nextPollTime() << endl;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
@@ -617,7 +1021,7 @@ bool Input::publishDataToDomoticz(int pollTimeIncrement, aJsonObject *emit, cons
|
|||||||
|
|
||||||
char* Input::getIdxField() {
|
char* Input::getIdxField() {
|
||||||
aJsonObject *idx = aJson.getObjectItem(inputObj, "idx");
|
aJsonObject *idx = aJson.getObjectItem(inputObj, "idx");
|
||||||
if(idx&&idx->valuestring)
|
if(idx&& idx->type == aJson_String && idx->valuestring)
|
||||||
return idx->valuestring;
|
return idx->valuestring;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,13 +35,39 @@ e-mail anklimov@gmail.com
|
|||||||
#define IN_COUNTER 8
|
#define IN_COUNTER 8
|
||||||
#define IN_UPTIME 16
|
#define IN_UPTIME 16
|
||||||
|
|
||||||
|
#define IS_IDLE 0
|
||||||
|
#define IS_PRESSED 1
|
||||||
|
#define IS_RELEASED 2
|
||||||
|
#define IS_LONG 3
|
||||||
|
#define IS_REPEAT 4
|
||||||
|
#define IS_WAITPRESS 5
|
||||||
|
#define IS_PRESSED2 6
|
||||||
|
#define IS_RELEASED2 7
|
||||||
|
#define IS_LONG2 8u
|
||||||
|
#define IS_REPEAT2 9u
|
||||||
|
#define IS_PRESSED3 10u
|
||||||
|
#define IS_LONG3 11u
|
||||||
|
#define IS_REPEAT3 12u
|
||||||
|
#define IS_WAITRELEASE 13u
|
||||||
|
#define IS_REQSTATE 0xFF
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define SAME_STATE_ATTEMPTS 3
|
#define SAME_STATE_ATTEMPTS 3
|
||||||
#define ANALOG_STATE_ATTEMPTS 6
|
#define ANALOG_STATE_ATTEMPTS 6
|
||||||
#define ANALOG_NOIZE 1
|
#define ANALOG_NOIZE 1
|
||||||
|
|
||||||
#define CHECK_INPUT 1
|
#define CHECK_SENSOR 1
|
||||||
#define CHECK_SENSOR 2
|
#define CHECK_INPUT 2
|
||||||
|
#define CHECK_INTERRUPT 3
|
||||||
|
|
||||||
|
|
||||||
|
#define T_LONG 1000
|
||||||
|
#define T_IDLE 600
|
||||||
|
#define T_RPT 300
|
||||||
|
#define T_RPT_PULSE 150
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// in syntaxis
|
// in syntaxis
|
||||||
// "pin": { "T":"N", "emit":"out_emit", item:"out_item", "scmd": "ON,OFF,TOGGLE,INCREASE,DECREASE", "rcmd": "ON,OFF,TOGGLE,INCREASE,DECREASE", "rcmd":"repeat_command" }
|
// "pin": { "T":"N", "emit":"out_emit", item:"out_item", "scmd": "ON,OFF,TOGGLE,INCREASE,DECREASE", "rcmd": "ON,OFF,TOGGLE,INCREASE,DECREASE", "rcmd":"repeat_command" }
|
||||||
@@ -79,11 +105,25 @@ extern aJsonObject *inputs;
|
|||||||
typedef union {
|
typedef union {
|
||||||
long int aslong;
|
long int aslong;
|
||||||
uint32_t timestamp;
|
uint32_t timestamp;
|
||||||
|
// Analog input structure
|
||||||
struct {
|
struct {
|
||||||
int8_t logicState;
|
uint8_t reserved;
|
||||||
int8_t bounce;
|
uint8_t logicState;
|
||||||
int16_t currentValue;
|
int16_t currentValue;
|
||||||
};
|
};
|
||||||
|
// Digital input structure
|
||||||
|
struct {
|
||||||
|
uint8_t toggle1:1;
|
||||||
|
uint8_t toggle2:1;
|
||||||
|
uint8_t toggle3:1;
|
||||||
|
uint8_t lastValue:1;
|
||||||
|
uint8_t delayedState:1;
|
||||||
|
uint8_t bounce:3;
|
||||||
|
uint8_t state:4;
|
||||||
|
uint8_t reqState:4;
|
||||||
|
uint16_t timestamp16;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
} inStore;
|
} inStore;
|
||||||
|
|
||||||
@@ -103,9 +143,9 @@ public:
|
|||||||
boolean isValid();
|
boolean isValid();
|
||||||
|
|
||||||
void onContactChanged(int newValue);
|
void onContactChanged(int newValue);
|
||||||
void onAnalogChanged(int newValue);
|
void onAnalogChanged(float newValue);
|
||||||
|
|
||||||
int poll(short cause);
|
int Poll(short cause);
|
||||||
void setup();
|
void setup();
|
||||||
|
|
||||||
static void inline onCounterChanged(int i);
|
static void inline onCounterChanged(int i);
|
||||||
@@ -121,8 +161,8 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
void Parse();
|
void Parse();
|
||||||
|
|
||||||
void contactPoll();
|
void contactPoll(short cause);
|
||||||
void analogPoll();
|
void analogPoll(short cause);
|
||||||
|
|
||||||
void dht22Poll();
|
void dht22Poll();
|
||||||
|
|
||||||
@@ -140,4 +180,6 @@ protected:
|
|||||||
bool publishDataToDomoticz(int , aJsonObject *, const char *format, ...);
|
bool publishDataToDomoticz(int , aJsonObject *, const char *format, ...);
|
||||||
|
|
||||||
char* getIdxField();
|
char* getIdxField();
|
||||||
|
bool changeState(uint8_t newState, short cause);
|
||||||
|
bool executeCommand(aJsonObject* cmd, int8_t toggle = -1, char* defCmd = NULL);
|
||||||
};
|
};
|
||||||
|
|||||||
1337
lighthub/item.cpp
1337
lighthub/item.cpp
File diff suppressed because it is too large
Load Diff
172
lighthub/item.h
172
lighthub/item.h
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright © 2017-2018 Andrey Klimov. All rights reserved.
|
/* Copyright © 2017-2020 Andrey Klimov. All rights reserved.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -17,18 +17,25 @@ GIT: https://github.com/anklimov/lighthub
|
|||||||
e-mail anklimov@gmail.com
|
e-mail anklimov@gmail.com
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
#pragma once
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
|
#include "abstractout.h"
|
||||||
|
|
||||||
#define S_SET 1
|
#define POLLING_SLOW 1
|
||||||
#define S_TEMP 2
|
#define POLLING_FAST 2
|
||||||
#define S_MODE 3
|
#define POLLING_INT 3
|
||||||
#define S_SETPOINT 4
|
|
||||||
#define S_POWER 5
|
#define S_NOTFOUND 0
|
||||||
#define S_VOL 6
|
#define S_SETnCMD 0
|
||||||
#define S_HEAT 7
|
#define S_CMD 1
|
||||||
#define S_HSV 8
|
#define S_SET 2
|
||||||
#define S_RGB 9
|
#define S_HSV 3
|
||||||
#define S_RPM 10
|
#define S_RGB 4
|
||||||
|
#define S_FAN 5
|
||||||
|
#define S_MODE 6
|
||||||
|
#define S_HUE 7
|
||||||
|
#define S_SAT 8
|
||||||
|
#define S_ADDITIONAL 64
|
||||||
|
|
||||||
#define CH_DIMMER 0 //DMX 1 ch
|
#define CH_DIMMER 0 //DMX 1 ch
|
||||||
#define CH_RGBW 1 //DMX 4 ch
|
#define CH_RGBW 1 //DMX 4 ch
|
||||||
@@ -40,7 +47,14 @@ e-mail anklimov@gmail.com
|
|||||||
#define CH_GROUP 7 //Group pseudochannel
|
#define CH_GROUP 7 //Group pseudochannel
|
||||||
#define CH_VCTEMP 8 //Vacom PID regulator
|
#define CH_VCTEMP 8 //Vacom PID regulator
|
||||||
#define CH_VC 9 //Vacom modbus motor regulator
|
#define CH_VC 9 //Vacom modbus motor regulator
|
||||||
#define CH_AC_HAIER 10 //AC Haier
|
#define CH_AC 10 //AC Haier
|
||||||
|
#define CH_SPILED 11
|
||||||
|
#define CH_MOTOR 12
|
||||||
|
//#define CHANNEL_TYPES 13
|
||||||
|
|
||||||
|
//static uint32_t pollInterval[CHANNEL_TYPES] = {0,0,0,0,MODB};
|
||||||
|
//static uint32_t nextPollTime[CHANNEL_TYPES] = {0,0,0,0,0,0,0,0,0,0,0,0,0};
|
||||||
|
|
||||||
#define CH_WHITE 127//
|
#define CH_WHITE 127//
|
||||||
|
|
||||||
#define CMD_NUM 0
|
#define CMD_NUM 0
|
||||||
@@ -58,12 +72,28 @@ e-mail anklimov@gmail.com
|
|||||||
#define CMD_XOFF 7 //off only if was previously turned on by CMD_XON
|
#define CMD_XOFF 7 //off only if was previously turned on by CMD_XON
|
||||||
#define CMD_UP 8 //increase
|
#define CMD_UP 8 //increase
|
||||||
#define CMD_DN 9 //decrease
|
#define CMD_DN 9 //decrease
|
||||||
#define CMD_SET 0xe
|
#define CMD_HEAT 0xa
|
||||||
#define CMD_MASK 0xf
|
#define CMD_COOL 0xb
|
||||||
|
#define CMD_AUTO 0xc
|
||||||
|
#define CMD_FAN 0xd
|
||||||
|
#define CMD_DRY 0xe
|
||||||
|
//#define CMD_SET 0xf
|
||||||
|
#define CMD_HIGH 0x10 //AC fan leve
|
||||||
|
#define CMD_MED 0x11
|
||||||
|
#define CMD_LOW 0x12
|
||||||
|
//#define CMD_CURTEMP 0xf
|
||||||
|
#define CMD_MASK 0xff
|
||||||
|
#define FLAG_MASK 0xff00
|
||||||
|
|
||||||
#define CMD_CURTEMP 127
|
|
||||||
#define CMD_RETRY 64
|
#define SEND_COMMAND 0x100
|
||||||
#define CMD_REPORT 32
|
#define SEND_PARAMETERS 0x200
|
||||||
|
#define SEND_RETRY 0x400
|
||||||
|
#define SEND_DEFFERED 0x800
|
||||||
|
#define ACTION_NEEDED 0x1000
|
||||||
|
#define ACTION_IN_PROCESS 0x2000
|
||||||
|
|
||||||
|
//#define CMD_REPORT 32
|
||||||
|
|
||||||
#define I_TYPE 0 //Type of item
|
#define I_TYPE 0 //Type of item
|
||||||
#define I_ARG 1 //Chanel-type depended argument or array of arguments (pin, address etc)
|
#define I_ARG 1 //Chanel-type depended argument or array of arguments (pin, address etc)
|
||||||
@@ -89,99 +119,89 @@ extern short thermoSetCurTemp(char *name, float t);
|
|||||||
|
|
||||||
int txt2cmd (char * payload);
|
int txt2cmd (char * payload);
|
||||||
|
|
||||||
|
#pragma pack(push, 1)
|
||||||
|
typedef union
|
||||||
|
{
|
||||||
|
long int aslong;
|
||||||
|
float asfloat;
|
||||||
|
struct
|
||||||
|
{ uint8_t v;
|
||||||
|
uint8_t s;
|
||||||
|
uint16_t h:15;
|
||||||
|
uint16_t hsv_flag:1;
|
||||||
|
};
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
uint8_t r;
|
||||||
|
uint8_t g;
|
||||||
|
uint8_t b;
|
||||||
|
uint8_t w:7;
|
||||||
|
uint8_t rgb_flag:1;
|
||||||
|
};
|
||||||
|
} CHstore;
|
||||||
|
|
||||||
|
/*
|
||||||
typedef union
|
typedef union
|
||||||
{
|
{
|
||||||
long int aslong;
|
long int aslong;
|
||||||
struct
|
struct
|
||||||
{
|
|
||||||
int16_t h;
|
|
||||||
int8_t s;
|
|
||||||
int8_t v;
|
|
||||||
};
|
|
||||||
} HSVstore;
|
|
||||||
|
|
||||||
|
} RGBWstore;
|
||||||
typedef union
|
*/
|
||||||
{
|
#pragma pack(pop)
|
||||||
long int aslong;
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
int8_t r;
|
|
||||||
int8_t g;
|
|
||||||
int8_t b;
|
|
||||||
int8_t v;
|
|
||||||
};
|
|
||||||
} RGBVstore;
|
|
||||||
|
|
||||||
class Item
|
class Item
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
aJsonObject *itemArr, *itemArg,*itemVal;
|
aJsonObject *itemArr, *itemArg,*itemVal,*itemExt;
|
||||||
uint8_t itemType;
|
uint8_t itemType;
|
||||||
|
abstractOut * driver;
|
||||||
|
|
||||||
Item(char * name);
|
Item(char * name);
|
||||||
Item(aJsonObject * obj);
|
Item(aJsonObject * obj);
|
||||||
|
~Item();
|
||||||
|
|
||||||
boolean isValid ();
|
boolean isValid ();
|
||||||
virtual int Ctrl(short cmd, short n=0, int * Parameters=NULL, boolean send=true, int subItem=0);
|
boolean Setup();
|
||||||
|
virtual int Ctrl(short cmd, short n=0, int * Parameters=NULL, boolean send=true, int suffixCode=0, char* subItem=NULL);
|
||||||
virtual int Ctrl(char * payload, boolean send=true, char * subItem=NULL);
|
virtual int Ctrl(char * payload, boolean send=true, char * subItem=NULL);
|
||||||
|
|
||||||
int getArg(short n=0);
|
int getArg(short n=0);
|
||||||
boolean getEnableCMD(int delta);
|
|
||||||
//int getVal(short n); //From VAL array. Negative if no array
|
//int getVal(short n); //From VAL array. Negative if no array
|
||||||
long int getVal(); //From int val OR array
|
long int getVal(); //From int val OR array
|
||||||
uint8_t getCmd(bool ext = false);
|
uint8_t getCmd();
|
||||||
|
long int getExt(); //From int val OR array
|
||||||
|
void setExt(long int par);
|
||||||
void setCmd(uint8_t cmdValue);
|
void setCmd(uint8_t cmdValue);
|
||||||
//void setVal(uint8_t n, int par);
|
short getFlag (short flag=FLAG_MASK);
|
||||||
|
void setFlag (short flag);
|
||||||
|
void clearFlag (short flag);
|
||||||
void setVal(long int par);
|
void setVal(long int par);
|
||||||
//void copyPar (aJsonObject *itemV);
|
int Poll(int cause);
|
||||||
|
int SendStatus(int sendFlags);
|
||||||
|
int isActive();
|
||||||
|
int getChanType();
|
||||||
inline int On (){return Ctrl(CMD_ON);};
|
inline int On (){return Ctrl(CMD_ON);};
|
||||||
inline int Off(){return Ctrl(CMD_OFF);};
|
inline int Off(){return Ctrl(CMD_OFF);};
|
||||||
inline int Toggle(){return Ctrl(CMD_TOGGLE);};
|
inline int Toggle(){return Ctrl(CMD_TOGGLE);};
|
||||||
int Poll();
|
|
||||||
int SendStatus(short cmd, short n=0, int * Par=NULL, boolean deferred = false);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
//short cmd2changeActivity(int lastActivity, short defaultCmd = CMD_SET);
|
||||||
int VacomSetFan (int8_t val, int8_t cmd=0);
|
int VacomSetFan (int8_t val, int8_t cmd=0);
|
||||||
int VacomSetHeat(int addr, int8_t val, int8_t cmd=0);
|
int VacomSetHeat(int8_t val, int8_t cmd=0);
|
||||||
int modbusDimmerSet(int addr, uint16_t _reg, int _regType, int _mask, uint16_t value);
|
int modbusDimmerSet(int addr, uint16_t _reg, int _regType, int _mask, uint16_t value);
|
||||||
void mb_fail(short addr, short op, int val, int cmd);
|
int modbusDimmerSet(uint16_t value);
|
||||||
int isActive();
|
void mb_fail();
|
||||||
void Parse();
|
void Parse();
|
||||||
int checkModbusDimmer();
|
int checkModbusDimmer();
|
||||||
int checkModbusDimmer(int data);
|
int checkModbusDimmer(int data);
|
||||||
boolean checkModbusRetry();
|
boolean checkModbusRetry();
|
||||||
|
boolean checkVCRetry();
|
||||||
|
boolean checkHeatRetry();
|
||||||
void sendDelayedStatus();
|
void sendDelayedStatus();
|
||||||
|
|
||||||
int checkFM();
|
int checkFM();
|
||||||
|
char defaultSubItem[10];
|
||||||
|
int defaultSuffixCode;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
class PooledItem : public Item
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual int onContactChanged() = 0;
|
|
||||||
virtual void Idle ();
|
|
||||||
protected:
|
|
||||||
int PoolingInterval;
|
|
||||||
unsigned long next;
|
|
||||||
virtual int Pool() =0;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Vacon : public Item
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
int Pool ();
|
|
||||||
virtual int Ctrl(short cmd, short n=0, int * Par=NULL);
|
|
||||||
protected:
|
|
||||||
};
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|||||||
@@ -67,6 +67,9 @@ PWM Out
|
|||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
|
#if defined(OTA)
|
||||||
|
#include <ArduinoOTA.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(__SAM3X8E__)
|
#if defined(__SAM3X8E__)
|
||||||
DueFlashStorage EEPROM;
|
DueFlashStorage EEPROM;
|
||||||
@@ -154,6 +157,7 @@ aJsonObject *pollingItem = NULL;
|
|||||||
bool owReady = false;
|
bool owReady = false;
|
||||||
bool configOk = false;
|
bool configOk = false;
|
||||||
int8_t ethernetIdleCount =0;
|
int8_t ethernetIdleCount =0;
|
||||||
|
int8_t configLocked = 0;
|
||||||
|
|
||||||
#ifdef _modbus
|
#ifdef _modbus
|
||||||
ModbusMaster node;
|
ModbusMaster node;
|
||||||
@@ -174,6 +178,24 @@ void watchdogSetup(void) {} //Do not remove - strong re-definition WDT Init f
|
|||||||
void cleanConf()
|
void cleanConf()
|
||||||
{
|
{
|
||||||
if (!root) return;
|
if (!root) return;
|
||||||
|
debugSerial<<F("Unlocking config ...");
|
||||||
|
while (configLocked)
|
||||||
|
{
|
||||||
|
//wdt_res();
|
||||||
|
cmdPoll();
|
||||||
|
#ifdef _owire
|
||||||
|
if (owReady && owArr) owLoop();
|
||||||
|
#endif
|
||||||
|
#ifdef _dmxin
|
||||||
|
DMXCheck();
|
||||||
|
#endif
|
||||||
|
if (lanStatus != RETAINING_COLLECTING) pollingLoop();
|
||||||
|
thermoLoop();
|
||||||
|
inputLoop();
|
||||||
|
}
|
||||||
|
|
||||||
|
pollingItem = NULL;;
|
||||||
|
|
||||||
debugSerial<<F("Deleting conf. RAM was:")<<freeRam();
|
debugSerial<<F("Deleting conf. RAM was:")<<freeRam();
|
||||||
aJson.deleteItem(root);
|
aJson.deleteItem(root);
|
||||||
root = NULL;
|
root = NULL;
|
||||||
@@ -265,8 +287,9 @@ else
|
|||||||
|
|
||||||
Item item(itemName);
|
Item item(itemName);
|
||||||
if (item.isValid()) {
|
if (item.isValid()) {
|
||||||
|
/*
|
||||||
if (item.itemType == CH_GROUP && (lanStatus == RETAINING_COLLECTING))
|
if (item.itemType == CH_GROUP && (lanStatus == RETAINING_COLLECTING))
|
||||||
return; //Do not restore group channels - they consist not relevant data
|
return; //Do not restore group channels - they consist not relevant data */
|
||||||
item.Ctrl((char *)payload, !(lanStatus == RETAINING_COLLECTING),subItem);
|
item.Ctrl((char *)payload, !(lanStatus == RETAINING_COLLECTING),subItem);
|
||||||
} //valid item
|
} //valid item
|
||||||
}
|
}
|
||||||
@@ -300,6 +323,8 @@ lan_status lanLoop() {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case HAVE_IP_ADDRESS:
|
case HAVE_IP_ADDRESS:
|
||||||
|
|
||||||
|
if (configLocked) return HAVE_IP_ADDRESS;
|
||||||
if (!configOk)
|
if (!configOk)
|
||||||
lanStatus = loadConfigFromHttp(0, NULL);
|
lanStatus = loadConfigFromHttp(0, NULL);
|
||||||
else lanStatus = IP_READY_CONFIG_LOADED_CONNECTING_TO_BROKER;
|
else lanStatus = IP_READY_CONFIG_LOADED_CONNECTING_TO_BROKER;
|
||||||
@@ -307,17 +332,20 @@ lan_status lanLoop() {
|
|||||||
|
|
||||||
case IP_READY_CONFIG_LOADED_CONNECTING_TO_BROKER:
|
case IP_READY_CONFIG_LOADED_CONNECTING_TO_BROKER:
|
||||||
wdt_res();
|
wdt_res();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ip_ready_config_loaded_connecting_to_broker();
|
ip_ready_config_loaded_connecting_to_broker();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RETAINING_COLLECTING:
|
case RETAINING_COLLECTING:
|
||||||
if (millis() > nextLanCheckTime) {
|
if (millis() > nextLanCheckTime) {
|
||||||
char buf[MQTT_TOPIC_LENGTH];
|
char buf[MQTT_TOPIC_LENGTH+1];
|
||||||
|
|
||||||
//Unsubscribe from status topics..
|
//Unsubscribe from status topics..
|
||||||
//strncpy_P(buf, outprefix, sizeof(buf));
|
//strncpy_P(buf, outprefix, sizeof(buf));
|
||||||
setTopic(buf,sizeof(buf),T_OUT);
|
setTopic(buf,sizeof(buf),T_OUT);
|
||||||
strncat(buf, "#", sizeof(buf));
|
strncat(buf, "+/+/#", sizeof(buf)); // Subscribing only on separated command/parameters topics
|
||||||
mqttClient.unsubscribe(buf);
|
mqttClient.unsubscribe(buf);
|
||||||
|
|
||||||
lanStatus = OPERATION;//3;
|
lanStatus = OPERATION;//3;
|
||||||
@@ -440,7 +468,7 @@ void onMQTTConnect(){
|
|||||||
strncat_P(topic, homie_P, sizeof(topic));
|
strncat_P(topic, homie_P, sizeof(topic));
|
||||||
strncpy_P(buf, homiever_P, sizeof(buf));
|
strncpy_P(buf, homiever_P, sizeof(buf));
|
||||||
mqttClient.publish(topic,buf,true);
|
mqttClient.publish(topic,buf,true);
|
||||||
|
configLocked++;
|
||||||
if (items) {
|
if (items) {
|
||||||
char datatype[32]="\0";
|
char datatype[32]="\0";
|
||||||
char format [64]="\0";
|
char format [64]="\0";
|
||||||
@@ -502,9 +530,33 @@ void onMQTTConnect(){
|
|||||||
strncat_P(topic, nodes_P, sizeof(topic));
|
strncat_P(topic, nodes_P, sizeof(topic));
|
||||||
/// mqttClient.publish(topic,buf,true);
|
/// mqttClient.publish(topic,buf,true);
|
||||||
}
|
}
|
||||||
|
configLocked--;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char* getStringFromConfig(aJsonObject * a, int i)
|
||||||
|
{
|
||||||
|
aJsonObject * element = NULL;
|
||||||
|
if (!a) return NULL;
|
||||||
|
if (a->type == aJson_Array)
|
||||||
|
element = aJson.getArrayItem(a, i);
|
||||||
|
// TODO - human readable JSON objects as alias
|
||||||
|
|
||||||
|
if (element && element->type == aJson_String) return element->valuestring;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
char* getStringFromConfig(aJsonObject * a, char * name)
|
||||||
|
{
|
||||||
|
aJsonObject * element = NULL;
|
||||||
|
if (!a) return NULL;
|
||||||
|
if (a->type == aJson_Object)
|
||||||
|
element = aJson.getObjectItem(a, name);
|
||||||
|
if (element && element->type == aJson_String) return element->valuestring;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ip_ready_config_loaded_connecting_to_broker() {
|
void ip_ready_config_loaded_connecting_to_broker() {
|
||||||
short n = 0;
|
short n = 0;
|
||||||
int port = 1883;
|
int port = 1883;
|
||||||
@@ -516,14 +568,14 @@ void ip_ready_config_loaded_connecting_to_broker() {
|
|||||||
char syslogDeviceHostname[16];
|
char syslogDeviceHostname[16];
|
||||||
if (mqttArr && (aJson.getArraySize(mqttArr)))
|
if (mqttArr && (aJson.getArraySize(mqttArr)))
|
||||||
{
|
{
|
||||||
deviceName = aJson.getArrayItem(mqttArr, 0)->valuestring;
|
deviceName = getStringFromConfig(mqttArr, 0);
|
||||||
debugSerial<<F("Device Name:")<<deviceName<<endl;
|
debugSerial<<F("Device Name:")<<deviceName<<endl;
|
||||||
}
|
}
|
||||||
#ifdef SYSLOG_ENABLE
|
#ifdef SYSLOG_ENABLE
|
||||||
//debugSerial<<"debugSerial:";
|
//debugSerial<<"debugSerial:";
|
||||||
delay(100);
|
delay(100);
|
||||||
if (udpSyslogArr && (n = aJson.getArraySize(udpSyslogArr))) {
|
if (udpSyslogArr && (n = aJson.getArraySize(udpSyslogArr))) {
|
||||||
char *syslogServer = aJson.getArrayItem(udpSyslogArr, 0)->valuestring;
|
char *syslogServer = getStringFromConfig(udpSyslogArr, 0);
|
||||||
if (n>1) syslogPort = aJson.getArrayItem(udpSyslogArr, 1)->valueint;
|
if (n>1) syslogPort = aJson.getArrayItem(udpSyslogArr, 1)->valueint;
|
||||||
|
|
||||||
inet_ntoa_r(Ethernet.localIP(),syslogDeviceHostname,sizeof(syslogDeviceHostname));
|
inet_ntoa_r(Ethernet.localIP(),syslogDeviceHostname,sizeof(syslogDeviceHostname));
|
||||||
@@ -543,11 +595,11 @@ void ip_ready_config_loaded_connecting_to_broker() {
|
|||||||
|
|
||||||
if (!mqttClient.connected() && mqttArr && ((n = aJson.getArraySize(mqttArr)) > 1)) {
|
if (!mqttClient.connected() && mqttArr && ((n = aJson.getArraySize(mqttArr)) > 1)) {
|
||||||
// char *client_id = aJson.getArrayItem(mqttArr, 0)->valuestring;
|
// char *client_id = aJson.getArrayItem(mqttArr, 0)->valuestring;
|
||||||
char *servername = aJson.getArrayItem(mqttArr, 1)->valuestring;
|
char *servername = getStringFromConfig(mqttArr, 1);
|
||||||
if (n >= 3) port = aJson.getArrayItem(mqttArr, 2)->valueint;
|
if (n >= 3) port = aJson.getArrayItem(mqttArr, 2)->valueint;
|
||||||
if (n >= 4) user = aJson.getArrayItem(mqttArr, 3)->valuestring;
|
if (n >= 4) user = getStringFromConfig(mqttArr, 3);
|
||||||
if (!loadFlash(OFFSET_MQTT_PWD, passwordBuf, sizeof(passwordBuf)) && (n >= 5)) {
|
if (!loadFlash(OFFSET_MQTT_PWD, passwordBuf, sizeof(passwordBuf)) && (n >= 5)) {
|
||||||
password = aJson.getArrayItem(mqttArr, 4)->valuestring;
|
password = getStringFromConfig(mqttArr, 4);
|
||||||
debugSerial<<F("Using MQTT password from config");
|
debugSerial<<F("Using MQTT password from config");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -578,11 +630,11 @@ void ip_ready_config_loaded_connecting_to_broker() {
|
|||||||
// wdt_en();
|
// wdt_en();
|
||||||
configOk = true;
|
configOk = true;
|
||||||
// ... Temporary subscribe to status topic
|
// ... Temporary subscribe to status topic
|
||||||
char buf[MQTT_TOPIC_LENGTH];
|
char buf[MQTT_TOPIC_LENGTH+1];
|
||||||
|
|
||||||
// strncpy_P(buf, outprefix, sizeof(buf));
|
// strncpy_P(buf, outprefix, sizeof(buf));
|
||||||
setTopic(buf,sizeof(buf),T_OUT);
|
setTopic(buf,sizeof(buf),T_OUT);
|
||||||
strncat(buf, "#", sizeof(buf));
|
strncat(buf, "+/+/#", sizeof(buf)); // Only on separated cmd/val topics
|
||||||
mqttClient.subscribe(buf);
|
mqttClient.subscribe(buf);
|
||||||
|
|
||||||
//Subscribing for command topics
|
//Subscribing for command topics
|
||||||
@@ -680,6 +732,10 @@ wifiManager.setTimeout(30);
|
|||||||
if (WiFi.status() == WL_CONNECTED) {
|
if (WiFi.status() == WL_CONNECTED) {
|
||||||
debugSerial<<F("WiFi connected. IP address: ")<<WiFi.localIP()<<endl;
|
debugSerial<<F("WiFi connected. IP address: ")<<WiFi.localIP()<<endl;
|
||||||
lanStatus = HAVE_IP_ADDRESS;//1;
|
lanStatus = HAVE_IP_ADDRESS;//1;
|
||||||
|
#ifdef OTA
|
||||||
|
// start the OTEthernet library with internal (flash) based storage
|
||||||
|
ArduinoOTA.begin(Ethernet.localIP(), "Lighthub", "password", InternalStorage);
|
||||||
|
#endif
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
debugSerial<<F("Problem with WiFi!");
|
debugSerial<<F("Problem with WiFi!");
|
||||||
@@ -714,6 +770,10 @@ wifiManager.setTimeout(30);
|
|||||||
} else Ethernet.begin(mac, ip);
|
} else Ethernet.begin(mac, ip);
|
||||||
debugSerial<<endl;
|
debugSerial<<endl;
|
||||||
lanStatus = HAVE_IP_ADDRESS;
|
lanStatus = HAVE_IP_ADDRESS;
|
||||||
|
#ifdef OTA
|
||||||
|
// start the OTEthernet library with internal (flash) based storage
|
||||||
|
ArduinoOTA.begin(Ethernet.localIP(), "Lighthub", "password", InternalStorage);
|
||||||
|
#endif
|
||||||
#ifdef _artnet
|
#ifdef _artnet
|
||||||
if (artnet) artnet->begin();
|
if (artnet) artnet->begin();
|
||||||
#endif
|
#endif
|
||||||
@@ -742,6 +802,10 @@ wifiManager.setTimeout(30);
|
|||||||
debugSerial<<F("Got IP address:");
|
debugSerial<<F("Got IP address:");
|
||||||
printIPAddress(Ethernet.localIP());
|
printIPAddress(Ethernet.localIP());
|
||||||
lanStatus = HAVE_IP_ADDRESS;//1;
|
lanStatus = HAVE_IP_ADDRESS;//1;
|
||||||
|
#ifdef OTA
|
||||||
|
// start the OTEthernet library with internal (flash) based storage
|
||||||
|
ArduinoOTA.begin(Ethernet.localIP(), "Lighthub", "password", InternalStorage);
|
||||||
|
#endif
|
||||||
#ifdef _artnet
|
#ifdef _artnet
|
||||||
if (artnet) artnet->begin();
|
if (artnet) artnet->begin();
|
||||||
#endif
|
#endif
|
||||||
@@ -780,7 +844,7 @@ void Changed(int i, DeviceAddress addr, float currentTemp) {
|
|||||||
debugSerial<<endl<<F("T:")<<valstr<<F("<");
|
debugSerial<<endl<<F("T:")<<valstr<<F("<");
|
||||||
aJsonObject *owObj = aJson.getObjectItem(owArr, addrstr);
|
aJsonObject *owObj = aJson.getObjectItem(owArr, addrstr);
|
||||||
if (owObj) {
|
if (owObj) {
|
||||||
owEmitString = aJson.getObjectItem(owObj, "emit")->valuestring;
|
owEmitString = getStringFromConfig(owObj, "emit");
|
||||||
debugSerial<<owEmitString<<F(">")<<endl;
|
debugSerial<<owEmitString<<F(">")<<endl;
|
||||||
if ((currentTemp != -127.0) && (currentTemp != 85.0) && (currentTemp != 0.0))
|
if ((currentTemp != -127.0) && (currentTemp != 85.0) && (currentTemp != 0.0))
|
||||||
{
|
{
|
||||||
@@ -789,7 +853,7 @@ void Changed(int i, DeviceAddress addr, float currentTemp) {
|
|||||||
|
|
||||||
#ifdef WITH_DOMOTICZ
|
#ifdef WITH_DOMOTICZ
|
||||||
aJsonObject *idx = aJson.getObjectItem(owObj, "idx");
|
aJsonObject *idx = aJson.getObjectItem(owObj, "idx");
|
||||||
if (idx && idx->valuestring) {//DOMOTICZ json format support
|
if (idx && && idx->type ==aJson_String && idx->valuestring) {//DOMOTICZ json format support
|
||||||
debugSerial << endl << idx->valuestring << F(" Domoticz valstr:");
|
debugSerial << endl << idx->valuestring << F(" Domoticz valstr:");
|
||||||
char valstr[50];
|
char valstr[50];
|
||||||
sprintf(valstr, "{\"idx\":%s,\"svalue\":\"%.1f\"}", idx->valuestring, currentTemp);
|
sprintf(valstr, "{\"idx\":%s,\"svalue\":\"%.1f\"}", idx->valuestring, currentTemp);
|
||||||
@@ -807,7 +871,7 @@ void Changed(int i, DeviceAddress addr, float currentTemp) {
|
|||||||
mqttClient.publish(addrstr, valstr);
|
mqttClient.publish(addrstr, valstr);
|
||||||
}
|
}
|
||||||
// And translate temp to internal items
|
// And translate temp to internal items
|
||||||
owItem = aJson.getObjectItem(owObj, "item")->valuestring;
|
owItem = getStringFromConfig(owObj, "item");
|
||||||
if (owItem)
|
if (owItem)
|
||||||
thermoSetCurTemp(owItem, currentTemp); ///TODO: Refactore using Items interface
|
thermoSetCurTemp(owItem, currentTemp); ///TODO: Refactore using Items interface
|
||||||
} // if valid temperature
|
} // if valid temperature
|
||||||
@@ -859,6 +923,7 @@ void cmdFunctionReboot(int arg_cnt, char **args) {
|
|||||||
|
|
||||||
void applyConfig() {
|
void applyConfig() {
|
||||||
if (!root) return;
|
if (!root) return;
|
||||||
|
configLocked++;
|
||||||
#ifdef _dmxin
|
#ifdef _dmxin
|
||||||
int itemsCount;
|
int itemsCount;
|
||||||
dmxArr = aJson.getObjectItem(root, "dmxin");
|
dmxArr = aJson.getObjectItem(root, "dmxin");
|
||||||
@@ -869,9 +934,10 @@ void applyConfig() {
|
|||||||
#endif
|
#endif
|
||||||
#ifdef _dmxout
|
#ifdef _dmxout
|
||||||
int maxChannels;
|
int maxChannels;
|
||||||
|
short numParams;
|
||||||
aJsonObject *dmxoutArr = aJson.getObjectItem(root, "dmx");
|
aJsonObject *dmxoutArr = aJson.getObjectItem(root, "dmx");
|
||||||
if (dmxoutArr && aJson.getArraySize(dmxoutArr) >=1 ) {
|
if (dmxoutArr && (numParams=aJson.getArraySize(dmxoutArr)) >=1 ) {
|
||||||
DMXoutSetup(maxChannels = aJson.getArrayItem(dmxoutArr, 1)->valueint);
|
DMXoutSetup(maxChannels = aJson.getArrayItem(dmxoutArr, numParams-1)->valueint);
|
||||||
debugSerial<<F("DMX out started. Channels: ")<<maxChannels<<endl;
|
debugSerial<<F("DMX out started. Channels: ")<<maxChannels<<endl;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -886,6 +952,7 @@ void applyConfig() {
|
|||||||
owReady = owSetup(&Changed);
|
owReady = owSetup(&Changed);
|
||||||
if (owReady) debugSerial<<F("One wire Ready\n");
|
if (owReady) debugSerial<<F("One wire Ready\n");
|
||||||
t_count = 0;
|
t_count = 0;
|
||||||
|
|
||||||
while (item && owReady) {
|
while (item && owReady) {
|
||||||
if ((item->type == aJson_Object)) {
|
if ((item->type == aJson_Object)) {
|
||||||
DeviceAddress addr;
|
DeviceAddress addr;
|
||||||
@@ -907,7 +974,8 @@ void applyConfig() {
|
|||||||
while (items && item)
|
while (items && item)
|
||||||
if (item->type == aJson_Array && aJson.getArraySize(item)>1) {
|
if (item->type == aJson_Array && aJson.getArraySize(item)>1) {
|
||||||
Item it(item);
|
Item it(item);
|
||||||
if (it.isValid()) {
|
if (it.isValid() && !it.Setup()) {
|
||||||
|
//Legacy Setup
|
||||||
short inverse = 0;
|
short inverse = 0;
|
||||||
int pin=it.getArg();
|
int pin=it.getArg();
|
||||||
if (pin<0) {pin=-pin; inverse = 1;}
|
if (pin<0) {pin=-pin; inverse = 1;}
|
||||||
@@ -944,6 +1012,8 @@ void applyConfig() {
|
|||||||
udpSyslogArr = aJson.getObjectItem(root, "syslog");
|
udpSyslogArr = aJson.getObjectItem(root, "syslog");
|
||||||
#endif
|
#endif
|
||||||
printConfigSummary();
|
printConfigSummary();
|
||||||
|
|
||||||
|
configLocked--;
|
||||||
}
|
}
|
||||||
|
|
||||||
void printConfigSummary() {
|
void printConfigSummary() {
|
||||||
@@ -1140,7 +1210,8 @@ void cmdFunctionPwd(int arg_cnt, char **args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void cmdFunctionSetMac(int arg_cnt, char **args) {
|
void cmdFunctionSetMac(int arg_cnt, char **args) {
|
||||||
if (sscanf(args[1], "%x:%x:%x:%x:%x:%x%с", &mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5]) < 6) {
|
char dummy;
|
||||||
|
if (sscanf(args[1], "%x:%x:%x:%x:%x:%x%c", &mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5], &dummy) < 6) {
|
||||||
debugSerial<<F("could not parse: ")<<args[1];
|
debugSerial<<F("could not parse: ")<<args[1];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1158,11 +1229,16 @@ void cmdFunctionGet(int arg_cnt, char **args) {
|
|||||||
void printBool(bool arg) { (arg) ? debugSerial<<F("+") : debugSerial<<F("-"); }
|
void printBool(bool arg) { (arg) ? debugSerial<<F("+") : debugSerial<<F("-"); }
|
||||||
|
|
||||||
void saveFlash(short n, char *str) {
|
void saveFlash(short n, char *str) {
|
||||||
short i;
|
|
||||||
short len=strlen(str);
|
short len=strlen(str);
|
||||||
if (len>31) len=31;
|
if (len>MAXFLASHSTR-1) len=MAXFLASHSTR-1;
|
||||||
for(int i=0;i<len;i++) EEPROM.write(n+i,str[i]);
|
for(int i=0;i<len;i++) EEPROM.write(n+i,str[i]);
|
||||||
EEPROM.write(n+len,0);
|
EEPROM.write(n+len,0);
|
||||||
|
|
||||||
|
#if defined(ARDUINO_ARCH_ESP8266)
|
||||||
|
// write the data to EEPROM
|
||||||
|
short res = EEPROM.commitReset();
|
||||||
|
Serial.println((res) ? "EEPROM Commit OK" : "Commit failed");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int loadFlash(short n, char *str, short l) {
|
int loadFlash(short n, char *str, short l) {
|
||||||
@@ -1176,6 +1252,12 @@ int loadFlash(short n, char *str, short l) {
|
|||||||
|
|
||||||
void saveFlash(short n, IPAddress& ip) {
|
void saveFlash(short n, IPAddress& ip) {
|
||||||
for(int i=0;i<4;i++) EEPROM.write(n++,ip[i]);
|
for(int i=0;i<4;i++) EEPROM.write(n++,ip[i]);
|
||||||
|
|
||||||
|
#if defined(ARDUINO_ARCH_ESP8266)
|
||||||
|
// write the data to EEPROM
|
||||||
|
short res = EEPROM.commitReset();
|
||||||
|
Serial.println((res) ? "EEPROM Commit OK" : "Commit failed");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int ipLoadFromFlash(short n, IPAddress &ip) {
|
int ipLoadFromFlash(short n, IPAddress &ip) {
|
||||||
@@ -1192,8 +1274,12 @@ lan_status loadConfigFromHttp(int arg_cnt, char **args)
|
|||||||
if (arg_cnt > 1) {
|
if (arg_cnt > 1) {
|
||||||
strncpy(configServer, args[1], sizeof(configServer) - 1);
|
strncpy(configServer, args[1], sizeof(configServer) - 1);
|
||||||
saveFlash(OFFSET_CONFIGSERVER, configServer);
|
saveFlash(OFFSET_CONFIGSERVER, configServer);
|
||||||
|
debugSerial<<configServer<<F(" Saved")<<endl;
|
||||||
} else if (!loadFlash(OFFSET_CONFIGSERVER, configServer))
|
} else if (!loadFlash(OFFSET_CONFIGSERVER, configServer))
|
||||||
|
{
|
||||||
strncpy_P(configServer,configserver,sizeof(configServer));
|
strncpy_P(configServer,configserver,sizeof(configServer));
|
||||||
|
debugSerial<<F(" Default config server used: ")<<configServer<<endl;
|
||||||
|
}
|
||||||
#ifndef DEVICE_NAME
|
#ifndef DEVICE_NAME
|
||||||
snprintf(URI, sizeof(URI), "/cnf/%02x-%02x-%02x-%02x-%02x-%02x.config.json", mac[0], mac[1], mac[2], mac[3], mac[4],
|
snprintf(URI, sizeof(URI), "/cnf/%02x-%02x-%02x-%02x-%02x-%02x.config.json", mac[0], mac[1], mac[2], mac[3], mac[4],
|
||||||
mac[5]);
|
mac[5]);
|
||||||
@@ -1500,6 +1586,33 @@ void printFirmwareVersionAndBuildOptions() {
|
|||||||
#else
|
#else
|
||||||
debugSerial<<F("\n(-)RESTART_LAN_ON_MQTT_ERRORS");
|
debugSerial<<F("\n(-)RESTART_LAN_ON_MQTT_ERRORS");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef CSSHDC_DISABLE
|
||||||
|
debugSerial<<F("\n(-)CCS811 & HDC1080");
|
||||||
|
#else
|
||||||
|
debugSerial<<F("\n(+)CCS811 & HDC1080");
|
||||||
|
#endif
|
||||||
|
#ifndef AC_DISABLE
|
||||||
|
debugSerial<<F("\n(+)AC HAIER");
|
||||||
|
#else
|
||||||
|
debugSerial<<F("\n(-)AC HAIER");
|
||||||
|
#endif
|
||||||
|
#ifndef MOTOR_DISABLE
|
||||||
|
debugSerial<<F("\n(+)MOTOR CTR");
|
||||||
|
#else
|
||||||
|
debugSerial<<F("\n(-)MOTOR CTR");
|
||||||
|
#endif
|
||||||
|
#ifndef SPILED_DISABLE
|
||||||
|
debugSerial<<F("\n(+)SPI LED");
|
||||||
|
#else
|
||||||
|
debugSerial<<F("\n(-)SPI LED");
|
||||||
|
#endif
|
||||||
|
#ifndef FASTLED
|
||||||
|
debugSerial<<F("\n(+)FASTLED");
|
||||||
|
#else
|
||||||
|
debugSerial<<F("\n(+)ADAFRUIT LED");
|
||||||
|
#endif
|
||||||
debugSerial<<endl;
|
debugSerial<<endl;
|
||||||
|
|
||||||
|
|
||||||
@@ -1524,7 +1637,7 @@ void publishStat(){
|
|||||||
char topic[64];
|
char topic[64];
|
||||||
char intbuf[16];
|
char intbuf[16];
|
||||||
uint32_t ut = millis()/1000UL;
|
uint32_t ut = millis()/1000UL;
|
||||||
if (!mqttClient.connected()) return;
|
if (!mqttClient.connected() || ethernetIdleCount) return;
|
||||||
|
|
||||||
// debugSerial<<F("\nfree RAM: ")<<fr;
|
// debugSerial<<F("\nfree RAM: ")<<fr;
|
||||||
setTopic(topic,sizeof(topic),T_DEV);
|
setTopic(topic,sizeof(topic),T_DEV);
|
||||||
@@ -1549,6 +1662,7 @@ for (short i = 0; i < 6; i++) {
|
|||||||
mac[i] = EEPROM.read(i);
|
mac[i] = EEPROM.read(i);
|
||||||
if (mac[i] != 0 && mac[i] != 0xff) isMacValid = true;
|
if (mac[i] != 0 && mac[i] != 0xff) isMacValid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isMacValid) {
|
if (!isMacValid) {
|
||||||
debugSerial<<F("No MAC configured: set firmware's MAC\n");
|
debugSerial<<F("No MAC configured: set firmware's MAC\n");
|
||||||
|
|
||||||
@@ -1556,6 +1670,9 @@ if (!isMacValid) {
|
|||||||
const char *macStr = QUOTE(CUSTOM_FIRMWARE_MAC);//colon(:) separated from build options
|
const char *macStr = QUOTE(CUSTOM_FIRMWARE_MAC);//colon(:) separated from build options
|
||||||
parseBytes(macStr, ':', mac, 6, 16);
|
parseBytes(macStr, ':', mac, 6, 16);
|
||||||
|
|
||||||
|
mac[0]&=0xFE;
|
||||||
|
mac[0]|=2;
|
||||||
|
|
||||||
#elif defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
|
#elif defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
|
||||||
//Using original MPU MAC
|
//Using original MPU MAC
|
||||||
WiFi.begin();
|
WiFi.begin();
|
||||||
@@ -1574,6 +1691,7 @@ if (!isMacValid) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
printMACAddress();
|
printMACAddress();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1596,6 +1714,10 @@ void setupCmdArduino() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void loop_main() {
|
void loop_main() {
|
||||||
|
#if defined(OTA)
|
||||||
|
ArduinoOTA.poll();
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(M5STACK)
|
#if defined(M5STACK)
|
||||||
// Initialize the M5Stack object
|
// Initialize the M5Stack object
|
||||||
M5.update();
|
M5.update();
|
||||||
@@ -1620,9 +1742,9 @@ void loop_main() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (items) {
|
if (items) {
|
||||||
#ifndef MODBUS_DISABLE
|
// #ifndef MODBUS_DISABLE
|
||||||
if (lanStatus != RETAINING_COLLECTING) pollingLoop();
|
if (lanStatus != RETAINING_COLLECTING) pollingLoop();
|
||||||
#endif
|
// #endif
|
||||||
//#ifdef _owire
|
//#ifdef _owire
|
||||||
thermoLoop();
|
thermoLoop();
|
||||||
//#endif
|
//#endif
|
||||||
@@ -1688,13 +1810,14 @@ void modbusIdle(void) {
|
|||||||
void inputLoop(void) {
|
void inputLoop(void) {
|
||||||
if (!inputs) return;
|
if (!inputs) return;
|
||||||
|
|
||||||
|
configLocked++;
|
||||||
if (millis() > nextInputCheck) {
|
if (millis() > nextInputCheck) {
|
||||||
aJsonObject *input = inputs->child;
|
aJsonObject *input = inputs->child;
|
||||||
|
|
||||||
while (input) {
|
while (input) {
|
||||||
if ((input->type == aJson_Object)) {
|
if ((input->type == aJson_Object)) {
|
||||||
Input in(input);
|
Input in(input);
|
||||||
in.poll(CHECK_INPUT);
|
in.Poll(CHECK_INPUT);
|
||||||
}
|
}
|
||||||
input = input->next;
|
input = input->next;
|
||||||
}
|
}
|
||||||
@@ -1706,18 +1829,18 @@ void inputLoop(void) {
|
|||||||
while (input) {
|
while (input) {
|
||||||
if ((input->type == aJson_Object)) {
|
if ((input->type == aJson_Object)) {
|
||||||
Input in(input);
|
Input in(input);
|
||||||
in.poll(CHECK_SENSOR);
|
in.Poll(CHECK_SENSOR);
|
||||||
}
|
}
|
||||||
input = input->next;
|
input = input->next;
|
||||||
}
|
}
|
||||||
nextSensorCheck = millis() + INTERVAL_CHECK_SENSOR;
|
nextSensorCheck = millis() + INTERVAL_CHECK_SENSOR;
|
||||||
}
|
}
|
||||||
|
configLocked--;
|
||||||
}
|
}
|
||||||
|
|
||||||
void inputSetup(void) {
|
void inputSetup(void) {
|
||||||
if (!inputs) return;
|
if (!inputs) return;
|
||||||
|
configLocked++;
|
||||||
aJsonObject *input = inputs->child;
|
aJsonObject *input = inputs->child;
|
||||||
while (input) {
|
while (input) {
|
||||||
if ((input->type == aJson_Object)) {
|
if ((input->type == aJson_Object)) {
|
||||||
@@ -1726,18 +1849,40 @@ void inputSetup(void) {
|
|||||||
}
|
}
|
||||||
input = input->next;
|
input = input->next;
|
||||||
}
|
}
|
||||||
|
configLocked--;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef MODBUS_DISABLE
|
|
||||||
void pollingLoop(void) {
|
void pollingLoop(void) {
|
||||||
|
// FAST POLLINT - as often AS possible every item
|
||||||
|
configLocked++;
|
||||||
|
if (items) {
|
||||||
|
aJsonObject * item = items->child;
|
||||||
|
while (items && item)
|
||||||
|
if (item->type == aJson_Array && aJson.getArraySize(item)>1) {
|
||||||
|
Item it(item);
|
||||||
|
if (it.isValid()) {
|
||||||
|
it.Poll(POLLING_FAST);
|
||||||
|
} //isValid
|
||||||
|
item = item->next;
|
||||||
|
} //if
|
||||||
|
}
|
||||||
|
configLocked--;
|
||||||
|
// SLOW POLLING
|
||||||
boolean done = false;
|
boolean done = false;
|
||||||
|
if (lanStatus == RETAINING_COLLECTING) return;
|
||||||
if (millis() > nextPollingCheck) {
|
if (millis() > nextPollingCheck) {
|
||||||
while (pollingItem && !done) {
|
while (pollingItem && !done) {
|
||||||
if (pollingItem->type == aJson_Array) {
|
if (pollingItem->type == aJson_Array) {
|
||||||
Item it(pollingItem);
|
Item it(pollingItem);
|
||||||
nextPollingCheck = millis() + it.Poll(); //INTERVAL_CHECK_MODBUS;
|
uint32_t ret = it.Poll(POLLING_SLOW);
|
||||||
done = true;
|
if (ret)
|
||||||
|
{
|
||||||
|
nextPollingCheck = millis() + ret; //INTERVAL_CHECK_MODBUS;
|
||||||
|
done = true;
|
||||||
|
}
|
||||||
}//if
|
}//if
|
||||||
|
if (!pollingItem) return; //Config was re-readed
|
||||||
pollingItem = pollingItem->next;
|
pollingItem = pollingItem->next;
|
||||||
if (!pollingItem) {
|
if (!pollingItem) {
|
||||||
pollingItem = items->child;
|
pollingItem = items->child;
|
||||||
@@ -1746,7 +1891,6 @@ void pollingLoop(void) {
|
|||||||
} //while
|
} //while
|
||||||
}//if
|
}//if
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
bool isThermostatWithMinArraySize(aJsonObject *item, int minimalArraySize) {
|
bool isThermostatWithMinArraySize(aJsonObject *item, int minimalArraySize) {
|
||||||
return (item->type == aJson_Array) && (aJson.getArrayItem(item, I_TYPE)->valueint == CH_THERMO) &&
|
return (item->type == aJson_Array) && (aJson.getArrayItem(item, I_TYPE)->valueint == CH_THERMO) &&
|
||||||
@@ -1754,8 +1898,15 @@ bool isThermostatWithMinArraySize(aJsonObject *item, int minimalArraySize) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool thermoDisabledOrDisconnected(aJsonObject *thermoExtensionArray, int thermoStateCommand) {
|
bool thermoDisabledOrDisconnected(aJsonObject *thermoExtensionArray, int thermoStateCommand) {
|
||||||
return thermoStateCommand == CMD_OFF || thermoStateCommand == CMD_HALT ||
|
if (aJson.getArrayItem(thermoExtensionArray, IET_ATTEMPTS)->valueint == 0) return true;
|
||||||
aJson.getArrayItem(thermoExtensionArray, IET_ATTEMPTS)->valueint == 0;
|
switch (thermoStateCommand) {
|
||||||
|
case CMD_ON:
|
||||||
|
case CMD_XON:
|
||||||
|
case CMD_AUTO:
|
||||||
|
case CMD_HEAT:
|
||||||
|
return false;
|
||||||
|
default: return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1765,6 +1916,7 @@ void thermoLoop(void) {
|
|||||||
return;
|
return;
|
||||||
if (!items) return;
|
if (!items) return;
|
||||||
bool thermostatCheckPrinted = false;
|
bool thermostatCheckPrinted = false;
|
||||||
|
configLocked++;
|
||||||
for (aJsonObject *thermoItem = items->child; thermoItem; thermoItem = thermoItem->next) {
|
for (aJsonObject *thermoItem = items->child; thermoItem; thermoItem = thermoItem->next) {
|
||||||
if (isThermostatWithMinArraySize(thermoItem, 5)) {
|
if (isThermostatWithMinArraySize(thermoItem, 5)) {
|
||||||
aJsonObject *thermoExtensionArray = aJson.getArrayItem(thermoItem, I_EXT);
|
aJsonObject *thermoExtensionArray = aJson.getArrayItem(thermoItem, I_EXT);
|
||||||
@@ -1789,17 +1941,17 @@ void thermoLoop(void) {
|
|||||||
<< F(" cmd:") << thermoStateCommand;
|
<< F(" cmd:") << thermoStateCommand;
|
||||||
if (thermoPin<0) pinMode(-thermoPin, OUTPUT); else pinMode(thermoPin, OUTPUT);
|
if (thermoPin<0) pinMode(-thermoPin, OUTPUT); else pinMode(thermoPin, OUTPUT);
|
||||||
if (thermoDisabledOrDisconnected(thermoExtensionArray, thermoStateCommand)) {
|
if (thermoDisabledOrDisconnected(thermoExtensionArray, thermoStateCommand)) {
|
||||||
if (thermoPin<0) digitalWrite(-thermoPin, LOW); digitalWrite(thermoPin, LOW);
|
if (thermoPin<0) digitalWrite(-thermoPin, LOW); else digitalWrite(thermoPin, LOW);
|
||||||
// Caution - for water heaters (negative pin#) if some comes wrong (or no connection with termometers output is LOW - valve OPEN)
|
// Caution - for water heaters (negative pin#) if some comes wrong (or no connection with termometers output is LOW - valve OPEN)
|
||||||
// OFF - also VALVE is OPEN (no teat control)
|
// OFF - also VALVE is OPEN (no teat control)
|
||||||
debugSerial<<F(" OFF");
|
debugSerial<<F(" OFF");
|
||||||
} else {
|
} else {
|
||||||
if (curTemp < thermoSetting - THERMO_GIST_CELSIUS) {
|
if (curTemp < thermoSetting - THERMO_GIST_CELSIUS) {
|
||||||
if (thermoPin<0) digitalWrite(-thermoPin, LOW); digitalWrite(thermoPin, HIGH);
|
if (thermoPin<0) digitalWrite(-thermoPin, LOW); else digitalWrite(thermoPin, HIGH);
|
||||||
debugSerial<<F(" ON");
|
debugSerial<<F(" ON");
|
||||||
} //too cold
|
} //too cold
|
||||||
else if (curTemp >= thermoSetting) {
|
else if (curTemp >= thermoSetting) {
|
||||||
if (thermoPin<0) digitalWrite(-thermoPin, HIGH); digitalWrite(thermoPin, LOW);
|
if (thermoPin<0) digitalWrite(-thermoPin, HIGH); else digitalWrite(thermoPin, LOW);
|
||||||
debugSerial<<F(" OFF");
|
debugSerial<<F(" OFF");
|
||||||
} //Reached settings
|
} //Reached settings
|
||||||
else debugSerial<<F(" -target zone-"); // Nothing to do
|
else debugSerial<<F(" -target zone-"); // Nothing to do
|
||||||
@@ -1808,7 +1960,7 @@ void thermoLoop(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
configLocked--;
|
||||||
nextThermostatCheck = millis() + THERMOSTAT_CHECK_PERIOD;
|
nextThermostatCheck = millis() + THERMOSTAT_CHECK_PERIOD;
|
||||||
publishStat();
|
publishStat();
|
||||||
#ifndef DISABLE_FREERAM_PRINT
|
#ifndef DISABLE_FREERAM_PRINT
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#if defined(ARDUINO_ARCH_ESP8266)
|
#if defined(ARDUINO_ARCH_ESP8266)
|
||||||
#include <FS.h> //this needs to be first, or it all crashes and burns...
|
#include <FS.h> //this needs to be first, or it all crashes and burns...
|
||||||
|
//#include "SPIFFS.h"
|
||||||
#include <ESP_EEPROM.h>
|
#include <ESP_EEPROM.h>
|
||||||
#include <ESP8266HTTPClient.h>
|
#include <ESP8266HTTPClient.h>
|
||||||
//#include <ArduinoHttpClient.h>
|
//#include <ArduinoHttpClient.h>
|
||||||
@@ -35,6 +36,7 @@
|
|||||||
|
|
||||||
#if defined ARDUINO_ARCH_ESP32
|
#if defined ARDUINO_ARCH_ESP32
|
||||||
#include <FS.h> //this needs to be first, or it all crashes and burns...
|
#include <FS.h> //this needs to be first, or it all crashes and burns...
|
||||||
|
//#include "SPIFFS.h"
|
||||||
//#include <EEPROM.h>
|
//#include <EEPROM.h>
|
||||||
#include <NRFFlashStorage.h>
|
#include <NRFFlashStorage.h>
|
||||||
//#include "HttpClient.h"
|
//#include "HttpClient.h"
|
||||||
@@ -121,9 +123,9 @@
|
|||||||
#include <ModbusMaster.h>
|
#include <ModbusMaster.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef DMX_DISABLE
|
//#ifndef DMX_DISABLE
|
||||||
#include "FastLED.h"
|
//#include "FastLED.h"
|
||||||
#endif
|
//#endif
|
||||||
|
|
||||||
#ifdef _owire
|
#ifdef _owire
|
||||||
#include "owTerm.h"
|
#include "owTerm.h"
|
||||||
@@ -153,7 +155,7 @@
|
|||||||
|
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "homiedef.h"
|
#include "textconst.h"
|
||||||
#include <PubSubClient.h>
|
#include <PubSubClient.h>
|
||||||
#include <SPI.h>
|
#include <SPI.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -171,8 +173,8 @@ enum lan_status {
|
|||||||
INITIAL_STATE = 0,
|
INITIAL_STATE = 0,
|
||||||
HAVE_IP_ADDRESS = 1,
|
HAVE_IP_ADDRESS = 1,
|
||||||
IP_READY_CONFIG_LOADED_CONNECTING_TO_BROKER = 2,
|
IP_READY_CONFIG_LOADED_CONNECTING_TO_BROKER = 2,
|
||||||
OPERATION = 3,
|
RETAINING_COLLECTING = 3,
|
||||||
RETAINING_COLLECTING = 4,
|
OPERATION = 4,
|
||||||
AWAITING_ADDRESS = -10,
|
AWAITING_ADDRESS = -10,
|
||||||
RECONNECT = 12,
|
RECONNECT = 12,
|
||||||
READ_RE_CONFIG = -11,
|
READ_RE_CONFIG = -11,
|
||||||
@@ -224,7 +226,7 @@ void printBool(bool arg);
|
|||||||
|
|
||||||
void saveFlash(short n, char *str);
|
void saveFlash(short n, char *str);
|
||||||
|
|
||||||
int loadFlash(short n, char *str, short l=32);
|
int loadFlash(short n, char *str, short l=MAXFLASHSTR);
|
||||||
|
|
||||||
void saveFlash(short n, IPAddress& ip);
|
void saveFlash(short n, IPAddress& ip);
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "Streaming.h"
|
#include "Streaming.h"
|
||||||
|
#include "item.h"
|
||||||
|
|
||||||
#if defined(M5STACK)
|
#if defined(M5STACK)
|
||||||
#include <M5Stack.h>
|
#include <M5Stack.h>
|
||||||
@@ -17,7 +18,7 @@ static bool HDC1080ready = false;
|
|||||||
static bool CCS811ready = false;
|
static bool CCS811ready = false;
|
||||||
|
|
||||||
|
|
||||||
int in_ccs811::Setup(int addr)
|
int in_ccs811::Setup()
|
||||||
{
|
{
|
||||||
if (CCS811ready) {debugSerial<<F("ccs811 is already initialized")<<endl; return 0;}
|
if (CCS811ready) {debugSerial<<F("ccs811 is already initialized")<<endl; return 0;}
|
||||||
|
|
||||||
@@ -33,9 +34,12 @@ Wire.begin(); //Inialize I2C Harware
|
|||||||
//It is recommended to check return status on .begin(), but it is not
|
//It is recommended to check return status on .begin(), but it is not
|
||||||
//required.
|
//required.
|
||||||
CCS811Core::status returnCode = ccs811.begin();
|
CCS811Core::status returnCode = ccs811.begin();
|
||||||
|
//CCS811Core::CC811_Status_e returnCode = ccs811.beginWithStatus();
|
||||||
if (returnCode != CCS811Core::SENSOR_SUCCESS)
|
if (returnCode != CCS811Core::SENSOR_SUCCESS)
|
||||||
|
//if (returnCode != CCS811Core::CCS811_Stat_SUCCESS)
|
||||||
{
|
{
|
||||||
Serial.println("CCS811 Init error");
|
Serial.print("CCS811 Init error ");
|
||||||
|
//Serial.println(ccs811.statusString(returnCode));
|
||||||
printDriverError(returnCode);
|
printDriverError(returnCode);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -52,7 +56,7 @@ delay(2000); */
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int in_hdc1080::Setup(int addr)
|
int in_hdc1080::Setup()
|
||||||
{
|
{
|
||||||
if (HDC1080ready) {debugSerial<<F("hdc1080 is already initialized")<<endl; return 0;}
|
if (HDC1080ready) {debugSerial<<F("hdc1080 is already initialized")<<endl; return 0;}
|
||||||
Serial.println("HDC1080 Init ");
|
Serial.println("HDC1080 Init ");
|
||||||
@@ -72,20 +76,21 @@ return 1;
|
|||||||
|
|
||||||
void i2cReset(){
|
void i2cReset(){
|
||||||
Wire.endTransmission(true);
|
Wire.endTransmission(true);
|
||||||
#if defined (ARDUINO_ARCH_ESP8266)
|
#if defined (SCL_RESET)
|
||||||
SCL_LOW();
|
SCL_LOW();
|
||||||
delay(300);
|
delay(300);
|
||||||
SCL_HIGH();
|
SCL_HIGH();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int in_hdc1080::Poll()
|
int in_hdc1080::Poll(short cause)
|
||||||
{
|
{
|
||||||
float h,t;
|
float h,t;
|
||||||
int reg;
|
int reg;
|
||||||
|
if (cause!=POLLING_SLOW) return 0;
|
||||||
if (!HDC1080ready) {debugSerial<<F("HDC1080 not initialized")<<endl; return 0;}
|
if (!HDC1080ready) {debugSerial<<F("HDC1080 not initialized")<<endl; return 0;}
|
||||||
Serial.print("HDC Status=");
|
Serial.print("HDC Status=");
|
||||||
Serial.print(reg=hdc1080.readRegister().rawData,HEX);
|
Serial.println(reg=hdc1080.readRegister().rawData,HEX);
|
||||||
if (reg!=0xff)
|
if (reg!=0xff)
|
||||||
{
|
{
|
||||||
Serial.print(" T=");
|
Serial.print(" T=");
|
||||||
@@ -115,10 +120,10 @@ else //ESP I2C glitch
|
|||||||
Serial.println("I2C Reset");
|
Serial.println("I2C Reset");
|
||||||
i2cReset();
|
i2cReset();
|
||||||
}
|
}
|
||||||
return 1;
|
return INTERVAL_POLLING;
|
||||||
}
|
}
|
||||||
|
|
||||||
int in_ccs811::Poll()
|
int in_ccs811::Poll(short cause)
|
||||||
{
|
{
|
||||||
if (!CCS811ready) {debugSerial<<F("ccs811 not initialized")<<endl; return 0;}
|
if (!CCS811ready) {debugSerial<<F("ccs811 not initialized")<<endl; return 0;}
|
||||||
#ifdef WAK_PIN
|
#ifdef WAK_PIN
|
||||||
@@ -156,10 +161,11 @@ int in_ccs811::Poll()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
if (co2<10000.) //Spontaneous calculation error suppress
|
||||||
|
{
|
||||||
publish(co2,"/CO2");
|
publish(co2,"/CO2");
|
||||||
publish(tvoc,"/TVOC");
|
publish(tvoc,"/TVOC");
|
||||||
publish(ccs811Baseline,"/base");
|
publish(ccs811Baseline,"/base");}
|
||||||
Serial.println("]");
|
Serial.println("]");
|
||||||
printSensorError();
|
printSensorError();
|
||||||
|
|
||||||
|
|||||||
@@ -18,8 +18,17 @@
|
|||||||
|
|
||||||
#define SCL_LOW() (GPES = (1 << twi_scl))
|
#define SCL_LOW() (GPES = (1 << twi_scl))
|
||||||
#define SCL_HIGH() (GPEC = (1 << twi_scl))
|
#define SCL_HIGH() (GPEC = (1 << twi_scl))
|
||||||
|
#define SCL_RESET
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
#if defined (__SAM3X8E__)
|
||||||
|
#define SCL_LOW() digitalWrite(21,LOW)
|
||||||
|
#define SCL_HIGH() digitalWrite(21,HIGH)
|
||||||
|
#define SCL_RESET
|
||||||
|
#endif
|
||||||
|
*/
|
||||||
|
|
||||||
#if defined (ARDUINO_ARCH_ESP32)
|
#if defined (ARDUINO_ARCH_ESP32)
|
||||||
#undef WAK_PIN
|
#undef WAK_PIN
|
||||||
//#ifndef WAK_PIN
|
//#ifndef WAK_PIN
|
||||||
@@ -40,8 +49,8 @@ public:
|
|||||||
//CCS811 ccs811(CCS811_ADDR);
|
//CCS811 ccs811(CCS811_ADDR);
|
||||||
//uint16_t ccs811Baseline;
|
//uint16_t ccs811Baseline;
|
||||||
in_ccs811(Input * _in):abstractIn(_in){};
|
in_ccs811(Input * _in):abstractIn(_in){};
|
||||||
int Setup(int addr) override;
|
int Setup() override;
|
||||||
int Poll() override;
|
int Poll(short cause) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void printDriverError( CCS811Core::status errorCode );
|
void printDriverError( CCS811Core::status errorCode );
|
||||||
@@ -52,8 +61,8 @@ class in_hdc1080 : public abstractIn {
|
|||||||
public:
|
public:
|
||||||
//ClosedCube_HDC1080 hdc1080;
|
//ClosedCube_HDC1080 hdc1080;
|
||||||
in_hdc1080(Input * _in):abstractIn(_in){};
|
in_hdc1080(Input * _in):abstractIn(_in){};
|
||||||
int Setup(int addr) override;
|
int Setup() override;
|
||||||
int Poll() override;
|
int Poll(short cause) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void printSerialNumber();
|
void printSerialNumber();
|
||||||
|
|||||||
470
lighthub/modules/out_ac.cpp
Normal file
470
lighthub/modules/out_ac.cpp
Normal file
@@ -0,0 +1,470 @@
|
|||||||
|
#ifndef AC_DISABLE
|
||||||
|
|
||||||
|
#include "modules/out_ac.h"
|
||||||
|
#include "Arduino.h"
|
||||||
|
#include "options.h"
|
||||||
|
#include "Streaming.h"
|
||||||
|
#include "item.h"
|
||||||
|
#include "textconst.h"
|
||||||
|
|
||||||
|
#ifndef AC_Serial
|
||||||
|
#define AC_Serial Serial3
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define INTERVAL_AC_POLLING 5000L
|
||||||
|
|
||||||
|
static int driverStatus = CST_UNKNOWN;
|
||||||
|
|
||||||
|
static int fresh =0;
|
||||||
|
static int power = 0;
|
||||||
|
static int swing =0;
|
||||||
|
static int lock_rem =0;
|
||||||
|
static int cur_tmp = 0;
|
||||||
|
static int set_tmp = 0;
|
||||||
|
static int fan_spd = 0;
|
||||||
|
static int mode = 0;
|
||||||
|
|
||||||
|
long prevPolling = 0;
|
||||||
|
byte inCheck = 0;
|
||||||
|
byte qstn[] = {255,255,10,0,0,0,0,0,1,1,77,1,90}; // Команда опроса
|
||||||
|
byte data[37] = {}; //Массив данных
|
||||||
|
byte on[] = {255,255,10,0,0,0,0,0,1,1,77,2,91}; // Включение кондиционера
|
||||||
|
byte off[] = {255,255,10,0,0,0,0,0,1,1,77,3,92}; // Выключение кондиционера
|
||||||
|
byte lock[] = {255,255,10,0,0,0,0,0,1,3,0,0,14}; // Блокировка пульта
|
||||||
|
|
||||||
|
//Extended subItem set
|
||||||
|
const char LOCK_P[] PROGMEM = "lock";
|
||||||
|
const char QUIET_P[] PROGMEM = "queit";
|
||||||
|
const char SWING_P[] PROGMEM = "swing";
|
||||||
|
const char RAW_P[] PROGMEM = "raw";
|
||||||
|
//const char IDLE_P[] PROGMEM = "IDLE";
|
||||||
|
/*
|
||||||
|
extern const char HEAT_P[] PROGMEM;
|
||||||
|
extern const char COOL_P[] PROGMEM;
|
||||||
|
extern const char AUTO_P[] PROGMEM;
|
||||||
|
extern const char FAN_ONLY_P[] PROGMEM;
|
||||||
|
extern const char DRY_P[] PROGMEM;
|
||||||
|
extern const char HIGH_P[] PROGMEM;
|
||||||
|
extern const char MED_P[] PROGMEM;
|
||||||
|
extern const char LOW_P[] PROGMEM;
|
||||||
|
*/
|
||||||
|
void out_AC::InsertData(byte data[], size_t size){
|
||||||
|
|
||||||
|
char s_mode[10];
|
||||||
|
set_tmp = data[B_SET_TMP]+16;
|
||||||
|
cur_tmp = data[B_CUR_TMP];
|
||||||
|
mode = data[B_MODE];
|
||||||
|
fan_spd = data[B_FAN_SPD];
|
||||||
|
swing = data[B_SWING];
|
||||||
|
power = data[B_POWER];
|
||||||
|
lock_rem = data[B_LOCK_REM];
|
||||||
|
fresh = data[B_FRESH];
|
||||||
|
/////////////////////////////////
|
||||||
|
if (fresh & 0x01)
|
||||||
|
publishTopic(item->itemArr->name, "ON","/fresh");
|
||||||
|
else publishTopic(item->itemArr->name, "OFF","/fresh");
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
if (lock_rem == 0x80){
|
||||||
|
publishTopic(item->itemArr->name, "ON","/lock");
|
||||||
|
}
|
||||||
|
if (lock_rem == 0x00){
|
||||||
|
publishTopic(item->itemArr->name, "OFF","/lock");
|
||||||
|
}
|
||||||
|
/////////////////////////////////
|
||||||
|
/*
|
||||||
|
if (power == 0x01 || power == 0x11){
|
||||||
|
publishTopic(item->itemArr->name,"Power", "on");
|
||||||
|
}
|
||||||
|
if (power == 0x00 || power == 0x10){
|
||||||
|
publishTopic(item->itemArr->name,"Power", "off");
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
Serial.print ("Power=");
|
||||||
|
Serial.println(power);
|
||||||
|
|
||||||
|
if (power & 0x08)
|
||||||
|
publishTopic(item->itemArr->name, "ON", "/quiet");
|
||||||
|
else publishTopic(item->itemArr->name, "OFF" , "/quiet");
|
||||||
|
|
||||||
|
|
||||||
|
if (power & 0x02) //Compressor on
|
||||||
|
publishTopic(item->itemArr->name, "ON","/compressor");
|
||||||
|
else
|
||||||
|
publishTopic(item->itemArr->name, "OFF","/compressor");
|
||||||
|
|
||||||
|
|
||||||
|
publishTopic(item->itemArr->name, (long) swing,"/swing");
|
||||||
|
//publishTopic(item->itemArr->name, (long) fan_spd,"/fan");
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
if (fan_spd == 0x00){
|
||||||
|
publishTopic(item->itemArr->name, "high","/fan");
|
||||||
|
}
|
||||||
|
if (fan_spd == 0x01){
|
||||||
|
publishTopic(item->itemArr->name, "medium","/fan");
|
||||||
|
}
|
||||||
|
if (fan_spd == 0x02){
|
||||||
|
publishTopic(item->itemArr->name, "low","/fan");
|
||||||
|
}
|
||||||
|
if (fan_spd == 0x03){
|
||||||
|
publishTopic(item->itemArr->name, "auto","/fan");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (swing == 0x00)
|
||||||
|
publishTopic(item->itemArr->name, "OFF","/swing");
|
||||||
|
else publishTopic(item->itemArr->name, "ON","/swing");
|
||||||
|
/*
|
||||||
|
if (swing == 0x01){
|
||||||
|
publishTopic(item->itemArr->name, "ud","swing");
|
||||||
|
}
|
||||||
|
if (swing == 0x02){
|
||||||
|
publishTopic(item->itemArr->name, "lr","swing");
|
||||||
|
}
|
||||||
|
if (swing == 0x03){
|
||||||
|
publishTopic(item->itemArr->name, "all","swing");
|
||||||
|
}*/
|
||||||
|
/////////////////////////////////
|
||||||
|
|
||||||
|
publishTopic(item->itemArr->name,(long)set_tmp,"/set");
|
||||||
|
publishTopic(item->itemArr->name, (long)cur_tmp, "/temp");
|
||||||
|
////////////////////////////////////
|
||||||
|
s_mode[0]='\0';
|
||||||
|
|
||||||
|
if (mode == 0x00){
|
||||||
|
strcpy_P(s_mode,AUTO_P);
|
||||||
|
}
|
||||||
|
else if (mode == 0x01){
|
||||||
|
strcpy_P(s_mode,COOL_P);
|
||||||
|
}
|
||||||
|
else if (mode == 0x02){
|
||||||
|
strcpy_P(s_mode,HEAT_P);
|
||||||
|
}
|
||||||
|
else if (mode == 0x03){
|
||||||
|
strcpy_P(s_mode,FAN_ONLY_P);
|
||||||
|
}
|
||||||
|
else if (mode == 0x04){
|
||||||
|
strcpy_P(s_mode,DRY_P);
|
||||||
|
}
|
||||||
|
|
||||||
|
publishTopic(item->itemArr->name, (long) mode, "/mode");
|
||||||
|
|
||||||
|
if (power & 0x01)
|
||||||
|
publishTopic(item->itemArr->name, s_mode,"/cmd");
|
||||||
|
|
||||||
|
else publishTopic(item->itemArr->name, "OFF","/cmd");
|
||||||
|
|
||||||
|
String raw_str;
|
||||||
|
char raw[75];
|
||||||
|
for (int i=0; i < 37; i++){
|
||||||
|
if (data[i] < 10){
|
||||||
|
raw_str += "0";
|
||||||
|
raw_str += String(data[i], HEX);
|
||||||
|
} else {
|
||||||
|
raw_str += String(data[i], HEX);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
raw_str.toUpperCase();
|
||||||
|
raw_str.toCharArray(raw,75);
|
||||||
|
publishTopic(item->itemArr->name, raw,"/raw");
|
||||||
|
Serial.println(raw);
|
||||||
|
|
||||||
|
///////////////////////////////////
|
||||||
|
}
|
||||||
|
|
||||||
|
byte getCRC(byte req[], size_t size){
|
||||||
|
byte crc = 0;
|
||||||
|
for (int i=2; i < size; i++){
|
||||||
|
crc += req[i];
|
||||||
|
}
|
||||||
|
return crc;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SendData(byte req[], size_t size){
|
||||||
|
AC_Serial.write(req, size - 1);
|
||||||
|
AC_Serial.write(getCRC(req, size-1));
|
||||||
|
AC_Serial.flush();
|
||||||
|
|
||||||
|
Serial.print("<<");
|
||||||
|
for (int i=0; i < size-1; i++)
|
||||||
|
{
|
||||||
|
if (req[i] < 10){
|
||||||
|
Serial.print("0");
|
||||||
|
Serial.print(req[i], HEX);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Serial.print(req[i], HEX);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Serial.println();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline unsigned char toHex( char ch ){
|
||||||
|
return ( ( ch >= 'A' ) ? ( ch - 'A' + 0xA ) : ( ch - '0' ) ) & 0x0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int out_AC::Setup()
|
||||||
|
{
|
||||||
|
Serial.println("AC Init");
|
||||||
|
AC_Serial.begin(9600);
|
||||||
|
driverStatus = CST_INITIALIZED;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int out_AC::Stop()
|
||||||
|
{
|
||||||
|
Serial.println("AC De-Init");
|
||||||
|
|
||||||
|
driverStatus = CST_UNKNOWN;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int out_AC::Status()
|
||||||
|
{
|
||||||
|
return driverStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
int out_AC::isActive()
|
||||||
|
{
|
||||||
|
return (power & 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int out_AC::Poll(short cause)
|
||||||
|
{
|
||||||
|
if (cause!=POLLING_SLOW) return 0;
|
||||||
|
|
||||||
|
long now = millis();
|
||||||
|
if (now - prevPolling > INTERVAL_AC_POLLING) {
|
||||||
|
prevPolling = now;
|
||||||
|
Serial.println ("Polling");
|
||||||
|
SendData(qstn, sizeof(qstn)/sizeof(byte)); //Опрос кондиционера
|
||||||
|
}
|
||||||
|
delay(100);
|
||||||
|
if(AC_Serial.available() > 0){
|
||||||
|
AC_Serial.readBytes(data, 37);
|
||||||
|
while(AC_Serial.available()){
|
||||||
|
delay(2);
|
||||||
|
AC_Serial.read();
|
||||||
|
}
|
||||||
|
if (data[36] != inCheck){
|
||||||
|
inCheck = data[36];
|
||||||
|
InsertData(data, 37);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return INTERVAL_POLLING;
|
||||||
|
};
|
||||||
|
|
||||||
|
int out_AC::Ctrl(short cmd, short n, int * Parameters, boolean send, int suffixCode, char* subItem)
|
||||||
|
{char s_mode[10];
|
||||||
|
// Some additional Subitems
|
||||||
|
if (strcmp_P(subItem, LOCK_P) == 0) suffixCode = S_LOCK;
|
||||||
|
else if (strcmp_P(subItem, SWING_P) == 0) suffixCode = S_SWING;
|
||||||
|
else if (strcmp_P(subItem, QUIET_P) == 0) suffixCode = S_QUIET;
|
||||||
|
else if (strcmp_P(subItem, RAW_P) == 0) suffixCode = S_RAW;
|
||||||
|
|
||||||
|
//data[B_POWER] = power;
|
||||||
|
// debugSerial<<F(".");
|
||||||
|
switch(suffixCode)
|
||||||
|
{
|
||||||
|
case S_SET:
|
||||||
|
set_tmp = Parameters[0];
|
||||||
|
if (set_tmp >= 10 && set_tmp <= 30)
|
||||||
|
{
|
||||||
|
data[B_SET_TMP] = set_tmp -16;
|
||||||
|
if (send) publishTopic(item->itemArr->name,(long) set_tmp,"/set");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case S_CMD:
|
||||||
|
s_mode[0]='\0';
|
||||||
|
switch (cmd)
|
||||||
|
{
|
||||||
|
case CMD_ON:
|
||||||
|
case CMD_XON:
|
||||||
|
data[B_POWER] = power;
|
||||||
|
data[B_POWER] |= 1;
|
||||||
|
SendData(on, sizeof(on)/sizeof(byte));
|
||||||
|
if (send) publishTopic(item->itemArr->name,"ON","/cmd");
|
||||||
|
return 1;
|
||||||
|
break;
|
||||||
|
case CMD_OFF:
|
||||||
|
case CMD_HALT:
|
||||||
|
data[B_POWER] = power;
|
||||||
|
data[B_POWER] &= ~1;
|
||||||
|
SendData(off, sizeof(off)/sizeof(byte));
|
||||||
|
if (send) publishTopic(item->itemArr->name,"OFF","/cmd");
|
||||||
|
return 1;
|
||||||
|
break;
|
||||||
|
case CMD_AUTO:
|
||||||
|
data[B_MODE] = 0;
|
||||||
|
data[B_POWER] = power;
|
||||||
|
data[B_POWER] |= 1;
|
||||||
|
strcpy_P(s_mode,AUTO_P);
|
||||||
|
break;
|
||||||
|
case CMD_COOL:
|
||||||
|
data[B_MODE] = 1;
|
||||||
|
data[B_POWER] = power;
|
||||||
|
data[B_POWER] |= 1;
|
||||||
|
strcpy_P(s_mode,COOL_P);
|
||||||
|
break;
|
||||||
|
case CMD_HEAT:
|
||||||
|
data[B_MODE] = 2;
|
||||||
|
data[B_POWER] = power;
|
||||||
|
data[B_POWER] |= 1;
|
||||||
|
strcpy_P(s_mode,HEAT_P);
|
||||||
|
break;
|
||||||
|
case CMD_DRY:
|
||||||
|
data[B_MODE] = 4;
|
||||||
|
data[B_POWER] = power;
|
||||||
|
data[B_POWER] |= 1;
|
||||||
|
strcpy_P(s_mode,DRY_P);
|
||||||
|
break;
|
||||||
|
case CMD_FAN:
|
||||||
|
data[B_MODE] = 3;
|
||||||
|
debugSerial<<"fan\n";
|
||||||
|
data[B_POWER] = power;
|
||||||
|
data[B_POWER] |= 1;
|
||||||
|
strcpy_P(s_mode,FAN_ONLY_P);
|
||||||
|
break;
|
||||||
|
case CMD_UNKNOWN:
|
||||||
|
return -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (send) publishTopic(item->itemArr->name,s_mode,"/cmd");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case S_FAN:
|
||||||
|
s_mode[0]='\0';
|
||||||
|
switch (cmd)
|
||||||
|
{
|
||||||
|
case CMD_AUTO:
|
||||||
|
data[B_FAN_SPD] = 3;
|
||||||
|
strcpy_P(s_mode,AUTO_P);
|
||||||
|
break;
|
||||||
|
case CMD_HIGH:
|
||||||
|
data[B_FAN_SPD] = 0;
|
||||||
|
strcpy_P(s_mode,HIGH_P);
|
||||||
|
break;
|
||||||
|
case CMD_MED:
|
||||||
|
data[B_FAN_SPD] = 1;
|
||||||
|
strcpy_P(s_mode,MED_P);
|
||||||
|
break;
|
||||||
|
case CMD_LOW:
|
||||||
|
data[B_FAN_SPD] = 2;
|
||||||
|
strcpy_P(s_mode,LOW_P);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (n) data[B_FAN_SPD] = Parameters[0];
|
||||||
|
//TODO - mapping digits to speed
|
||||||
|
}
|
||||||
|
if (send) publishTopic(item->itemArr->name,s_mode,"/fan");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case S_MODE:
|
||||||
|
data[B_MODE] = Parameters[0];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case S_LOCK:
|
||||||
|
switch (cmd)
|
||||||
|
{
|
||||||
|
case CMD_ON:
|
||||||
|
data[B_LOCK_REM] = 80;
|
||||||
|
break;
|
||||||
|
case CMD_OFF:
|
||||||
|
data[B_LOCK_REM] = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case S_SWING:
|
||||||
|
switch (cmd)
|
||||||
|
{
|
||||||
|
case CMD_ON:
|
||||||
|
data[B_LOCK_REM] = 3;
|
||||||
|
break;
|
||||||
|
case CMD_OFF:
|
||||||
|
data[B_LOCK_REM] = 0;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (n) data[B_SWING] = Parameters[0];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case S_QUIET:
|
||||||
|
switch (cmd)
|
||||||
|
{
|
||||||
|
case CMD_ON:
|
||||||
|
data[B_POWER] |= 8;
|
||||||
|
break;
|
||||||
|
case CMD_OFF:
|
||||||
|
data[B_POWER] &= ~8;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case S_RAW:
|
||||||
|
/*
|
||||||
|
{
|
||||||
|
char buf[75];
|
||||||
|
char hexbyte[3] = {0};
|
||||||
|
strPayload.toCharArray(buf, 75);
|
||||||
|
int octets[sizeof(buf) / 2] ;
|
||||||
|
for (int i=0; i < 76; i += 2){
|
||||||
|
hexbyte[0] = buf[i] ;
|
||||||
|
hexbyte[1] = buf[i+1] ;
|
||||||
|
data[i/2] = (toHex(hexbyte[0]) << 4) | toHex(hexbyte[1]);
|
||||||
|
AC_Serial.write(data, 37);
|
||||||
|
AC_Serial.flush();
|
||||||
|
publishTopic("RAW", buf);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case S_NOTFOUND:
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
//////////
|
||||||
|
|
||||||
|
if (strTopic == "/myhome/in/Conditioner/Swing"){
|
||||||
|
if (strPayload == "off"){
|
||||||
|
data[B_SWING] = 0;
|
||||||
|
}
|
||||||
|
if (strPayload == "ud"){
|
||||||
|
data[B_SWING] = 1;
|
||||||
|
}
|
||||||
|
if (strPayload == "lr"){
|
||||||
|
data[B_SWING] = 2;
|
||||||
|
}
|
||||||
|
if (strPayload == "all"){
|
||||||
|
data[B_SWING] = 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
////////
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
//if (strTopic == "/myhome/in/Conditioner/RAW")
|
||||||
|
|
||||||
|
data[B_CMD] = 0;
|
||||||
|
data[9] = 1;
|
||||||
|
data[10] = 77;
|
||||||
|
data[11] = 95;
|
||||||
|
SendData(data, sizeof(data)/sizeof(byte));
|
||||||
|
//InsertData(data, sizeof(data)/sizeof(byte));
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
37
lighthub/modules/out_ac.h
Normal file
37
lighthub/modules/out_ac.h
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
|
||||||
|
#pragma once
|
||||||
|
#ifndef AC_DISABLE
|
||||||
|
#include <abstractout.h>
|
||||||
|
|
||||||
|
#define LEN_B 37
|
||||||
|
#define B_CUR_TMP 13 //Текущая температура
|
||||||
|
#define B_CMD 17 // 00-команда 7F-ответ ???
|
||||||
|
#define B_MODE 23 //04 - DRY, 01 - cool, 02 - heat, 00 - smart 03 - вентиляция
|
||||||
|
#define B_FAN_SPD 25 //Скорость 02 - min, 01 - mid, 00 - max, 03 - auto
|
||||||
|
#define B_SWING 27 //01 - верхний и нижний предел вкл. 00 - выкл. 02 - левый/правый вкл. 03 - оба вкл
|
||||||
|
#define B_LOCK_REM 28 //80 блокировка вкл. 00 - выкл
|
||||||
|
#define B_POWER 29 //on/off 01 - on, 00 - off (10, 11)-Компрессор??? 09 - QUIET
|
||||||
|
#define B_FRESH 31 //fresh 00 - off, 01 - on
|
||||||
|
#define B_SET_TMP 35 //Установленная температура
|
||||||
|
|
||||||
|
#define S_LOCK S_ADDITIONAL+1
|
||||||
|
#define S_QUIET S_ADDITIONAL+2
|
||||||
|
#define S_SWING S_ADDITIONAL+3
|
||||||
|
#define S_RAW S_ADDITIONAL+4
|
||||||
|
|
||||||
|
extern void modbusIdle(void) ;
|
||||||
|
class out_AC : public abstractOut {
|
||||||
|
public:
|
||||||
|
|
||||||
|
out_AC(Item * _item):abstractOut(_item){};
|
||||||
|
int Setup() override;
|
||||||
|
int Poll(short cause) override;
|
||||||
|
int Stop() override;
|
||||||
|
int Status() override;
|
||||||
|
int isActive() override;
|
||||||
|
int Ctrl(short cmd, short n=0, int * Parameters=NULL, boolean send=true, int suffixCode=0, char* subItem=NULL) override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void InsertData(byte data[], size_t size);
|
||||||
|
};
|
||||||
|
#endif
|
||||||
284
lighthub/modules/out_motor.cpp
Normal file
284
lighthub/modules/out_motor.cpp
Normal file
@@ -0,0 +1,284 @@
|
|||||||
|
#ifndef MOTOR_DISABLE
|
||||||
|
|
||||||
|
#include "modules/out_motor.h"
|
||||||
|
#include "Arduino.h"
|
||||||
|
#include "options.h"
|
||||||
|
#include "Streaming.h"
|
||||||
|
|
||||||
|
#include "item.h"
|
||||||
|
|
||||||
|
static int driverStatus = CST_UNKNOWN;
|
||||||
|
|
||||||
|
void out_Motor::getConfig()
|
||||||
|
{
|
||||||
|
pinUp=item->getArg(0);
|
||||||
|
if(pinUp<=0 || pinUp>=PINS_COUNT) pinUp=32;
|
||||||
|
|
||||||
|
pinDown=item->getArg(1);
|
||||||
|
if (pinDown<=0 || pinDown>=PINS_COUNT) pinDown=33;
|
||||||
|
|
||||||
|
pinFeedback=item->getArg(2);
|
||||||
|
if (pinFeedback<0 || pinFeedback>=PINS_COUNT) pinFeedback=0;
|
||||||
|
|
||||||
|
feedbackOpen=item->getArg(3);
|
||||||
|
if (feedbackOpen<=0 || feedbackOpen>1024) feedbackOpen=0;
|
||||||
|
|
||||||
|
feedbackClosed=item->getArg(4);
|
||||||
|
if (feedbackClosed<0 || feedbackClosed>1024) feedbackClosed=1024;
|
||||||
|
|
||||||
|
maxOnTime=item->getArg(5);
|
||||||
|
if (maxOnTime<=0) maxOnTime=10000;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int out_Motor::Setup()
|
||||||
|
{
|
||||||
|
getConfig();
|
||||||
|
Serial.println("Motor Init");
|
||||||
|
pinMode(pinUp,OUTPUT);
|
||||||
|
pinMode(pinDown,OUTPUT);
|
||||||
|
digitalWrite(pinUp,LOW);
|
||||||
|
digitalWrite(pinDown,LOW);
|
||||||
|
pinMode(pinFeedback, INPUT);
|
||||||
|
item->setExt(0);
|
||||||
|
item->clearFlag(ACTION_NEEDED);
|
||||||
|
item->clearFlag(ACTION_IN_PROCESS);
|
||||||
|
driverStatus = CST_INITIALIZED;
|
||||||
|
motorQuote = MOTOR_QUOTE;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int out_Motor::Stop()
|
||||||
|
{
|
||||||
|
Serial.println("Motor De-Init");
|
||||||
|
digitalWrite(pinUp,LOW);
|
||||||
|
digitalWrite(pinDown,LOW);
|
||||||
|
item->setExt(0);
|
||||||
|
driverStatus = CST_UNKNOWN;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int out_Motor::Status()
|
||||||
|
{
|
||||||
|
return driverStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
int out_Motor::isActive()
|
||||||
|
{
|
||||||
|
return item->getVal();
|
||||||
|
}
|
||||||
|
|
||||||
|
int out_Motor::Poll(short cause)
|
||||||
|
{
|
||||||
|
int curPos = -1;
|
||||||
|
int targetPos = -1;
|
||||||
|
int dif;
|
||||||
|
if (!item->getFlag(ACTION_NEEDED)) return 0;
|
||||||
|
|
||||||
|
if (!item->getFlag(ACTION_IN_PROCESS))
|
||||||
|
{
|
||||||
|
if (motorQuote)
|
||||||
|
{
|
||||||
|
item->setFlag(ACTION_IN_PROCESS);
|
||||||
|
motorQuote--;
|
||||||
|
}
|
||||||
|
else return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t motorOfftime = item->getExt();
|
||||||
|
|
||||||
|
switch (item->getCmd())
|
||||||
|
{
|
||||||
|
case CMD_ON:
|
||||||
|
case CMD_XON:
|
||||||
|
targetPos = item->getVal();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CMD_OFF:
|
||||||
|
case CMD_HALT:
|
||||||
|
targetPos = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pinFeedback && isAnalogPin(pinFeedback))
|
||||||
|
{
|
||||||
|
curPos=map(analogRead(pinFeedback),feedbackClosed,feedbackOpen,0,100);
|
||||||
|
if (curPos<0) curPos=0;
|
||||||
|
if (curPos>100) curPos=100;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (motorOfftime && motorOfftime<millis()) //Time over
|
||||||
|
{dif = 0; debugSerial<<F("Motor timeout")<<endl;}
|
||||||
|
else if (curPos>=0)
|
||||||
|
dif=targetPos-curPos;
|
||||||
|
else
|
||||||
|
dif=targetPos-50; // Have No feedback
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (dif<-POS_ERR)
|
||||||
|
{
|
||||||
|
|
||||||
|
digitalWrite(pinDown,LOW);
|
||||||
|
if (!item->getExt())item->setExt(millis()+maxOnTime);
|
||||||
|
|
||||||
|
//
|
||||||
|
//PINS_COUNT
|
||||||
|
//PIN_ATTR_ANALOG
|
||||||
|
// uint32_t attr = g_APinDescription[pinUp].ulPinAttribute;
|
||||||
|
// if ((attr & PIN_ATTR_PWM) == PIN_ATTR_PWM) ;
|
||||||
|
#ifndef ESP32
|
||||||
|
if (digitalPinHasPWM(pinUp))
|
||||||
|
{
|
||||||
|
//Serial.println("pinUP PWM");
|
||||||
|
int velocity = map(-dif, 0, 10, 0, 255);
|
||||||
|
if (velocity>255) velocity=255;
|
||||||
|
if (velocity<0) velocity=0;
|
||||||
|
analogWrite(pinUp,velocity);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (digitalPinHasPWM(pinDown))
|
||||||
|
{
|
||||||
|
// Serial.println("pinDown PWM fallback");
|
||||||
|
digitalWrite(pinUp,HIGH);
|
||||||
|
int velocity = map(-dif, 0, 10, 255, 0);
|
||||||
|
if (velocity>255) velocity=255;
|
||||||
|
if (velocity<0) velocity=0;
|
||||||
|
analogWrite(pinDown,velocity);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
// Serial.print(pinUp);
|
||||||
|
// Serial.println(" pinUP noPWM");
|
||||||
|
digitalWrite(pinUp,HIGH);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
|
||||||
|
if (dif>POS_ERR)
|
||||||
|
{
|
||||||
|
digitalWrite(pinUp,LOW);
|
||||||
|
|
||||||
|
if (!item->getExt()) item->setExt(millis()+maxOnTime);
|
||||||
|
#ifndef ESP32
|
||||||
|
if (digitalPinHasPWM(pinDown))
|
||||||
|
{
|
||||||
|
//Serial.println("pinDown PWM");
|
||||||
|
int velocity = map(dif, 0, 10, 0, 255);
|
||||||
|
if (velocity>255) velocity=255;
|
||||||
|
if (velocity<0) velocity=0;
|
||||||
|
analogWrite(pinDown,velocity);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (digitalPinHasPWM(pinUp))
|
||||||
|
{
|
||||||
|
//Serial.println("pinUP PWM fallback");
|
||||||
|
digitalWrite(pinDown,HIGH);
|
||||||
|
int velocity = map(dif, 0, 10, 255, 0);
|
||||||
|
if (velocity>255) velocity=255;
|
||||||
|
if (velocity<0) velocity=0;
|
||||||
|
analogWrite(pinUp,velocity);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
//Serial.print(pinDown);
|
||||||
|
//Serial.println(" pinDown noPWM");
|
||||||
|
digitalWrite(pinDown,HIGH);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else //Target zone
|
||||||
|
{ Serial.println("Target");
|
||||||
|
digitalWrite(pinUp,LOW);
|
||||||
|
digitalWrite(pinDown,LOW);
|
||||||
|
item->setExt(0);
|
||||||
|
item->clearFlag(ACTION_NEEDED);
|
||||||
|
item->clearFlag(ACTION_IN_PROCESS);
|
||||||
|
motorQuote++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
int out_Motor::getChanType()
|
||||||
|
{
|
||||||
|
return CH_PWM;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int out_Motor::Ctrl(short cmd, short n, int * Parameters, boolean send, int suffixCode, char* subItem)
|
||||||
|
{
|
||||||
|
int chActive = item->isActive();
|
||||||
|
bool toExecute = (chActive>0);
|
||||||
|
long st;
|
||||||
|
if (cmd>0 && !suffixCode) suffixCode=S_CMD; //if some known command find, but w/o correct suffix - got it
|
||||||
|
|
||||||
|
item->setFlag(ACTION_NEEDED);
|
||||||
|
|
||||||
|
switch(suffixCode)
|
||||||
|
{
|
||||||
|
case S_NOTFOUND:
|
||||||
|
// turn on and set
|
||||||
|
toExecute = true;
|
||||||
|
debugSerial<<F("Forced execution");
|
||||||
|
case S_SET:
|
||||||
|
if (!Parameters || n==0) return 0;
|
||||||
|
item->setVal(st=Parameters[0]); //Store
|
||||||
|
if (!suffixCode)
|
||||||
|
{
|
||||||
|
if (chActive>0 && !st) item->setCmd(CMD_OFF);
|
||||||
|
if (chActive==0 && st) item->setCmd(CMD_ON);
|
||||||
|
item->SendStatus(SEND_COMMAND | SEND_PARAMETERS | SEND_DEFFERED);
|
||||||
|
if (item->getExt()) item->setExt(millis()+maxOnTime); //Extend motor time
|
||||||
|
}
|
||||||
|
else item->SendStatus(SEND_PARAMETERS | SEND_DEFFERED);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
//break;
|
||||||
|
|
||||||
|
case S_CMD:
|
||||||
|
item->setCmd(cmd);
|
||||||
|
switch (cmd)
|
||||||
|
{
|
||||||
|
case CMD_ON:
|
||||||
|
//retrive stored values
|
||||||
|
st = item->getVal();
|
||||||
|
|
||||||
|
|
||||||
|
if (st && (st<MIN_VOLUME) && send) st=INIT_VOLUME;
|
||||||
|
item->setVal(st);
|
||||||
|
|
||||||
|
if (st) //Stored smthng
|
||||||
|
{
|
||||||
|
if (send) item->SendStatus(SEND_COMMAND | SEND_PARAMETERS);
|
||||||
|
debugSerial<<F("Restored: ")<<st<<endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
debugSerial<<st<<F(": No stored values - default\n");
|
||||||
|
// Store
|
||||||
|
st=100;
|
||||||
|
item->setVal(st);
|
||||||
|
if (send) item->SendStatus(SEND_COMMAND | SEND_PARAMETERS );
|
||||||
|
}
|
||||||
|
if (item->getExt()) item->setExt(millis()+maxOnTime); //Extend motor time
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
case CMD_OFF:
|
||||||
|
if (send) item->SendStatus(SEND_COMMAND);
|
||||||
|
if (item->getExt()) item->setExt(millis()+maxOnTime); //Extend motor time
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
} //switch cmd
|
||||||
|
|
||||||
|
break;
|
||||||
|
} //switch suffix
|
||||||
|
debugSerial<<F("Unknown cmd")<<endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
39
lighthub/modules/out_motor.h
Normal file
39
lighthub/modules/out_motor.h
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "options.h"
|
||||||
|
#ifndef MOTOR_DISABLE
|
||||||
|
#include <abstractout.h>
|
||||||
|
#include <item.h>
|
||||||
|
|
||||||
|
#ifndef POS_ERR
|
||||||
|
#define POS_ERR 2
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// The number of simultaniusly working motors
|
||||||
|
#ifndef MOTOR_QUOTE
|
||||||
|
#define MOTOR_QUOTE 2
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static int8_t motorQuote = MOTOR_QUOTE;
|
||||||
|
|
||||||
|
class out_Motor : public abstractOut {
|
||||||
|
public:
|
||||||
|
|
||||||
|
out_Motor(Item * _item):abstractOut(_item){getConfig();};
|
||||||
|
int Setup() override;
|
||||||
|
int Poll(short cause) override;
|
||||||
|
int Stop() override;
|
||||||
|
int Status() override;
|
||||||
|
int isActive() override;
|
||||||
|
int getChanType() override;
|
||||||
|
int Ctrl(short cmd, short n=0, int * Parameters=NULL, boolean send=true, int suffixCode=0, char* subItem=NULL) override;
|
||||||
|
|
||||||
|
int8_t pinUp;
|
||||||
|
int8_t pinDown;
|
||||||
|
int8_t pinFeedback;
|
||||||
|
int16_t maxOnTime;
|
||||||
|
uint16_t feedbackOpen;
|
||||||
|
uint16_t feedbackClosed;
|
||||||
|
protected:
|
||||||
|
void getConfig();
|
||||||
|
};
|
||||||
|
#endif
|
||||||
335
lighthub/modules/out_spiled.cpp
Normal file
335
lighthub/modules/out_spiled.cpp
Normal file
@@ -0,0 +1,335 @@
|
|||||||
|
#ifndef SPILED_DISABLE
|
||||||
|
|
||||||
|
#include "modules/out_spiled.h"
|
||||||
|
#include "Arduino.h"
|
||||||
|
#include "options.h"
|
||||||
|
#include "Streaming.h"
|
||||||
|
|
||||||
|
#include "item.h"
|
||||||
|
|
||||||
|
#ifdef ADAFRUIT_LED
|
||||||
|
|
||||||
|
#include <Adafruit_NeoPixel.h>
|
||||||
|
#ifdef __AVR__
|
||||||
|
#include <avr/power.h> // Required for 16 MHz Adafruit Trinket
|
||||||
|
#endif
|
||||||
|
Adafruit_NeoPixel *leds = NULL;
|
||||||
|
|
||||||
|
#else
|
||||||
|
#include "FastLED.h"
|
||||||
|
static CRGB *leds = NULL;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define NUM_LEDS 43
|
||||||
|
|
||||||
|
static int driverStatus = CST_UNKNOWN;
|
||||||
|
|
||||||
|
void out_SPILed::getConfig()
|
||||||
|
{
|
||||||
|
pin=item->getArg(0);
|
||||||
|
if(pin<=0) pin=3;
|
||||||
|
|
||||||
|
numLeds=item->getArg(1);
|
||||||
|
if (numLeds<=0) numLeds=NUM_LEDS;
|
||||||
|
|
||||||
|
ledsType=item->getArg(2);
|
||||||
|
#ifdef ADAFRUIT_LED
|
||||||
|
if (ledsType<=0) ledsType= NEO_BRG + NEO_KHZ800;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int out_SPILed::Setup()
|
||||||
|
{
|
||||||
|
getConfig();
|
||||||
|
Serial.println("SPI-LED Init");
|
||||||
|
|
||||||
|
if (!leds)
|
||||||
|
{
|
||||||
|
#ifdef ADAFRUIT_LED
|
||||||
|
#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
|
||||||
|
clock_prescale_set(clock_div_1);
|
||||||
|
#endif
|
||||||
|
leds = new Adafruit_NeoPixel(numLeds, pin, ledsType);
|
||||||
|
leds->begin();
|
||||||
|
#else
|
||||||
|
leds = new CRGB [numLeds]; //Allocate dynamic memory for LED objects
|
||||||
|
//template< CONTROLLER = TM1809, uint8_t DATA_PIN = pin, EOrder ORDER = BRG >
|
||||||
|
//FastLED.addLeds<TM1809, pin, BRG>(leds, numLeds);
|
||||||
|
FastLED.addLeds<CONTROLLER, DATA_PIN, ORDER>(leds, numLeds);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
driverStatus = CST_INITIALIZED;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int out_SPILed::Stop()
|
||||||
|
{
|
||||||
|
Serial.println("SPI-LED De-Init");
|
||||||
|
//FastLED.addLeds<TM1809, DATA_PIN, BRG>(leds, NUM_LEDS);
|
||||||
|
#ifdef ADAFRUIT_LED
|
||||||
|
leds->clear();
|
||||||
|
delete leds;
|
||||||
|
#else
|
||||||
|
FastLED.clear(true);
|
||||||
|
delete [] leds;
|
||||||
|
#endif
|
||||||
|
driverStatus = CST_UNKNOWN;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int out_SPILed::Status()
|
||||||
|
{
|
||||||
|
return driverStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
int out_SPILed::isActive()
|
||||||
|
{
|
||||||
|
CHstore st;
|
||||||
|
st.aslong = item->getVal(); //Restore old params
|
||||||
|
debugSerial<< F(" val:")<<st.v<<endl;
|
||||||
|
return st.v;
|
||||||
|
}
|
||||||
|
|
||||||
|
int out_SPILed::Poll(short cause)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
int out_SPILed::getChanType()
|
||||||
|
{
|
||||||
|
if ((ledsType>>4) == (ledsType>>6))
|
||||||
|
return CH_RGB;
|
||||||
|
else
|
||||||
|
return CH_RGBW;
|
||||||
|
}
|
||||||
|
|
||||||
|
int out_SPILed::PixelCtrl(CHstore *st, short cmd, int from, int to, bool show, bool rgb)
|
||||||
|
{
|
||||||
|
//debugSerial<<F("cmd: ")<<cmd<<endl;
|
||||||
|
#ifdef ADAFRUIT_LED
|
||||||
|
uint32_t pixel;
|
||||||
|
#else
|
||||||
|
CRGB pixel;
|
||||||
|
#endif
|
||||||
|
if (!rgb)
|
||||||
|
{
|
||||||
|
int Saturation = map(st->s, 0, 100, 0, 255);
|
||||||
|
int Value = map(st->v, 0, 100, 0, 255);
|
||||||
|
|
||||||
|
#ifdef ADAFRUIT_LED
|
||||||
|
uint16_t Hue = map(st->h, 0, 365, 0, 65535);
|
||||||
|
pixel = leds->ColorHSV(Hue, Saturation, Value);
|
||||||
|
#else
|
||||||
|
int Hue = map(st->h, 0, 365, 0, 255);
|
||||||
|
pixel = CHSV(Hue, Saturation, Value);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
debugSerial<<F("hsv: ")<<st->h<<F(",")<<st->s<<F(",")<<st->v<<endl;
|
||||||
|
}
|
||||||
|
if (to>numLeds-1) to=numLeds-1;
|
||||||
|
if (from<0) from=0;
|
||||||
|
|
||||||
|
for (int i=from;i<=to;i++)
|
||||||
|
{
|
||||||
|
switch (cmd) {
|
||||||
|
case CMD_ON:
|
||||||
|
|
||||||
|
#ifdef ADAFRUIT_LED
|
||||||
|
if (!leds->getPixelColor(i)) leds->setPixelColor(i, leds->Color(255, 255, 255));
|
||||||
|
#else
|
||||||
|
if (!leds[i].r && !leds[i].g &&!leds[i].b) leds[i] = CRGB::White;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
break;
|
||||||
|
case CMD_OFF:
|
||||||
|
#ifdef ADAFRUIT_LED
|
||||||
|
leds->setPixelColor(i, leds->Color(0, 0, 0));
|
||||||
|
#else
|
||||||
|
leds[i] = CRGB::Black;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (rgb)
|
||||||
|
{
|
||||||
|
#ifdef ADAFRUIT_LED
|
||||||
|
leds->setPixelColor(i, leds->Color(st->r,st->g,st->b));
|
||||||
|
#else
|
||||||
|
leds[i] = CRGB(st->r,st->g,st->b);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#ifdef ADAFRUIT_LED
|
||||||
|
leds->setPixelColor(i, pixel);
|
||||||
|
#else
|
||||||
|
leds[i] = pixel;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
} //for
|
||||||
|
if (show)
|
||||||
|
{
|
||||||
|
#ifdef ADAFRUIT_LED
|
||||||
|
leds->show();
|
||||||
|
#else
|
||||||
|
FastLED.show();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
debugSerial<<F("Show")<<endl;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int out_SPILed::Ctrl(short cmd, short n, int * Parameters, boolean send, int suffixCode, char* subItem)
|
||||||
|
{
|
||||||
|
int chActive = item->isActive();
|
||||||
|
bool toExecute = (chActive>0);
|
||||||
|
CHstore st;
|
||||||
|
if (cmd>0 && !suffixCode) suffixCode=S_CMD; //if some known command find, but w/o correct suffix - got it
|
||||||
|
|
||||||
|
int from=0, to=numLeds-1; //All LEDs on the strip by default
|
||||||
|
// retrive LEDs range from suffix
|
||||||
|
if (subItem)
|
||||||
|
{ //Just single LED to control todo - range
|
||||||
|
// debugSerial<<F("Range:")<<subItem<<endl;
|
||||||
|
if (sscanf(subItem,"%d-%d",&from,&to) == 1) to=from;
|
||||||
|
}
|
||||||
|
debugSerial<<from<<F("-")<<to<<F(" cmd=")<<cmd<<endl;
|
||||||
|
|
||||||
|
|
||||||
|
switch(suffixCode)
|
||||||
|
{
|
||||||
|
case S_NOTFOUND:
|
||||||
|
// turn on and set
|
||||||
|
toExecute = true;
|
||||||
|
case S_SET:
|
||||||
|
case S_HSV:
|
||||||
|
st.aslong = item->getVal(); //Restore old params
|
||||||
|
switch (n) //How many parameters are passed?
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
st.v = Parameters[0]; //Volume only
|
||||||
|
if (!st.hsv_flag)
|
||||||
|
{
|
||||||
|
st.h = 0; //Filling by default
|
||||||
|
st.s = 0;
|
||||||
|
st.hsv_flag = 1; // Mark stored vals as HSV
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 2: // Just hue and saturation
|
||||||
|
st.h = Parameters[0];
|
||||||
|
st.s = Parameters[1];
|
||||||
|
st.hsv_flag = 1;
|
||||||
|
break;
|
||||||
|
case 3: //complete triplet
|
||||||
|
st.h = Parameters[0];
|
||||||
|
st.s = Parameters[1];
|
||||||
|
st.v = Parameters[2];
|
||||||
|
st.hsv_flag = 1;
|
||||||
|
}
|
||||||
|
PixelCtrl(&st,0,from,to,toExecute);
|
||||||
|
|
||||||
|
if (!subItem) //Whole strip
|
||||||
|
{
|
||||||
|
item->setVal(st.aslong); //Store
|
||||||
|
if (!suffixCode)
|
||||||
|
{
|
||||||
|
if (chActive>0 && !st.v) item->setCmd(CMD_OFF);
|
||||||
|
if (chActive==0 && st.v) item->setCmd(CMD_ON);
|
||||||
|
item->SendStatus(SEND_COMMAND | SEND_PARAMETERS | SEND_DEFFERED);
|
||||||
|
}
|
||||||
|
else item->SendStatus(SEND_PARAMETERS | SEND_DEFFERED);
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
//break;
|
||||||
|
case S_RGB:
|
||||||
|
st.r = Parameters[0];
|
||||||
|
st.g = Parameters[1];
|
||||||
|
st.b = Parameters[2];
|
||||||
|
st.w = 0;
|
||||||
|
st.hsv_flag = 0;
|
||||||
|
PixelCtrl(&st,0,from,to,toExecute,true);
|
||||||
|
//item->setVal(st.aslong); //Store
|
||||||
|
if (!suffixCode)
|
||||||
|
{
|
||||||
|
if (chActive>0 && !st.aslong) item->setCmd(CMD_OFF);
|
||||||
|
if (chActive==0 && st.aslong) item->setCmd(CMD_ON);
|
||||||
|
item->SendStatus(SEND_COMMAND | SEND_PARAMETERS | SEND_DEFFERED);
|
||||||
|
}
|
||||||
|
else item->SendStatus(SEND_PARAMETERS | SEND_DEFFERED);
|
||||||
|
return 1;
|
||||||
|
//break;
|
||||||
|
case S_CMD:
|
||||||
|
item->setCmd(cmd);
|
||||||
|
switch (cmd)
|
||||||
|
{
|
||||||
|
case CMD_ON:
|
||||||
|
|
||||||
|
/*
|
||||||
|
if (chActive>0 && send)
|
||||||
|
{
|
||||||
|
SendStatus(SEND_COMMAND);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
//retrive stored values
|
||||||
|
st.aslong = item->getVal();
|
||||||
|
|
||||||
|
if (subItem) // LED range, not whole strip
|
||||||
|
PixelCtrl(&st,CMD_ON,from,to);
|
||||||
|
else //whole strip
|
||||||
|
{
|
||||||
|
if (st.aslong && (st.v<MIN_VOLUME) && send) st.v=INIT_VOLUME;
|
||||||
|
item->setVal(st.aslong);
|
||||||
|
|
||||||
|
if (st.aslong ) //Stored smthng
|
||||||
|
{
|
||||||
|
if (send) item->SendStatus(SEND_COMMAND | SEND_PARAMETERS);
|
||||||
|
debugSerial<<F("Restored: ")<<st.h<<F(",")<<st.s<<F(",")<<st.v<<endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
debugSerial<<st.aslong<<F(": No stored values - default\n");
|
||||||
|
st.h = 100;
|
||||||
|
st.s = 0;
|
||||||
|
st.v = 100;
|
||||||
|
st.hsv_flag=1;
|
||||||
|
// Store
|
||||||
|
item->setVal(st.aslong);
|
||||||
|
if (send) item->SendStatus(SEND_COMMAND | SEND_PARAMETERS );
|
||||||
|
}
|
||||||
|
|
||||||
|
PixelCtrl(&st,0,from,to);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
case CMD_OFF:
|
||||||
|
if (subItem) // LED range, not whole strip
|
||||||
|
PixelCtrl(&st,CMD_OFF,from,to);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
st.v=0;
|
||||||
|
PixelCtrl(&st,0,from,to);
|
||||||
|
if (send) item->SendStatus(SEND_COMMAND);
|
||||||
|
// if (send) item->publishTopic(item->itemArr->name,"OFF","/cmd");
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
} //switch cmd
|
||||||
|
|
||||||
|
break;
|
||||||
|
} //switch suffix
|
||||||
|
debugSerial<<F("Unknown cmd")<<endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
32
lighthub/modules/out_spiled.h
Normal file
32
lighthub/modules/out_spiled.h
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "options.h"
|
||||||
|
#ifndef SPILED_DISABLE
|
||||||
|
#include <abstractout.h>
|
||||||
|
#include <item.h>
|
||||||
|
#ifdef ADAFRUIT_LED
|
||||||
|
|
||||||
|
#include <Adafruit_NeoPixel.h>
|
||||||
|
#else
|
||||||
|
#include "FastLED.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class out_SPILed : public abstractOut {
|
||||||
|
public:
|
||||||
|
|
||||||
|
out_SPILed(Item * _item):abstractOut(_item){getConfig();};
|
||||||
|
int Setup() override;
|
||||||
|
int Poll(short cause) override;
|
||||||
|
int Stop() override;
|
||||||
|
int Status() override;
|
||||||
|
int isActive() override;
|
||||||
|
int getChanType() override;
|
||||||
|
int Ctrl(short cmd, short n=0, int * Parameters=NULL, boolean send=true, int suffixCode=0, char* subItem=NULL) override;
|
||||||
|
int PixelCtrl(CHstore *st, short cmd, int from =0 , int to = 1024, bool show = 1, bool rgb = 0);
|
||||||
|
int numLeds;
|
||||||
|
int8_t pin;
|
||||||
|
int ledsType;
|
||||||
|
protected:
|
||||||
|
void getConfig();
|
||||||
|
};
|
||||||
|
#endif
|
||||||
1
lighthub/monitor.bat
Normal file
1
lighthub/monitor.bat
Normal file
@@ -0,0 +1 @@
|
|||||||
|
pio device monitor -b 115200
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
/*
|
|
||||||
int mqtt::publish(int value)
|
|
||||||
{};
|
|
||||||
|
|
||||||
int mqtt::publish(float value)
|
|
||||||
{
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
int mqtt::publish(char * value)
|
|
||||||
{
|
|
||||||
char addrstr[MQTT_TOPIC_LENGTH];
|
|
||||||
aJsonObject *emit = aJson.getObjectItem(in, "emit");
|
|
||||||
strncpy(addrstr,emit->valuestring,sizeof(addrstr));
|
|
||||||
if (!strchr(addrstr,'/')) setTopic(addrstr,sizeof(addrstr),T_OUT,emit->valuestring);
|
|
||||||
if mqttClient.connected() mqttClient.publish(addrstr, value, true);
|
|
||||||
};
|
|
||||||
*/
|
|
||||||
@@ -1,13 +1,29 @@
|
|||||||
// Configuration of drivers enabled
|
// Configuration of drivers enabled
|
||||||
#ifndef PIO_SRC_REV
|
|
||||||
#define PIO_SRC_REV v0.999
|
#ifndef FASTLED
|
||||||
|
#define ADAFRUIT_LED
|
||||||
|
#endif
|
||||||
|
// ADAFRUIT library allow to dynamically configure SPI LED Strip Parameters
|
||||||
|
|
||||||
|
// If not defined ADAFRUIT_LED - FastLED library will be used instead
|
||||||
|
// And strip type, pin, order must defined on compilation time
|
||||||
|
#ifndef CONTROLLER
|
||||||
|
#define CONTROLLER TM1809
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef DATA_PIN
|
||||||
|
#define DATA_PIN 4
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ORDER
|
||||||
|
#define ORDER BRG
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define TXEnablePin 13
|
#define TXEnablePin 13
|
||||||
#define ESP_EEPROM_SIZE 2048
|
#define ESP_EEPROM_SIZE 2048
|
||||||
|
|
||||||
#ifndef AVR_DMXOUT_PIN
|
#ifndef AVR_DMXOUT_PIN
|
||||||
#define AVR_DMXOUT_PIN 3
|
#define AVR_DMXOUT_PIN 18
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define T_ATTEMPTS 200
|
#define T_ATTEMPTS 200
|
||||||
@@ -18,8 +34,11 @@
|
|||||||
#define THERMO_OVERHEAT_CELSIUS 38.
|
#define THERMO_OVERHEAT_CELSIUS 38.
|
||||||
#define FM_OVERHEAT_CELSIUS 40.
|
#define FM_OVERHEAT_CELSIUS 40.
|
||||||
|
|
||||||
#define MIN_VOLUME 10
|
#define MIN_VOLUME 25
|
||||||
#define INIT_VOLUME 50
|
#define INIT_VOLUME 40
|
||||||
|
|
||||||
|
#define MAXFLASHSTR 32
|
||||||
|
#define PWDFLASHSTR 16
|
||||||
|
|
||||||
#define OFFSET_MAC 0
|
#define OFFSET_MAC 0
|
||||||
#define OFFSET_IP OFFSET_MAC+6
|
#define OFFSET_IP OFFSET_MAC+6
|
||||||
@@ -27,12 +46,12 @@
|
|||||||
#define OFFSET_GW OFFSET_DNS+4
|
#define OFFSET_GW OFFSET_DNS+4
|
||||||
#define OFFSET_MASK OFFSET_GW+4
|
#define OFFSET_MASK OFFSET_GW+4
|
||||||
#define OFFSET_CONFIGSERVER OFFSET_MASK+4
|
#define OFFSET_CONFIGSERVER OFFSET_MASK+4
|
||||||
#define OFFSET_MQTT_PWD OFFSET_CONFIGSERVER+32
|
#define OFFSET_MQTT_PWD OFFSET_CONFIGSERVER+MAXFLASHSTR
|
||||||
#define EEPROM_offset_NotAlligned OFFSET_MQTT_PWD+16
|
#define EEPROM_offset_NotAlligned OFFSET_MQTT_PWD+PWDFLASHSTR
|
||||||
#define EEPROM_offset EEPROM_offset_NotAlligned + (4 -(EEPROM_offset_NotAlligned & 3))
|
#define EEPROM_offset EEPROM_offset_NotAlligned + (4 -(EEPROM_offset_NotAlligned & 3))
|
||||||
|
|
||||||
#ifndef INTERVAL_CHECK_INPUT
|
#ifndef INTERVAL_CHECK_INPUT
|
||||||
#define INTERVAL_CHECK_INPUT 50
|
#define INTERVAL_CHECK_INPUT 15
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef INTERVAL_CHECK_SENSOR
|
#ifndef INTERVAL_CHECK_SENSOR
|
||||||
@@ -75,19 +94,6 @@
|
|||||||
#ifndef HOMETOPIC
|
#ifndef HOMETOPIC
|
||||||
#define HOMETOPIC "myhome"
|
#define HOMETOPIC "myhome"
|
||||||
#endif
|
#endif
|
||||||
/*
|
|
||||||
#ifndef OUTTOPIC
|
|
||||||
#define OUTTOPIC "/myhome/s_out/"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef CMDTOPIC
|
|
||||||
#define CMDTOPIC "/myhome/in/command/"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef INTOPIC
|
|
||||||
#define INTOPIC "/myhome/in/"
|
|
||||||
#endif
|
|
||||||
*/
|
|
||||||
|
|
||||||
//Default output topic
|
//Default output topic
|
||||||
#ifndef OUTTOPIC
|
#ifndef OUTTOPIC
|
||||||
@@ -128,12 +134,16 @@
|
|||||||
#define LAN_INIT_DELAY 500
|
#define LAN_INIT_DELAY 500
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define DEFAULT_INC_STEP 5
|
||||||
|
|
||||||
#if defined(ARDUINO_ARCH_AVR)
|
#if defined(ARDUINO_ARCH_AVR)
|
||||||
//All options available
|
//All options available
|
||||||
#ifdef CONTROLLINO
|
#ifdef CONTROLLINO
|
||||||
#define modbusSerial Serial3
|
#define modbusSerial Serial3
|
||||||
|
#define AC_Serial Serial2
|
||||||
#else
|
#else
|
||||||
#define modbusSerial Serial2
|
#define modbusSerial Serial2
|
||||||
|
#define AC_Serial Serial3
|
||||||
#endif
|
#endif
|
||||||
#define dmxin DMXSerial
|
#define dmxin DMXSerial
|
||||||
#define dmxout DmxSimple
|
#define dmxout DmxSimple
|
||||||
@@ -141,6 +151,7 @@
|
|||||||
|
|
||||||
#if defined(__SAM3X8E__)
|
#if defined(__SAM3X8E__)
|
||||||
#define modbusSerial Serial2
|
#define modbusSerial Serial2
|
||||||
|
#define AC_Serial Serial3
|
||||||
#define dmxout DmxDue1
|
#define dmxout DmxDue1
|
||||||
#define dmxin DmxDue1
|
#define dmxin DmxDue1
|
||||||
#endif
|
#endif
|
||||||
@@ -159,7 +170,9 @@
|
|||||||
#ifndef DMX_DISABLE
|
#ifndef DMX_DISABLE
|
||||||
#define _espdmx
|
#define _espdmx
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define modbusSerial Serial1
|
#define modbusSerial Serial1
|
||||||
|
#define AC_Serial Serial1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(ARDUINO_ARCH_ESP32)
|
#if defined(ARDUINO_ARCH_ESP32)
|
||||||
@@ -194,6 +207,10 @@
|
|||||||
#define strncpy_P strncpy
|
#define strncpy_P strncpy
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef DMX_SMOOTH_DELAY
|
||||||
|
#define DMX_SMOOTH_DELAY 10
|
||||||
|
#endif
|
||||||
|
|
||||||
//#ifdef M5STACK
|
//#ifdef M5STACK
|
||||||
//#define debugSerial M5.Lcd
|
//#define debugSerial M5.Lcd
|
||||||
//#endif
|
//#endif
|
||||||
@@ -207,3 +224,33 @@
|
|||||||
#else
|
#else
|
||||||
#define W5500_ETHERNET_SHIELD
|
#define W5500_ETHERNET_SHIELD
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(ARDUINO_ARCH_AVR)
|
||||||
|
#define PINS_COUNT NUM_DIGITAL_PINS
|
||||||
|
#define isAnalogPin(p) ((p >= 54) && (p<=69))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__SAM3X8E__)
|
||||||
|
#define isAnalogPin(p) (g_APinDescription[p].ulPinAttribute & PIN_ATTR_ANALOG) == PIN_ATTR_ANALOG
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(ARDUINO_ARCH_STM32)
|
||||||
|
#define PINS_COUNT NUM_DIGITAL_PINS
|
||||||
|
#define isAnalogPin(p) ((p >= 44) && (p<=57))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(ESP8266)
|
||||||
|
#define PINS_COUNT NUM_DIGITAL_PINS
|
||||||
|
#define isAnalogPin(p) ( p ==17 )
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(ARDUINO_ARCH_ESP32)
|
||||||
|
#define PINS_COUNT NUM_DIGITAL_PINS
|
||||||
|
#define isAnalogPin(p) ((p ==4) || (p>=12)&& (p<=15) || (p>=25)&& (p<=27)||(p>=32)&& (p<=33) || (p>=37)&& (p<=38))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(NRF5)
|
||||||
|
#define PINS_COUNT NUM_DIGITAL_PINS
|
||||||
|
#define isAnalogPin(p) ((p >= 14) && (p<=21))
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -42,9 +42,13 @@ owChangedType owChanged;
|
|||||||
int owUpdate() {
|
int owUpdate() {
|
||||||
#ifndef OWIRE_DISABLE
|
#ifndef OWIRE_DISABLE
|
||||||
unsigned long finish = millis() + OW_UPDATE_INTERVAL;
|
unsigned long finish = millis() + OW_UPDATE_INTERVAL;
|
||||||
short sr;
|
/*
|
||||||
|
if (oneWire->getError() == DS2482_ERROR_SHORT)
|
||||||
|
{
|
||||||
|
debugSerial<<F("1-wire shorted.")<<endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
*/
|
||||||
Serial.println(F("Searching"));
|
Serial.println(F("Searching"));
|
||||||
if (oneWire) oneWire->reset_search();
|
if (oneWire) oneWire->reset_search();
|
||||||
for (short i = 0; i < t_count; i++) wstat[i] &= ~SW_FIND; //absent
|
for (short i = 0; i < t_count; i++) wstat[i] &= ~SW_FIND; //absent
|
||||||
@@ -78,6 +82,7 @@ int owUpdate() {
|
|||||||
|
|
||||||
debugSerial<<F("1-wire count: ")<<t_count<<endl;
|
debugSerial<<F("1-wire count: ")<<t_count<<endl;
|
||||||
#endif
|
#endif
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -119,6 +124,12 @@ int owSetup(owChangedType owCh) {
|
|||||||
if (oneWire->wireReset())
|
if (oneWire->wireReset())
|
||||||
debugSerial.println(F("\tReset done"));
|
debugSerial.println(F("\tReset done"));
|
||||||
|
|
||||||
|
if (oneWire->getError() == DS2482_ERROR_SHORT)
|
||||||
|
{
|
||||||
|
debugSerial<<F("1-wire shorted.")<<endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
sensors->begin();
|
sensors->begin();
|
||||||
owChanged = owCh;
|
owChanged = owCh;
|
||||||
//owUpdate();
|
//owUpdate();
|
||||||
@@ -141,7 +152,13 @@ int owSetup(owChangedType owCh) {
|
|||||||
|
|
||||||
|
|
||||||
int sensors_loop(void) {
|
int sensors_loop(void) {
|
||||||
if (!sensors) return -1;
|
if (!sensors) return 100000;
|
||||||
|
if (oneWire->getError() == DS2482_ERROR_SHORT)
|
||||||
|
{
|
||||||
|
debugSerial<<F("1-wire disabled (shorted)")<<endl;
|
||||||
|
return 100000;
|
||||||
|
}
|
||||||
|
|
||||||
if (si >= t_count) {
|
if (si >= t_count) {
|
||||||
owUpdate(); //every check circle - scan for new devices
|
owUpdate(); //every check circle - scan for new devices
|
||||||
si = 0;
|
si = 0;
|
||||||
|
|||||||
85
lighthub/textconst.h
Normal file
85
lighthub/textconst.h
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
const char state_P[] PROGMEM = "$state";
|
||||||
|
const char disconnected_P[] PROGMEM = "disconnected";
|
||||||
|
const char ready_P[] PROGMEM = "ready";
|
||||||
|
|
||||||
|
const char homie_P[] PROGMEM = "$homie";
|
||||||
|
const char homiever_P[] PROGMEM = "2.1.0";
|
||||||
|
|
||||||
|
const char name_P[] PROGMEM = "$name";
|
||||||
|
const char nameval_P[] PROGMEM = "LightHub ";
|
||||||
|
|
||||||
|
const char nodes_P[] PROGMEM = "$nodes";
|
||||||
|
const char localip_P[] PROGMEM = "$localip";
|
||||||
|
const char mac_P[] PROGMEM = "$mac";
|
||||||
|
const char fwname_P[] PROGMEM = "$fw/name";
|
||||||
|
const char fwversion_P[] PROGMEM = "$fw/version";
|
||||||
|
const char implementation_P[] PROGMEM = "$implementation";
|
||||||
|
const char interval_P[] PROGMEM = "$stats/interval";
|
||||||
|
const char color_P[] PROGMEM = "color";
|
||||||
|
|
||||||
|
const char datatype_P[] PROGMEM = "$datatype";
|
||||||
|
|
||||||
|
const char float_P[] PROGMEM = "float";
|
||||||
|
const char hsv_P[] PROGMEM = "hsv";
|
||||||
|
const char int_P[] PROGMEM = "integer";
|
||||||
|
const char enum_P[] PROGMEM = "enum";
|
||||||
|
const char format_P[] PROGMEM = "$format";
|
||||||
|
const char true_P[] PROGMEM = "true";
|
||||||
|
const char false_P[] PROGMEM = "false";
|
||||||
|
|
||||||
|
const char enumformat_P[] PROGMEM = "ON,OFF,HALT,REST,XON,XOFF,TOGGLE";
|
||||||
|
const char intformat_P[] PROGMEM = "0-100";
|
||||||
|
|
||||||
|
const char stats_P[] PROGMEM = "$stats";
|
||||||
|
const char statsval_P[] PROGMEM = "uptime,freeheap";
|
||||||
|
const char uptime_P[] PROGMEM = "uptime";
|
||||||
|
const char freeheap_P[] PROGMEM = "freeheap";
|
||||||
|
|
||||||
|
|
||||||
|
//Commands
|
||||||
|
const char ON_P[] PROGMEM = "ON";
|
||||||
|
const char OFF_P[] PROGMEM = "OFF";
|
||||||
|
const char REST_P[] PROGMEM = "REST";
|
||||||
|
const char TOGGLE_P[] PROGMEM = "TOGGLE";
|
||||||
|
const char HALT_P[] PROGMEM = "HALT";
|
||||||
|
const char XON_P[] PROGMEM = "XON";
|
||||||
|
const char XOFF_P[] PROGMEM = "XOFF";
|
||||||
|
const char INCREASE_P[] PROGMEM = "INCREASE";
|
||||||
|
const char DECREASE_P[] PROGMEM = "DECREASE";
|
||||||
|
const char TRUE_P[] PROGMEM = "TRUE";
|
||||||
|
const char FALSE_P[] PROGMEM = "FALSE";
|
||||||
|
|
||||||
|
const char ENABLED_P[] PROGMEM = "ENABLED";
|
||||||
|
const char DISABLED_P[] PROGMEM = "DISABLED";
|
||||||
|
|
||||||
|
const char HEAT_P[] PROGMEM = "HEAT";
|
||||||
|
const char COOL_P[] PROGMEM = "COOL";
|
||||||
|
const static char AUTO_P[] PROGMEM = "AUTO";
|
||||||
|
const char FAN_ONLY_P[] PROGMEM = "FAN_ONLY";
|
||||||
|
const char DRY_P[] PROGMEM = "DRY";
|
||||||
|
const char HIGH_P[] PROGMEM = "HIGH";
|
||||||
|
const char MED_P[] PROGMEM = "MEDIUM";
|
||||||
|
const char LOW_P[] PROGMEM = "LOW";
|
||||||
|
// SubTopics
|
||||||
|
const char SET_P[] PROGMEM = "set";
|
||||||
|
const char CMD_P[] PROGMEM = "cmd";
|
||||||
|
const char MODE_P[] PROGMEM = "mode";
|
||||||
|
const char FAN_P[] PROGMEM = "fan";
|
||||||
|
const char HUE_P[] PROGMEM = "hue";
|
||||||
|
const char SAT_P[] PROGMEM = "sat";
|
||||||
|
/*
|
||||||
|
const char TEMP_P[] PROGMEM = "temp";
|
||||||
|
const char SETPOINT_P[] PROGMEM = "setpoint";
|
||||||
|
const char POWER_P[] PROGMEM = "power";
|
||||||
|
const char VOL_P[] PROGMEM = "vol";
|
||||||
|
const char HEAT_P[] PROGMEM = "heat";
|
||||||
|
*/
|
||||||
|
const char HSV_P[] PROGMEM = "HSV";
|
||||||
|
const char RGB_P[] PROGMEM = "RGB";
|
||||||
|
|
||||||
|
/*
|
||||||
|
const char RPM_P[] PROGMEM = "rpm";
|
||||||
|
const char STATE_P[] PROGMEM = "state";
|
||||||
|
*/
|
||||||
@@ -21,7 +21,7 @@ e-mail anklimov@gmail.com
|
|||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "stdarg.h"
|
#include "stdarg.h"
|
||||||
#include <wire.h>
|
#include <Wire.h>
|
||||||
|
|
||||||
#if defined(__SAM3X8E__) || defined(ARDUINO_ARCH_STM32)
|
#if defined(__SAM3X8E__) || defined(ARDUINO_ARCH_STM32)
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
@@ -377,7 +377,7 @@ void printIPAddress(IPAddress ipAddress) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char* setTopic(char* buf, int8_t buflen, topicType tt, char* suffix)
|
char* setTopic(char* buf, int8_t buflen, topicType tt, const char* suffix)
|
||||||
{
|
{
|
||||||
aJsonObject *_root = NULL;
|
aJsonObject *_root = NULL;
|
||||||
aJsonObject *_l2 = NULL;
|
aJsonObject *_l2 = NULL;
|
||||||
@@ -396,11 +396,11 @@ if (topics && topics->type == aJson_Object)
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
if (_root) strncpy(buf,_root->valuestring,buflen);
|
if (_root && _root->type == aJson_String) strncpy(buf,_root->valuestring,buflen);
|
||||||
else strncpy_P(buf,homeTopic,buflen);
|
else strncpy_P(buf,homeTopic,buflen);
|
||||||
strncat(buf,"/",buflen);
|
strncat(buf,"/",buflen);
|
||||||
|
|
||||||
if (_l2) strncat(buf,_l2->valuestring,buflen);
|
if (_l2 && _l2->type == aJson_String) strncat(buf,_l2->valuestring,buflen);
|
||||||
else
|
else
|
||||||
switch (tt) {
|
switch (tt) {
|
||||||
case T_DEV:
|
case T_DEV:
|
||||||
@@ -504,5 +504,13 @@ RebootFunc();
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
bool isTimeOver(uint32_t timestamp, uint32_t currTime, uint32_t time, uint32_t modulo)
|
||||||
|
{
|
||||||
|
uint32_t endTime=(timestamp + time) % modulo;
|
||||||
|
return ((currTime>endTime) && (currTime <timestamp)) ||
|
||||||
|
((timestamp<endTime) && ((currTime>endTime) || (currTime <timestamp)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#pragma message(VAR_NAME_VALUE(debugSerial))
|
#pragma message(VAR_NAME_VALUE(debugSerial))
|
||||||
#pragma message(VAR_NAME_VALUE(SERIAL_BAUD))
|
#pragma message(VAR_NAME_VALUE(SERIAL_BAUD))
|
||||||
|
|||||||
@@ -55,7 +55,8 @@ void ReadUniqueID( uint32_t * pdwUniqueID );
|
|||||||
int inet_aton(const char* aIPAddrString, IPAddress& aResult);
|
int inet_aton(const char* aIPAddrString, IPAddress& aResult);
|
||||||
char *inet_ntoa_r(IPAddress addr, char *buf, int buflen);
|
char *inet_ntoa_r(IPAddress addr, char *buf, int buflen);
|
||||||
void printIPAddress(IPAddress ipAddress);
|
void printIPAddress(IPAddress ipAddress);
|
||||||
char* setTopic(char* buf, int8_t buflen, topicType tt, char* suffix = NULL);
|
char* setTopic(char* buf, int8_t buflen, topicType tt, const char* suffix = NULL);
|
||||||
void printUlongValueToStr(char *valstr, unsigned long value);
|
void printUlongValueToStr(char *valstr, unsigned long value);
|
||||||
void scan_i2c_bus();
|
void scan_i2c_bus();
|
||||||
void softRebootFunc();
|
void softRebootFunc();
|
||||||
|
bool isTimeOver(uint32_t timestamp, uint32_t currTime, uint32_t time, uint32_t modulo = 0xFFFFFFFF);
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
#! /bin/bash
|
|
||||||
echo /tmp/$1/pioenvs
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
#! /bin/bash
|
|
||||||
echo /tmp/$1/piolibdeps
|
|
||||||
112
platformio.ini
112
platformio.ini
@@ -11,7 +11,7 @@
|
|||||||
;home_dir = C:\platformio
|
;home_dir = C:\platformio
|
||||||
src_dir = lighthub
|
src_dir = lighthub
|
||||||
;monitor_speed = 115200
|
;monitor_speed = 115200
|
||||||
env_default =
|
default_envs =
|
||||||
; ****** UNCOMMENT single environment name for target platform below *******
|
; ****** UNCOMMENT single environment name for target platform below *******
|
||||||
; Arduino Mega (without onewire) + Ethernet shield Wiznet 5100
|
; Arduino Mega (without onewire) + Ethernet shield Wiznet 5100
|
||||||
; mega2560slim-5100
|
; mega2560slim-5100
|
||||||
@@ -29,7 +29,7 @@ env_default =
|
|||||||
; due-5100
|
; due-5100
|
||||||
|
|
||||||
; Arduino DUE + Ethernet shield Wiznet 5500
|
; Arduino DUE + Ethernet shield Wiznet 5500
|
||||||
; due-5500
|
; due-5500
|
||||||
|
|
||||||
; ESP 8266
|
; ESP 8266
|
||||||
; esp8266-wifi
|
; esp8266-wifi
|
||||||
@@ -58,7 +58,7 @@ board = nrf52840_dk
|
|||||||
;upload_protocol = mbed
|
;upload_protocol = mbed
|
||||||
;upload_port = /dev/cu.SLAB_USBtoUART
|
;upload_port = /dev/cu.SLAB_USBtoUART
|
||||||
framework = arduino
|
framework = arduino
|
||||||
build_flags = !bash check_custom_build_flags_nrf52840.sh
|
build_flags = !python get_build_flags.py nrf52840-5500
|
||||||
lib_ignore =
|
lib_ignore =
|
||||||
ESP_EEPROM
|
ESP_EEPROM
|
||||||
DmxSimple
|
DmxSimple
|
||||||
@@ -86,6 +86,8 @@ lib_ignore =
|
|||||||
SparkFun CCS811 Arduino Library
|
SparkFun CCS811 Arduino Library
|
||||||
ESP8266HTTPClient
|
ESP8266HTTPClient
|
||||||
M5Stack
|
M5Stack
|
||||||
|
;ArduinoOTA
|
||||||
|
|
||||||
lib_deps =
|
lib_deps =
|
||||||
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
||||||
https://github.com/anklimov/DS2482_OneWire
|
https://github.com/anklimov/DS2482_OneWire
|
||||||
@@ -96,11 +98,13 @@ lib_deps =
|
|||||||
https://github.com/anklimov/ModbusMaster
|
https://github.com/anklimov/ModbusMaster
|
||||||
https://github.com/knolleary/pubsubclient.git
|
https://github.com/knolleary/pubsubclient.git
|
||||||
; https://github.com/anklimov/Artnet.git
|
; https://github.com/anklimov/Artnet.git
|
||||||
; FastLED
|
; FastLED@3.3.2
|
||||||
Adafruit Unified Sensor
|
Adafruit Unified Sensor
|
||||||
DHT sensor library
|
DHT sensor library
|
||||||
Streaming
|
Streaming
|
||||||
https://github.com/anklimov/NRFFlashStorage
|
https://github.com/anklimov/NRFFlashStorage
|
||||||
|
https://github.com/adafruit/Adafruit_NeoPixel.git
|
||||||
|
https://github.com/anklimov/ArduinoOTA
|
||||||
; https://github.com/livello/PrintEx#is-select-redecl
|
; https://github.com/livello/PrintEx#is-select-redecl
|
||||||
|
|
||||||
|
|
||||||
@@ -110,7 +114,7 @@ platform = espressif32
|
|||||||
board = m5stack-core-esp32
|
board = m5stack-core-esp32
|
||||||
framework = arduino
|
framework = arduino
|
||||||
upload_speed = 921600
|
upload_speed = 921600
|
||||||
build_flags = !bash check_custom_build_flags_esp32.sh
|
build_flags = !python get_build_flags.py m5stack
|
||||||
lib_ignore =
|
lib_ignore =
|
||||||
DmxSimple
|
DmxSimple
|
||||||
DMXSerial
|
DMXSerial
|
||||||
@@ -145,11 +149,13 @@ lib_deps =
|
|||||||
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
||||||
https://github.com/anklimov/DS2482_OneWire
|
https://github.com/anklimov/DS2482_OneWire
|
||||||
https://github.com/anklimov/ESP-Dmx
|
https://github.com/anklimov/ESP-Dmx
|
||||||
FastLED
|
FastLED@3.3.2
|
||||||
ClosedCube HDC1080
|
ClosedCube HDC1080
|
||||||
;SparkFun CCS811 Arduino Library
|
;SparkFun CCS811 Arduino Library
|
||||||
https://github.com/sparkfun/SparkFun_CCS811_Arduino_Library.git
|
SparkFun CCS811 Arduino Library@~1.0.7
|
||||||
M5Stack
|
M5Stack
|
||||||
|
Adafruit NeoPixel
|
||||||
|
https://github.com/anklimov/ArduinoOTA
|
||||||
|
|
||||||
[env:esp32-wifi]
|
[env:esp32-wifi]
|
||||||
platform = espressif32
|
platform = espressif32
|
||||||
@@ -157,7 +163,7 @@ framework = arduino
|
|||||||
;board = pico32
|
;board = pico32
|
||||||
board = esp32-evb
|
board = esp32-evb
|
||||||
upload_speed = 115200
|
upload_speed = 115200
|
||||||
build_flags = !bash check_custom_build_flags_esp32.sh
|
build_flags = !python get_build_flags.py esp32-wifi
|
||||||
lib_ignore =
|
lib_ignore =
|
||||||
DmxSimple
|
DmxSimple
|
||||||
DMXSerial
|
DMXSerial
|
||||||
@@ -193,15 +199,18 @@ lib_deps =
|
|||||||
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
||||||
https://github.com/anklimov/DS2482_OneWire
|
https://github.com/anklimov/DS2482_OneWire
|
||||||
https://github.com/anklimov/ESP-Dmx
|
https://github.com/anklimov/ESP-Dmx
|
||||||
FastLED
|
FastLED@3.3.2
|
||||||
ClosedCube HDC1080
|
ClosedCube HDC1080
|
||||||
;SparkFun CCS811 Arduino Library
|
;SparkFun CCS811 Arduino Library
|
||||||
https://github.com/sparkfun/SparkFun_CCS811_Arduino_Library.git
|
SparkFun CCS811 Arduino Library@~1.0.7
|
||||||
|
Adafruit NeoPixel
|
||||||
|
https://github.com/anklimov/ArduinoOTA
|
||||||
|
|
||||||
[env:due-5100]
|
[env:due-5100]
|
||||||
platform = atmelsam
|
platform = atmelsam
|
||||||
framework = arduino
|
framework = arduino
|
||||||
board = due
|
board = due
|
||||||
build_flags = !bash check_custom_build_flags_due.sh
|
build_flags = !python get_build_flags.py due-5100
|
||||||
lib_ignore =
|
lib_ignore =
|
||||||
DHT sensor library for ESPx
|
DHT sensor library for ESPx
|
||||||
ESP_EEPROM
|
ESP_EEPROM
|
||||||
@@ -217,6 +226,7 @@ lib_ignore =
|
|||||||
UIPEthernet
|
UIPEthernet
|
||||||
EEPROM
|
EEPROM
|
||||||
M5Stack
|
M5Stack
|
||||||
|
;ArduinoOTA
|
||||||
lib_deps =
|
lib_deps =
|
||||||
https://github.com/sebnil/DueFlashStorage
|
https://github.com/sebnil/DueFlashStorage
|
||||||
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
||||||
@@ -229,7 +239,7 @@ lib_deps =
|
|||||||
https://github.com/anklimov/Ethernet
|
https://github.com/anklimov/Ethernet
|
||||||
https://github.com/knolleary/pubsubclient.git
|
https://github.com/knolleary/pubsubclient.git
|
||||||
https://github.com/anklimov/Artnet.git
|
https://github.com/anklimov/Artnet.git
|
||||||
FastLED
|
FastLED@3.3.2
|
||||||
SD
|
SD
|
||||||
SdFat
|
SdFat
|
||||||
Adafruit Unified Sensor
|
Adafruit Unified Sensor
|
||||||
@@ -237,14 +247,16 @@ lib_deps =
|
|||||||
https://github.com/arcao/Syslog.git
|
https://github.com/arcao/Syslog.git
|
||||||
Streaming
|
Streaming
|
||||||
ClosedCube HDC1080
|
ClosedCube HDC1080
|
||||||
SparkFun CCS811 Arduino Library
|
SparkFun CCS811 Arduino Library@~1.0.7
|
||||||
|
Adafruit NeoPixel
|
||||||
|
https://github.com/anklimov/ArduinoOTA
|
||||||
|
|
||||||
[env:mega2560slim-5100]
|
[env:mega2560slim-5100]
|
||||||
platform = atmelavr
|
platform = atmelavr
|
||||||
board = megaatmega2560
|
board = megaatmega2560
|
||||||
;upload_port = net:192.168.88.31:23
|
;upload_port = net:192.168.88.31:23
|
||||||
framework = arduino
|
framework = arduino
|
||||||
build_flags = !bash check_custom_build_flags_mega2560-slim.sh
|
build_flags = !python get_build_flags.py mega2560slim-5100
|
||||||
lib_ignore =
|
lib_ignore =
|
||||||
DHT sensor library for ESPx
|
DHT sensor library for ESPx
|
||||||
DmxDue
|
DmxDue
|
||||||
@@ -269,25 +281,28 @@ lib_deps =
|
|||||||
https://github.com/anklimov/Ethernet
|
https://github.com/anklimov/Ethernet
|
||||||
https://github.com/knolleary/pubsubclient.git
|
https://github.com/knolleary/pubsubclient.git
|
||||||
https://github.com/anklimov/Artnet.git
|
https://github.com/anklimov/Artnet.git
|
||||||
FastLED
|
FastLED@3.3.2
|
||||||
;EEPROM
|
;EEPROM
|
||||||
Adafruit Unified Sensor
|
Adafruit Unified Sensor
|
||||||
DHT sensor library
|
DHT sensor library
|
||||||
https://github.com/arcao/Syslog.git
|
https://github.com/arcao/Syslog.git
|
||||||
Streaming
|
Streaming
|
||||||
ClosedCube HDC1080
|
ClosedCube HDC1080
|
||||||
SparkFun CCS811 Arduino Library
|
SparkFun CCS811 Arduino Library@~1.0.7
|
||||||
|
Adafruit NeoPixel
|
||||||
|
https://github.com/anklimov/ArduinoOTA
|
||||||
|
|
||||||
[env:mega2560-5500]
|
[env:mega2560-5500]
|
||||||
platform = atmelavr
|
platform = atmelavr
|
||||||
board = megaatmega2560
|
board = megaatmega2560
|
||||||
framework = arduino
|
framework = arduino
|
||||||
build_flags = !bash check_custom_build_flags_mega2560-5500.sh
|
build_flags = !python get_build_flags.py mega2560-5500
|
||||||
lib_ignore =
|
lib_ignore =
|
||||||
DHT sensor library for ESPx
|
DHT sensor library for ESPx
|
||||||
DmxDue
|
DmxDue
|
||||||
DueFlashStorage
|
DueFlashStorage
|
||||||
WifiManager
|
WifiManager
|
||||||
|
Ethernet
|
||||||
Ethernet3
|
Ethernet3
|
||||||
HTTPClient
|
HTTPClient
|
||||||
NRFFlashStorage
|
NRFFlashStorage
|
||||||
@@ -304,23 +319,33 @@ lib_deps =
|
|||||||
https://github.com/anklimov/CmdArduino
|
https://github.com/anklimov/CmdArduino
|
||||||
https://github.com/anklimov/ModbusMaster
|
https://github.com/anklimov/ModbusMaster
|
||||||
https://github.com/anklimov/DMXSerial
|
https://github.com/anklimov/DMXSerial
|
||||||
https://github.com/anklimov/Ethernet
|
https://github.com/anklimov/Ethernet2
|
||||||
https://github.com/knolleary/pubsubclient.git
|
https://github.com/knolleary/pubsubclient.git
|
||||||
https://github.com/anklimov/Artnet.git
|
https://github.com/anklimov/Artnet.git
|
||||||
FastLED
|
FastLED@3.3.2
|
||||||
Adafruit Unified Sensor
|
Adafruit Unified Sensor
|
||||||
DHT sensor library
|
DHT sensor library
|
||||||
https://github.com/arcao/Syslog.git
|
https://github.com/arcao/Syslog.git
|
||||||
Streaming
|
Streaming
|
||||||
ClosedCube HDC1080
|
ClosedCube HDC1080
|
||||||
SparkFun CCS811 Arduino Library
|
SparkFun CCS811 Arduino Library@~1.0.7
|
||||||
|
Adafruit NeoPixel
|
||||||
|
https://github.com/anklimov/ArduinoOTA
|
||||||
|
|
||||||
|
|
||||||
[env:esp8266-wifi]
|
[env:esp8266-wifi]
|
||||||
platform = espressif8266
|
platform = espressif8266
|
||||||
framework = arduino
|
framework = arduino
|
||||||
board = nodemcuv2
|
board = nodemcuv2
|
||||||
build_flags = !bash check_custom_build_flags_esp8266.sh
|
upload_protocol = esptool
|
||||||
|
|
||||||
|
;upload_protocol = espota
|
||||||
|
;upload_port = Lighthub.local
|
||||||
|
|
||||||
|
;upload_flags =
|
||||||
|
; --auth=password
|
||||||
|
; --port=65280
|
||||||
|
build_flags = !python get_build_flags.py esp8266-wifi
|
||||||
lib_ignore =
|
lib_ignore =
|
||||||
DmxSimple
|
DmxSimple
|
||||||
DMXSerial
|
DMXSerial
|
||||||
@@ -359,14 +384,18 @@ lib_deps =
|
|||||||
Streaming
|
Streaming
|
||||||
ESP_EEPROM
|
ESP_EEPROM
|
||||||
ClosedCube HDC1080
|
ClosedCube HDC1080
|
||||||
SparkFun CCS811 Arduino Library
|
SparkFun CCS811 Arduino Library@~1.0.7
|
||||||
|
Adafruit NeoPixel
|
||||||
|
https://github.com/anklimov/ArduinoOTA.git
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[env:mega2560-5100]
|
[env:mega2560-5100]
|
||||||
platform = atmelavr
|
platform = atmelavr
|
||||||
board = megaatmega2560
|
board = megaatmega2560
|
||||||
framework = arduino
|
framework = arduino
|
||||||
upload_port = net:192.168.88.2:23000
|
upload_port = net:192.168.88.2:23000
|
||||||
build_flags = !bash check_custom_build_flags_mega2560.sh
|
build_flags = !python get_build_flags.py mega2560-5100
|
||||||
lib_ignore =
|
lib_ignore =
|
||||||
DHT sensor library for ESPx
|
DHT sensor library for ESPx
|
||||||
DmxDue
|
DmxDue
|
||||||
@@ -393,19 +422,22 @@ lib_deps =
|
|||||||
https://github.com/anklimov/Ethernet
|
https://github.com/anklimov/Ethernet
|
||||||
https://github.com/knolleary/pubsubclient.git
|
https://github.com/knolleary/pubsubclient.git
|
||||||
https://github.com/anklimov/Artnet.git
|
https://github.com/anklimov/Artnet.git
|
||||||
FastLED
|
FastLED@3.3.2
|
||||||
Adafruit Unified Sensor
|
Adafruit Unified Sensor
|
||||||
DHT sensor library
|
DHT sensor library
|
||||||
https://github.com/arcao/Syslog.git
|
https://github.com/arcao/Syslog.git
|
||||||
Streaming
|
Streaming
|
||||||
ClosedCube HDC1080
|
ClosedCube HDC1080
|
||||||
SparkFun CCS811 Arduino Library
|
SparkFun CCS811 Arduino Library@~1.0.7
|
||||||
|
Adafruit NeoPixel
|
||||||
|
https://github.com/anklimov/ArduinoOTA
|
||||||
|
|
||||||
[env:due-5500]
|
[env:due-5500]
|
||||||
platform = atmelsam
|
platform = atmelsam
|
||||||
framework = arduino
|
framework = arduino
|
||||||
board = due
|
board = due
|
||||||
build_flags = !bash check_custom_build_flags_due-5500.sh
|
;build_flags = !bash check_custom_build_flags_due-5500.sh
|
||||||
|
build_flags = !python get_build_flags.py due-5500
|
||||||
lib_ignore =
|
lib_ignore =
|
||||||
DHT sensor library for ESPx
|
DHT sensor library for ESPx
|
||||||
ESPDMX
|
ESPDMX
|
||||||
@@ -422,6 +454,7 @@ lib_ignore =
|
|||||||
ESP_EEPROM
|
ESP_EEPROM
|
||||||
EEPROM
|
EEPROM
|
||||||
M5Stack
|
M5Stack
|
||||||
|
;ArduinoOTA
|
||||||
lib_deps =
|
lib_deps =
|
||||||
https://github.com/sebnil/DueFlashStorage
|
https://github.com/sebnil/DueFlashStorage
|
||||||
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
||||||
@@ -434,7 +467,7 @@ lib_deps =
|
|||||||
https://github.com/anklimov/Ethernet2
|
https://github.com/anklimov/Ethernet2
|
||||||
https://github.com/knolleary/pubsubclient.git
|
https://github.com/knolleary/pubsubclient.git
|
||||||
https://github.com/anklimov/Artnet.git
|
https://github.com/anklimov/Artnet.git
|
||||||
FastLED
|
FastLED@3.3.2
|
||||||
SD
|
SD
|
||||||
SdFat
|
SdFat
|
||||||
Adafruit Unified Sensor
|
Adafruit Unified Sensor
|
||||||
@@ -443,13 +476,15 @@ lib_deps =
|
|||||||
Streaming
|
Streaming
|
||||||
https://github.com/livello/PrintEx#is-select-redecl
|
https://github.com/livello/PrintEx#is-select-redecl
|
||||||
ClosedCube HDC1080
|
ClosedCube HDC1080
|
||||||
SparkFun CCS811 Arduino Library
|
SparkFun CCS811 Arduino Library@~1.0.7
|
||||||
|
Adafruit NeoPixel
|
||||||
|
https://github.com/anklimov/ArduinoOTA
|
||||||
|
|
||||||
[env:lighthub21]
|
[env:lighthub21]
|
||||||
platform = atmelsam
|
platform = atmelsam
|
||||||
framework = arduino
|
framework = arduino
|
||||||
board = due
|
board = due
|
||||||
build_flags = !bash check_custom_build_flags_lighthub21.sh
|
build_flags = !python get_build_flags.py lighthub21
|
||||||
lib_ignore =
|
lib_ignore =
|
||||||
DHT sensor library for ESPx
|
DHT sensor library for ESPx
|
||||||
ESPDMX
|
ESPDMX
|
||||||
@@ -466,6 +501,7 @@ lib_ignore =
|
|||||||
ESP_EEPROM
|
ESP_EEPROM
|
||||||
EEPROM
|
EEPROM
|
||||||
M5Stack
|
M5Stack
|
||||||
|
;ArduinoOTA
|
||||||
lib_deps =
|
lib_deps =
|
||||||
https://github.com/sebnil/DueFlashStorage
|
https://github.com/sebnil/DueFlashStorage
|
||||||
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
||||||
@@ -478,7 +514,7 @@ lib_deps =
|
|||||||
https://github.com/anklimov/Ethernet2
|
https://github.com/anklimov/Ethernet2
|
||||||
https://github.com/knolleary/pubsubclient.git
|
https://github.com/knolleary/pubsubclient.git
|
||||||
https://github.com/anklimov/Artnet.git
|
https://github.com/anklimov/Artnet.git
|
||||||
FastLED
|
FastLED@3.3.2
|
||||||
SD
|
SD
|
||||||
SdFat
|
SdFat
|
||||||
Adafruit Unified Sensor
|
Adafruit Unified Sensor
|
||||||
@@ -487,14 +523,16 @@ lib_deps =
|
|||||||
Streaming
|
Streaming
|
||||||
https://github.com/livello/PrintEx#is-select-redecl
|
https://github.com/livello/PrintEx#is-select-redecl
|
||||||
ClosedCube HDC1080
|
ClosedCube HDC1080
|
||||||
SparkFun CCS811 Arduino Library
|
SparkFun CCS811 Arduino Library@~1.0.7
|
||||||
|
Adafruit NeoPixel
|
||||||
|
https://github.com/anklimov/ArduinoOTA
|
||||||
|
|
||||||
|
|
||||||
[env:controllino]
|
[env:controllino]
|
||||||
platform = atmelavr
|
platform = atmelavr
|
||||||
board = megaatmega2560
|
board = megaatmega2560
|
||||||
framework = arduino
|
framework = arduino
|
||||||
build_flags = !bash check_custom_build_flags_controllino.sh
|
build_flags = !python get_build_flags.py controllino
|
||||||
lib_ignore =
|
lib_ignore =
|
||||||
DHT sensor library for ESPx
|
DHT sensor library for ESPx
|
||||||
DmxDue
|
DmxDue
|
||||||
@@ -521,14 +559,16 @@ lib_deps =
|
|||||||
https://github.com/anklimov/Ethernet
|
https://github.com/anklimov/Ethernet
|
||||||
https://github.com/knolleary/pubsubclient.git
|
https://github.com/knolleary/pubsubclient.git
|
||||||
https://github.com/anklimov/Artnet.git
|
https://github.com/anklimov/Artnet.git
|
||||||
FastLED
|
FastLED@3.3.2
|
||||||
;EEPROM
|
;EEPROM
|
||||||
Adafruit Unified Sensor
|
Adafruit Unified Sensor
|
||||||
DHT sensor library
|
DHT sensor library
|
||||||
Streaming
|
Streaming
|
||||||
https://github.com/livello/PrintEx#is-select-redecl
|
https://github.com/livello/PrintEx#is-select-redecl
|
||||||
ClosedCube HDC1080
|
ClosedCube HDC1080
|
||||||
SparkFun CCS811 Arduino Library
|
SparkFun CCS811 Arduino Library@~1.0.7
|
||||||
|
Adafruit NeoPixel
|
||||||
|
https://github.com/anklimov/ArduinoOTA
|
||||||
|
|
||||||
[env:stm32-enc2860]
|
[env:stm32-enc2860]
|
||||||
platform = ststm32
|
platform = ststm32
|
||||||
@@ -536,7 +576,7 @@ framework = arduino
|
|||||||
board = nucleo_f103rb
|
board = nucleo_f103rb
|
||||||
upload_protocol = stlink
|
upload_protocol = stlink
|
||||||
debug_tool = stlink
|
debug_tool = stlink
|
||||||
build_flags = !bash check_custom_build_flags_stm32.sh
|
build_flags = !python get_build_flags.py stm32-enc2860
|
||||||
lib_ignore =
|
lib_ignore =
|
||||||
DHT sensor library for ESPx
|
DHT sensor library for ESPx
|
||||||
DmxDue
|
DmxDue
|
||||||
@@ -566,6 +606,7 @@ lib_ignore =
|
|||||||
ClosedCube HDC1080
|
ClosedCube HDC1080
|
||||||
SparkFun CCS811 Arduino Library
|
SparkFun CCS811 Arduino Library
|
||||||
M5Stack
|
M5Stack
|
||||||
|
ArduinoOTA
|
||||||
lib_deps =
|
lib_deps =
|
||||||
https://github.com/anklimov/aJson
|
https://github.com/anklimov/aJson
|
||||||
https://github.com/anklimov/CmdArduino
|
https://github.com/anklimov/CmdArduino
|
||||||
@@ -574,3 +615,4 @@ lib_deps =
|
|||||||
Streaming
|
Streaming
|
||||||
UIPEthernet
|
UIPEthernet
|
||||||
https://github.com/anklimov/NRFFlashStorage
|
https://github.com/anklimov/NRFFlashStorage
|
||||||
|
Adafruit NeoPixel
|
||||||
|
|||||||
7663
spare_files/flows (4).json
Normal file
7663
spare_files/flows (4).json
Normal file
File diff suppressed because it is too large
Load Diff
0
mosquitto_examples.sh → spare_files/mosquitto_examples.sh
Normal file → Executable file
0
mosquitto_examples.sh → spare_files/mosquitto_examples.sh
Normal file → Executable file
Reference in New Issue
Block a user