mirror of
https://github.com/anklimov/lighthub
synced 2025-12-06 11:49:51 +03:00
Merge pull request #37 from anklimov/develop
Release candidate for V2.0
This commit is contained in:
7
.gitignore
vendored
7
.gitignore
vendored
@@ -3,3 +3,10 @@
|
||||
.clang_complete
|
||||
.gcc-flags.json
|
||||
CMakeListsPrivate.txt
|
||||
build_flags_due.sh
|
||||
build_flags_esp32.sh
|
||||
build_flags_esp8266.sh
|
||||
build_flags_stm32.sh
|
||||
build_flags_due-5500.sh
|
||||
build_flags_mega2560.sh
|
||||
build_flags_controllino.sh
|
||||
8
.idea/markdown-exported-files.xml
generated
Normal file
8
.idea/markdown-exported-files.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="MarkdownExportedFiles">
|
||||
<htmlFiles />
|
||||
<imageFiles />
|
||||
<otherFiles />
|
||||
</component>
|
||||
</project>
|
||||
BIN
.vscode/.browse.c_cpp.db
vendored
Normal file
BIN
.vscode/.browse.c_cpp.db
vendored
Normal file
Binary file not shown.
4
.vscode/arduino.json
vendored
Normal file
4
.vscode/arduino.json
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"board": "arduino:sam:arduino_due_x",
|
||||
"port": "/dev/cu.usbmodem1411"
|
||||
}
|
||||
108
.vscode/c_cpp_properties.json
vendored
Normal file
108
.vscode/c_cpp_properties.json
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
{
|
||||
"!!! 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
Normal file
7
.vscode/extensions.json
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
||||
// for the documentation about the extensions.json format
|
||||
"recommendations": [
|
||||
"platformio.platformio-ide"
|
||||
]
|
||||
}
|
||||
34
.vscode/launch.json
vendored
Normal file
34
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
// 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
Normal file
6
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
}
|
||||
136
README.md
136
README.md
@@ -7,6 +7,7 @@ It may operate both:
|
||||
|
||||
Lighthub allows connecting together:
|
||||
* Contact sensors (switches, buttons etc)
|
||||
* Analog sensors (Leak detectors, Knobs etc)
|
||||
* 1-Wire temperature sensors (up to 20 on single bus)
|
||||
* Standard nonexpensive Relay board with TTL inputs, [like this](http://ali.pub/2zlosh) to control AC powered lamps, floor heaters, boilers etc
|
||||
* [Standard nonexpensive LED dimmers](http://ali.pub/2zlokp) and [AC DMX-512 dimmers](http://ali.pub/2zlont)
|
||||
@@ -14,14 +15,18 @@ Lighthub allows connecting together:
|
||||
* Simple DMX wall sensor panel [like this](http://ali.pub/2zlohe)
|
||||
|
||||
[List of non-expensive compatible components from AliExpress here](http://ppv.alipromo.com/custom/promo.php?hash=pjagwaovaero6vkeabjpkpvy4gznbgkc&landing_id=39661)
|
||||
|
||||

|
||||
|
||||
Where is possible both, to configure local control/mapping between inputs and outputs (light, floor heating thermostats) and remote control from MQTT enabled software. At the moment, LightHub tested with following set of complementary free software:
|
||||
|
||||

|
||||
|
||||
Where is possible both, to configure local control/mapping between inputs and outputs (light, floor heating thermostats) and remote control from MQTT enabled software. At the moment, LightHub tested and perfectly working with following set of complementary free software:
|
||||
* [Openhab or Openhab2 Smarthome software](http://www.openhab.org/)
|
||||
Openhab provides own native mobile app both, for IoS and Android, and even allow you to use Apple's HomeKit to say "Siri, turn on light in bedroom" but requires some server to be installed (Raspberry PI with [Openhabian](https://docs.openhab.org/installation/openhabian) will good enough)
|
||||
Openhab provides own native mobile app both, for IoS and Android, and even allow you to use Apple's HomeKit and Google Home to say "Siri, turn on light in bedroom" or "Hey Google, set bedroom light to Red" but requires some server to be installed in-premises (Raspberry PI with [Openhabian](https://docs.openhab.org/installation/openhabian) will good enough)
|
||||
* [HomeRemote mobile client](http://thehomeremote.com/)
|
||||
Home Remote mobile applicatios for IoS and Android requires just MQTT broker to be working. Any Cloud-based MQTT broker, like [CloudMQTT](https://www.cloudmqtt.com/) will enough to serve average household, even with free account.
|
||||
* [Node-Red](https://nodered.org/) Possibly, the best solution to deploy event-based authomation and scripting on top of MQTT/LightHub. The easy to use universal and visual tool to wire many different devices in single system. Having own Dashbord which allow control from web/mobile web, even without mobile apps (but excelent co-working with OpenHab and HomeRemote)
|
||||
Home Remote mobile applicatios for IoS and Android requires just MQTT broker to be working. Any Cloud-based MQTT broker, like [CloudMQTT](https://www.cloudmqtt.com/) will enough to serve average household, even with free account.
|
||||
* [Node-Red](https://nodered.org/) Possibly, the best solution to deploy event-based authomation and scripting on top of MQTT/LightHub. The easy to use universal and visual tool to wire many different devices in single system. Having own Dashbord which allow control from web/mobile web, even without mobile apps (excelent co-working with OpenHab and HomeRemote)
|
||||
|
||||
Scalability of Lighthub is virtually unlimited: Setup so many controllers you needed in most convenient places of your house - MQTT broker will allow controllers communicate each other and with Openhab/NodeRed/HomeRemote and propagate commands across network.
|
||||
|
||||
@@ -31,105 +36,27 @@ Scalability of Lighthub is virtually unlimited: Setup so many controllers you ne
|
||||
* [Channel commands](https://github.com/anklimov/lighthub/wiki/Channel-commands)
|
||||
* [OpenHab integration](https://github.com/anklimov/lighthub/wiki/OpenHab--integration)
|
||||
|
||||
Finished portation of project to Arduino DUE and ESP8266 (ESP32 not tested).
|
||||
|
||||
Compiled image has been added to [compiled/](https://github.com/anklimov/lighthub/tree/master/compiled) folder. Flash your Mega 2560
|
||||
|
||||
```bash
|
||||
avrdude -v -V -patmega2560 -cwiring -b115200 -D -Uflash:w:firmware.hex:i
|
||||
```
|
||||
|
||||
or flash your DUE (need to correct path and port, of course)
|
||||
```bash
|
||||
/Users/<user>/Library/Arduino15/packages/arduino/tools/bossac/1.6.1-arduino/bossac -i -d --port=cu.usbmodem1451 -U false -e -w -v -b firmware.bin -R
|
||||
```
|
||||
Note: binary images usually not up-to-date with recent code. The preferred way, to compile and upload firmware to your controller.
|
||||
|
||||
# Dependencies
|
||||
(quite big number of libs required. Use git clone to have your local copy in your Arduino libs folder)
|
||||
Please check updates for all dependences.
|
||||
|
||||
For patched libraries, appropriate GitHub repo URL provided:
|
||||
|
||||
* Arduino-Temperature-Control-Library https://github.com/anklimov/Arduino-Temperature-Control-Library
|
||||
* DS2482_OneWire https://github.com/anklimov/DS2482_OneWire
|
||||
* FastLED
|
||||
* Wire (standard)
|
||||
* Artnet https://github.com/anklimov/Artnet.git
|
||||
* DmxSimple https://github.com/anklimov/DmxSimple (for AVR) or https://github.com/anklimov/ESP-Dmx (for ESP) or https://github.com/anklimov/DmxDue (for DUE)
|
||||
* HTTPClient (for AVR) https://github.com/anklimov/HTTPClient or https://github.com/arduino-libraries/ArduinoHttpClient for other platforms
|
||||
* aJson https://github.com/anklimov/aJson
|
||||
* CmdArduino https://github.com/anklimov/CmdArduino
|
||||
* EEPROM (standard for AVR) or DueFlashStorage for DUE: https://github.com/sebnil/DueFlashStorage
|
||||
* ModbusMaster https://github.com/anklimov/ModbusMaster
|
||||
* pubsubclient-2.6
|
||||
* DMXSerial-master (for AVR) https://github.com/anklimov/DMXSerial
|
||||
* Ethernet https://github.com/anklimov/Ethernet
|
||||
* SPI (standard)
|
||||
|
||||
Portation from AVR Mega 2560 to SAM3X8E (Arduino DUE) done since v 0.96 and tested against Wiznet 5100 Ethernet shield and Wiznet 5500 Ethernet module
|
||||
|
||||
# Platforms specific details:
|
||||
|
||||
AVR version is basic, long tome in production and have all functions
|
||||
*DMX-out is software (DMXSimple) on pin3
|
||||
**AVR** version (Arduino Mega) is basic, long time in production and have all functions
|
||||
* DMX-out is software (DMXSimple) on pin3, can be re-defined to PIN 18 (USART1 TX)
|
||||
* DMX-in - hardware
|
||||
* WIZNET 5100 and 5500 Ethernets are supported
|
||||
* Modbus on USART2
|
||||
|
||||
**SAM3X8E**: (Tested. Recomended hardware at current moment)
|
||||
* default PWM frequency
|
||||
**SAM3X8E** (Arduino DUE): (Tested. In production. Recomended hardware at current moment)
|
||||
* default PWM out frequency
|
||||
* both, DMX-in and DMX-out are hardware USART based. Use USART1 (pins 18 and 19) for DMX-out and DMX-in
|
||||
* WIZNET 5100 and 5500 Ethernets are supported
|
||||
* Modbus on USART2
|
||||
|
||||
**ESP8266**: (Developed but not tested in production)
|
||||
**ESP8266**: (Developed, working, but not tested in production)
|
||||
* DMX-OUT on USART1 TX
|
||||
* DMX-IN - not possible to deploy in ESP8266
|
||||
* DMX-IN - disabled - not possible to deploy in ESP8266
|
||||
* Modbus - disabled. Might be configured in future on USART0 instead CLI/DEBUG
|
||||
|
||||
since v. 0.97:
|
||||
Mega and DUE:
|
||||
Need to use compiler directive -D Wiz5500 and https://github.com/anklimov/Ethernet2 library to compile with Wiznet 5500 instead 5100
|
||||
|
||||
Prefered way to compile project is using platformio toolchain, suitable for Arduino Due, and Arduino Mega2560
|
||||
|
||||
# Due compilation issue "USART0_Handler redefinition"
|
||||
Please, open /variants/arduino_due_x/variant.cpp file, then add USART0_Handler method definition like this
|
||||
void USART0_Handler(void) __attribute__((weak));
|
||||
|
||||
The normal path to find this file in platformio is:
|
||||
.platformio/packages/framework-arduinosam/variants/arduino_due_x
|
||||
|
||||
# Platformio command line build instructions
|
||||
[First of all install platformio framework.]( http://docs.platformio.org/en/latest/installation.html) [Good tutorial for fast start in RUSSIAN.](https://geektimes.ru/post/273852/)
|
||||
|
||||
In linux\OSX you can open terminal, navigate to your programming directory, then
|
||||
|
||||
```bash
|
||||
git clone https://github.com/anklimov/lighthub.git
|
||||
cd lighthub
|
||||
```
|
||||
now prepare project files for your IDE
|
||||
```bash
|
||||
pio init --ide [atom|clion|codeblocks|eclipse|emacs|netbeans|qtcreator|sublimetext|vim|visualstudio|vscode]
|
||||
```
|
||||
Set custom build flags. first make your own copy of template
|
||||
```bash
|
||||
cp build_flags_template.sh my_build_flags.sh
|
||||
```
|
||||
then edit, change or comment unnecessary sections and source it
|
||||
```bash
|
||||
nano my_build_flags.sh
|
||||
source my_build_flags.sh
|
||||
```
|
||||
build and upload firmware for due|megaatmega2560|esp8266 board
|
||||
```bash
|
||||
pio run -e due|megaatmega2560|esp8266 -t upload
|
||||
```
|
||||
Clean pio libraries folder. Try it if you have compilation problem:
|
||||
```bash
|
||||
rm -Rf .piolibdeps
|
||||
```
|
||||
open COM-port monitor with specified baud rate
|
||||
```bash
|
||||
platformio device monitor -b 115200
|
||||
```
|
||||
**ESP32**, **NRF52840** : Still early development stage
|
||||
|
||||
# Custom build flags
|
||||
|
||||
@@ -145,7 +72,18 @@ platformio device monitor -b 115200
|
||||
* MODBUS_DISABLE // disable Modbus support
|
||||
* OWIRE_DISABLE // disable OneWire support
|
||||
* ARTNET_ENABLE //Enable Artnet protocol support
|
||||
* AVR_DMXOUT_PIN=18 // Set Pin for DMXOUT on megaatmega2560
|
||||
* CONTROLLINO //Change Modbus port, direction pins and Wiznet SS pins to be working on [Controllino](http://controllino.biz/)
|
||||
* LAN_INIT_DELAY=2000 // set lan init delay for Wiznet ethernet shield
|
||||
* ESP_WIFI_AP=MYAP // esp wifi access point name
|
||||
* ESP_WIFI_PWD=MYPWD // esp wifi access point password
|
||||
* WIFI_MANAGER_DISABLE //Disable wifi manager for esp8266
|
||||
* DHT_COUNTER_DISABLE //disable DHT, Counter, Uptime input support (for RAM savings on mega2560)
|
||||
* RESTART_LAN_ON_MQTT_ERRORS //reinit LAN if many mqtt errors occured
|
||||
* DEVICE_NAME short handy device name which is used instead of mac for download config http://{MY_CONFIG_SERVER}/{DEVICE_NAME}_config.json
|
||||
* SYSLOG_ENABLE enable UDP SYSLOG support feature(under DEVELOPMENT) that must be configured through config file
|
||||
* WITH_PRINTEX_LIB use PrintEx library (develop experimental feature)
|
||||
|
||||
|
||||
|
||||
# Default compilation behavior:
|
||||
@@ -156,13 +94,19 @@ platformio device monitor -b 115200
|
||||
* Serial speed 115200
|
||||
* Wiznet 5100 (for MEGA & DUE)
|
||||
* Free Ram printing enabled
|
||||
* de:ad:be:ef:fe:00
|
||||
* de:ad:be:ef:fe:ff default MAC address
|
||||
* DMX support enabled
|
||||
* Modbus support enabled
|
||||
* OneWire support enabled
|
||||
* Artnet disabled
|
||||
* LAN_INIT_DELAY=500 //ms
|
||||
* Defailt MQTT input topic: /myhome/in
|
||||
* Default MQTT topic to publish device status: /myhome/s_out
|
||||
* Default Alarm output topic /alarm
|
||||
* DHT, Counter, Uptime support enabled
|
||||
* Wifi manager for esp8266 enabled
|
||||
* RESTART_LAN_ON_MQTT_ERRORS disabled
|
||||
* DEVICE_NAME disabled
|
||||
* SYSLOG_ENABLE disabled
|
||||
* WITH_PRINTEX_LIB diabled, using Streaming library
|
||||
|
||||
If you've using Arduino IDE to compile & flash firmware, it will use Default options above and you will not able to configure additional compilers options except edit "options.h" file
|
||||
|
||||
30
build_flags_mega2560-net.sh
Normal file
30
build_flags_mega2560-net.sh
Normal file
@@ -0,0 +1,30 @@
|
||||
#! /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,21 +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="-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:00"
|
||||
export FLAGS="$FLAGS -DDMX_DISABLE"
|
||||
export FLAGS="$FLAGS -DMODBUS_DISABLE"
|
||||
export FLAGS="$FLAGS -DOWIRE_DISABLE"
|
||||
export PLATFORMIO_BUILD_FLAGS="$FLAGS"
|
||||
unset FLAGS
|
||||
9
check_custom_build_flags_controllino.sh
Executable file
9
check_custom_build_flags_controllino.sh
Executable file
@@ -0,0 +1,9 @@
|
||||
#! /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
|
||||
9
check_custom_build_flags_due-5500.sh
Executable file
9
check_custom_build_flags_due-5500.sh
Executable file
@@ -0,0 +1,9 @@
|
||||
#! /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
|
||||
7
check_custom_build_flags_due.sh
Executable file
7
check_custom_build_flags_due.sh
Executable file
@@ -0,0 +1,7 @@
|
||||
#! /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
|
||||
13
check_custom_build_flags_esp32.sh
Executable file
13
check_custom_build_flags_esp32.sh
Executable file
@@ -0,0 +1,13 @@
|
||||
#! /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 -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
|
||||
9
check_custom_build_flags_esp8266.sh
Executable file
9
check_custom_build_flags_esp8266.sh
Executable file
@@ -0,0 +1,9 @@
|
||||
#! /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
|
||||
7
check_custom_build_flags_mega2560-net.sh
Executable file
7
check_custom_build_flags_mega2560-net.sh
Executable file
@@ -0,0 +1,7 @@
|
||||
#! /bin/bash
|
||||
CUSTOM_BUILD_FLAGS_FILE=custom-build-flags/build_flags_mega2560-net.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
|
||||
8
check_custom_build_flags_mega2560.sh
Executable file
8
check_custom_build_flags_mega2560.sh
Executable file
@@ -0,0 +1,8 @@
|
||||
#! /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)
|
||||
#TODO: make one file for all envs
|
||||
if [ -f $CUSTOM_BUILD_FLAGS_FILE ]; then
|
||||
source $CUSTOM_BUILD_FLAGS_FILE
|
||||
fi
|
||||
echo $FLAGS
|
||||
15
check_custom_build_flags_nrf52840.sh
Executable file
15
check_custom_build_flags_nrf52840.sh
Executable file
@@ -0,0 +1,15 @@
|
||||
#! /bin/bash
|
||||
export FLAGS="$FLAGS -DWiz5500"
|
||||
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"
|
||||
|
||||
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
|
||||
12
check_custom_build_flags_stm32.sh
Executable file
12
check_custom_build_flags_stm32.sh
Executable file
@@ -0,0 +1,12 @@
|
||||
#! /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"
|
||||
if [ -f $CUSTOM_BUILD_FLAGS_FILE ]; then
|
||||
source $CUSTOM_BUILD_FLAGS_FILE
|
||||
fi
|
||||
echo $FLAGS
|
||||
Binary file not shown.
3
compiled/DUE/upload.bat
Normal file
3
compiled/DUE/upload.bat
Normal file
@@ -0,0 +1,3 @@
|
||||
mode com3:1200,n,8,1
|
||||
pause
|
||||
C:\Users\Akmal\.platformio\packages\tool-bossac\bossac.exe -i --port=com3 -U false -e -w -v -b C:\Users\Akmal\ownCloud\compiled\due\Wiz5500\firmware.bin -R
|
||||
3
compiled/DUE/upload999.bat
Normal file
3
compiled/DUE/upload999.bat
Normal file
@@ -0,0 +1,3 @@
|
||||
mode com3:1200,n,8,1
|
||||
pause
|
||||
C:\Users\Akmal\.platformio\packages\tool-bossac\bossac.exe -i --port=com3 -U false -e -w -v -b C:\Users\Akmal\ownCloud\compiled\due\Wiz5500\firmware999.bin -R
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
1
compiled/mon.bat
Normal file
1
compiled/mon.bat
Normal file
@@ -0,0 +1 @@
|
||||
pio device monitor -b 115200
|
||||
30
config-examples/c4-3e-11-03-1b-1e.config.json
Normal file
30
config-examples/c4-3e-11-03-1b-1e.config.json
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"mqtt":["garden","192.168.10.114",1883,"test","test"],
|
||||
"ow":{
|
||||
"28FFADCE601705A3":{"emit":"t_soil1","item":"h_relay6"},
|
||||
"286164123FF96F55":{"emit":"t_soil2"},
|
||||
"28FFEF6D60170335":{"emit":"t_soil3"}
|
||||
},
|
||||
"items":{
|
||||
"h_relay1":[6,39,1,1],
|
||||
"h_relay2":[6,38,1,1],
|
||||
"h_relay3":[6,37,1,1],
|
||||
"h_relay4":[6,36,1,1],
|
||||
"h_relay5":[6,35,1,1],
|
||||
"h_relay6":[5,34,27,1],
|
||||
"h_relay7":[6,33,1,1],
|
||||
"h_relay8":[6,32,1,1],
|
||||
"h_auto":[6,29,1,1]
|
||||
},
|
||||
"in":{
|
||||
"5": {"T":4,"emit": "/myhome/s_out/t_dht1"},
|
||||
"40":{"emit":"/myhome/s_out/g_in1","scmd":"CLOSED","rcmd":"OPEN"},
|
||||
"41":{"emit":"/myhome/s_out/g_in2","scmd":"CLOSED","rcmd":"OPEN"},
|
||||
"42":{"emit":"/myhome/s_out/g_in3","scmd":"CLOSED","rcmd":"OPEN"},
|
||||
"43":{"emit":"/myhome/s_out/g_in4","scmd":"CLOSED","rcmd":"OPEN"},
|
||||
"44":{"emit":"/myhome/s_out/g_in5","scmd":"CLOSED","rcmd":"OPEN"},
|
||||
"45":{"emit":"/myhome/s_out/g_in6","scmd":"CLOSED","rcmd":"OPEN"},
|
||||
"46":{"emit":"/myhome/s_out/g_in7","scmd":"CLOSED","rcmd":"OPEN"},
|
||||
"47":{"emit":"/myhome/s_out/g_in8","scmd":"CLOSED","rcmd":"OPEN"}
|
||||
}
|
||||
}
|
||||
9
config-examples/c4-3e-1f-03-1b-1b.config.json
Executable file
9
config-examples/c4-3e-1f-03-1b-1b.config.json
Executable file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"mqtt": ["test_esp","192.168.10.1",1883,"test","test"],
|
||||
"items":{
|
||||
"h_speed0": [6,9],
|
||||
"h_speed1": [6,10]},
|
||||
"in": {
|
||||
"5": {"T":4,"emit": "/myhome/s_out/t_vent_street"}
|
||||
}
|
||||
}
|
||||
31
custom-build-flags/build_flags_controllino.sh
Executable file
31
custom-build-flags/build_flags_controllino.sh
Executable file
@@ -0,0 +1,31 @@
|
||||
#! /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 -DDHT_COUNTER_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)
|
||||
30
custom-build-flags/build_flags_mega2560-net.sh
Normal file
30
custom-build-flags/build_flags_mega2560-net.sh
Normal file
@@ -0,0 +1,30 @@
|
||||
#! /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: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
|
||||
31
custom-build-flags/build_flags_nrf52840.sh
Normal file
31
custom-build-flags/build_flags_nrf52840.sh
Normal file
@@ -0,0 +1,31 @@
|
||||
#! /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 -DSYSLOG_DISABLE"
|
||||
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
|
||||
32
custom-build-flags/build_flags_template.sh
Executable file
32
custom-build-flags/build_flags_template.sh
Executable file
@@ -0,0 +1,32 @@
|
||||
#! /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_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
|
||||
|
Before Width: | Height: | Size: 178 KiB After Width: | Height: | Size: 178 KiB |
@@ -23,14 +23,16 @@ e-mail anklimov@gmail.com
|
||||
#include "options.h"
|
||||
|
||||
#ifdef _dmxin
|
||||
#if defined(__AVR__)
|
||||
#if defined(ARDUINO_ARCH_AVR)
|
||||
#include <DMXSerial.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__ESP__)
|
||||
#if defined(ESP8266)
|
||||
#ifndef DMX_DISABLE
|
||||
DMXESPSerial dmxout;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
uint8_t * DMXin = NULL;
|
||||
int D_State=0;
|
||||
@@ -137,7 +139,7 @@ for (short tch=0; tch<=3 ; tch++)
|
||||
{
|
||||
D_State |= (1<<tch);
|
||||
updated=1;
|
||||
//Serial.print("Changed :"); Serial.print(DMXin[tch*4+trh]); Serial.print(" => "); Serial.print(t);Serial.println();
|
||||
//Serial.print("onContactChanged :"); Serial.print(DMXin[tch*4+trh]); Serial.print(" => "); Serial.print(t);Serial.println();
|
||||
DMXin[base+trh]=t;
|
||||
//DMXImmediateUpdate(tch,trh,t);
|
||||
//break;
|
||||
@@ -205,7 +207,7 @@ void DMXinSetup(int channels)
|
||||
|
||||
#if defined(_dmxin)
|
||||
DMXin = new uint8_t [channels];
|
||||
#if defined(__AVR__)
|
||||
#if defined(ARDUINO_ARCH_AVR)
|
||||
DMXSerial.init(DMXReceiver,0,channels);
|
||||
if (DMXSerial.getBuffer()) {Serial.print(F("Init in ch:"));Serial.println(channels);} else Serial.println(F("DMXin Buffer alloc err"));
|
||||
//DMXSerial.maxChannel(channels);
|
||||
@@ -228,13 +230,13 @@ dmxin.begin();
|
||||
void DMXoutSetup(int channels)
|
||||
{
|
||||
#ifdef _dmxout
|
||||
#if defined(__AVR__)
|
||||
#if defined(ARDUINO_ARCH_AVR)
|
||||
DmxSimple.usePin(AVR_DMXOUT_PIN);
|
||||
DmxSimple.maxChannel(channels);
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(__ESP__)
|
||||
#if defined(ESP8266)
|
||||
dmxout.init(channels);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@ GIT: https://github.com/anklimov/lighthub
|
||||
e-mail anklimov@gmail.com
|
||||
|
||||
*/
|
||||
|
||||
#define D_UPDATED1 1
|
||||
#define D_UPDATED2 2
|
||||
#define D_UPDATED3 4
|
||||
@@ -33,12 +32,12 @@ e-mail anklimov@gmail.com
|
||||
|
||||
#if defined(_dmxout)
|
||||
|
||||
#if defined(__AVR__)
|
||||
#if defined(ARDUINO_ARCH_AVR)
|
||||
#include <DmxSimple.h>
|
||||
#define DmxWrite DmxSimple.write
|
||||
#endif
|
||||
|
||||
#if defined(__ESP__)
|
||||
#if defined(ESP8266)
|
||||
#include <ESPDMX.h>
|
||||
extern DMXESPSerial dmxout;
|
||||
#define DmxWrite dmxout.write
|
||||
@@ -56,7 +55,7 @@ extern Artnet *artnet;
|
||||
#endif
|
||||
|
||||
#ifdef _dmxin
|
||||
#if defined(__AVR__)
|
||||
#if defined(ARDUINO_ARCH_AVR)
|
||||
#include <DMXSerial.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
#include "options.h"
|
||||
#ifdef __ESP__
|
||||
#include "esp.h"
|
||||
|
||||
ESP8266WiFiMulti wifiMulti;
|
||||
WiFiClient ethClient;
|
||||
|
||||
char mqtt_password[16];
|
||||
|
||||
//default custom static IP
|
||||
//char static_ip[16] = "10.0.1.56";
|
||||
//char static_gw[16] = "10.0.1.1";
|
||||
//char static_sn[16] = "255.255.255.0";
|
||||
|
||||
//flag for saving data
|
||||
bool shouldSaveConfig = false;
|
||||
|
||||
//callback notifying us of the need to save config
|
||||
void saveConfigCallback () {
|
||||
Serial.println(F("Should save config"));
|
||||
shouldSaveConfig = true;
|
||||
}
|
||||
|
||||
|
||||
void espSetup () {
|
||||
Serial.println(F("Setting up Wifi"));
|
||||
shouldSaveConfig = true;
|
||||
//WiFiManager
|
||||
|
||||
WiFiManagerParameter custom_mqtt_password("", "mqtt password", mqtt_password, 16);
|
||||
//Local intialization. Once its business is done, there is no need to keep it around
|
||||
WiFiManager wifiManager;
|
||||
|
||||
wifiManager.setSaveConfigCallback(saveConfigCallback);
|
||||
|
||||
wifiManager.addParameter(&custom_mqtt_password);
|
||||
wifiManager.setMinimumSignalQuality();
|
||||
|
||||
if (!wifiManager.autoConnect()) {
|
||||
Serial.println(F("failed to connect and hit timeout"));
|
||||
delay(3000);
|
||||
//reset and try again, or maybe put it to deep sleep
|
||||
ESP.reset();
|
||||
delay(5000);
|
||||
}
|
||||
|
||||
//if you get here you have connected to the WiFi
|
||||
Serial.println(F("connected...yeey :)"));
|
||||
|
||||
//read updated parameters
|
||||
strcpy(mqtt_password, custom_mqtt_password.getValue());
|
||||
|
||||
}
|
||||
#endif
|
||||
@@ -1,24 +0,0 @@
|
||||
#include <ESP8266WiFi.h>
|
||||
//needed for library
|
||||
#include <DNSServer.h>
|
||||
#include <ESP8266WebServer.h>
|
||||
#include <WiFiManager.h> //https://github.com/tzapu/WiFiManager
|
||||
#include <ESP8266WiFiMulti.h>
|
||||
|
||||
extern ESP8266WiFiMulti wifiMulti;
|
||||
extern WiFiClient ethClient;
|
||||
//WiFiManager wifiManager;
|
||||
|
||||
//define your default values here, if there are different values in config.json, they are overwritten.
|
||||
//length should be max size + 1
|
||||
extern char mqtt_password[16];
|
||||
|
||||
//default custom static IP
|
||||
//char static_ip[16] = "10.0.1.56";
|
||||
//char static_gw[16] = "10.0.1.1";
|
||||
//char static_sn[16] = "255.255.255.0";
|
||||
|
||||
//flag for saving data
|
||||
extern bool shouldSaveConfig;
|
||||
|
||||
void espSetup ();
|
||||
31
lighthub/homiedef.h
Normal file
31
lighthub/homiedef.h
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
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 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";
|
||||
@@ -19,129 +19,520 @@ e-mail anklimov@gmail.com
|
||||
*/
|
||||
|
||||
#include "inputs.h"
|
||||
#include "aJSON.h"
|
||||
#include "item.h"
|
||||
#include "utils.h"
|
||||
#include <PubSubClient.h>
|
||||
|
||||
#ifndef DHT_DISABLE
|
||||
#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)
|
||||
#include <DHTesp.h>
|
||||
|
||||
#else
|
||||
#include "DHT.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
extern PubSubClient mqttClient;
|
||||
|
||||
#ifndef COUNTER_DISABLE
|
||||
static volatile unsigned long nextPollMillisValue[5];
|
||||
static volatile int nextPollMillisPin[5] = {0,0,0,0,0};
|
||||
#if defined(ARDUINO_ARCH_AVR)
|
||||
static volatile long counter_value[6];
|
||||
#endif
|
||||
|
||||
#if defined(ARDUINO_ARCH_ESP8266)
|
||||
static volatile long counter_value[6];
|
||||
#endif
|
||||
|
||||
#if defined(ARDUINO_ARCH_ESP32)
|
||||
static volatile long counter_value[6];
|
||||
#endif
|
||||
|
||||
#if defined(__SAM3X8E__) || defined(ARDUINO_ARCH_STM32F1)
|
||||
static short counter_irq_map[54];
|
||||
static long counter_value[54];
|
||||
static int counters_count;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
Input::Input(char * name) //Constructor
|
||||
{
|
||||
if (name)
|
||||
if (name)
|
||||
inputObj= aJson.getObjectItem(inputs, name);
|
||||
else inputObj=NULL;
|
||||
|
||||
Parse();
|
||||
|
||||
Parse();
|
||||
}
|
||||
|
||||
|
||||
Input::Input(int pin) //Constructor
|
||||
Input::Input(int pin)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
||||
Input::Input(aJsonObject * obj) //Constructor
|
||||
{
|
||||
inputObj= obj;
|
||||
Input::Input(aJsonObject * obj)
|
||||
{
|
||||
inputObj= obj;
|
||||
Parse();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
boolean Input::isValid ()
|
||||
{
|
||||
return (pin && store);
|
||||
return (pin && store);
|
||||
}
|
||||
|
||||
void Input::Parse()
|
||||
{
|
||||
store = NULL;
|
||||
inType = 0;
|
||||
pin = 0;
|
||||
|
||||
if (inputObj && (inputObj->type==aJson_Object))
|
||||
{
|
||||
aJsonObject * s;
|
||||
|
||||
s = aJson.getObjectItem(inputObj,"T");
|
||||
if (s) inType = s->valueint;
|
||||
|
||||
pin = atoi(inputObj->name);
|
||||
|
||||
|
||||
s = aJson.getObjectItem(inputObj,"S");
|
||||
if (!s) { Serial.print(F("In: "));Serial.print(pin);Serial.print(F("/"));Serial.println(inType);
|
||||
aJson.addNumberToObject(inputObj,"S", 0);
|
||||
s = aJson.getObjectItem(inputObj,"S");
|
||||
}
|
||||
|
||||
if (s) store= (inStore *) &s->valueint;
|
||||
}
|
||||
}
|
||||
|
||||
int Input::Poll()
|
||||
{
|
||||
boolean v;
|
||||
if (!isValid()) return -1;
|
||||
|
||||
|
||||
if (inType & IN_ACTIVE_HIGH)
|
||||
{ pinMode(pin, INPUT);
|
||||
v = (digitalRead(pin)==HIGH);
|
||||
}
|
||||
else
|
||||
{ pinMode(pin, INPUT_PULLUP);
|
||||
v = (digitalRead(pin)==LOW);
|
||||
}
|
||||
if (v!=store->cur) // value changed
|
||||
{
|
||||
if (store->bounce) store->bounce--;
|
||||
else //confirmed change
|
||||
{
|
||||
Changed(v);
|
||||
store->cur=v;
|
||||
}
|
||||
}
|
||||
else // no change
|
||||
store->bounce=3;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Input::Changed (int val)
|
||||
{
|
||||
Serial.print(pin);Serial.print(F("="));Serial.println(val);
|
||||
aJsonObject * item = aJson.getObjectItem(inputObj,"item");
|
||||
aJsonObject * scmd = aJson.getObjectItem(inputObj,"scmd");
|
||||
aJsonObject * rcmd = aJson.getObjectItem(inputObj,"rcmd");
|
||||
aJsonObject * emit = aJson.getObjectItem(inputObj,"emit");
|
||||
|
||||
if (emit)
|
||||
{
|
||||
|
||||
if (val)
|
||||
{ //send set command
|
||||
if (!scmd) mqttClient.publish(emit->valuestring,"ON",true); else if (strlen(scmd->valuestring)) mqttClient.publish(emit->valuestring,scmd->valuestring,true);
|
||||
}
|
||||
else
|
||||
{ //send reset command
|
||||
if (!rcmd) mqttClient.publish(emit->valuestring,"OFF",true); else if (strlen(rcmd->valuestring)) mqttClient.publish(emit->valuestring,rcmd->valuestring,true);
|
||||
}
|
||||
}
|
||||
|
||||
if (item)
|
||||
{
|
||||
Item it(item->valuestring);
|
||||
if (it.isValid())
|
||||
{
|
||||
if (val)
|
||||
{ //send set command
|
||||
if (!scmd) it.Ctrl(CMD_ON,0,NULL,true); else if (strlen(scmd->valuestring)) it.Ctrl(txt2cmd(scmd->valuestring),0,NULL,true);
|
||||
}
|
||||
else
|
||||
{ //send reset command
|
||||
if (!rcmd) it.Ctrl(CMD_OFF,0,NULL,true); else if (strlen(rcmd->valuestring)) it.Ctrl(txt2cmd(rcmd->valuestring),0,NULL,true);
|
||||
}
|
||||
}
|
||||
}
|
||||
store = NULL;
|
||||
inType = 0;
|
||||
pin = 0;
|
||||
if (inputObj && (inputObj->type == aJson_Object)) {
|
||||
aJsonObject *itemBuffer;
|
||||
itemBuffer = aJson.getObjectItem(inputObj, "T");
|
||||
if (itemBuffer) inType = static_cast<uint8_t>(itemBuffer->valueint);
|
||||
pin = static_cast<uint8_t>(atoi(inputObj->name));
|
||||
itemBuffer = aJson.getObjectItem(inputObj, "S");
|
||||
if (!itemBuffer) {
|
||||
debugSerial<<F("In: ")<<pin<<F("/")<<inType<<endl;
|
||||
aJson.addNumberToObject(inputObj, "S", 0);
|
||||
itemBuffer = aJson.getObjectItem(inputObj, "S");
|
||||
}
|
||||
if (itemBuffer) store = (inStore *) &itemBuffer->valueint;
|
||||
}
|
||||
}
|
||||
|
||||
int Input::poll() {
|
||||
if (!isValid()) return -1;
|
||||
if (0) ;
|
||||
|
||||
#ifndef DHT_DISABLE
|
||||
else if (inType & IN_DHT22)
|
||||
dht22Poll();
|
||||
else if (inType & IN_COUNTER)
|
||||
counterPoll();
|
||||
else if (inType & IN_UPTIME)
|
||||
uptimePoll();
|
||||
#endif
|
||||
else if (inType & IN_ANALOG)
|
||||
analogPoll();
|
||||
else
|
||||
contactPoll();
|
||||
return 0;
|
||||
|
||||
// contactPoll();
|
||||
}
|
||||
|
||||
#ifndef COUNTER_DISABLE
|
||||
void Input::counterPoll() {
|
||||
if(nextPollTime()>millis())
|
||||
return;
|
||||
if (store->logicState == 0) {
|
||||
#if defined(ARDUINO_ARCH_AVR)
|
||||
#define interrupt_number pin
|
||||
if (interrupt_number >= 0 && interrupt_number < 6) {
|
||||
const short mega_interrupt_array[6] = {2, 3, 21, 20, 19, 18};
|
||||
short real_pin = mega_interrupt_array[interrupt_number];
|
||||
attachInterruptPinIrq(real_pin,interrupt_number);
|
||||
} else {
|
||||
Serial.print(F("IRQ:"));
|
||||
Serial.print(pin);
|
||||
Serial.print(F(" Counter type. INCORRECT Interrupt number!!!"));
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(__SAM3X8E__)
|
||||
attachInterruptPinIrq(pin,counters_count);
|
||||
counter_irq_map[counters_count]=pin;
|
||||
counters_count++;
|
||||
#endif
|
||||
store->logicState = 1;
|
||||
return;
|
||||
}
|
||||
long counterValue = counter_value[pin];
|
||||
debugSerial<<F("IN:")<<(pin)<<F(" Counter type. val=")<<counterValue;
|
||||
|
||||
aJsonObject *emit = aJson.getObjectItem(inputObj, "emit");
|
||||
if (emit) {
|
||||
char valstr[10];
|
||||
char addrstr[100] = "";
|
||||
strcat(addrstr, emit->valuestring);
|
||||
sprintf(valstr, "%d", counterValue);
|
||||
mqttClient.publish(addrstr, valstr);
|
||||
setNextPollTime(millis() + DHT_POLL_DELAY_DEFAULT);
|
||||
debugSerial<<F(" NextPollMillis=")<<nextPollTime();
|
||||
}
|
||||
else
|
||||
debugSerial<<F(" No emit data!");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef COUNTER_DISABLE
|
||||
void Input::attachInterruptPinIrq(int realPin, int irq) {
|
||||
pinMode(realPin, INPUT);
|
||||
int real_irq;
|
||||
#if defined(ARDUINO_ARCH_AVR)
|
||||
real_irq = irq;
|
||||
#endif
|
||||
#if defined(__SAM3X8E__)
|
||||
real_irq = realPin;
|
||||
#endif
|
||||
switch(irq){
|
||||
case 0:
|
||||
attachInterrupt(real_irq, onCounterChanged0, RISING);
|
||||
break;
|
||||
case 1:
|
||||
attachInterrupt(real_irq, onCounterChanged1, RISING);
|
||||
break;
|
||||
case 2:
|
||||
attachInterrupt(real_irq, onCounterChanged2, RISING);
|
||||
break;
|
||||
case 3:
|
||||
attachInterrupt(real_irq, onCounterChanged3, RISING);
|
||||
break;
|
||||
case 4:
|
||||
attachInterrupt(real_irq, onCounterChanged4, RISING);
|
||||
break;
|
||||
case 5:
|
||||
attachInterrupt(real_irq, onCounterChanged5, RISING);
|
||||
break;
|
||||
default:
|
||||
Serial.print(F("Incorrect irq:"));Serial.println(irq);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Input::dht22Poll() {
|
||||
if (nextPollTime() > millis())
|
||||
return;
|
||||
#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)
|
||||
DHTesp dhtSensor;
|
||||
dhtSensor.setup(pin, DHTesp::DHT22);
|
||||
TempAndHumidity dhtSensorData = dhtSensor.getTempAndHumidity();
|
||||
float temp = roundf(dhtSensorData.temperature * 10) / 10;
|
||||
float humidity = roundf(dhtSensorData.humidity);
|
||||
#else
|
||||
DHT dht(pin, DHT22);
|
||||
float temp = dht.readTemperature();
|
||||
float humidity = dht.readHumidity();
|
||||
#endif
|
||||
aJsonObject *emit = aJson.getObjectItem(inputObj, "emit");
|
||||
debugSerial << F("IN:") << pin << F(" DHT22 type. T=") << temp << F("°C H=") << humidity << F("%");
|
||||
if (emit && temp && humidity && temp == temp && humidity == humidity) {
|
||||
char addrstr[100] = "";
|
||||
#ifdef WITH_DOMOTICZ
|
||||
if(getIdxField()){
|
||||
publishDataToDomoticz(DHT_POLL_DELAY_DEFAULT, emit, "{\"idx\":%s,\"svalue\":\"%.1f;%.0f;0\"}", getIdxField(), temp, humidity);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
char valstr[10];
|
||||
strcat(addrstr, emit->valuestring);
|
||||
strcat(addrstr, "T");
|
||||
printFloatValueToStr(temp, valstr);
|
||||
mqttClient.publish(addrstr, valstr);
|
||||
addrstr[strlen(addrstr) - 1] = 'H';
|
||||
printFloatValueToStr(humidity, valstr);
|
||||
mqttClient.publish(addrstr, valstr);
|
||||
|
||||
setNextPollTime(millis() + DHT_POLL_DELAY_DEFAULT);
|
||||
debugSerial << F(" NextPollMillis=") << nextPollTime() << endl;
|
||||
} else
|
||||
setNextPollTime(millis() + DHT_POLL_DELAY_DEFAULT / 3);
|
||||
}
|
||||
|
||||
unsigned long Input::nextPollTime() const {
|
||||
for(int i=0;i<5;i++){
|
||||
if(nextPollMillisPin[i]==pin)
|
||||
return nextPollMillisValue[i];
|
||||
else if(nextPollMillisPin[i]==0) {
|
||||
nextPollMillisPin[i]=pin;
|
||||
return nextPollMillisValue[i] = 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void Input::setNextPollTime(unsigned long pollTime) {
|
||||
for (int i = 0; i < 5; i++) {
|
||||
if (nextPollMillisPin[i] == pin) {
|
||||
nextPollMillisValue[i] = pollTime;
|
||||
return;
|
||||
} else if (nextPollMillisPin[i] == 0) {
|
||||
nextPollMillisPin[i] == pin;
|
||||
nextPollMillisValue[i] = pollTime;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Input::uptimePoll() {
|
||||
if (nextPollTime() > millis())
|
||||
return;
|
||||
aJsonObject *emit = aJson.getObjectItem(inputObj, "emit");
|
||||
if (emit) {
|
||||
#ifdef WITH_DOMOTICZ
|
||||
if(getIdxField()){
|
||||
publishDataToDomoticz(DHT_POLL_DELAY_DEFAULT, emit, "{\"idx\":%s,\"svalue\":\"%d\"}", getIdxField(), millis());
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
char valstr[11];
|
||||
// printUlongValueToStr(valstr,millis());
|
||||
printUlongValueToStr(valstr, millis());
|
||||
mqttClient.publish(emit->valuestring, valstr);
|
||||
}
|
||||
setNextPollTime(millis() + UPTIME_POLL_DELAY_DEFAULT);
|
||||
}
|
||||
|
||||
void Input::onCounterChanged(int i) {
|
||||
#if defined(__SAM3X8E__)
|
||||
counter_value[counter_irq_map[i]]++;
|
||||
#endif
|
||||
|
||||
#if defined(ARDUINO_ARCH_AVR)
|
||||
counter_value[i]++;
|
||||
#endif
|
||||
}
|
||||
|
||||
void Input::onCounterChanged0() {
|
||||
onCounterChanged(0);
|
||||
}
|
||||
void Input::onCounterChanged1() {
|
||||
onCounterChanged(1);
|
||||
}
|
||||
void Input::onCounterChanged2() {
|
||||
onCounterChanged(2);
|
||||
}
|
||||
void Input::onCounterChanged3() {
|
||||
onCounterChanged(3);
|
||||
}
|
||||
void Input::onCounterChanged4() {
|
||||
onCounterChanged(4);
|
||||
}
|
||||
void Input::onCounterChanged5() {
|
||||
onCounterChanged(5);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
void Input::contactPoll() {
|
||||
boolean currentInputState;
|
||||
#if defined(ARDUINO_ARCH_STM32F1)
|
||||
WiringPinMode inputPinMode;
|
||||
#endif
|
||||
#if defined(__SAM3X8E__)||defined(ARDUINO_ARCH_AVR)||defined(ARDUINO_ARCH_ESP8266)||defined(ARDUINO_ARCH_ESP32)
|
||||
|
||||
#endif
|
||||
uint32_t inputPinMode;
|
||||
uint8_t inputOnLevel;
|
||||
if (inType & IN_ACTIVE_HIGH) {
|
||||
inputOnLevel = HIGH;
|
||||
inputPinMode = INPUT;
|
||||
} else {
|
||||
inputOnLevel = LOW;
|
||||
inputPinMode = INPUT_PULLUP;
|
||||
}
|
||||
pinMode(pin, inputPinMode);
|
||||
currentInputState = (digitalRead(pin) == inputOnLevel);
|
||||
if (currentInputState != store->currentValue) // value changed
|
||||
{
|
||||
if (store->bounce) store->bounce = store->bounce - 1;
|
||||
else //confirmed change
|
||||
{
|
||||
if (inType & IN_PUSH_TOGGLE) {
|
||||
if (currentInputState) { //react on leading edge only (change from 0 to 1)
|
||||
store->logicState = !store->logicState;
|
||||
onContactChanged(store->logicState);
|
||||
}
|
||||
} else {
|
||||
store->logicState = currentInputState;
|
||||
onContactChanged(currentInputState);
|
||||
}
|
||||
store->currentValue = currentInputState;
|
||||
}
|
||||
} else // no change
|
||||
store->bounce = SAME_STATE_ATTEMPTS;
|
||||
}
|
||||
|
||||
|
||||
void Input::analogPoll() {
|
||||
int16_t mappedInputVal;
|
||||
aJsonObject *inputMap = aJson.getObjectItem(inputObj, "map");
|
||||
short Noize = ANALOG_NOIZE;
|
||||
short simple = 0;
|
||||
|
||||
#if defined(ARDUINO_ARCH_STM32F1)
|
||||
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) {
|
||||
inputPinMode = INPUT;
|
||||
} else {
|
||||
inputPinMode = INPUT_PULLUP;
|
||||
}
|
||||
pinMode(pin, inputPinMode);
|
||||
mappedInputVal = analogRead(pin);
|
||||
// Mapping
|
||||
if (inputMap && inputMap->type == aJson_Array)
|
||||
{
|
||||
int max;
|
||||
if (aJson.getArraySize(inputMap)>=4)
|
||||
mappedInputVal = map (mappedInputVal,
|
||||
aJson.getArrayItem(inputMap, 0)->valueint,
|
||||
aJson.getArrayItem(inputMap, 1)->valueint,
|
||||
aJson.getArrayItem(inputMap, 2)->valueint,
|
||||
max=aJson.getArrayItem(inputMap, 3)->valueint);
|
||||
if (aJson.getArraySize(inputMap)==5) Noize = aJson.getArrayItem(inputMap, 4)->valueint;
|
||||
if (mappedInputVal>max) mappedInputVal=max;
|
||||
if (aJson.getArraySize(inputMap)==2)
|
||||
{
|
||||
simple = 1;
|
||||
if (mappedInputVal < aJson.getArrayItem(inputMap, 0)->valueint) mappedInputVal = 0;
|
||||
else if (mappedInputVal > aJson.getArrayItem(inputMap, 1)->valueint) mappedInputVal = 1;
|
||||
else return;
|
||||
}
|
||||
}
|
||||
if (simple) {
|
||||
if (mappedInputVal != store->currentValue)
|
||||
{
|
||||
onContactChanged(mappedInputVal);
|
||||
store->currentValue = mappedInputVal;
|
||||
}}
|
||||
else
|
||||
if (abs(mappedInputVal - store->currentValue)>Noize) // value changed >ANALOG_NOIZE
|
||||
store->bounce = 0;
|
||||
else // no change
|
||||
if (store->bounce<ANALOG_STATE_ATTEMPTS) store->bounce ++;
|
||||
|
||||
if (store->bounce<ANALOG_STATE_ATTEMPTS-1 && (mappedInputVal != store->currentValue)) //confirmed change
|
||||
{
|
||||
onAnalogChanged(mappedInputVal);
|
||||
store->currentValue = mappedInputVal;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void Input::onContactChanged(int newValue) {
|
||||
debugSerial << F("IN:") << (pin) << F("=") << newValue << endl;
|
||||
aJsonObject *item = aJson.getObjectItem(inputObj, "item");
|
||||
aJsonObject *scmd = aJson.getObjectItem(inputObj, "scmd");
|
||||
aJsonObject *rcmd = aJson.getObjectItem(inputObj, "rcmd");
|
||||
aJsonObject *emit = aJson.getObjectItem(inputObj, "emit");
|
||||
if (emit) {
|
||||
#ifdef WITH_DOMOTICZ
|
||||
if (getIdxField()) {
|
||||
(newValue)? publishDataToDomoticz(0, emit, "{\"command\":\"switchlight\",\"idx\":%s,\"switchcmd\":\"On\"}", getIdxField())
|
||||
: publishDataToDomoticz(0,emit,"{\"command\":\"switchlight\",\"idx\":%s,\"switchcmd\":\"Off\"}",getIdxField());
|
||||
} else
|
||||
#endif
|
||||
if (newValue) { //send set command
|
||||
if (!scmd) mqttClient.publish(emit->valuestring, "ON", true);
|
||||
else if (strlen(scmd->valuestring))
|
||||
mqttClient.publish(emit->valuestring, scmd->valuestring, true);
|
||||
} else { //send reset command
|
||||
if (!rcmd) mqttClient.publish(emit->valuestring, "OFF", true);
|
||||
else if (strlen(rcmd->valuestring))mqttClient.publish(emit->valuestring, rcmd->valuestring, true);
|
||||
}
|
||||
}
|
||||
|
||||
if (item) {
|
||||
Item it(item->valuestring);
|
||||
if (it.isValid()) {
|
||||
if (newValue) { //send set command
|
||||
if (!scmd) it.Ctrl(CMD_ON, 0, NULL, true);
|
||||
else if (strlen(scmd->valuestring))
|
||||
it.Ctrl(scmd->valuestring, true);
|
||||
} else { //send reset command
|
||||
if (!rcmd) it.Ctrl(CMD_OFF, 0, NULL, true);
|
||||
else if (strlen(rcmd->valuestring))
|
||||
it.Ctrl(rcmd->valuestring, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Input::onAnalogChanged(int newValue) {
|
||||
debugSerial << F("IN:") << (pin) << F("=") << newValue << endl;
|
||||
aJsonObject *item = aJson.getObjectItem(inputObj, "item");
|
||||
aJsonObject *emit = aJson.getObjectItem(inputObj, "emit");
|
||||
|
||||
|
||||
if (emit) {
|
||||
|
||||
//#ifdef WITH_DOMOTICZ
|
||||
// if (getIdxField()) {
|
||||
// (newValue)? publishDataToDomoticz(0, emit, "{\"command\":\"switchlight\",\"idx\":%s,\"switchcmd\":\"On\"}", getIdxField())
|
||||
// : publishDataToDomoticz(0,emit,"{\"command\":\"switchlight\",\"idx\":%s,\"switchcmd\":\"Off\"}",getIdxField());
|
||||
// } else
|
||||
//#endif
|
||||
char strVal[16];
|
||||
itoa(newValue,strVal,10);
|
||||
mqttClient.publish(emit->valuestring, strVal, true);
|
||||
}
|
||||
|
||||
if (item) {
|
||||
Item it(item->valuestring);
|
||||
if (it.isValid()) {
|
||||
it.Ctrl(0, 1, &newValue, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Input::printUlongValueToStr(char *valstr, unsigned long value) {
|
||||
char buf[11];
|
||||
int i=0;
|
||||
for(;value>0;i++){
|
||||
unsigned long mod = value - ((unsigned long)(value/10))*10;
|
||||
buf[i]=mod+48;
|
||||
value = (unsigned long)(value/10);
|
||||
}
|
||||
|
||||
for(int n=0;n<=i;n++){
|
||||
valstr[n]=buf[i-n-1];
|
||||
}
|
||||
valstr[i]='\0';
|
||||
}
|
||||
bool Input::publishDataToDomoticz(int pollTimeIncrement, aJsonObject *emit, const char *format, ...)
|
||||
{
|
||||
#ifdef WITH_DOMOTICZ
|
||||
debugSerial << F("\nDomoticz valstr:");
|
||||
char valstr[50];
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
vsnprintf(valstr, sizeof(valstr) - 1, format, args);
|
||||
va_end(args);
|
||||
debugSerial << valstr;
|
||||
mqttClient.publish(emit->valuestring, valstr);
|
||||
if (pollTimeIncrement)
|
||||
setNextPollTime(millis() + pollTimeIncrement);
|
||||
debugSerial << F(" NextPollMillis=") << nextPollTime() << endl;
|
||||
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
char* Input::getIdxField() {
|
||||
aJsonObject *idx = aJson.getObjectItem(inputObj, "idx");
|
||||
if(idx&&idx->valuestring)
|
||||
return idx->valuestring;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -18,80 +18,116 @@ e-mail anklimov@gmail.com
|
||||
|
||||
*/
|
||||
|
||||
#include "aJSON.h"
|
||||
#include <aJSON.h>
|
||||
|
||||
#define IN_ACTIVE_HIGH 128 // High level = PUSHED/ CLOSED/ ON othervise :Low Level
|
||||
#define IN_ACTIVE_HIGH 2 // High level = PUSHED/ CLOSED/ ON othervise :Low Level. Use INPUT mode instead of INPUT_PULLUP for digital pin
|
||||
#define IN_ANALOG 64 // Analog input
|
||||
#define IN_RE 32 // Rotary Encoder (for further use)
|
||||
|
||||
#define IN_PUSH_ON 0 // PUSH - ON, Release - OFF (ovverrided by pcmd/rcmd) - DEFAULT
|
||||
#define IN_PUSH_TOGGLE 1 // Every physicall push toggle logical switch on/off
|
||||
#define IN_PUSH_TOGGLE 1 // Used for push buttons. Every physicall push toggle logical switch on/off. Toggle on leading edge
|
||||
#define IN_DHT22 4
|
||||
#define IN_COUNTER 8
|
||||
#define IN_UPTIME 16
|
||||
|
||||
#define SAME_STATE_ATTEMPTS 3
|
||||
#define ANALOG_STATE_ATTEMPTS 6
|
||||
#define ANALOG_NOIZE 1
|
||||
|
||||
// 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" }
|
||||
|
||||
//
|
||||
//
|
||||
//Switch/Restore all
|
||||
//"pin": { "T":"1", "emit":"/all", item:"local_all", "scmd": "OFF", "rcmd": "RESTORE"}
|
||||
|
||||
//
|
||||
//
|
||||
//Normal (not button) Switch (toggled mode)
|
||||
//"pin": { "T":"1", "emit":"/light1", item:"light1", "scmd": "TOGGLE", "rcmd": "TOGGLE"}
|
||||
//"pin": { "T":"0", "emit":"/light1", item:"light1", "scmd": "TOGGLE", "rcmd": "TOGGLE"}
|
||||
// or
|
||||
// "pin": { "T":"xx", "emit":"/light1", item:"light1"}
|
||||
|
||||
//Normal (not button) Switch
|
||||
//"pin": { "T":"0", "emit":"/light1", item:"light1", "scmd": "ON", "rcmd": "OFF"}
|
||||
//Use Button
|
||||
//"pin": { "T":"1", "emit":"/light1", item:"light1", "scmd": "ON", "rcmd": "OFF"}
|
||||
// or
|
||||
// "pin": { "T":"0", "emit":"/light1", item:"light1"}
|
||||
//or
|
||||
// "pin": { "T":"1", "emit":"/light1", item:"light1"}
|
||||
//or
|
||||
// "pin": { "emit":"/light1", item:"light1"}
|
||||
|
||||
//1-Button dimmer
|
||||
//1-Button dimmer
|
||||
//"pin": { "T":"1", "emit":"/light1", item:"light1", "scmd": "ON", srcmd:"INCREASE",rrcmd:"DECREASE", "rcmd": "OFF"}
|
||||
// or
|
||||
// "pin": { "T":"xx", "emit":"/light1", item:"light1"}
|
||||
|
||||
//2-Buttons dimmer
|
||||
//2-Buttons dimmer
|
||||
//"pin1": { "T":"0", "emit":"/light1", item:"light1", "scmd": "ON", repcmd:"INCREASE"}
|
||||
//"pin2": { "T":"0", "emit":"/light1", item:"light1", "scmd": "OFF", repcmd:"INCREASE"}
|
||||
|
||||
extern aJsonObject *inputs;
|
||||
|
||||
|
||||
typedef union
|
||||
{
|
||||
long int aslong;
|
||||
struct
|
||||
{
|
||||
int8_t reserve;
|
||||
int8_t logicState;
|
||||
int8_t bounce;
|
||||
int8_t cur;
|
||||
};
|
||||
extern aJsonObject *inputs;
|
||||
|
||||
|
||||
typedef union {
|
||||
long int aslong;
|
||||
struct {
|
||||
int8_t logicState;
|
||||
int8_t bounce;
|
||||
int16_t currentValue;
|
||||
};
|
||||
|
||||
} inStore;
|
||||
|
||||
class Input
|
||||
{
|
||||
public:
|
||||
aJsonObject *inputObj;
|
||||
uint8_t inType;
|
||||
uint8_t pin;
|
||||
inStore * store;
|
||||
class Input {
|
||||
public:
|
||||
aJsonObject *inputObj;
|
||||
uint8_t inType;
|
||||
uint8_t pin;
|
||||
inStore *store;
|
||||
|
||||
Input(int pin);
|
||||
Input(aJsonObject * obj);
|
||||
Input(char * name);
|
||||
|
||||
boolean isValid ();
|
||||
void Changed (int val);
|
||||
Input(int pin);
|
||||
|
||||
int Poll();
|
||||
protected:
|
||||
void Parse();
|
||||
Input(aJsonObject *obj);
|
||||
|
||||
Input(char *name);
|
||||
|
||||
boolean isValid();
|
||||
|
||||
void onContactChanged(int newValue);
|
||||
void onAnalogChanged(int newValue);
|
||||
|
||||
int poll();
|
||||
|
||||
static void inline onCounterChanged(int i);
|
||||
static void onCounterChanged0();
|
||||
static void onCounterChanged1();
|
||||
static void onCounterChanged2();
|
||||
static void onCounterChanged3();
|
||||
static void onCounterChanged4();
|
||||
static void onCounterChanged5();
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
void Parse();
|
||||
|
||||
void contactPoll();
|
||||
void analogPoll();
|
||||
|
||||
void dht22Poll();
|
||||
|
||||
|
||||
void counterPoll();
|
||||
|
||||
void attachInterruptPinIrq(int realPin, int irq);
|
||||
|
||||
unsigned long nextPollTime() const;
|
||||
void setNextPollTime(unsigned long pollTime);
|
||||
|
||||
|
||||
void uptimePoll();
|
||||
|
||||
void printUlongValueToStr(char *valstr, unsigned long value);
|
||||
bool publishDataToDomoticz(int , aJsonObject *, const char *format, ...);
|
||||
|
||||
char* getIdxField();
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -19,53 +19,71 @@ e-mail anklimov@gmail.com
|
||||
*/
|
||||
#include "options.h"
|
||||
|
||||
#define CH_DIMMER 0 //DMX 1 ch
|
||||
#define CH_DIMMER 0 //DMX 1 ch
|
||||
#define CH_RGBW 1 //DMX 4 ch
|
||||
#define CH_RGB 2 //DMX 3 ch
|
||||
#define CH_PWM 3 //PWM output directly to PIN
|
||||
#define CH_MODBUS 4 //Modbus AC Dimmer
|
||||
#define CH_THERMO 5 //Simple ON/OFF thermostat
|
||||
#define CH_THERMO 5 //Simple ON/OFF thermostat
|
||||
#define CH_RELAY 6 //ON_OFF relay output
|
||||
#define CH_GROUP 7 //Group pseudochannel
|
||||
#define CH_VCTEMP 8 //Vacom PID regulator
|
||||
#define CH_VC 9 //Vacom modbus motor regulator
|
||||
#define CH_WHITE 127//
|
||||
#define CH_VC 9 //Vacom modbus motor regulator
|
||||
#define CH_AC_HAIER 10 //AC Haier
|
||||
#define CH_WHITE 127//
|
||||
|
||||
#define CMD_ON 1
|
||||
#define CMD_OFF 2
|
||||
#define CMD_HALT 5
|
||||
#define CMD_RESTORE 3
|
||||
#define CMD_RESTORE 3 //on only if was turned off by CMD_HALT
|
||||
#define CMD_TOGGLE 4
|
||||
#define CMD_HALT 5 //just Off
|
||||
#define CMD_XON 6 //just on
|
||||
#define CMD_XOFF 7 //off only if was previously turned on by CMD_XON
|
||||
#define CMD_UP 8 //just on
|
||||
#define CMD_DN 9 //off only if was previously turned on by CMD_XON
|
||||
#define CMD_SET 0xe
|
||||
#define CMD_MASK 0xf
|
||||
|
||||
#define CMD_CURTEMP 127
|
||||
#define CMD_SET 9
|
||||
#define CMD_RETRY 64
|
||||
#define CMD_REPORT 32
|
||||
|
||||
#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)
|
||||
#define I_VAL 2 //Latest preset (int or array of presets)
|
||||
#define I_CMD 3 //Latest CMD received
|
||||
#define I_EXT 4 //Chanell-depended extension - array
|
||||
|
||||
#define MODBUS_CMD_ARG_ADDR 0
|
||||
#define MODBUS_CMD_ARG_REG 1
|
||||
#define MODBUS_CMD_ARG_MASK 2
|
||||
#define MODBUS_CMD_ARG_MAX_SCALE 3
|
||||
#define MODBUS_CMD_ARG_REG_TYPE 4
|
||||
|
||||
#define MODBUS_COIL_REG_TYPE 0
|
||||
#define MODBUS_DISCRETE_REG_TYPE 1
|
||||
#define MODBUS_HOLDING_REG_TYPE 2
|
||||
#define MODBUS_INPUT_REG_TYPE 3
|
||||
|
||||
#include "aJSON.h"
|
||||
|
||||
extern aJsonObject *items;
|
||||
|
||||
|
||||
int txt2cmd (char * payload);
|
||||
|
||||
typedef union
|
||||
typedef union
|
||||
{
|
||||
long int aslong;
|
||||
struct
|
||||
{
|
||||
int16_t h;
|
||||
int8_t s;
|
||||
int8_t v;
|
||||
int8_t v;
|
||||
};
|
||||
} HSVstore;
|
||||
|
||||
|
||||
typedef union
|
||||
typedef union
|
||||
{
|
||||
long int aslong;
|
||||
struct
|
||||
@@ -73,27 +91,29 @@ typedef union
|
||||
int8_t r;
|
||||
int8_t g;
|
||||
int8_t b;
|
||||
int8_t v;
|
||||
int8_t v;
|
||||
};
|
||||
} RGBVstore;
|
||||
|
||||
class Item
|
||||
class Item
|
||||
{
|
||||
public:
|
||||
aJsonObject *itemArr, *itemArg,*itemVal;
|
||||
uint8_t itemType;
|
||||
|
||||
|
||||
|
||||
Item(char * name);
|
||||
Item(aJsonObject * obj);
|
||||
boolean isValid ();
|
||||
virtual int Ctrl(short cmd, short n=0, int * Parameters=NULL, boolean send=true);
|
||||
virtual int Ctrl(char * payload, boolean send=true);
|
||||
|
||||
int getArg(short n=0);
|
||||
boolean getEnableCMD(int delta);
|
||||
//int getVal(short n); //From VAL array. Negative if no array
|
||||
long int getVal(); //From int val OR array
|
||||
uint8_t getCmd();
|
||||
void setCmd(uint8_t cmd);
|
||||
uint8_t getCmd(bool ext = false);
|
||||
void setCmd(uint8_t cmdValue);
|
||||
//void setVal(uint8_t n, int par);
|
||||
void setVal(long int par);
|
||||
//void copyPar (aJsonObject *itemV);
|
||||
@@ -102,11 +122,11 @@ class Item
|
||||
inline int Toggle(){Ctrl(CMD_TOGGLE);};
|
||||
int Poll();
|
||||
int SendStatus(short cmd, short n=0, int * Par=NULL, boolean deferred = false);
|
||||
|
||||
protected:
|
||||
|
||||
protected:
|
||||
int VacomSetFan (int8_t val, int8_t cmd=0);
|
||||
int VacomSetHeat(int addr, int8_t val, int8_t cmd=0);
|
||||
int modbusDimmerSet(int addr, uint16_t _reg, 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 isActive();
|
||||
void Parse();
|
||||
@@ -125,13 +145,13 @@ class Item
|
||||
class PooledItem : public Item
|
||||
{
|
||||
public:
|
||||
virtual int Changed() = 0;
|
||||
virtual int onContactChanged() = 0;
|
||||
virtual void Idle ();
|
||||
protected:
|
||||
int PoolingInterval;
|
||||
unsigned long next;
|
||||
virtual int Pool() =0;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -143,7 +163,7 @@ class Vacon : public Item
|
||||
public:
|
||||
int Pool ();
|
||||
virtual int Ctrl(short cmd, short n=0, int * Par=NULL);
|
||||
protected:
|
||||
protected:
|
||||
};
|
||||
|
||||
*/
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
#include "main.h"
|
||||
void setup(){
|
||||
setup_main();
|
||||
//if (millis()>1000)
|
||||
setup_main();
|
||||
//else Serial.println("Hello");
|
||||
//delay(1000);
|
||||
}
|
||||
void loop(){
|
||||
loop_main();
|
||||
//if (millis()>10000)
|
||||
loop_main();
|
||||
}
|
||||
|
||||
1742
lighthub/main.cpp
1742
lighthub/main.cpp
File diff suppressed because it is too large
Load Diff
198
lighthub/main.h
198
lighthub/main.h
@@ -1,8 +1,48 @@
|
||||
#pragma once
|
||||
|
||||
#include "options.h"
|
||||
#if defined(__SAM3X8E__)
|
||||
#include <DueFlashStorage.h>
|
||||
#include <watchdog.h>
|
||||
#include <ArduinoHttpClient.h>
|
||||
#endif
|
||||
|
||||
#ifndef LIGHTHUB_MAIN_H
|
||||
#define LIGHTHUB_MAIN_H
|
||||
#if defined(ARDUINO_ARCH_AVR)
|
||||
#include "HTTPClientAVR.h"
|
||||
#include <avr/pgmspace.h>
|
||||
#include <avr/wdt.h>
|
||||
#include <EEPROM.h>
|
||||
#endif
|
||||
|
||||
#if defined(ARDUINO_ARCH_ESP8266)
|
||||
#include <FS.h> //this needs to be first, or it all crashes and burns...
|
||||
#include <EEPROM.h>
|
||||
#include <ESP8266HTTPClient.h>
|
||||
#include <WiFiManager.h>
|
||||
#include <DNSServer.h>
|
||||
#include <ESP8266WebServer.h>
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <user_interface.h>
|
||||
#endif
|
||||
|
||||
#if defined ARDUINO_ARCH_ESP32
|
||||
//#include <FS.h> //this needs to be first, or it all crashes and burns...
|
||||
//#include <EEPROM.h>
|
||||
#include <NRFFlashStorage.h>
|
||||
#include <HttpClient.h>
|
||||
#include <WiFi.h>
|
||||
#include <WiFiClient.h>
|
||||
#include <WiFiClientSecure.h>
|
||||
#include <WebServer.h>
|
||||
#include <WiFiManager.h>
|
||||
#include <DNSServer.h>
|
||||
|
||||
#define Ethernet WiFi
|
||||
#endif
|
||||
|
||||
#ifdef NRF5
|
||||
#include <NRFFlashStorage.h>
|
||||
#endif
|
||||
|
||||
#if defined(__SAM3X8E__)
|
||||
#define wdt_res() watchdogReset()
|
||||
@@ -10,79 +50,80 @@
|
||||
#define wdt_dis()
|
||||
#endif
|
||||
|
||||
#if defined(__AVR__)
|
||||
#define wdt_en() wdt_enable(WDTO_8S)
|
||||
#define wdt_dis() wdt_disable()
|
||||
#define wdt_res() wdt_reset()
|
||||
#endif
|
||||
|
||||
#if defined(__ESP__)
|
||||
#if defined(ARDUINO_ARCH_STM32F1)
|
||||
#define wdt_res()
|
||||
#define wdt_en()
|
||||
#define wdt_dis()
|
||||
#endif
|
||||
|
||||
#if defined(WATCH_DOG_TICKER_DISABLE) && defined(__AVR__)
|
||||
#ifndef DHCP_RETRY_INTERVAL
|
||||
#define DHCP_RETRY_INTERVAL 60000
|
||||
#endif
|
||||
|
||||
#if defined(ESP8266)
|
||||
#define wdt_en() wdt_enable(WDTO_8S)
|
||||
#define wdt_dis() wdt_disable()
|
||||
#define wdt_res() wdt_reset()
|
||||
#endif
|
||||
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
#define wdt_res()
|
||||
#define wdt_en()
|
||||
#define wdt_dis()
|
||||
#endif
|
||||
|
||||
#if defined(NRF5)
|
||||
#define wdt_res()
|
||||
#define wdt_en()
|
||||
#define wdt_dis()
|
||||
#endif
|
||||
|
||||
//#if defined(ESP8266)
|
||||
//#define wdt_res()
|
||||
//#define wdt_en()
|
||||
//#define wdt_dis()
|
||||
//#endif
|
||||
#if defined(ARDUINO_ARCH_AVR)
|
||||
#if defined(WATCH_DOG_TICKER_DISABLE)
|
||||
#define wdt_en() wdt_disable()
|
||||
#define wdt_dis() wdt_disable()
|
||||
#define wdt_res() wdt_disable()
|
||||
#else
|
||||
#define wdt_en() wdt_enable(WDTO_8S)
|
||||
#define wdt_dis() wdt_disable()
|
||||
#define wdt_res() wdt_reset()
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "Arduino.h"
|
||||
#ifndef OWIRE_DISABLE
|
||||
#include "DallasTemperature.h"
|
||||
#include <PubSubClient.h>
|
||||
#include <SPI.h>
|
||||
#include "utils.h"
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#ifndef MODBUS_DISABLE
|
||||
#include <ModbusMaster.h>
|
||||
#include "aJSON.h"
|
||||
#include <Cmd.h>
|
||||
#include "stdarg.h"
|
||||
#include "item.h"
|
||||
#include "inputs.h"
|
||||
#endif
|
||||
|
||||
#ifndef DMX_DISABLE
|
||||
#include "FastLED.h"
|
||||
#include "Dns.h"
|
||||
//#include "hsv2rgb.h"
|
||||
|
||||
#if defined(__SAM3X8E__)
|
||||
|
||||
#include <DueFlashStorage.h>
|
||||
#include <watchdog.h>
|
||||
#include <ArduinoHttpClient.h>
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__AVR__)
|
||||
#include "HTTPClient.h"
|
||||
#include <avr/pgmspace.h>
|
||||
#include <avr/wdt.h>
|
||||
#include <EEPROM.h>
|
||||
#endif
|
||||
|
||||
#if defined(__ESP__)
|
||||
#include <FS.h> //this needs to be first, or it all crashes and burns...
|
||||
#include "esp.h"
|
||||
#include <EEPROM.h>
|
||||
#include <ArduinoHttpClient.h>
|
||||
#endif
|
||||
|
||||
#ifdef _owire
|
||||
|
||||
#include "owTerm.h"
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(_dmxin) || defined(_dmxout) || defined (_artnet)
|
||||
|
||||
#include "dmx.h"
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef Wiz5500
|
||||
#include <Ethernet2.h>
|
||||
#else
|
||||
#if defined(ARDUINO_ARCH_AVR) || defined(__SAM3X8E__) || defined(NRF5)
|
||||
#include <Ethernet.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef _artnet
|
||||
#include <Artnet.h>
|
||||
@@ -92,27 +133,46 @@
|
||||
#include "sd_card_w5100.h"
|
||||
#endif
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "utils.h"
|
||||
#include "homiedef.h"
|
||||
#include <PubSubClient.h>
|
||||
#include <SPI.h>
|
||||
#include <string.h>
|
||||
#include "aJSON.h"
|
||||
#include <Cmd.h>
|
||||
#include "stdarg.h"
|
||||
#include "item.h"
|
||||
#include "inputs.h"
|
||||
|
||||
#ifdef _artnet
|
||||
extern Artnet *artnet;
|
||||
#endif
|
||||
|
||||
enum lan_status {
|
||||
INITIAL_STATE = 0,
|
||||
HAVE_IP_ADDRESS = 1,
|
||||
IP_READY_CONFIG_LOADED_CONNECTING_TO_BROKER = 2,
|
||||
OPERATION = 3,
|
||||
RETAINING_COLLECTING = 4,
|
||||
AWAITING_ADDRESS = -10,
|
||||
RECONNECT = 12,
|
||||
READ_RE_CONFIG = -11,
|
||||
DO_NOTHING = -14
|
||||
};
|
||||
|
||||
|
||||
//void watchdogSetup(void);
|
||||
|
||||
void mqttCallback(char *topic, byte *payload, unsigned int length);
|
||||
|
||||
#ifndef __ESP__
|
||||
|
||||
void printIPAddress();
|
||||
|
||||
#endif
|
||||
|
||||
void printMACAddress();
|
||||
|
||||
void restoreState();
|
||||
lan_status lanLoop();
|
||||
|
||||
int lanLoop();
|
||||
|
||||
void Changed(int i, DeviceAddress addr, int val);
|
||||
#ifndef OWIRE_DISABLE
|
||||
void Changed(int i, DeviceAddress addr, float currentTemp);
|
||||
#endif
|
||||
|
||||
void modbusIdle(void);
|
||||
|
||||
@@ -124,7 +184,7 @@ void applyConfig();
|
||||
|
||||
void cmdFunctionLoad(int arg_cnt, char **args);
|
||||
|
||||
int loadConfigFromEEPROM(int arg_cnt, char **args);
|
||||
int loadConfigFromEEPROM();
|
||||
|
||||
void cmdFunctionReq(int arg_cnt, char **args);
|
||||
|
||||
@@ -146,9 +206,9 @@ int loadFlash(short n, char *str, short l=32);
|
||||
|
||||
void saveFlash(short n, IPAddress& ip);
|
||||
|
||||
int loadFlash(short n, IPAddress& ip);
|
||||
int ipLoadFromFlash(short n, IPAddress &ip);
|
||||
|
||||
int getConfig(int arg_cnt=0, char **args=NULL);
|
||||
lan_status loadConfigFromHttp(int arg_cnt = 0, char **args = NULL);
|
||||
|
||||
void preTransmission();
|
||||
|
||||
@@ -168,7 +228,7 @@ void pollingLoop(void);
|
||||
|
||||
void thermoLoop(void);
|
||||
|
||||
short thermoSetCurTemp(char *name, short t);
|
||||
short thermoSetCurTemp(char *name, float t);
|
||||
|
||||
void modbusIdle(void);
|
||||
|
||||
@@ -178,8 +238,18 @@ void setupCmdArduino();
|
||||
|
||||
void setupMacAddress();
|
||||
|
||||
int getConfig(int arg_cnt, char **args);
|
||||
|
||||
void printFirmwareVersionAndBuildOptions();
|
||||
|
||||
#endif //LIGHTHUB_MAIN_H
|
||||
bool IsThermostat(const aJsonObject *item);
|
||||
|
||||
bool disabledDisconnected(const aJsonObject *thermoExtensionArray, int thermoLatestCommand);
|
||||
|
||||
void resetHard();
|
||||
|
||||
void onInitialStateInitLAN();
|
||||
|
||||
void ip_ready_config_loaded_connecting_to_broker();
|
||||
|
||||
void printCurentLanConfig();
|
||||
|
||||
//void printFreeRam();
|
||||
|
||||
@@ -13,10 +13,12 @@
|
||||
#define IET_TEMP 0
|
||||
#define IET_ATTEMPTS 1
|
||||
|
||||
#define THERMO_GIST_CELSIUS 2
|
||||
#define THERMO_OVERHEAT_CELSIUS 38
|
||||
#define THERMO_GIST_CELSIUS 1.
|
||||
#define THERMO_OVERHEAT_CELSIUS 38.
|
||||
#define FM_OVERHEAT_CELSIUS 40.
|
||||
|
||||
#define MIN_VOLUME 10
|
||||
#define INIT_VOLUME 30
|
||||
|
||||
#define OFFSET_MAC 0
|
||||
#define OFFSET_IP OFFSET_MAC+6
|
||||
@@ -27,16 +29,26 @@
|
||||
#define OFFSET_MQTT_PWD OFFSET_CONFIGSERVER+32
|
||||
#define EEPROM_offset OFFSET_MQTT_PWD+16
|
||||
|
||||
#ifndef INTERVAL_CHECK_INPUT
|
||||
#define INTERVAL_CHECK_INPUT 50
|
||||
#endif
|
||||
#define INTERVAL_CHECK_MODBUS 2000
|
||||
#define INTERVAL_POLLING 100
|
||||
#define THERMOSTAT_CHECK_PERIOD 5000
|
||||
|
||||
#ifndef OW_UPDATE_INTERVAL
|
||||
#define OW_UPDATE_INTERVAL 5000
|
||||
#endif
|
||||
|
||||
#ifndef MODBUS_SERIAL_BAUD
|
||||
#define MODBUS_SERIAL_BAUD 9600
|
||||
#endif
|
||||
|
||||
#define dimPar SERIAL_8E1
|
||||
#ifndef MODBUS_DIMMER_PARAM
|
||||
#define MODBUS_DIMMER_PARAM SERIAL_8E1
|
||||
#endif
|
||||
|
||||
#define dimPar MODBUS_DIMMER_PARAM
|
||||
#define fmPar SERIAL_8N1
|
||||
|
||||
#ifndef SERIAL_BAUD
|
||||
@@ -53,13 +65,34 @@
|
||||
#define CONFIG_SERVER QUOTE(MY_CONFIG_SERVER)
|
||||
#endif
|
||||
|
||||
#ifndef HOMETOPIC
|
||||
#define HOMETOPIC "/myhome"
|
||||
#endif
|
||||
/*
|
||||
#ifndef OUTTOPIC
|
||||
#define OUTTOPIC "/myhome/s_out/"
|
||||
#endif
|
||||
|
||||
#ifndef CMDTOPIC
|
||||
#define CMDTOPIC "/myhome/in/command/"
|
||||
#endif
|
||||
|
||||
#ifndef INTOPIC
|
||||
#define INTOPIC "/myhome/in/"
|
||||
#endif
|
||||
*/
|
||||
|
||||
#ifndef OUTTOPIC
|
||||
#define OUTTOPIC "s_out"
|
||||
#endif
|
||||
|
||||
#ifndef CMDTOPIC
|
||||
#define CMDTOPIC "command"
|
||||
#endif
|
||||
|
||||
#ifndef INTOPIC
|
||||
#define INTOPIC "in"
|
||||
#endif
|
||||
|
||||
#define MQTT_SUBJECT_LENGTH 20
|
||||
#define MQTT_TOPIC_LENGTH 20
|
||||
@@ -81,11 +114,11 @@
|
||||
#define _artnet
|
||||
#endif
|
||||
|
||||
#if defined(ESP8266)
|
||||
#define __ESP__
|
||||
#ifndef LAN_INIT_DELAY
|
||||
#define LAN_INIT_DELAY 500
|
||||
#endif
|
||||
|
||||
#if defined(__AVR__)
|
||||
#if defined(ARDUINO_ARCH_AVR)
|
||||
//All options available
|
||||
#ifdef CONTROLLINO
|
||||
#define modbusSerial Serial3
|
||||
@@ -102,13 +135,50 @@
|
||||
#define dmxin DmxDue1
|
||||
#endif
|
||||
|
||||
#if defined(__ESP__)
|
||||
#if defined(ARDUINO_ARCH_ESP8266)
|
||||
#undef _dmxin
|
||||
#undef _modbus
|
||||
|
||||
#ifndef DMX_DISABLE
|
||||
#define _espdmx
|
||||
#endif
|
||||
#define modbusSerial Serial1
|
||||
#endif
|
||||
|
||||
#if defined(ARDUINO_ARCH_ESP32)
|
||||
#undef _dmxin
|
||||
#undef _modbus
|
||||
#undef _dmxout
|
||||
#undef modbusSerial
|
||||
#endif
|
||||
|
||||
#ifndef _dmxout
|
||||
#undef _artnet
|
||||
#endif
|
||||
|
||||
#ifdef WIFI_MANAGER_DISABLE
|
||||
#ifndef ESP_WIFI_AP
|
||||
#define ESP_WIFI_AP mywifiap
|
||||
#endif
|
||||
|
||||
#ifndef ESP_WIFI_PWD
|
||||
#define ESP_WIFI_PWD mywifipass
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define DHT_POLL_DELAY_DEFAULT 15000
|
||||
#define UPTIME_POLL_DELAY_DEFAULT 30000
|
||||
|
||||
#ifdef ARDUINO_ARCH_STM32F1
|
||||
#define strncpy_P strncpy
|
||||
#endif
|
||||
|
||||
#ifndef debugSerial
|
||||
#define debugSerial Serial
|
||||
#endif
|
||||
|
||||
#ifndef Wiz5500
|
||||
#define W5100_ETHERNET_SHIELD
|
||||
#else
|
||||
#define W5500_ETHERNET_SHIELD
|
||||
#endif
|
||||
|
||||
@@ -18,6 +18,7 @@ e-mail anklimov@gmail.com
|
||||
|
||||
*/
|
||||
|
||||
#ifndef OWIRE_DISABLE
|
||||
|
||||
#include "owTerm.h"
|
||||
#include <Arduino.h>
|
||||
@@ -26,11 +27,9 @@ e-mail anklimov@gmail.com
|
||||
|
||||
|
||||
OneWire *net = NULL;
|
||||
// Pass our oneWire reference to Dallas Temperature.
|
||||
//DallasTemperature sensors(&net);
|
||||
|
||||
DeviceAddress *term = NULL;
|
||||
//int *regs = NULL;
|
||||
|
||||
uint16_t *wstat = NULL;
|
||||
DallasTemperature *sensors = NULL;
|
||||
|
||||
@@ -41,10 +40,11 @@ unsigned long owTimer = 0;
|
||||
owChangedType owChanged;
|
||||
|
||||
int owUpdate() {
|
||||
unsigned long finish = millis() + 5000;
|
||||
#ifndef OWIRE_DISABLE
|
||||
unsigned long finish = millis() + OW_UPDATE_INTERVAL;
|
||||
short sr;
|
||||
|
||||
//net.setStrongPullup();
|
||||
|
||||
Serial.println(F("Searching"));
|
||||
if (net) net->reset_search();
|
||||
for (short i = 0; i < t_count; i++) wstat[i] &= ~SW_FIND; //absent
|
||||
@@ -56,18 +56,16 @@ int owUpdate() {
|
||||
if (!memcmp(term[i], term[t_count], 8)) {
|
||||
ifind = i;
|
||||
wstat[i] |= SW_FIND;
|
||||
Serial.print(F(" Node:"));
|
||||
PrintBytes(term[t_count], 8);
|
||||
Serial.println(F(" alive"));
|
||||
debugSerial.print(F(" Node:"));
|
||||
PrintBytes(term[t_count], 8,0);
|
||||
debugSerial.println(F(" alive"));
|
||||
break;
|
||||
}; //alive
|
||||
if (ifind < 0 && sensors) {
|
||||
wstat[t_count] = SW_FIND; //Newly detected
|
||||
Serial.print(F("dev#"));
|
||||
Serial.print(t_count);
|
||||
Serial.print(F(" Addr:"));
|
||||
PrintBytes(term[t_count], 8);
|
||||
Serial.println();
|
||||
debugSerial<<F("dev#")<<t_count<<F(" Addr:");
|
||||
PrintBytes(term[t_count], 8,0);
|
||||
debugSerial.println();
|
||||
if (term[t_count][0] == 0x28) {
|
||||
sensors->setResolution(term[t_count], TEMPERATURE_PRECISION);
|
||||
net->setStrongPullup();
|
||||
@@ -78,22 +76,22 @@ int owUpdate() {
|
||||
}//if
|
||||
} //while
|
||||
|
||||
Serial.print(F("1-wire count: "));
|
||||
Serial.println(t_count);
|
||||
|
||||
debugSerial<<F("1-wire count: ")<<t_count;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
int owSetup(owChangedType owCh) {
|
||||
#ifndef OWIRE_DISABLE
|
||||
//// todo - move memory allocation to here
|
||||
if (net) return true; // Already initialized
|
||||
#ifdef DS2482_100_I2C_TO_1W_BRIDGE
|
||||
Serial.println(F("DS2482_100_I2C_TO_1W_BRIDGE init"));
|
||||
debugSerial<<F("DS2482_100_I2C_TO_1W_BRIDGE init");
|
||||
net = new OneWire;
|
||||
#else
|
||||
Serial.print(F("One wire setup on PIN:"));
|
||||
Serial.println(QUOTE(USE_1W_PIN));
|
||||
net = new OneWire (USE_1W_PIN);
|
||||
debugSerial.print(F("One wire setup on PIN:"));
|
||||
debugSerial.println(QUOTE(USE_1W_PIN));
|
||||
net = new OneWire (USE_1W_PIN);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -109,35 +107,36 @@ net = new OneWire (USE_1W_PIN);
|
||||
#ifdef DS2482_100_I2C_TO_1W_BRIDGE
|
||||
Wire.begin();
|
||||
if (net->checkPresence()) {
|
||||
Serial.println(F("DS2482-100 present"));
|
||||
debugSerial.println(F("DS2482-100 present"));
|
||||
net->deviceReset();
|
||||
#ifdef APU_OFF
|
||||
Serial.println(F("APU off"));
|
||||
debugSerial.println(F("APU off"));
|
||||
#else
|
||||
net->setActivePullup();
|
||||
#endif
|
||||
|
||||
Serial.println(F("\tChecking for 1-Wire devices..."));
|
||||
debugSerial.println(F("\tChecking for 1-Wire devices..."));
|
||||
if (net->wireReset())
|
||||
Serial.println(F("\tReset done"));
|
||||
debugSerial.println(F("\tReset done"));
|
||||
|
||||
sensors->begin();
|
||||
owChanged = owCh;
|
||||
//owUpdate();
|
||||
//Serial.println(F("\t1-w Updated"));
|
||||
//debugSerial.println(F("\t1-w Updated"));
|
||||
sensors->setWaitForConversion(false);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
Serial.println(F("\tDS2482 error"));
|
||||
debugSerial.println(F("\tDS2482 error"));
|
||||
return false;
|
||||
// IC Default 9 bit. If you have troubles consider upping it 12. Ups the delay giving the IC more time to process the temperature measurement
|
||||
|
||||
|
||||
delay(500);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -149,12 +148,11 @@ int sensors_loop(void) {
|
||||
return 8000;
|
||||
}
|
||||
|
||||
int t;
|
||||
float t;
|
||||
switch (term[si][0]) {
|
||||
|
||||
case 0x28: // Thermomerer
|
||||
t = sensors->getTempC(term[si]);//*10.0;
|
||||
//Serial.println("o");
|
||||
if (owChanged) owChanged(si, term[si], t);
|
||||
sensors->requestTemperaturesByAddress(term[si]);
|
||||
si++;
|
||||
@@ -182,20 +180,21 @@ int owFind(DeviceAddress addr) {
|
||||
}
|
||||
|
||||
void owAdd(DeviceAddress addr) {
|
||||
#ifndef OWIRE_DISABLE
|
||||
if (t_count>=t_max) return;
|
||||
wstat[t_count] = SW_FIND; //Newly detected
|
||||
memcpy(term[t_count], addr, 8);
|
||||
//term[t_count]=addr;
|
||||
|
||||
Serial.print(F("dev#"));
|
||||
Serial.print(t_count);
|
||||
Serial.print(F(" Addr:"));
|
||||
PrintBytes(term[t_count], 8);
|
||||
Serial.println();
|
||||
debugSerial<<F("dev#")<<t_count<<F(" Addr:");
|
||||
PrintBytes(term[t_count], 8,0);
|
||||
debugSerial.println();
|
||||
if (term[t_count][0] == 0x28) {
|
||||
sensors->setResolution(term[t_count], TEMPERATURE_PRECISION);
|
||||
net->setStrongPullup();
|
||||
// sensors.requestTemperaturesByAddress(term[t_count]);
|
||||
}
|
||||
t_count++;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -32,31 +32,36 @@ e-mail anklimov@gmail.com
|
||||
#define recheck_interval 5
|
||||
#define check_circle 2000/t_count
|
||||
|
||||
#define SW_FIND 1
|
||||
#define SW_FIND 1
|
||||
#define SW_DOUBLECHECK 2 //Doublecheck required
|
||||
#define SW_PULSE0 4 //Pulse Reset started
|
||||
#define SW_PULSE1 8 //Pulse Reset stsrted
|
||||
#define SW_PULSE0 4 //Pulse Reset started
|
||||
#define SW_PULSE1 8 //Pulse Reset stsrted
|
||||
#define SW_PULSE_P0 0x10 //Pulse reset in process
|
||||
#define SW_PULSE_P1 0x20 //Pulse reset in process
|
||||
#define SW_CHANGED_P0 0x40 //Changes while pulse in progress
|
||||
#define SW_CHANGED_P1 0x80 //Changes while pulse in progress
|
||||
#define SW_PULSE0_R 0x100 //Pulse Reset requested
|
||||
#define SW_PULSE1_R 0x200 //Pulse Reset requested
|
||||
#define SW_PULSE0_R 0x100 //Pulse Reset requested
|
||||
#define SW_PULSE1_R 0x200 //Pulse Reset requested
|
||||
|
||||
|
||||
#define recheck_interval 5
|
||||
#define check_circle 2000/t_count
|
||||
|
||||
#define t_max 20 //Maximum number of 1w devices
|
||||
#define TEMPERATURE_PRECISION 9
|
||||
#define TEMPERATURE_PRECISION 12 //9
|
||||
|
||||
#ifndef OWIRE_DISABLE
|
||||
|
||||
#ifndef ARDUINO_ARCH_STM32F1
|
||||
#include <DS2482_OneWire.h>
|
||||
#endif
|
||||
|
||||
#include <DallasTemperature.h>
|
||||
#include "aJSON.h"
|
||||
|
||||
extern aJsonObject *owArr;
|
||||
|
||||
typedef void (*owChangedType) (int , DeviceAddress, int) ;
|
||||
typedef void (*owChangedType) (int , DeviceAddress, float) ;
|
||||
#ifndef USE_1W_PIN
|
||||
#define DS2482_100_I2C_TO_1W_BRIDGE // HW driver
|
||||
#endif
|
||||
@@ -81,7 +86,8 @@ extern owChangedType owChanged;
|
||||
int owUpdate();
|
||||
int owSetup(owChangedType owCh);
|
||||
void owLoop();
|
||||
void owIdle(void) ;
|
||||
void owIdle(void) ;
|
||||
int owFind(DeviceAddress addr);
|
||||
void owAdd (DeviceAddress addr);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -19,8 +19,10 @@ e-mail anklimov@gmail.com
|
||||
*/
|
||||
|
||||
#include "utils.h"
|
||||
#include "options.h"
|
||||
#include "stdarg.h"
|
||||
|
||||
#if defined(__SAM3X8E__)
|
||||
#if defined(__SAM3X8E__) || defined(ARDUINO_ARCH_STM32F1)
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
|
||||
@@ -30,6 +32,13 @@ extern "C" {
|
||||
}
|
||||
#endif
|
||||
|
||||
const char outTopic[] PROGMEM = OUTTOPIC;
|
||||
const char inTopic[] PROGMEM = INTOPIC;
|
||||
const char homeTopic[] PROGMEM = HOMETOPIC;
|
||||
extern char *deviceName;
|
||||
extern aJsonObject *topics;
|
||||
|
||||
|
||||
void PrintBytes(uint8_t *addr, uint8_t count, bool newline) {
|
||||
for (uint8_t i = 0; i < count; i++) {
|
||||
Serial.print(addr[i] >> 4, HEX);
|
||||
@@ -53,7 +62,7 @@ void SetBytes(uint8_t *addr, uint8_t count, char *out) {
|
||||
|
||||
|
||||
byte HEX2DEC(char i) {
|
||||
byte v;
|
||||
byte v=0;
|
||||
if ('a' <= i && i <= 'f') { v = i - 97 + 10; }
|
||||
else if ('A' <= i && i <= 'F') { v = i - 65 + 10; }
|
||||
else if ('0' <= i && i <= '9') { v = i - 48; }
|
||||
@@ -80,20 +89,34 @@ int getInt(char **chan) {
|
||||
}
|
||||
|
||||
|
||||
#if defined(ESP8266)
|
||||
#if defined(ARDUINO_ARCH_ESP32) || defined(ESP8266)
|
||||
unsigned long freeRam ()
|
||||
{return system_get_free_heap_size();}
|
||||
#endif
|
||||
|
||||
#if defined(__AVR__)
|
||||
unsigned long freeRam ()
|
||||
unsigned long freeRam ()
|
||||
{
|
||||
extern int __heap_start, *__brkval;
|
||||
int v;
|
||||
return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
|
||||
extern int __heap_start, *__brkval;
|
||||
int v;
|
||||
return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(ARDUINO_ARCH_STM32F1)
|
||||
extern char _end;
|
||||
extern "C" char *sbrk(int i);
|
||||
|
||||
unsigned long freeRam() {
|
||||
char *heapend = sbrk(0);
|
||||
register char *stack_ptr asm( "sp" );
|
||||
struct mallinfo mi = mallinfo();
|
||||
|
||||
return stack_ptr - heapend + mi.fordblks;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__SAM3X8E__)
|
||||
extern char _end;
|
||||
extern "C" char *sbrk(int i);
|
||||
@@ -110,6 +133,23 @@ unsigned long freeRam() {
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(NRF5)
|
||||
extern char _end;
|
||||
extern "C" char *sbrk(int i);
|
||||
|
||||
unsigned long freeRam() {
|
||||
char *ramstart = (char *) 0x20070000;
|
||||
char *ramend = (char *) 0x20088000;
|
||||
char *heapend = sbrk(0);
|
||||
register char *stack_ptr asm( "sp" );
|
||||
//struct mallinfo mi = mallinfo();
|
||||
|
||||
return stack_ptr - heapend;// + mi.fordblks;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
void parseBytes(const char *str, char separator, byte *bytes, int maxBytes, int base) {
|
||||
for (int i = 0; i < maxBytes; i++) {
|
||||
bytes[i] = strtoul(str, NULL, base); // Convert byte
|
||||
@@ -119,4 +159,258 @@ void parseBytes(const char *str, char separator, byte *bytes, int maxBytes, int
|
||||
}
|
||||
str++; // Point to next character after separator
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void printFloatValueToStr(float value, char *valstr) {
|
||||
#if defined(ESP8266) || defined(ARDUINO_ARCH_ESP32)
|
||||
sprintf(valstr, "%2.1f", value);
|
||||
#endif
|
||||
#if defined(__AVR__)
|
||||
sprintf(valstr, "%d", (int)value);
|
||||
int fractional = 10.0*((float)abs(value)-(float)abs((int)value));
|
||||
int val_len =strlen(valstr);
|
||||
valstr[val_len]='.';
|
||||
valstr[val_len+1]='0'+fractional;
|
||||
valstr[val_len+2]='\0';
|
||||
#endif
|
||||
#if defined(__SAM3X8E__)
|
||||
sprintf(valstr, "%2.1f",value);
|
||||
#endif
|
||||
}
|
||||
|
||||
#define ARDBUFFER 16 //Buffer for storing intermediate strings. Performance may vary depending on size.
|
||||
|
||||
int log(const char *str, ...)//TODO: __FlashStringHelper str support
|
||||
{
|
||||
int i, count=0, j=0, flag=0;
|
||||
char temp[ARDBUFFER+1];
|
||||
for(i=0; str[i]!='\0';i++) if(str[i]=='%') count++; //Evaluate number of arguments required to be printed
|
||||
|
||||
va_list argv;
|
||||
va_start(argv, count);
|
||||
for(i=0,j=0; str[i]!='\0';i++) //Iterate over formatting string
|
||||
{
|
||||
if(str[i]=='%')
|
||||
{
|
||||
//Clear buffer
|
||||
temp[j] = '\0';
|
||||
Serial.print(temp);
|
||||
j=0;
|
||||
temp[0] = '\0';
|
||||
|
||||
//Process argument
|
||||
switch(str[++i])
|
||||
{
|
||||
case 'd': debugSerial.print(va_arg(argv, int));
|
||||
break;
|
||||
case 'l': debugSerial.print(va_arg(argv, long));
|
||||
break;
|
||||
case 'f': debugSerial.print(va_arg(argv, double));
|
||||
break;
|
||||
case 'c': debugSerial.print((char)va_arg(argv, int));
|
||||
break;
|
||||
case 's': debugSerial.print(va_arg(argv, char *));
|
||||
break;
|
||||
default: ;
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
//Add to buffer
|
||||
temp[j] = str[i];
|
||||
j = (j+1)%ARDBUFFER;
|
||||
if(j==0) //If buffer is full, empty buffer.
|
||||
{
|
||||
temp[ARDBUFFER] = '\0';
|
||||
debugSerial.print(temp);
|
||||
temp[0]='\0';
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Serial.println(); //Print trailing newline
|
||||
return count + 1; //Return number of arguments detected
|
||||
}
|
||||
|
||||
/* Code borrowed from http://forum.arduino.cc/index.php?topic=289190.0
|
||||
Awesome work Mark T!*/
|
||||
|
||||
|
||||
__attribute__ ((section (".ramfunc")))
|
||||
|
||||
void ReadUniqueID( unsigned int * pdwUniqueID )
|
||||
{
|
||||
unsigned int status ;
|
||||
|
||||
#if defined(__SAM3X8E__)
|
||||
|
||||
/* Send the Start Read unique Identifier command (STUI) by writing the Flash Command Register with the STUI command.*/
|
||||
EFC1->EEFC_FCR = (0x5A << 24) | EFC_FCMD_STUI;
|
||||
do
|
||||
{
|
||||
status = EFC1->EEFC_FSR ;
|
||||
} while ( (status & EEFC_FSR_FRDY) == EEFC_FSR_FRDY ) ;
|
||||
|
||||
/* The Unique Identifier is located in the first 128 bits of the Flash memory mapping. So, at the address 0x400000-0x400003. */
|
||||
pdwUniqueID[0] = *(uint32_t *)IFLASH1_ADDR;
|
||||
pdwUniqueID[1] = *(uint32_t *)(IFLASH1_ADDR + 4);
|
||||
pdwUniqueID[2] = *(uint32_t *)(IFLASH1_ADDR + 8);
|
||||
pdwUniqueID[3] = *(uint32_t *)(IFLASH1_ADDR + 12);
|
||||
|
||||
/* To stop the Unique Identifier mode, the user needs to send the Stop Read unique Identifier
|
||||
command (SPUI) by writing the Flash Command Register with the SPUI command. */
|
||||
EFC1->EEFC_FCR = (0x5A << 24) | EFC_FCMD_SPUI ;
|
||||
|
||||
/* When the Stop read Unique Unique Identifier command (SPUI) has been performed, the
|
||||
FRDY bit in the Flash Programming Status Register (EEFC_FSR) rises. */
|
||||
do
|
||||
{
|
||||
status = EFC1->EEFC_FSR ;
|
||||
} while ( (status & EEFC_FSR_FRDY) != EEFC_FSR_FRDY ) ;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
int inet_aton(const char* aIPAddrString, IPAddress& aResult)
|
||||
{
|
||||
// See if we've been given a valid IP address
|
||||
const char* p =aIPAddrString;
|
||||
while (*p &&
|
||||
( (*p == '.') || (*p >= '0') || (*p <= '9') ))
|
||||
{
|
||||
p++;
|
||||
}
|
||||
|
||||
if (*p == '\0')
|
||||
{
|
||||
// It's looking promising, we haven't found any invalid characters
|
||||
p = aIPAddrString;
|
||||
int segment =0;
|
||||
int segmentValue =0;
|
||||
while (*p && (segment < 4))
|
||||
{
|
||||
if (*p == '.')
|
||||
{
|
||||
// We've reached the end of a segment
|
||||
if (segmentValue > 255)
|
||||
{
|
||||
// You can't have IP address segments that don't fit in a byte
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
aResult[segment] = (byte)segmentValue;
|
||||
segment++;
|
||||
segmentValue = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Next digit
|
||||
segmentValue = (segmentValue*10)+(*p - '0');
|
||||
}
|
||||
p++;
|
||||
}
|
||||
// We've reached the end of address, but there'll still be the last
|
||||
// segment to deal with
|
||||
if ((segmentValue > 255) || (segment > 3))
|
||||
{
|
||||
// You can't have IP address segments that don't fit in a byte,
|
||||
// or more than four segments
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
aResult[segment] = (byte)segmentValue;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as ipaddr_ntoa, but reentrant since a user-supplied buffer is used.
|
||||
*
|
||||
* @param addr ip address in network order to convert
|
||||
* @param buf target buffer where the string is stored
|
||||
* @param buflen length of buf
|
||||
* @return either pointer to buf which now holds the ASCII
|
||||
* representation of addr or NULL if buf was too small
|
||||
*/
|
||||
char *inet_ntoa_r(IPAddress addr, char *buf, int buflen)
|
||||
{
|
||||
short n;
|
||||
char intbuf[4];
|
||||
|
||||
|
||||
buf[0]=0;
|
||||
for(n = 0; n < 4; n++) {
|
||||
if (addr[n]>255) addr[n]=-1;
|
||||
itoa(addr[n],intbuf,10);
|
||||
strncat(buf,intbuf,buflen);
|
||||
if (n<3) strncat(buf,".",buflen);
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
void printIPAddress(IPAddress ipAddress) {
|
||||
for (byte i = 0; i < 4; i++)
|
||||
#ifdef WITH_PRINTEX_LIB
|
||||
(i < 3) ? debugSerial << (ipAddress[i]) << F(".") : debugSerial << (ipAddress[i])<<F(", ");
|
||||
#else
|
||||
(i < 3) ? debugSerial << _DEC(ipAddress[i]) << F(".") : debugSerial << _DEC(ipAddress[i]) << F(", ");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
char* setTopic(char* buf, int8_t buflen, topicType tt, char* suffix=NULL)
|
||||
{
|
||||
aJsonObject *_root = NULL;
|
||||
aJsonObject *_l2 = NULL;
|
||||
|
||||
if (topics && topics->type == aJson_Object)
|
||||
{
|
||||
_root = aJson.getObjectItem(topics, "root");
|
||||
switch (tt) {
|
||||
case T_OUT:
|
||||
_l2 = aJson.getObjectItem(topics, "out");
|
||||
break;
|
||||
case T_BCST:
|
||||
_l2 = aJson.getObjectItem(topics, "bcst");
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if (_root) strncpy(buf,_root->valuestring,buflen);
|
||||
else strncpy_P(buf,homeTopic,buflen);
|
||||
strncat(buf,"/",buflen);
|
||||
|
||||
if (_l2) strncat(buf,_l2->valuestring,buflen);
|
||||
else
|
||||
switch (tt) {
|
||||
case T_DEV:
|
||||
strncat(buf,deviceName,buflen);
|
||||
break;
|
||||
case T_OUT:
|
||||
strncat_P(buf,outTopic,buflen);
|
||||
break;
|
||||
case T_BCST:
|
||||
strncat_P(buf,inTopic,buflen); /////
|
||||
break;
|
||||
}
|
||||
strncat(buf,"/",buflen);
|
||||
if (suffix) strncat(buf,suffix,buflen);
|
||||
|
||||
return buf;
|
||||
|
||||
}
|
||||
|
||||
#pragma message(VAR_NAME_VALUE(debugSerial))
|
||||
#pragma message(VAR_NAME_VALUE(SERIAL_BAUD))
|
||||
|
||||
@@ -19,13 +19,38 @@ e-mail anklimov@gmail.com
|
||||
*/
|
||||
#define Q(x) #x
|
||||
#define QUOTE(x) Q(x)
|
||||
#define VALUE_TO_STRING(x) #x
|
||||
#define VALUE(x) VALUE_TO_STRING(x)
|
||||
#define VAR_NAME_VALUE(var) #var "=" VALUE(var)
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <IPAddress.h>
|
||||
#include "aJSON.h"
|
||||
#include "options.h"
|
||||
#ifdef WITH_PRINTEX_LIB
|
||||
#include "PrintEx.h"
|
||||
using namespace ios;
|
||||
#else
|
||||
#include "Streaming.h"
|
||||
#endif
|
||||
|
||||
void PrintBytes(uint8_t* addr, uint8_t count, bool newline=0);
|
||||
enum topicType {
|
||||
T_DEV = 1,
|
||||
T_BCST= 2,
|
||||
T_OUT = 3
|
||||
};
|
||||
|
||||
void PrintBytes(uint8_t* addr, uint8_t count, bool newline);
|
||||
void SetBytes(uint8_t* addr, uint8_t count, char * out);
|
||||
void SetAddr(char * out, uint8_t* addr);
|
||||
uint8_t HEX2DEC(char i);
|
||||
int getInt(char ** chan);
|
||||
unsigned long freeRam ();
|
||||
void parseBytes(const char* str, char separator, byte* bytes, int maxBytes, int base);
|
||||
void parseBytes(const char* str, char separator, byte* bytes, int maxBytes, int base);
|
||||
int log(const char *str, ...);
|
||||
void printFloatValueToStr(float value, char *valstr);
|
||||
void ReadUniqueID( unsigned int * pdwUniqueID );
|
||||
int inet_aton(const char* aIPAddrString, IPAddress& aResult);
|
||||
char *inet_ntoa_r(IPAddress addr, char *buf, int buflen);
|
||||
void printIPAddress(IPAddress ipAddress);
|
||||
char* setTopic(char* buf, int8_t buflen, topicType tt, char* suffix = NULL);
|
||||
|
||||
2
mosquitto_examples.sh
Normal file
2
mosquitto_examples.sh
Normal file
@@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env bash
|
||||
mosquitto_pub -t 'domoticz/in' -h broker_url -p port -u user -P pass -m '{"command": "udevice", "idx": 20, "svalue": "15"}'
|
||||
2
pioenvs.sh
Executable file
2
pioenvs.sh
Executable file
@@ -0,0 +1,2 @@
|
||||
#! /bin/bash
|
||||
echo /tmp/$1/pioenvs
|
||||
2
piolibdeps.sh
Executable file
2
piolibdeps.sh
Executable file
@@ -0,0 +1,2 @@
|
||||
#! /bin/bash
|
||||
echo /tmp/$1/piolibdeps
|
||||
463
platformio.ini
463
platformio.ini
@@ -9,172 +9,363 @@
|
||||
; http://docs.platformio.org/page/projectconf.html
|
||||
[platformio]
|
||||
src_dir = lighthub
|
||||
env_default =
|
||||
due-5500
|
||||
; controllino
|
||||
; megaatmega2560-net
|
||||
; megaatmega2560-5500
|
||||
; due
|
||||
; esp8266
|
||||
|
||||
env_default = megaatmega2560-net
|
||||
;monitor_speed = 115200
|
||||
; megaatmega2560
|
||||
; megaatmega2560-net
|
||||
; due
|
||||
; esp8266
|
||||
; esp32
|
||||
; megaatmega2560-5500
|
||||
; due-5500
|
||||
; controllino
|
||||
; stm32
|
||||
; esp32-evb
|
||||
; nrf52840_dk
|
||||
|
||||
|
||||
;build_dir = /tmp/pioenvs
|
||||
;libdeps_dir = /tmp/piolibdeps
|
||||
[env:nrf52840_dk]
|
||||
platform = nordicnrf52
|
||||
board = nrf52840_dk
|
||||
;upload_protocol = mbed
|
||||
;upload_port = /dev/cu.SLAB_USBtoUART
|
||||
framework = arduino
|
||||
build_flags = !bash check_custom_build_flags_nrf52840.sh
|
||||
lib_ignore =
|
||||
DmxSimple
|
||||
DMXSerial
|
||||
DmxDue
|
||||
EEPROM
|
||||
SD
|
||||
SdFat
|
||||
WifiManager
|
||||
Ethernet
|
||||
Ethernet3
|
||||
httpClient
|
||||
FastLED
|
||||
ESPDMX
|
||||
DueFlashStorage
|
||||
PrintEx
|
||||
DHT sensor library
|
||||
DHT sensor library for ESPx
|
||||
Adafruit Unified Sensor
|
||||
WebServer
|
||||
; Adafruit_Sensor
|
||||
lib_deps =
|
||||
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
||||
https://github.com/anklimov/DS2482_OneWire
|
||||
Ethernet2
|
||||
ESP8266HTTPClient
|
||||
https://github.com/anklimov/aJson
|
||||
https://github.com/anklimov/CmdArduino
|
||||
https://github.com/anklimov/ModbusMaster
|
||||
https://github.com/knolleary/pubsubclient.git
|
||||
; https://github.com/anklimov/Artnet.git
|
||||
; FastLED
|
||||
; Adafruit Unified Sensor
|
||||
; DHT sensor library for ESPx
|
||||
; DHT sensor library
|
||||
Streaming
|
||||
https://github.com/anklimov/NRFFlashStorage
|
||||
; https://github.com/livello/PrintEx#is-select-redecl
|
||||
|
||||
|
||||
[env:esp32]
|
||||
platform = espressif32
|
||||
framework = arduino
|
||||
;board = pico32
|
||||
board = esp32-evb
|
||||
upload_speed = 115200
|
||||
build_flags = !bash check_custom_build_flags_esp32.sh
|
||||
lib_ignore =
|
||||
DmxSimple
|
||||
DMXSerial
|
||||
DmxDue
|
||||
DueFlashStorage
|
||||
SD
|
||||
SdFat
|
||||
Ethernet
|
||||
Ethernet2
|
||||
Ethernet3
|
||||
HTTPClient
|
||||
httpClient
|
||||
EEPROM
|
||||
https://github.com/anklimov/ModbusMaster
|
||||
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
||||
https://github.com/anklimov/DS2482_OneWire
|
||||
DS2482_OneWire
|
||||
OneWire
|
||||
DallasTemperature
|
||||
ModbusMaster
|
||||
Artnet
|
||||
https://github.com/anklimov/Artnet.git
|
||||
FastLED
|
||||
Adafruit Unified Sensor
|
||||
DHT sensor library for ESPx
|
||||
DHT sensor library
|
||||
Wire
|
||||
;WifiManager
|
||||
;HTTPClient
|
||||
;HttpClient
|
||||
lib_deps =
|
||||
https://github.com/ebenolson/WIFIMANAGER-ESP32.git
|
||||
https://github.com/zhouhan0126/WebServer-esp32.git
|
||||
https://github.com/arduino-libraries/ArduinoHttpClient.git
|
||||
https://github.com/anklimov/aJson
|
||||
https://github.com/anklimov/CmdArduino
|
||||
https://github.com/knolleary/pubsubclient.git
|
||||
Streaming
|
||||
https://github.com/anklimov/NRFFlashStorage
|
||||
[env:due]
|
||||
platform = atmelsam
|
||||
framework = arduino
|
||||
board = due
|
||||
lib_ldf_mode = chain+
|
||||
build_flags = !echo -n "-DPIO_SRC_REV="$(git rev-parse --short HEAD)
|
||||
build_flags = !bash check_custom_build_flags_due.sh
|
||||
lib_ignore =
|
||||
DHT sensor library for ESPx
|
||||
DMXSerial
|
||||
DmxSimple
|
||||
httpClient
|
||||
ESPDMX
|
||||
WifiManager
|
||||
Ethernet3
|
||||
NRFFlashStorage
|
||||
WebServer
|
||||
lib_deps =
|
||||
https://github.com/sebnil/DueFlashStorage
|
||||
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
||||
https://github.com/anklimov/DS2482_OneWire
|
||||
https://github.com/anklimov/DmxDue
|
||||
https://github.com/anklimov/ArduinoHttpClient
|
||||
https://github.com/anklimov/aJson
|
||||
https://github.com/anklimov/CmdArduino
|
||||
https://github.com/anklimov/ModbusMaster
|
||||
https://github.com/anklimov/Ethernet
|
||||
; https://github.com/PaulStoffregen/SPI.git
|
||||
https://github.com/knolleary/pubsubclient.git
|
||||
https://github.com/anklimov/Artnet.git
|
||||
FastLED
|
||||
161
|
||||
322
|
||||
https://github.com/sebnil/DueFlashStorage
|
||||
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
||||
https://github.com/anklimov/DS2482_OneWire
|
||||
https://github.com/anklimov/DmxDue
|
||||
https://github.com/anklimov/ArduinoHttpClient
|
||||
https://github.com/anklimov/aJson
|
||||
https://github.com/anklimov/CmdArduino
|
||||
https://github.com/anklimov/ModbusMaster
|
||||
https://github.com/anklimov/Ethernet
|
||||
https://github.com/knolleary/pubsubclient.git
|
||||
https://github.com/anklimov/Artnet.git
|
||||
FastLED
|
||||
SD
|
||||
SdFat
|
||||
Adafruit Unified Sensor
|
||||
DHT sensor library
|
||||
https://github.com/arcao/Syslog.git
|
||||
Streaming
|
||||
|
||||
|
||||
[env:megaatmega2560]
|
||||
platform = atmelavr
|
||||
board = megaatmega2560
|
||||
;upload_port = net:192.168.88.31:23
|
||||
framework = arduino
|
||||
;lib_ldf_mode = chain+
|
||||
build_flags = !echo -n "-DPIO_SRC_REV="$(git rev-parse --short HEAD)
|
||||
build_flags = !bash check_custom_build_flags_mega2560.sh
|
||||
lib_ignore =
|
||||
DHT sensor library for ESPx
|
||||
DmxDue
|
||||
DueFlashStorage
|
||||
WifiManager
|
||||
Ethernet3
|
||||
HTTPClient
|
||||
NRFFlashStorage
|
||||
WebServer
|
||||
lib_deps =
|
||||
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
||||
https://github.com/anklimov/DS2482_OneWire
|
||||
https://github.com/anklimov/DmxSimple
|
||||
https://github.com/anklimov/httpClient
|
||||
https://github.com/anklimov/aJson
|
||||
https://github.com/anklimov/CmdArduino
|
||||
https://github.com/anklimov/ModbusMaster
|
||||
https://github.com/anklimov/DMXSerial
|
||||
https://github.com/anklimov/Ethernet
|
||||
https://github.com/PaulStoffregen/SPI.git
|
||||
https://github.com/knolleary/pubsubclient.git
|
||||
https://github.com/anklimov/Artnet.git
|
||||
FastLED
|
||||
; 161
|
||||
; 322
|
||||
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
||||
https://github.com/anklimov/DS2482_OneWire
|
||||
https://github.com/anklimov/DmxSimple
|
||||
https://github.com/anklimov/httpClient
|
||||
https://github.com/anklimov/aJson
|
||||
https://github.com/anklimov/CmdArduino
|
||||
https://github.com/anklimov/ModbusMaster
|
||||
https://github.com/anklimov/DMXSerial
|
||||
https://github.com/anklimov/Ethernet
|
||||
https://github.com/knolleary/pubsubclient.git
|
||||
https://github.com/anklimov/Artnet.git
|
||||
FastLED
|
||||
EEPROM
|
||||
Adafruit Unified Sensor
|
||||
DHT sensor library
|
||||
https://github.com/arcao/Syslog.git
|
||||
Streaming
|
||||
|
||||
[env:esp8266]
|
||||
platform = espressif8266
|
||||
framework = arduino
|
||||
board = nodemcuv2
|
||||
build_flags = !bash check_custom_build_flags_esp8266.sh
|
||||
lib_ignore =
|
||||
DmxSimple
|
||||
DMXSerial
|
||||
DmxDue
|
||||
DueFlashStorage
|
||||
SD
|
||||
SdFat
|
||||
httpClient
|
||||
Ethernet3
|
||||
NRFFlashStorage
|
||||
lib_deps =
|
||||
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
||||
https://github.com/anklimov/DS2482_OneWire
|
||||
https://github.com/anklimov/ESP-Dmx
|
||||
ESP8266HTTPClient
|
||||
https://github.com/anklimov/aJson
|
||||
https://github.com/anklimov/CmdArduino
|
||||
https://github.com/anklimov/ModbusMaster
|
||||
https://github.com/knolleary/pubsubclient.git
|
||||
https://github.com/anklimov/Artnet.git
|
||||
FastLED
|
||||
Adafruit Unified Sensor
|
||||
DHT sensor library for ESPx
|
||||
DHT sensor library
|
||||
WifiManager
|
||||
https://github.com/arcao/Syslog.git
|
||||
Streaming
|
||||
|
||||
[env:megaatmega2560-net]
|
||||
platform = atmelavr
|
||||
board = megaatmega2560
|
||||
framework = arduino
|
||||
upload_port = net:192.168.88.2:23000
|
||||
;lib_ldf_mode = chain+
|
||||
build_flags = !echo -n "-DPIO_SRC_REV="$(git rev-parse --short HEAD)
|
||||
build_flags = !bash check_custom_build_flags_mega2560-net.sh
|
||||
lib_ignore =
|
||||
DHT sensor library for ESPx
|
||||
DmxDue
|
||||
DueFlashStorage
|
||||
ESP-Dmx
|
||||
WifiManager
|
||||
Ethernet3
|
||||
Ethernet2
|
||||
NRFFlashStorage
|
||||
WebServer
|
||||
lib_deps =
|
||||
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
||||
https://github.com/anklimov/DS2482_OneWire
|
||||
https://github.com/anklimov/DmxSimple
|
||||
https://github.com/anklimov/httpClient
|
||||
https://github.com/anklimov/aJson
|
||||
https://github.com/anklimov/CmdArduino
|
||||
https://github.com/anklimov/ModbusMaster
|
||||
https://github.com/anklimov/DMXSerial
|
||||
https://github.com/anklimov/Ethernet
|
||||
https://github.com/PaulStoffregen/SPI.git
|
||||
https://github.com/knolleary/pubsubclient.git
|
||||
https://github.com/anklimov/Artnet.git
|
||||
FastLED
|
||||
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
||||
https://github.com/anklimov/DS2482_OneWire
|
||||
https://github.com/anklimov/DmxSimple
|
||||
https://github.com/anklimov/httpClient
|
||||
https://github.com/anklimov/aJson
|
||||
https://github.com/anklimov/CmdArduino
|
||||
https://github.com/anklimov/ModbusMaster
|
||||
https://github.com/anklimov/DMXSerial
|
||||
https://github.com/anklimov/Ethernet
|
||||
https://github.com/knolleary/pubsubclient.git
|
||||
https://github.com/anklimov/Artnet.git
|
||||
FastLED
|
||||
Adafruit Unified Sensor
|
||||
DHT sensor library
|
||||
https://github.com/arcao/Syslog.git
|
||||
Streaming
|
||||
|
||||
[env:due-5500]
|
||||
platform = atmelsam
|
||||
framework = arduino
|
||||
board = due
|
||||
build_flags = !bash check_custom_build_flags_due-5500.sh
|
||||
lib_ignore =
|
||||
DHT sensor library for ESPx
|
||||
https://github.com/anklimov/Ethernet
|
||||
ESP-Dmx
|
||||
DMXSerial
|
||||
ESPDMX
|
||||
WifiManager
|
||||
DmxSimple
|
||||
httpClient
|
||||
Ethernet
|
||||
Ethernet3
|
||||
NRFFlashStorage
|
||||
WebServer
|
||||
|
||||
lib_deps =
|
||||
|
||||
https://github.com/sebnil/DueFlashStorage
|
||||
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
||||
https://github.com/anklimov/DS2482_OneWire
|
||||
https://github.com/anklimov/DmxDue
|
||||
https://github.com/anklimov/ArduinoHttpClient
|
||||
https://github.com/anklimov/aJson
|
||||
https://github.com/anklimov/CmdArduino
|
||||
https://github.com/anklimov/ModbusMaster
|
||||
https://github.com/anklimov/Ethernet2
|
||||
https://github.com/knolleary/pubsubclient.git
|
||||
https://github.com/anklimov/Artnet.git
|
||||
FastLED
|
||||
SD
|
||||
SdFat
|
||||
Adafruit Unified Sensor
|
||||
DHT sensor library
|
||||
https://github.com/arcao/Syslog.git
|
||||
Streaming
|
||||
https://github.com/livello/PrintEx#is-select-redecl
|
||||
|
||||
|
||||
[env:controllino]
|
||||
platform = atmelavr
|
||||
board = megaatmega2560
|
||||
framework = arduino
|
||||
build_flags = !echo -n "-DPIO_SRC_REV="$(git rev-parse --short HEAD)
|
||||
build_flags = -D CONTROLLINO -D CUSTOM_FIRMWARE_MAC=de:ad:be:ef:fe:07
|
||||
build_flags = !bash check_custom_build_flags_controllino.sh
|
||||
lib_ignore =
|
||||
DHT sensor library for ESPx
|
||||
DmxDue
|
||||
DueFlashStorage
|
||||
ESP-Dmx
|
||||
WifiManager
|
||||
Ethernet3
|
||||
Ethernet2
|
||||
NRFFlashStorage
|
||||
WebServer
|
||||
lib_deps =
|
||||
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
||||
https://github.com/anklimov/DS2482_OneWire
|
||||
https://github.com/anklimov/DmxSimple
|
||||
https://github.com/anklimov/httpClient
|
||||
https://github.com/anklimov/aJson
|
||||
https://github.com/anklimov/CmdArduino
|
||||
https://github.com/anklimov/ModbusMaster
|
||||
https://github.com/anklimov/DMXSerial
|
||||
https://github.com/anklimov/Ethernet
|
||||
https://github.com/PaulStoffregen/SPI.git
|
||||
https://github.com/knolleary/pubsubclient.git
|
||||
https://github.com/anklimov/Artnet.git
|
||||
FastLED
|
||||
; 161
|
||||
; 322
|
||||
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
||||
https://github.com/anklimov/DS2482_OneWire
|
||||
https://github.com/anklimov/DmxSimple
|
||||
https://github.com/anklimov/httpClient
|
||||
https://github.com/anklimov/aJson
|
||||
https://github.com/anklimov/CmdArduino
|
||||
https://github.com/anklimov/ModbusMaster
|
||||
https://github.com/anklimov/DMXSerial
|
||||
https://github.com/anklimov/Ethernet
|
||||
https://github.com/knolleary/pubsubclient.git
|
||||
https://github.com/anklimov/Artnet.git
|
||||
FastLED
|
||||
EEPROM
|
||||
Adafruit Unified Sensor
|
||||
DHT sensor library
|
||||
Streaming
|
||||
https://github.com/livello/PrintEx#is-select-redecl
|
||||
|
||||
[env:due-5500]
|
||||
platform = atmelsam
|
||||
[env:stm32]
|
||||
platform = ststm32
|
||||
framework = arduino
|
||||
board = due
|
||||
lib_ldf_mode = chain+
|
||||
build_flags = !echo -n "-DPIO_SRC_REV="$(git rev-parse --short HEAD)
|
||||
build_flags = -D Wiz5500 -D ARTNET_ENABLE
|
||||
lib_deps =
|
||||
https://github.com/sebnil/DueFlashStorage
|
||||
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
||||
https://github.com/anklimov/DS2482_OneWire
|
||||
https://github.com/anklimov/DmxDue
|
||||
https://github.com/anklimov/ArduinoHttpClient
|
||||
https://github.com/anklimov/aJson
|
||||
https://github.com/anklimov/CmdArduino
|
||||
https://github.com/anklimov/ModbusMaster
|
||||
https://github.com/anklimov/Ethernet2
|
||||
; https://github.com/PaulStoffregen/SPI.git
|
||||
https://github.com/knolleary/pubsubclient.git
|
||||
https://github.com/anklimov/Artnet.git
|
||||
; https://github.com/brokentoaster/Syslog
|
||||
FastLED
|
||||
; 161
|
||||
; 322
|
||||
board = nucleo_f103rb
|
||||
upload_protocol = stlink
|
||||
debug_tool = stlink
|
||||
build_flags = !bash check_custom_build_flags_stm32.sh
|
||||
lib_ignore =
|
||||
DHT sensor library for ESPx
|
||||
DmxDue
|
||||
DueFlashStorage
|
||||
ESP-Dmx
|
||||
WifiManager
|
||||
FastLED
|
||||
Ethernet
|
||||
https://github.com/anklimov/Ethernet
|
||||
DMXSerial
|
||||
DmxSimple
|
||||
httpClient
|
||||
SD
|
||||
PrintEx
|
||||
Ethernet2
|
||||
Artnet
|
||||
Ethernet3
|
||||
NRFFlashStorage
|
||||
WebServer
|
||||
|
||||
[env:megaatmega2560-5500]
|
||||
platform = atmelavr
|
||||
board = megaatmega2560
|
||||
framework = arduino
|
||||
lib_ldf_mode = chain+
|
||||
build_flags = !echo -n "-DPIO_SRC_REV="$(git rev-parse --short HEAD)
|
||||
build_flags = -D Wiz5500 -D AVR_DMXOUT_PIN=18
|
||||
lib_deps =
|
||||
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
||||
https://github.com/anklimov/DS2482_OneWire
|
||||
https://github.com/anklimov/DmxSimple
|
||||
https://github.com/anklimov/httpClient
|
||||
https://github.com/anklimov/aJson
|
||||
https://github.com/anklimov/CmdArduino
|
||||
https://github.com/anklimov/ModbusMaster
|
||||
https://github.com/anklimov/DMXSerial
|
||||
https://github.com/anklimov/Ethernet2
|
||||
https://github.com/PaulStoffregen/SPI.git
|
||||
https://github.com/knolleary/pubsubclient.git
|
||||
https://github.com/anklimov/Artnet.git
|
||||
FastLED
|
||||
EEPROM
|
||||
; 161
|
||||
; 322
|
||||
|
||||
[env:esp8266]
|
||||
platform = espressif8266
|
||||
framework = arduino
|
||||
board = nodemcuv2
|
||||
lib_ldf_mode = chain+
|
||||
lib_deps =
|
||||
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
||||
https://github.com/anklimov/DS2482_OneWire
|
||||
https://github.com/anklimov/ESP-Dmx
|
||||
https://github.com/arduino-libraries/ArduinoHttpClient
|
||||
https://github.com/anklimov/aJson
|
||||
https://github.com/anklimov/CmdArduino
|
||||
https://github.com/anklimov/ModbusMaster
|
||||
https://github.com/anklimov/DMXSerial
|
||||
https://github.com/knolleary/pubsubclient.git
|
||||
https://github.com/anklimov/Artnet.git
|
||||
FastLED
|
||||
; DallasTemperature
|
||||
https://github.com/anklimov/aJson
|
||||
https://github.com/anklimov/CmdArduino
|
||||
ArduinoHttpClient
|
||||
https://github.com/knolleary/pubsubclient.git
|
||||
Adafruit Unified Sensor
|
||||
DHT sensor library
|
||||
Streaming
|
||||
|
||||
2
prepareDue.sh
Executable file
2
prepareDue.sh
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env bash
|
||||
sed -i -- 's/void USART0_Handler(void)/void USART0_Handler(void ) __attribute__((weak)); void USART0_Handler(void )/g' ~/.platformio/packages/framework-arduinosam/variants/arduino_due_x/variant.cpp
|
||||
Reference in New Issue
Block a user