mirror of
https://github.com/anklimov/lighthub
synced 2025-12-06 03:39:49 +03:00
Removed envs can be used with setting up build flags.
This commit is contained in:
@@ -1,4 +0,0 @@
|
||||
To avoid interrupt corflicts between DmxDue an USART1 need to copy patched file over DUE sys lib
|
||||
|
||||
Patch example for OSX:
|
||||
/Users/andrey/Library/Arduino15/packages/arduino/hardware/sam/1.6.11/variants/arduino_due_x/variant.cpp
|
||||
@@ -1,455 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2011 Arduino. All right reserved.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "variant.h"
|
||||
|
||||
/*
|
||||
* DUE Board pin | PORT | Label
|
||||
* ----------------+--------+-------
|
||||
* 0 | PA8 | "RX0"
|
||||
* 1 | PA9 | "TX0"
|
||||
* 2 TIOA0 | PB25 |
|
||||
* 3 TIOA7 | PC28 |
|
||||
* 4 NPCS1 | PA29 |
|
||||
* TIOB6 | PC26 |
|
||||
* 5 TIOA6 | PC25 |
|
||||
* 6 PWML7 | PC24 |
|
||||
* 7 PWML6 | PC23 |
|
||||
* 8 PWML5 | PC22 |
|
||||
* 9 PWML4 | PC21 |
|
||||
* 10 NPCS0 | PA28 |
|
||||
* TIOB7 | PC29 |
|
||||
* 11 TIOA8 | PD7 |
|
||||
* 12 TIOB8 | PD8 |
|
||||
* 13 TIOB0 | PB27 | LED AMBER "L"
|
||||
* 14 TXD3 | PD4 | "TX3"
|
||||
* 15 RXD3 | PD5 | "RX3"
|
||||
* 16 TXD1 | PA13 | "TX2"
|
||||
* 17 RXD1 | PA12 | "RX2"
|
||||
* 18 TXD0 | PA11 | "TX1"
|
||||
* 19 RXD0 | PA10 | "RX1"
|
||||
* 20 | PB12 | "SDA"
|
||||
* 21 | PB13 | "SCL"
|
||||
* 22 | PB26 |
|
||||
* 23 | PA14 |
|
||||
* 24 | PA15 |
|
||||
* 25 | PD0 |
|
||||
* 26 | PD1 |
|
||||
* 27 | PD2 |
|
||||
* 28 | PD3 |
|
||||
* 29 | PD6 |
|
||||
* 30 | PD9 |
|
||||
* 31 | PA7 |
|
||||
* 32 | PD10 |
|
||||
* 33 | PC1 |
|
||||
* 34 | PC2 |
|
||||
* 35 | PC3 |
|
||||
* 36 | PC4 |
|
||||
* 37 | PC5 |
|
||||
* 38 | PC6 |
|
||||
* 39 | PC7 |
|
||||
* 40 | PC8 |
|
||||
* 41 | PC9 |
|
||||
* 42 | PA19 |
|
||||
* 43 | PA20 |
|
||||
* 44 | PC19 |
|
||||
* 45 | PC18 |
|
||||
* 46 | PC17 |
|
||||
* 47 | PC16 |
|
||||
* 48 | PC15 |
|
||||
* 49 | PC14 |
|
||||
* 50 | PC13 |
|
||||
* 51 | PC12 |
|
||||
* 52 NPCS2 | PB21 |
|
||||
* 53 | PB14 |
|
||||
* 54 | PA16 | "A0"
|
||||
* 55 | PA24 | "A1"
|
||||
* 56 | PA23 | "A2"
|
||||
* 57 | PA22 | "A3"
|
||||
* 58 TIOB2 | PA6 | "A4"
|
||||
* 69 | PA4 | "A5"
|
||||
* 60 TIOB1 | PA3 | "A6"
|
||||
* 61 TIOA1 | PA2 | "A7"
|
||||
* 62 | PB17 | "A8"
|
||||
* 63 | PB18 | "A9"
|
||||
* 64 | PB19 | "A10"
|
||||
* 65 | PB20 | "A11"
|
||||
* 66 | PB15 | "DAC0"
|
||||
* 67 | PB16 | "DAC1"
|
||||
* 68 | PA1 | "CANRX"
|
||||
* 69 | PA0 | "CANTX"
|
||||
* 70 | PA17 | "SDA1"
|
||||
* 71 | PA18 | "SCL1"
|
||||
* 72 | PC30 | LED AMBER "RX"
|
||||
* 73 | PA21 | LED AMBER "TX"
|
||||
* 74 MISO | PA25 |
|
||||
* 75 MOSI | PA26 |
|
||||
* 76 SCLK | PA27 |
|
||||
* 77 NPCS0 | PA28 |
|
||||
* 78 NPCS3 | PB23 | unconnected!
|
||||
*
|
||||
* USB pin | PORT
|
||||
* ----------------+--------
|
||||
* ID | PB11
|
||||
* VBOF | PB10
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Pins descriptions
|
||||
*/
|
||||
extern const PinDescription g_APinDescription[]=
|
||||
{
|
||||
// 0 .. 53 - Digital pins
|
||||
// ----------------------
|
||||
// 0/1 - UART (Serial)
|
||||
{ PIOA, PIO_PA8A_URXD, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // URXD
|
||||
{ PIOA, PIO_PA9A_UTXD, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // UTXD
|
||||
|
||||
// 2
|
||||
{ PIOB, PIO_PB25B_TIOA0, ID_PIOB, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NOT_ON_PWM, TC0_CHA0 }, // TIOA0
|
||||
{ PIOC, PIO_PC28B_TIOA7, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NOT_ON_PWM, TC2_CHA7 }, // TIOA7
|
||||
{ PIOC, PIO_PC26B_TIOB6, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NOT_ON_PWM, TC2_CHB6 }, // TIOB6
|
||||
|
||||
// 5
|
||||
{ PIOC, PIO_PC25B_TIOA6, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NOT_ON_PWM, TC2_CHA6 }, // TIOA6
|
||||
{ PIOC, PIO_PC24B_PWML7, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM), NO_ADC, NO_ADC, PWM_CH7, NOT_ON_TIMER }, // PWML7
|
||||
{ PIOC, PIO_PC23B_PWML6, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM), NO_ADC, NO_ADC, PWM_CH6, NOT_ON_TIMER }, // PWML6
|
||||
{ PIOC, PIO_PC22B_PWML5, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM), NO_ADC, NO_ADC, PWM_CH5, NOT_ON_TIMER }, // PWML5
|
||||
{ PIOC, PIO_PC21B_PWML4, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM), NO_ADC, NO_ADC, PWM_CH4, NOT_ON_TIMER }, // PWML4
|
||||
// 10
|
||||
{ PIOC, PIO_PC29B_TIOB7, ID_PIOC, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NOT_ON_PWM, TC2_CHB7 }, // TIOB7
|
||||
{ PIOD, PIO_PD7B_TIOA8, ID_PIOD, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NOT_ON_PWM, TC2_CHA8 }, // TIOA8
|
||||
{ PIOD, PIO_PD8B_TIOB8, ID_PIOD, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NOT_ON_PWM, TC2_CHB8 }, // TIOB8
|
||||
|
||||
// 13 - AMBER LED
|
||||
{ PIOB, PIO_PB27B_TIOB0, ID_PIOB, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_TIMER), NO_ADC, NO_ADC, NOT_ON_PWM, TC0_CHB0 }, // TIOB0
|
||||
|
||||
// 14/15 - USART3 (Serial3)
|
||||
{ PIOD, PIO_PD4B_TXD3, ID_PIOD, PIO_PERIPH_B, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // TXD3
|
||||
{ PIOD, PIO_PD5B_RXD3, ID_PIOD, PIO_PERIPH_B, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // RXD3
|
||||
|
||||
// 16/17 - USART1 (Serial2)
|
||||
{ PIOA, PIO_PA13A_TXD1, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // TXD1
|
||||
{ PIOA, PIO_PA12A_RXD1, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // RXD1
|
||||
|
||||
// 18/19 - USART0 (Serial1)
|
||||
{ PIOA, PIO_PA11A_TXD0, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // TXD0
|
||||
{ PIOA, PIO_PA10A_RXD0, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // RXD0
|
||||
|
||||
// 20/21 - TWI1
|
||||
{ PIOB, PIO_PB12A_TWD1, ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // TWD1 - SDA0
|
||||
{ PIOB, PIO_PB13A_TWCK1, ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // TWCK1 - SCL0
|
||||
|
||||
// 22
|
||||
{ PIOB, PIO_PB26, ID_PIOB, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 22
|
||||
{ PIOA, PIO_PA14, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 23
|
||||
{ PIOA, PIO_PA15, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 24
|
||||
{ PIOD, PIO_PD0, ID_PIOD, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 25
|
||||
|
||||
// 26
|
||||
{ PIOD, PIO_PD1, ID_PIOD, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 26
|
||||
{ PIOD, PIO_PD2, ID_PIOD, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 27
|
||||
{ PIOD, PIO_PD3, ID_PIOD, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 28
|
||||
{ PIOD, PIO_PD6, ID_PIOD, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 29
|
||||
|
||||
// 30
|
||||
{ PIOD, PIO_PD9, ID_PIOD, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 30
|
||||
{ PIOA, PIO_PA7, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 31
|
||||
{ PIOD, PIO_PD10, ID_PIOD, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 32
|
||||
{ PIOC, PIO_PC1, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 33
|
||||
|
||||
// 34
|
||||
{ PIOC, PIO_PC2, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 34
|
||||
{ PIOC, PIO_PC3, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 35
|
||||
{ PIOC, PIO_PC4, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 36
|
||||
{ PIOC, PIO_PC5, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 37
|
||||
|
||||
// 38
|
||||
{ PIOC, PIO_PC6, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 38
|
||||
{ PIOC, PIO_PC7, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 39
|
||||
{ PIOC, PIO_PC8, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 40
|
||||
{ PIOC, PIO_PC9, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 41
|
||||
|
||||
// 42
|
||||
{ PIOA, PIO_PA19, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 42
|
||||
{ PIOA, PIO_PA20, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 43
|
||||
{ PIOC, PIO_PC19, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 44
|
||||
{ PIOC, PIO_PC18, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 45
|
||||
|
||||
// 46
|
||||
{ PIOC, PIO_PC17, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 46
|
||||
{ PIOC, PIO_PC16, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 47
|
||||
{ PIOC, PIO_PC15, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 48
|
||||
{ PIOC, PIO_PC14, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 49
|
||||
|
||||
// 50
|
||||
{ PIOC, PIO_PC13, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 50
|
||||
{ PIOC, PIO_PC12, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 51
|
||||
{ PIOB, PIO_PB21, ID_PIOB, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 52
|
||||
{ PIOB, PIO_PB14, ID_PIOB, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // PIN 53
|
||||
|
||||
|
||||
// 54 .. 65 - Analog pins
|
||||
// ----------------------
|
||||
{ PIOA, PIO_PA16X1_AD7, ID_PIOA, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC0, ADC7, NOT_ON_PWM, NOT_ON_TIMER }, // AD0
|
||||
{ PIOA, PIO_PA24X1_AD6, ID_PIOA, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC1, ADC6, NOT_ON_PWM, NOT_ON_TIMER }, // AD1
|
||||
{ PIOA, PIO_PA23X1_AD5, ID_PIOA, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC2, ADC5, NOT_ON_PWM, NOT_ON_TIMER }, // AD2
|
||||
{ PIOA, PIO_PA22X1_AD4, ID_PIOA, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC3, ADC4, NOT_ON_PWM, NOT_ON_TIMER }, // AD3
|
||||
// 58
|
||||
{ PIOA, PIO_PA6X1_AD3, ID_PIOA, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC4, ADC3, NOT_ON_PWM, TC0_CHB2 }, // AD4
|
||||
{ PIOA, PIO_PA4X1_AD2, ID_PIOA, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC5, ADC2, NOT_ON_PWM, NOT_ON_TIMER }, // AD5
|
||||
{ PIOA, PIO_PA3X1_AD1, ID_PIOA, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC6, ADC1, NOT_ON_PWM, TC0_CHB1 }, // AD6
|
||||
{ PIOA, PIO_PA2X1_AD0, ID_PIOA, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC7, ADC0, NOT_ON_PWM, TC0_CHA1 }, // AD7
|
||||
// 62
|
||||
{ PIOB, PIO_PB17X1_AD10, ID_PIOB, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC8, ADC10, NOT_ON_PWM, NOT_ON_TIMER }, // AD8
|
||||
{ PIOB, PIO_PB18X1_AD11, ID_PIOB, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC9, ADC11, NOT_ON_PWM, NOT_ON_TIMER }, // AD9
|
||||
{ PIOB, PIO_PB19X1_AD12, ID_PIOB, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC10, ADC12, NOT_ON_PWM, NOT_ON_TIMER }, // AD10
|
||||
{ PIOB, PIO_PB20X1_AD13, ID_PIOB, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC11, ADC13, NOT_ON_PWM, NOT_ON_TIMER }, // AD11
|
||||
|
||||
// 66/67 - DAC0/DAC1
|
||||
{ PIOB, PIO_PB15X1_DAC0, ID_PIOB, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC12, DA0, NOT_ON_PWM, NOT_ON_TIMER }, // DAC0
|
||||
{ PIOB, PIO_PB16X1_DAC1, ID_PIOB, PIO_INPUT, PIO_DEFAULT, PIN_ATTR_ANALOG, ADC13, DA1, NOT_ON_PWM, NOT_ON_TIMER }, // DAC1
|
||||
|
||||
// 68/69 - CANRX0/CANTX0
|
||||
{ PIOA, PIO_PA1A_CANRX0, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, ADC14, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // CANRX
|
||||
{ PIOA, PIO_PA0A_CANTX0, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, ADC15, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // CANTX
|
||||
|
||||
// 70/71 - TWI0
|
||||
{ PIOA, PIO_PA17A_TWD0, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // TWD0 - SDA1
|
||||
{ PIOA, PIO_PA18A_TWCK0, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // TWCK0 - SCL1
|
||||
|
||||
// 72/73 - LEDs
|
||||
{ PIOC, PIO_PC30, ID_PIOC, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // LED AMBER RXL
|
||||
{ PIOA, PIO_PA21, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // LED AMBER TXL
|
||||
|
||||
// 74/75/76 - SPI
|
||||
{ PIOA, PIO_PA25A_SPI0_MISO,ID_PIOA,PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // MISO
|
||||
{ PIOA, PIO_PA26A_SPI0_MOSI,ID_PIOA,PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // MOSI
|
||||
{ PIOA, PIO_PA27A_SPI0_SPCK,ID_PIOA,PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // SPCK
|
||||
|
||||
// 77 - SPI CS0
|
||||
{ PIOA, PIO_PA28A_SPI0_NPCS0,ID_PIOA,PIO_PERIPH_A,PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // NPCS0
|
||||
|
||||
// 78 - SPI CS3 (unconnected)
|
||||
{ PIOB, PIO_PB23B_SPI0_NPCS3,ID_PIOB,PIO_PERIPH_B,PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // NPCS3
|
||||
|
||||
// 79 .. 84 - "All pins" masks
|
||||
|
||||
// 79 - TWI0 all pins
|
||||
{ PIOA, PIO_PA17A_TWD0|PIO_PA18A_TWCK0, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_COMBO), NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER },
|
||||
// 80 - TWI1 all pins
|
||||
{ PIOB, PIO_PB12A_TWD1|PIO_PB13A_TWCK1, ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_COMBO), NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER },
|
||||
// 81 - UART (Serial) all pins
|
||||
{ PIOA, PIO_PA8A_URXD|PIO_PA9A_UTXD, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_COMBO), NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER },
|
||||
// 82 - USART0 (Serial1) all pins
|
||||
{ PIOA, PIO_PA11A_TXD0|PIO_PA10A_RXD0, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_COMBO), NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER },
|
||||
// 83 - USART1 (Serial2) all pins
|
||||
{ PIOA, PIO_PA13A_TXD1|PIO_PA12A_RXD1, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_COMBO), NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER },
|
||||
// 84 - USART3 (Serial3) all pins
|
||||
{ PIOD, PIO_PD4B_TXD3|PIO_PD5B_RXD3, ID_PIOD, PIO_PERIPH_B, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_COMBO), NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER },
|
||||
|
||||
// 85 - USB
|
||||
{ PIOB, PIO_PB11A_UOTGID|PIO_PB10A_UOTGVBOF, ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL,NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // ID - VBOF
|
||||
|
||||
// 86 - SPI CS2
|
||||
{ PIOB, PIO_PB21B_SPI0_NPCS2, ID_PIOB, PIO_PERIPH_B, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // NPCS2
|
||||
|
||||
// 87 - SPI CS1
|
||||
{ PIOA, PIO_PA29A_SPI0_NPCS1, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // NPCS1
|
||||
|
||||
// 88/89 - CANRX1/CANTX1 (same physical pin for 66/53)
|
||||
{ PIOB, PIO_PB15A_CANRX1, ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // CANRX1
|
||||
{ PIOB, PIO_PB14A_CANTX1, ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT, PIN_ATTR_DIGITAL, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }, // CANTX1
|
||||
|
||||
// 90 .. 91 - "All CAN pins" masks
|
||||
// 90 - CAN0 all pins
|
||||
{ PIOA, PIO_PA1A_CANRX0|PIO_PA0A_CANTX0, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_COMBO), NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER },
|
||||
// 91 - CAN1 all pins
|
||||
{ PIOB, PIO_PB15A_CANRX1|PIO_PB14A_CANTX1, ID_PIOB, PIO_PERIPH_A, PIO_DEFAULT, (PIN_ATTR_DIGITAL|PIN_ATTR_COMBO), NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER },
|
||||
|
||||
// END
|
||||
{ NULL, 0, 0, PIO_NOT_A_PIN, PIO_DEFAULT, 0, NO_ADC, NO_ADC, NOT_ON_PWM, NOT_ON_TIMER }
|
||||
} ;
|
||||
|
||||
|
||||
uint8_t g_pinStatus[PINS_COUNT] = {0};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* UART objects
|
||||
*/
|
||||
RingBuffer rx_buffer1;
|
||||
RingBuffer tx_buffer1;
|
||||
|
||||
UARTClass Serial(UART, UART_IRQn, ID_UART, &rx_buffer1, &tx_buffer1);
|
||||
void serialEvent() __attribute__((weak));
|
||||
void serialEvent() { }
|
||||
|
||||
// IT handlers
|
||||
void UART_Handler(void)
|
||||
{
|
||||
Serial.IrqHandler();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/*
|
||||
* USART objects
|
||||
*/
|
||||
RingBuffer rx_buffer2;
|
||||
RingBuffer rx_buffer3;
|
||||
RingBuffer rx_buffer4;
|
||||
RingBuffer tx_buffer2;
|
||||
RingBuffer tx_buffer3;
|
||||
RingBuffer tx_buffer4;
|
||||
|
||||
///USARTClass Serial1(USART0, USART0_IRQn, ID_USART0, &rx_buffer2, &tx_buffer2);
|
||||
void serialEvent1() __attribute__((weak));
|
||||
void serialEvent1() { }
|
||||
USARTClass Serial2(USART1, USART1_IRQn, ID_USART1, &rx_buffer3, &tx_buffer3);
|
||||
void serialEvent2() __attribute__((weak));
|
||||
void serialEvent2() { }
|
||||
USARTClass Serial3(USART3, USART3_IRQn, ID_USART3, &rx_buffer4, &tx_buffer4);
|
||||
void serialEvent3() __attribute__((weak));
|
||||
void serialEvent3() { }
|
||||
|
||||
// IT handlers
|
||||
|
||||
///void USART0_Handler(void)
|
||||
///{
|
||||
/// Serial1.IrqHandler();
|
||||
///}
|
||||
|
||||
void USART1_Handler(void)
|
||||
{
|
||||
Serial2.IrqHandler();
|
||||
}
|
||||
|
||||
void USART3_Handler(void)
|
||||
{
|
||||
Serial3.IrqHandler();
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void serialEventRun(void)
|
||||
{
|
||||
if (Serial.available()) serialEvent();
|
||||
/// if (Serial1.available()) serialEvent1();
|
||||
if (Serial2.available()) serialEvent2();
|
||||
if (Serial3.available()) serialEvent3();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void __libc_init_array(void);
|
||||
|
||||
void init( void )
|
||||
{
|
||||
SystemInit();
|
||||
|
||||
// Set Systick to 1ms interval, common to all SAM3 variants
|
||||
if (SysTick_Config(SystemCoreClock / 1000))
|
||||
{
|
||||
// Capture error
|
||||
while (true);
|
||||
}
|
||||
|
||||
// Initialize C library
|
||||
__libc_init_array();
|
||||
|
||||
// Disable pull-up on every pin
|
||||
for (unsigned i = 0; i < PINS_COUNT; i++)
|
||||
digitalWrite(i, LOW);
|
||||
|
||||
// Enable parallel access on PIO output data registers
|
||||
PIOA->PIO_OWER = 0xFFFFFFFF;
|
||||
PIOB->PIO_OWER = 0xFFFFFFFF;
|
||||
PIOC->PIO_OWER = 0xFFFFFFFF;
|
||||
PIOD->PIO_OWER = 0xFFFFFFFF;
|
||||
|
||||
// Initialize Serial port U(S)ART pins
|
||||
PIO_Configure(
|
||||
g_APinDescription[PINS_UART].pPort,
|
||||
g_APinDescription[PINS_UART].ulPinType,
|
||||
g_APinDescription[PINS_UART].ulPin,
|
||||
g_APinDescription[PINS_UART].ulPinConfiguration);
|
||||
digitalWrite(0, HIGH); // Enable pullup for RX0
|
||||
PIO_Configure(
|
||||
g_APinDescription[PINS_USART0].pPort,
|
||||
g_APinDescription[PINS_USART0].ulPinType,
|
||||
g_APinDescription[PINS_USART0].ulPin,
|
||||
g_APinDescription[PINS_USART0].ulPinConfiguration);
|
||||
PIO_Configure(
|
||||
g_APinDescription[PINS_USART1].pPort,
|
||||
g_APinDescription[PINS_USART1].ulPinType,
|
||||
g_APinDescription[PINS_USART1].ulPin,
|
||||
g_APinDescription[PINS_USART1].ulPinConfiguration);
|
||||
PIO_Configure(
|
||||
g_APinDescription[PINS_USART3].pPort,
|
||||
g_APinDescription[PINS_USART3].ulPinType,
|
||||
g_APinDescription[PINS_USART3].ulPin,
|
||||
g_APinDescription[PINS_USART3].ulPinConfiguration);
|
||||
|
||||
// Initialize USB pins
|
||||
PIO_Configure(
|
||||
g_APinDescription[PINS_USB].pPort,
|
||||
g_APinDescription[PINS_USB].ulPinType,
|
||||
g_APinDescription[PINS_USB].ulPin,
|
||||
g_APinDescription[PINS_USB].ulPinConfiguration);
|
||||
|
||||
// Initialize CAN pins
|
||||
PIO_Configure(
|
||||
g_APinDescription[PINS_CAN0].pPort,
|
||||
g_APinDescription[PINS_CAN0].ulPinType,
|
||||
g_APinDescription[PINS_CAN0].ulPin,
|
||||
g_APinDescription[PINS_CAN0].ulPinConfiguration);
|
||||
PIO_Configure(
|
||||
g_APinDescription[PINS_CAN1].pPort,
|
||||
g_APinDescription[PINS_CAN1].ulPinType,
|
||||
g_APinDescription[PINS_CAN1].ulPin,
|
||||
g_APinDescription[PINS_CAN1].ulPinConfiguration);
|
||||
|
||||
// Initialize Analog Controller
|
||||
pmc_enable_periph_clk(ID_ADC);
|
||||
adc_init(ADC, SystemCoreClock, ADC_FREQ_MAX, ADC_STARTUP_FAST);
|
||||
adc_configure_timing(ADC, 0, ADC_SETTLING_TIME_3, 1);
|
||||
adc_configure_trigger(ADC, ADC_TRIG_SW, 0); // Disable hardware trigger.
|
||||
adc_disable_interrupt(ADC, 0xFFFFFFFF); // Disable all ADC interrupts.
|
||||
adc_disable_all_channel(ADC);
|
||||
|
||||
// Initialize analogOutput module
|
||||
analogOutputInit();
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
70
README.md
70
README.md
@@ -1,34 +1,48 @@
|
||||
# LightHub
|
||||
is Flexible, Arduino-Mega/Arduino DUE/ESP8266 based SmartHome controller. [RU](https://geektimes.ru/post/295109/)
|
||||
|
||||
It allows connecting together:
|
||||
is Flexible, Arduino-Mega/Arduino DUE/ESP8266 open-software and open-hardware SmartHome controller. [RU](https://geektimes.ru/post/295109/) [HOME-site RU](http://lazyhome.ru)
|
||||
It may operate both:
|
||||
* On [especially designed hardware board](http://www.lazyhome.ru/index.php/featurerequest) with 16 optocoupled digital inputs, 16 ESD protected digital/analog Inputs/outputs, 8 open-collector outputs (up to 0.5A/50V), DMX IN/OUT, MODBUS RTU and hardware 1-wire support circuit.
|
||||
* On plain Arduino MEGA 2560, Arduino DUE, ESP8266 and even on [Controllino](http://controllino.biz/)
|
||||
(Controllino and ESP8266 is not tested enough and in experimental stage yet)
|
||||
|
||||
Lighthub allows connecting together:
|
||||
* Contact sensors (switches, buttons etc)
|
||||
* 1-Wire temperature sensors (up to 20 on single bus)
|
||||
* Standard nonexpensive Relay board with TTL inputs, (like this) to control AC powered lamps, floor heaters, boilers etc
|
||||
* Standard LED and AC DMX-512 dimmer boards
|
||||
* Modbus RTU devices (Currently, are deployed two types of Modbus devices: AC Dimmer and Ventilation set (Based on Vacon 10 controller)
|
||||
* Simple DMX wall sensor panel
|
||||
* Standard nonexpensive Relay board with TTL inputs, [like this](https://aliexpress.com/item/16-Channel-20A-Relay-Control-Module-for-Arduino-UNO-MEGA2560-R3-Raspberry-Pi/32747887693.html) to control AC powered lamps, floor heaters, boilers etc
|
||||
* [Standard nonexpensive LED dimmers](https://aliexpress.com/item/30-channel-27channel-Easy-DMX-LED-controller-dmx-decoder-driver-rgb-led-controller/2015743918.html) and [AC DMX-512 dimmers](https://aliexpress.com/item/DMX302-led-DMX-triac-dimmer-brightness-controller-AC90V-240V-Output-3channels-1A-CH-High-voltage-led/32822841266.html)
|
||||
* Modbus RTU devices (Currently, are deployed two types of Modbus devices: AC Dimmer and Ventilation set (Based on [Vacon 10 controller](http://files.danfoss.com/download/Drives/Vacon-10-Quick-Guide-DPD00714F1-UK.pdf))
|
||||
* Simple DMX wall sensor panel [like this](https://aliexpress.com/item/New-Ltech-D8-LED-rgb-RGBW-touch-panel-controller-DMX512-controller-DC12-24V-4-zones-4/32800199589.html)
|
||||
|
||||
Where is possible both, to configure local control/mapping between inputs and outputs (light, floor heating thermostats) and remote control from Openhab or Openhab2 Smarthome software
|
||||

|
||||
|
||||
Scalability 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 and propagate commands across network.
|
||||
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:
|
||||
* [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)
|
||||
* [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)
|
||||
|
||||
[Prease refer to our Wiki for insructions.](https://github.com/anklimov/lighthub/wiki/Configuring)
|
||||
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.
|
||||
|
||||
# [Please refer to our Wiki for insructions.](https://github.com/anklimov/lighthub/wiki/Configuring)
|
||||
* [Compiling and flashing](https://github.com/anklimov/lighthub/wiki/Compiling-and-flashing)
|
||||
* [Configuring](https://github.com/anklimov/lighthub/wiki/Configuring)
|
||||
* [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:lighthub.ino.hex:i
|
||||
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 lighthub.ino.bin -R
|
||||
/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)
|
||||
@@ -45,41 +59,42 @@ For patched libraries, appropriate GitHub repo URL provided:
|
||||
* 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
|
||||
* 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
|
||||
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 and has all functions
|
||||
AVR version is basic, long tome in production and have all functions
|
||||
*DMX-out is software (DMXSimple) on pin3
|
||||
|
||||
**SAM3X8E**:
|
||||
**SAM3X8E**: (Tested. Recomended hardware at current moment)
|
||||
* default PWM frequency
|
||||
* both, DMX-in and DMX-out are hardware USART based. Use USART1 (pins 18 and 19) for DMX-out and DMX-in
|
||||
|
||||
**ESP8266**:
|
||||
**ESP8266**: (Developed but not tested in production)
|
||||
* DMX-OUT on USART1 TX
|
||||
* DMX-IN - 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
|
||||
|
||||
There is first attempt to use Wiznet 5500 (still not stable enough)
|
||||
Need to use compiler directive -D Wiz5500 and https://github.com/anklimov/Ethernet2 library
|
||||
|
||||
Prefered way to compile project is using platformio toolchain, suitable for Arduino Due, and Arduino Mega2560, but work is still in progress.
|
||||
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 edit USART0_Handler method definition like this
|
||||
|
||||
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/)
|
||||
|
||||
@@ -128,6 +143,8 @@ platformio device monitor -b 115200
|
||||
* DMX_DISABLE //disable DMX support
|
||||
* MODBUS_DISABLE // disable Modbus support
|
||||
* OWIRE_DISABLE // disable OneWire support
|
||||
* ARTNET_ENABLE //Enable Artnet protocol support
|
||||
* CONTROLLINO //Change Modbus port, direction pins and Wiznet SS pins to be working on [Controllino](http://controllino.biz/)
|
||||
|
||||
|
||||
# Default compilation behavior:
|
||||
@@ -142,4 +159,9 @@ platformio device monitor -b 115200
|
||||
* DMX support enabled
|
||||
* Modbus support enabled
|
||||
* OneWire support enabled
|
||||
* Artnet disabled
|
||||
* Defailt MQTT input topic: /myhome/in
|
||||
* Default MQTT topic to publish device status: /myhome/s_out
|
||||
* Default Alarm output topic /alarm
|
||||
|
||||
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
|
||||
|
||||
@@ -17,5 +17,7 @@
|
||||
export FLAGS="$FLAGS -DDMX_DISABLE"
|
||||
export FLAGS="$FLAGS -DMODBUS_DISABLE"
|
||||
export FLAGS="$FLAGS -DOWIRE_DISABLE"
|
||||
export FLAGS="$FLAGS -DARTNET_ENABLE"
|
||||
export FLAGS="$FLAGS -DCONTROLLINO"
|
||||
export PLATFORMIO_BUILD_FLAGS="$FLAGS"
|
||||
unset FLAGS
|
||||
BIN
compiled/DUE/Wiz5100/firmware.bin
Executable file
BIN
compiled/DUE/Wiz5100/firmware.bin
Executable file
Binary file not shown.
BIN
compiled/DUE/Wiz5500/firmware.bin
Executable file
BIN
compiled/DUE/Wiz5500/firmware.bin
Executable file
Binary file not shown.
Binary file not shown.
3617
compiled/Mega2560/Wiz5100/firmware.hex
Normal file
3617
compiled/Mega2560/Wiz5100/firmware.hex
Normal file
File diff suppressed because it is too large
Load Diff
3593
compiled/Mega2560/Wiz5500/firmware.hex
Normal file
3593
compiled/Mega2560/Wiz5500/firmware.hex
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
29
config/c4-3e-11-03-1b-1e.config.json
Normal file
29
config/c4-3e-11-03-1b-1e.config.json
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"mqtt":["garden","192.168.10.115",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,23],
|
||||
"h_relay7":[6,33,1,1],
|
||||
"h_relay8":[6,32,1,1],
|
||||
"h_auto":[6,29,1,1]
|
||||
},
|
||||
"in":{
|
||||
"40":{"emit":"/garden/s_in/1"},
|
||||
"41":{"emit":"/garden/s_in/2"},
|
||||
"42":{"emit":"/garden/s_in/3"},
|
||||
"43":{"emit":"/garden/s_in/4"},
|
||||
"44":{"emit":"/garden/s_in/5"},
|
||||
"45":{"emit":"/garden/s_in/6"},
|
||||
"46":{"emit":"/garden/s_in/7"},
|
||||
"47":{"emit":"/garden/s_in/8"}
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,7 @@
|
||||
"fm_h":[8,"fm"]
|
||||
|
||||
},
|
||||
"mqtt":["public_test2","m21.cloudmqtt.com",12299,"bkyyvlha","RpHF-x6v4YWb"]
|
||||
"mqtt":["public_test2","m2m.eclipse.org"]
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"mqtt":["public_test1","m21.cloudmqtt.com",12299,"bkyyvlha","RpHF-x6v4YWb"],
|
||||
"mqtt":["public_test1","m2m.eclipse.org"],
|
||||
"ow":{
|
||||
"2807FFD503000036":{"emit":"t_balk1","item":"h_balk1"},
|
||||
"284811170400005B":{"emit":"t_entr"},
|
||||
|
||||
BIN
docs/LightHubAppDiagram.png
Normal file
BIN
docs/LightHubAppDiagram.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 178 KiB |
BIN
hardware/LightHub.pdf
Normal file
BIN
hardware/LightHub.pdf
Normal file
Binary file not shown.
@@ -49,6 +49,7 @@ extern aJsonObject *dmxArr;
|
||||
|
||||
int itemCtrl2(char* name,int r,int g, int b, int w)
|
||||
{
|
||||
if (!items) return 0;
|
||||
aJsonObject *itemArr= aJson.getObjectItem(items, name);
|
||||
|
||||
if (itemArr && (itemArr->type==aJson_Array))
|
||||
@@ -88,6 +89,7 @@ int itemCtrl2(char* name,int r,int g, int b, int w)
|
||||
} //itemtype
|
||||
// break;
|
||||
} //if have correct array
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -97,7 +99,7 @@ void DMXImmediateUpdate(short tch,short r, short g, short b, short w) {
|
||||
|
||||
{
|
||||
char* itemname = aJson.getArrayItem(dmxArr,tch)->valuestring;
|
||||
itemCtrl2(itemname,r,g,b,w);
|
||||
if (itemname) itemCtrl2(itemname,r,g,b,w);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,6 +123,10 @@ void DMXUpdate(void)
|
||||
{
|
||||
#if defined(_dmxin)
|
||||
int t;
|
||||
if(!DMXin) return;
|
||||
#if defined(__SAM3X8E__)
|
||||
if (dmxin.getRxLength()<16) return;
|
||||
#endif
|
||||
for (short tch=0; tch<=3 ; tch++)
|
||||
{
|
||||
short base = tch*4;
|
||||
@@ -207,9 +213,8 @@ void DMXinSetup(int channels)
|
||||
#endif
|
||||
|
||||
#if defined(__SAM3X8E__)
|
||||
dmxin.begin();
|
||||
dmxin.setRxEvent(DMXUpdate);
|
||||
|
||||
dmxin.begin();
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -32,8 +32,6 @@ e-mail anklimov@gmail.com
|
||||
#include <ModbusMaster.h>
|
||||
#include <PubSubClient.h>
|
||||
|
||||
#define dimPar SERIAL_8E1
|
||||
#define fmPar SERIAL_8N1
|
||||
|
||||
short modbusBusy = 0;
|
||||
extern aJsonObject *pollingItem;
|
||||
@@ -121,8 +119,10 @@ void Item::setCmd(uint8_t cmd) {
|
||||
int Item::getArg(short n) //Return arg int or first array element if Arg is array
|
||||
{
|
||||
if (!itemArg) return -1;
|
||||
if (itemArg->type == aJson_Int) return itemArg->valueint;
|
||||
else if (itemArg->type == aJson_Array) return aJson.getArrayItem(itemArg, n)->valueint;
|
||||
if (itemArg->type == aJson_Int){
|
||||
if (!n) return itemArg->valueint; else return -1;
|
||||
}
|
||||
if ((itemArg->type == aJson_Array) && ( n < aJson.getArraySize(itemArg))) return aJson.getArrayItem(itemArg, n)->valueint;
|
||||
else return -2;
|
||||
}
|
||||
|
||||
@@ -265,7 +265,23 @@ int Item::Ctrl(short cmd, short n, int *Parameters, boolean send) {
|
||||
break;
|
||||
|
||||
case CMD_ON:
|
||||
if (itemType!=CH_RGBW || getCmd() != CMD_ON) {
|
||||
if (itemType==CH_RGBW && getCmd() == CMD_ON && getEnableCMD(500)) {
|
||||
Serial.println(F("Force White"));
|
||||
itemType = CH_WHITE;
|
||||
Par[1] = 0; //Zero saturation
|
||||
Par[2] = 100; //Full power
|
||||
// Store
|
||||
st.h = Par[0];
|
||||
st.s = Par[1];
|
||||
st.v = Par[2];
|
||||
setVal(st.aslong);
|
||||
//Send to OH
|
||||
if (send) SendStatus(0, 3, Par);
|
||||
break;
|
||||
} // if forcewhite
|
||||
|
||||
// if (itemType!=CH_RGBW || getCmd() != CMD_ON) {
|
||||
{
|
||||
short params = 0;
|
||||
setCmd(cmd);
|
||||
//retrive stored values
|
||||
@@ -303,8 +319,8 @@ int Item::Ctrl(short cmd, short n, int *Parameters, boolean send) {
|
||||
break;
|
||||
default:
|
||||
if (send) SendStatus(cmd); // Just send ON
|
||||
}//itemtype
|
||||
else {// Default settings
|
||||
}//itemtype switch
|
||||
else {// Default settings, values not stored yet
|
||||
Serial.print(st.aslong);
|
||||
Serial.println(F(": No stored values - default"));
|
||||
|
||||
@@ -323,18 +339,24 @@ int Item::Ctrl(short cmd, short n, int *Parameters, boolean send) {
|
||||
params = 3;
|
||||
SendStatus(0, params, Par,true);
|
||||
break;
|
||||
case CH_RELAY:
|
||||
Par[0] = 100;
|
||||
params = 1;
|
||||
if (send) SendStatus(CMD_ON);
|
||||
break;
|
||||
default:
|
||||
Par[0] = 100;
|
||||
params = 1;
|
||||
SendStatus(0, params, Par);
|
||||
}
|
||||
}
|
||||
} // default handler
|
||||
for (short i = 0; i < params; i++) {
|
||||
Serial.print(F("Restored: "));
|
||||
Serial.print(i);
|
||||
Serial.print(F("="));
|
||||
Serial.println(Par[i]);
|
||||
}
|
||||
/*
|
||||
} else { //Double ON - apply special preset - clean white full power
|
||||
if (getEnableCMD(500)) switch (itemType) {
|
||||
case CH_RGBW:
|
||||
@@ -354,10 +376,10 @@ int Item::Ctrl(short cmd, short n, int *Parameters, boolean send) {
|
||||
break;
|
||||
} //itemtype
|
||||
} //else
|
||||
|
||||
*/
|
||||
//Serial.print("Sa:");Serial.println(Par[1]);
|
||||
if ((itemType == CH_RGBW) && (Par[1] == 0)) itemType = CH_WHITE;
|
||||
|
||||
}
|
||||
|
||||
break; //CMD_ON
|
||||
|
||||
@@ -434,13 +456,16 @@ int Item::Ctrl(short cmd, short n, int *Parameters, boolean send) {
|
||||
|
||||
#ifdef _modbus
|
||||
case CH_MODBUS: {
|
||||
|
||||
if ((itemArg->type == aJson_Array) && (aJson.getArraySize(itemArg) == 3)) {
|
||||
short numpar=0;
|
||||
if ((itemArg->type == aJson_Array) && ((numpar = aJson.getArraySize(itemArg)) >= 2)) {
|
||||
int _addr = aJson.getArrayItem(itemArg, 0)->valueint;
|
||||
int _reg = aJson.getArrayItem(itemArg, 1)->valueint;
|
||||
int _mask = aJson.getArrayItem(itemArg, 2)->valueint;
|
||||
|
||||
modbusDimmerSet(_addr, _reg, _mask, map(Par[0], 0, 100, 0, 0x3f));
|
||||
int _mask = -1;
|
||||
if (numpar >= 3) _mask = aJson.getArrayItem(itemArg, 2)->valueint;
|
||||
int _maxval = 0x3f;
|
||||
if (numpar >=4) _maxval = aJson.getArrayItem(itemArg, 3)->valueint;
|
||||
if (_maxval) modbusDimmerSet(_addr, _reg, _mask, map(Par[0], 0, 100, 0, _maxval));
|
||||
else modbusDimmerSet(_addr, _reg, _mask, Par[0]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -588,6 +613,7 @@ int Item::isActive() {
|
||||
case CH_THERMO:
|
||||
case CH_VC:
|
||||
case CH_VCTEMP:
|
||||
case CH_PWM:
|
||||
val = st.aslong;
|
||||
} //switch
|
||||
Serial.print(F(":="));
|
||||
@@ -810,10 +836,12 @@ int Item::modbusDimmerSet(int addr, uint16_t _reg, int _mask, uint16_t value) {
|
||||
node.begin(addr, modbusSerial);
|
||||
|
||||
|
||||
if (_mask) {
|
||||
switch (_mask) {
|
||||
case 1:
|
||||
value <<= 8;
|
||||
value |= (0xff);
|
||||
} else {
|
||||
break;
|
||||
case 0:
|
||||
value &= 0xff;
|
||||
value |= (0xff00);
|
||||
}
|
||||
@@ -918,7 +946,7 @@ int Item::checkFM() {
|
||||
int pwr = node.getResponseBuffer(3);
|
||||
if (pwr > 0) aJson.addNumberToObject(out, "pwr", pwr / 10.); else aJson.addNumberToObject(out, "pwr", 0);
|
||||
|
||||
if (ftemp>fset+FM_OVERHEAT_CELSIUS && set)
|
||||
if (ftemp>FM_OVERHEAT_CELSIUS && set)
|
||||
{
|
||||
mqttClient.publish("/alarm/ovrht", itemArr->name);
|
||||
Ctrl(CMD_OFF); //Shut down
|
||||
@@ -999,10 +1027,17 @@ int Item::checkModbusDimmer() {
|
||||
|
||||
int Item::checkModbusDimmer(int data) {
|
||||
short mask = getArg(2);
|
||||
if (mask < 0) return 0;
|
||||
|
||||
short maxVal = getArg(3);
|
||||
if (maxVal<=0) maxVal = 0x3f;
|
||||
|
||||
int d = data;
|
||||
if (mask) d >>= 8;
|
||||
d &= 0xff;
|
||||
d = map(d, 0, 0x3f, 0, 100);
|
||||
if (mask == 1) d >>= 8;
|
||||
if (mask == 0 || mask == 1) d &= 0xff;
|
||||
|
||||
if (maxVal) d = map(d, 0, maxVal, 0, 100);
|
||||
|
||||
int cmd = getCmd();
|
||||
//Serial.println(d);
|
||||
if (getVal() != d || d && cmd == CMD_OFF || d && cmd == CMD_HALT) //volume changed or turned on manualy
|
||||
@@ -1083,4 +1118,3 @@ void Item::sendDelayedStatus(){
|
||||
setCmd(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,6 @@ Relay array channel
|
||||
Relay DMX array channel
|
||||
Config URL & MQTT password commandline configuration
|
||||
1-wire Update refactoring (save memory)
|
||||
Static IP
|
||||
Topic configuration
|
||||
Timer
|
||||
Modbus response check
|
||||
@@ -66,7 +65,7 @@ PWM Out
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "main.h"
|
||||
#include "options.h"
|
||||
|
||||
@@ -81,6 +80,8 @@ EthernetClient ethClient;
|
||||
|
||||
const char outprefix[] PROGMEM = OUTTOPIC;
|
||||
const char inprefix[] PROGMEM = INTOPIC;
|
||||
const char configServerPrecompiled[] PROGMEM = CONFIG_SERVER;
|
||||
|
||||
|
||||
aJsonObject *root = NULL;
|
||||
aJsonObject *items = NULL;
|
||||
@@ -99,6 +100,7 @@ unsigned long nextThermostatCheck = 0;
|
||||
aJsonObject *pollingItem = NULL;
|
||||
|
||||
bool owReady = false;
|
||||
bool configOk = false;
|
||||
int lanStatus = 0;
|
||||
|
||||
#ifdef _modbus
|
||||
@@ -113,15 +115,17 @@ PubSubClient mqttClient(ethClient);
|
||||
|
||||
void watchdogSetup(void) {} //Do not remove - strong re-definition WDT Init for DUE
|
||||
|
||||
|
||||
// MQTT Callback routine
|
||||
#define MQTT_SUBJECT_LENGTH 20
|
||||
#define MQTT_TOPIC_LENGTH 20
|
||||
|
||||
|
||||
void mqttCallback(char *topic, byte *payload, unsigned int length) {
|
||||
payload[length] = 0;
|
||||
|
||||
Serial.print(F("\n["));
|
||||
Serial.print(topic);
|
||||
Serial.print(F("] "));
|
||||
if (!payload) return;
|
||||
payload[length] = 0;
|
||||
|
||||
int fr = freeRam();
|
||||
if (fr < 250) {
|
||||
@@ -261,15 +265,35 @@ int lanLoop() {
|
||||
switch (lanStatus) {
|
||||
//Initial state
|
||||
case 0: //Ethernet.begin(mac,ip);
|
||||
|
||||
{
|
||||
#ifdef __ESP__
|
||||
//WiFi.mode(WIFI_STA);
|
||||
//wifiMulti.addAP("Smartbox", "");
|
||||
if((wifiMulti.run() == WL_CONNECTED)) lanStatus=1;
|
||||
#else
|
||||
IPAddress ip;
|
||||
IPAddress dns;
|
||||
IPAddress gw;
|
||||
IPAddress mask;
|
||||
int res = 1;
|
||||
Serial.println(F("Starting lan"));
|
||||
if (loadIPAddressFromFlash(OFFSET_IP, ip))
|
||||
if (loadIPAddressFromFlash(OFFSET_DNS, dns))
|
||||
if (loadIPAddressFromFlash(OFFSET_GW, gw))
|
||||
if (loadIPAddressFromFlash(OFFSET_MASK, mask)) Ethernet.begin(mac,ip,dns,gw,mask);
|
||||
else Ethernet.begin(mac,ip,dns,gw);
|
||||
else Ethernet.begin(mac,ip,dns);
|
||||
else Ethernet.begin(mac,ip);
|
||||
else
|
||||
{
|
||||
wdt_dis();
|
||||
if (Ethernet.begin(mac, 12000) == 0) {
|
||||
res = Ethernet.begin(mac, 12000);
|
||||
wdt_en();
|
||||
wdt_res();
|
||||
}
|
||||
|
||||
|
||||
if (res == 0) {
|
||||
Serial.println(F("Failed to configure Ethernet using DHCP"));
|
||||
lanStatus = -10;
|
||||
lanCheck = millis() + 60000;
|
||||
@@ -277,14 +301,16 @@ if((wifiMulti.run() == WL_CONNECTED)) lanStatus=1;
|
||||
printIPAddress();
|
||||
lanStatus = 1;
|
||||
}
|
||||
wdt_en();
|
||||
wdt_res();
|
||||
|
||||
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
//Have IP address
|
||||
case 1:
|
||||
|
||||
if (!configOk)
|
||||
lanStatus = getConfig(0, NULL); //got config from server or load from NVRAM
|
||||
else lanStatus = 2;
|
||||
#ifdef _artnet
|
||||
if (artnet) artnet->begin();
|
||||
#endif
|
||||
@@ -297,17 +323,23 @@ if((wifiMulti.run() == WL_CONNECTED)) lanStatus=1;
|
||||
int port = 1883;
|
||||
char empty = 0;
|
||||
char *user = ∅
|
||||
char *password = ∅
|
||||
char passwordBuf[16]="";
|
||||
char *password = passwordBuf;
|
||||
|
||||
|
||||
if (!mqttClient.connected() && mqttArr && ((n = aJson.getArraySize(mqttArr)) > 1)) {
|
||||
char *client_id = aJson.getArrayItem(mqttArr, 0)->valuestring;
|
||||
char *servername = aJson.getArrayItem(mqttArr, 1)->valuestring;
|
||||
if (n >= 3) port = aJson.getArrayItem(mqttArr, 2)->valueint;
|
||||
|
||||
if (n >= 4) user = aJson.getArrayItem(mqttArr, 3)->valuestring;
|
||||
if (n >= 5) password = aJson.getArrayItem(mqttArr, 4)->valuestring;
|
||||
if (!loadStringFromFlash(OFFSET_MQTT_PWD, passwordBuf, sizeof(passwordBuf)) && (n >= 5))
|
||||
{
|
||||
password = aJson.getArrayItem(mqttArr, 4)->valuestring;
|
||||
Serial.println(F("Using MQTT password from config"));
|
||||
}
|
||||
|
||||
mqttClient.setServer(servername, port);
|
||||
mqttClient.setCallback(mqttCallback);
|
||||
|
||||
Serial.print(F("Attempting MQTT connection to "));
|
||||
Serial.print(servername);
|
||||
@@ -317,11 +349,12 @@ if((wifiMulti.run() == WL_CONNECTED)) lanStatus=1;
|
||||
Serial.print(user);
|
||||
Serial.print(F(" ..."));
|
||||
|
||||
wdt_dis(); //potential unsafe for ethernetIdle(), but needed to avoid cyclic reboot if mosquitto out of order
|
||||
if (mqttClient.connect(client_id, user, password)) {
|
||||
Serial.print(F("connected as "));
|
||||
Serial.println(client_id);
|
||||
|
||||
|
||||
wdt_en();
|
||||
configOk=true;
|
||||
// ... Temporary subscribe to status topic
|
||||
char buf[MQTT_TOPIC_LENGTH];
|
||||
|
||||
@@ -344,7 +377,7 @@ if((wifiMulti.run() == WL_CONNECTED)) lanStatus=1;
|
||||
Serial.print(mqttClient.state());
|
||||
Serial.println(F(" try again in 5 seconds"));
|
||||
lanCheck = millis() + 5000;
|
||||
lanStatus = -12;
|
||||
lanStatus = 12;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -374,7 +407,7 @@ if((wifiMulti.run() == WL_CONNECTED)) lanStatus=1;
|
||||
lanStatus = 0;
|
||||
break;
|
||||
//Reconnect
|
||||
case -12:
|
||||
case 12:
|
||||
if (millis() > lanCheck)
|
||||
|
||||
lanStatus = 2;
|
||||
@@ -398,9 +431,15 @@ if((wifiMulti.run() == WL_CONNECTED)) lanStatus=1;
|
||||
wdt_dis();
|
||||
if (lanStatus > 0)
|
||||
switch (Ethernet.maintain()) {
|
||||
case NO_LINK:
|
||||
Serial.println(F("No link"));
|
||||
if (mqttClient.connected()) mqttClient.disconnect();
|
||||
lanStatus = -10;
|
||||
break;
|
||||
case DHCP_CHECK_RENEW_FAIL:
|
||||
//renewed fail
|
||||
Serial.println(F("Error: renewed fail"));
|
||||
if (mqttClient.connected()) mqttClient.disconnect();
|
||||
lanStatus = -10;
|
||||
break;
|
||||
|
||||
@@ -411,6 +450,7 @@ if((wifiMulti.run() == WL_CONNECTED)) lanStatus=1;
|
||||
|
||||
case DHCP_CHECK_REBIND_FAIL:
|
||||
Serial.println(F("Error: rebind fail"));
|
||||
if (mqttClient.connected()) mqttClient.disconnect();
|
||||
lanStatus = -10;
|
||||
break;
|
||||
|
||||
@@ -501,7 +541,7 @@ void Changed(int i, DeviceAddress addr, int val) {
|
||||
}
|
||||
*/
|
||||
|
||||
if ((val == -127) || (val == 85)) {
|
||||
if ((val == -127) || (val == 85) || (val == 0)) { //ToDo: 1-w short circuit mapped to "0" celsium
|
||||
// Serial.print("Temp err ");Serial.println(t);
|
||||
return;
|
||||
}
|
||||
@@ -525,21 +565,24 @@ void cmdFunctionHelp(int arg_cnt, char **args)
|
||||
{
|
||||
printFirmwareVersionAndBuildOptions();
|
||||
Serial.println(F("Use the commands: 'help' - this text\n"
|
||||
"'set de:ad:be:ef:fe:00' set and store MAC-address in EEPROM\n"
|
||||
"'mac de:ad:be:ef:fe:00' set and store MAC-address in EEPROM\n"
|
||||
"'ip [ip[,dns[,gw[,subnet]]]]' - set static IP\n"
|
||||
"'save' - save config in NVRAM\n"
|
||||
"'get' - get config from pre-configured URL\n"
|
||||
"'get' [config addr]' - get config from pre-configured URL and store addr\n"
|
||||
"'load' - load config from NVRAM\n"
|
||||
"'pwd' - define MQTT password\n"
|
||||
"'kill' - test watchdog"));
|
||||
}
|
||||
|
||||
void cmdFunctionKill(int arg_cnt, char **args) {
|
||||
for (short i = 17; i > 0; i--) {
|
||||
for (short i = 1; i < 20; i++) {
|
||||
delay(1000);
|
||||
Serial.println(i);
|
||||
};
|
||||
}
|
||||
|
||||
void applyConfig() {
|
||||
if (!root) return;
|
||||
#ifdef _dmxout
|
||||
int maxChannels;
|
||||
aJsonObject *dmxoutArr = aJson.getObjectItem(root, "dmx");
|
||||
@@ -550,7 +593,6 @@ void applyConfig() {
|
||||
Serial.println(maxChannels);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef _dmxin
|
||||
int itemsCount;
|
||||
dmxArr = aJson.getObjectItem(root, "dmxin");
|
||||
@@ -560,7 +602,6 @@ void applyConfig() {
|
||||
Serial.println(itemsCount * 4);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef _modbus
|
||||
modbusArr = aJson.getObjectItem(root, "modbus");
|
||||
#endif
|
||||
@@ -574,7 +615,7 @@ void applyConfig() {
|
||||
aJsonObject *item = owArr->child;
|
||||
owReady = owSetup(&Changed);
|
||||
t_count = 0;
|
||||
while (item) {
|
||||
while (item && owReady) {
|
||||
if ((item->type == aJson_Object)) {
|
||||
DeviceAddress addr;
|
||||
//Serial.print(F("Add:")),Serial.println(item->name);
|
||||
@@ -586,7 +627,37 @@ void applyConfig() {
|
||||
}
|
||||
#endif
|
||||
items = aJson.getObjectItem(root, "items");
|
||||
|
||||
// Digital output related Items initialization
|
||||
pollingItem=NULL;
|
||||
if (items) {
|
||||
aJsonObject * item = items->child;
|
||||
while (items && item)
|
||||
if (item->type == aJson_Array && aJson.getArraySize(item)>1) {
|
||||
Item it(item);
|
||||
if (it.isValid()) {
|
||||
int pin=it.getArg();
|
||||
int cmd = it.getCmd();
|
||||
switch (it.itemType) {
|
||||
case CH_THERMO:
|
||||
if (cmd<1) it.setCmd(CMD_OFF);
|
||||
case CH_RELAY:
|
||||
{
|
||||
int k;
|
||||
pinMode(pin, OUTPUT);
|
||||
digitalWrite(pin, k = ((cmd == CMD_ON) ? HIGH : LOW));
|
||||
Serial.print(F("Pin:"));
|
||||
Serial.print(pin);
|
||||
Serial.print(F("="));
|
||||
Serial.println(k);
|
||||
}
|
||||
break;
|
||||
} //switch
|
||||
} //isValid
|
||||
item = item->next;
|
||||
} //if
|
||||
pollingItem = items->child;
|
||||
}
|
||||
inputs = aJson.getObjectItem(root, "in");
|
||||
mqttArr = aJson.getObjectItem(root, "mqtt");
|
||||
printConfigSummary();
|
||||
@@ -629,6 +700,7 @@ int loadConfigFromEEPROM(int arg_cnt, char **args)
|
||||
}
|
||||
Serial.println(F("Loaded"));
|
||||
applyConfig();
|
||||
ethClient.stop(); //Refresh MQTT connect to get retained info
|
||||
return 1;
|
||||
} else {
|
||||
Serial.println(F("No stored config"));
|
||||
@@ -688,6 +760,35 @@ void cmdFunctionSave(int arg_cnt, char **args)
|
||||
Serial.println(F("Saved to EEPROM"));
|
||||
}
|
||||
|
||||
void cmdFunctionIp(int arg_cnt, char **args)
|
||||
//(char* tokens)
|
||||
{ IPAddress ip0 (0,0,0,0);
|
||||
IPAddress ip;
|
||||
DNSClient dns;
|
||||
switch (arg_cnt) {
|
||||
case 5: if (dns.inet_aton(args[4],ip)) saveIPAddressToFlash(OFFSET_MASK, ip); else
|
||||
saveIPAddressToFlash(OFFSET_MASK, ip0);
|
||||
case 4: if (dns.inet_aton(args[3],ip)) saveIPAddressToFlash(OFFSET_GW, ip); else
|
||||
saveIPAddressToFlash(OFFSET_GW, ip0);
|
||||
case 3: if (dns.inet_aton(args[2],ip)) saveIPAddressToFlash(OFFSET_DNS, ip); else
|
||||
saveIPAddressToFlash(OFFSET_DNS, ip0);
|
||||
case 2: if (dns.inet_aton(args[1],ip)) saveIPAddressToFlash(OFFSET_IP, ip); else
|
||||
saveIPAddressToFlash(OFFSET_IP, ip0);
|
||||
break;
|
||||
case 1: //dynamic IP
|
||||
saveIPAddressToFlash(OFFSET_IP, ip0);
|
||||
}
|
||||
Serial.println(F("Saved"));
|
||||
}
|
||||
|
||||
void cmdFunctionPwd(int arg_cnt, char **args)
|
||||
//(char* tokens)
|
||||
{ char empty[]="";
|
||||
if (arg_cnt)
|
||||
saveStringToFlash(OFFSET_MQTT_PWD, args[1]);
|
||||
else saveStringToFlash(OFFSET_MQTT_PWD, empty);
|
||||
Serial.println(F("Password updated"));
|
||||
}
|
||||
|
||||
void cmdFunctionSetMac(int arg_cnt, char **args) {
|
||||
|
||||
@@ -710,22 +811,40 @@ void cmdFunctionSetMac(int arg_cnt, char **args) {
|
||||
}
|
||||
|
||||
void cmdFunctionGet(int arg_cnt, char **args) {
|
||||
getConfig(arg_cnt, args);
|
||||
restoreState();
|
||||
lanStatus=getConfig(arg_cnt, args);
|
||||
ethClient.stop(); //Refresh MQTT connect to get retained info
|
||||
//restoreState();
|
||||
}
|
||||
|
||||
void printBool(bool arg) { (arg) ? Serial.println(F("on")) : Serial.println(F("off")); }
|
||||
|
||||
|
||||
void saveFlash(short n, char *str) {}
|
||||
void saveStringToFlash(short n, char *str) {
|
||||
short i;
|
||||
short len=strlen(str);
|
||||
if (len>31) len=31;
|
||||
for(int i=0;i<len;i++) EEPROM.write(n+i,str[i]);
|
||||
EEPROM.write(n+len,0);
|
||||
}
|
||||
|
||||
void loadFlash(short n, char *str) {}
|
||||
int loadStringFromFlash(short offset, char *str, short numBytes) {
|
||||
short i;
|
||||
uint8_t ch = EEPROM.read(offset);
|
||||
if (!ch || (ch == 0xff)) return 0;
|
||||
for (i=0;i<numBytes-1 && (str[i] = EEPROM.read(offset++));i++);
|
||||
str[i]=0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifndef MY_CONFIG_SERVER
|
||||
#define CONFIG_SERVER "lazyhome.ru"
|
||||
#else
|
||||
#define CONFIG_SERVER QUOTE(MY_CONFIG_SERVER)
|
||||
#endif
|
||||
void saveIPAddressToFlash(short n, IPAddress &ip) {
|
||||
for(int i=0;i<4;i++) EEPROM.write(n++,ip[i]);
|
||||
}
|
||||
|
||||
int loadIPAddressFromFlash(short n, IPAddress &ip) {
|
||||
for(int i=0;i<4;i++) ip[i]=EEPROM.read(n++);
|
||||
if (ip[0] && (ip[0] != 0xff)) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int getConfig(int arg_cnt, char **args)
|
||||
//(char *tokens)
|
||||
@@ -734,12 +853,13 @@ int getConfig(int arg_cnt, char **args)
|
||||
|
||||
int responseStatusCode = 0;
|
||||
char ch;
|
||||
char URI[40];
|
||||
char configServer[32] = CONFIG_SERVER;
|
||||
if (arg_cnt > 0) {
|
||||
char URI[CONFIG_URI_LENGTH];
|
||||
char configServer[CONFIG_SERVER_ADDRESS_LENGTH]="";
|
||||
if (arg_cnt > 1) {
|
||||
strncpy(configServer, args[1], sizeof(configServer) - 1);
|
||||
saveFlash(0, configServer);
|
||||
} else loadFlash(0, configServer);
|
||||
saveStringToFlash(OFFSET_CONFIGSERVER, configServer);
|
||||
} else if (!loadStringFromFlash(OFFSET_CONFIGSERVER, configServer))
|
||||
strncpy_P(configServer,configServerPrecompiled,sizeof(configServer));
|
||||
|
||||
snprintf(URI, sizeof(URI), "/%02x-%02x-%02x-%02x-%02x-%02x.config.json", mac[0], mac[1], mac[2], mac[3], mac[4],
|
||||
mac[5]);
|
||||
@@ -749,22 +869,24 @@ int getConfig(int arg_cnt, char **args)
|
||||
|
||||
#if defined(__AVR__)
|
||||
FILE *result;
|
||||
//byte hserver[] = { 192,168,88,2 };
|
||||
wdt_dis();
|
||||
HTTPClient hclient(configServer, 80);
|
||||
|
||||
|
||||
HTTPClient hclient(configServer, CONFIG_SERVER_PORT);
|
||||
// FILE is the return STREAM type of the HTTPClient
|
||||
result = hclient.getURI(URI);
|
||||
responseStatusCode = hclient.getLastReturnCode();
|
||||
wdt_en();
|
||||
|
||||
if (result != NULL) {
|
||||
if (responseStatusCode == 200) {
|
||||
|
||||
Serial.println(F("got Config"));
|
||||
aJsonFileStream as = aJsonFileStream(result);
|
||||
noInterrupts();
|
||||
aJson.deleteItem(root);
|
||||
root = aJson.parse(&as);
|
||||
interrupts();
|
||||
// Serial.println(F("Parsed."));
|
||||
hclient.closeStream(result); // this is very important -- be sure to close the STREAM
|
||||
|
||||
if (!root) {
|
||||
@@ -775,7 +897,7 @@ int getConfig(int arg_cnt, char **args)
|
||||
// char *outstr = aJson.print(root);
|
||||
// Serial.println(outstr);
|
||||
// free(outstr);
|
||||
|
||||
Serial.println(F("Applying."));
|
||||
applyConfig();
|
||||
|
||||
|
||||
@@ -798,11 +920,12 @@ int getConfig(int arg_cnt, char **args)
|
||||
#else
|
||||
//Non AVR code
|
||||
String response;
|
||||
|
||||
HttpClient htclient = HttpClient(ethClient, configServer, 80);
|
||||
htclient.setHttpResponseTimeout(4000);
|
||||
EthernetClient configEthClient;
|
||||
HttpClient htclient = HttpClient(configEthClient, configServer, CONFIG_SERVER_PORT);
|
||||
//htclient.stop(); //_socket =MAX
|
||||
htclient.setHttpResponseTimeout(CONFIG_SERVER_RESPONSE_TIMEOUT);
|
||||
wdt_res();
|
||||
//Serial.println("making GET request");
|
||||
//Serial.println("making GET request");get
|
||||
htclient.beginRequest();
|
||||
htclient.get(URI);
|
||||
htclient.endRequest();
|
||||
@@ -848,14 +971,22 @@ int getConfig(int arg_cnt, char **args)
|
||||
}
|
||||
|
||||
void preTransmission() {
|
||||
#ifdef CONTROLLINO
|
||||
// set DE and RE on HIGH
|
||||
PORTJ |= B01100000;
|
||||
#else
|
||||
digitalWrite(TXEnablePin, 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
void postTransmission() {
|
||||
//modbusSerial.flush();
|
||||
#ifdef CONTROLLINO
|
||||
// set DE and RE on LOW
|
||||
PORTJ &= B10011111;
|
||||
#else
|
||||
digitalWrite(TXEnablePin, 0);
|
||||
#endif
|
||||
}
|
||||
//#define PIO_SRC_REV commit 8034a6b765229d94a94d90fd08dd9588acf5f3da Author: livello <livello@bk.ru> Date: Wed Mar 28 02:35:50 2018 +0300 refactoring
|
||||
|
||||
void setup_main() {
|
||||
setupCmdArduino();
|
||||
@@ -874,7 +1005,14 @@ void setup_main() {
|
||||
loadConfigFromEEPROM(0, NULL);
|
||||
|
||||
#ifdef _modbus
|
||||
#ifdef CONTROLLINO
|
||||
//set PORTJ pin 5,6 direction (RE,DE)
|
||||
DDRJ |= B01100000;
|
||||
//set RE,DE on LOW
|
||||
PORTJ &= B10011111;
|
||||
#else
|
||||
pinMode(TXEnablePin, OUTPUT);
|
||||
#endif
|
||||
modbusSerial.begin(MODBUS_SERIAL_BAUD);
|
||||
node.idle(&modbusIdle);
|
||||
// Callbacks allow us to configure the RS485 transceiver correctly
|
||||
@@ -894,7 +1032,11 @@ void setup_main() {
|
||||
#ifdef _artnet
|
||||
ArtnetSetup();
|
||||
#endif
|
||||
|
||||
/*
|
||||
SPI.begin();
|
||||
while (Ethernet.maintain() == NO_LINK && millis()<3000UL) {delay(500);Serial.print(F("."));}
|
||||
*/
|
||||
//delay(1000); //Wiz5500
|
||||
//TODO: checkForRemoteSketchUpdate();
|
||||
}
|
||||
|
||||
@@ -982,9 +1124,11 @@ void setupCmdArduino() {
|
||||
cmdAdd("save", cmdFunctionSave);
|
||||
cmdAdd("load", cmdFunctionLoad);
|
||||
cmdAdd("get", cmdFunctionGet);
|
||||
cmdAdd("set", cmdFunctionSetMac);
|
||||
cmdAdd("mac", cmdFunctionSetMac);
|
||||
cmdAdd("kill", cmdFunctionKill);
|
||||
cmdAdd("req", cmdFunctionReq);
|
||||
cmdAdd("ip", cmdFunctionIp);
|
||||
cmdAdd("pwd", cmdFunctionPwd);
|
||||
}
|
||||
|
||||
void loop_main() {
|
||||
@@ -1015,7 +1159,7 @@ void loop_main() {
|
||||
}
|
||||
|
||||
|
||||
if (inputs) inputLoop();
|
||||
inputLoop();
|
||||
|
||||
#if defined (_espdmx)
|
||||
dmxout.update();
|
||||
@@ -1041,6 +1185,11 @@ void owIdle(void) {
|
||||
dmxout.update();
|
||||
#endif
|
||||
}
|
||||
void ethernetIdle(void){
|
||||
wdt_res();
|
||||
inputLoop();
|
||||
// Serial.print(".");
|
||||
};
|
||||
|
||||
void modbusIdle(void) {
|
||||
wdt_res();
|
||||
@@ -1049,8 +1198,10 @@ void modbusIdle(void) {
|
||||
#ifdef _artnet
|
||||
if (artnet) artnet->read();
|
||||
#endif
|
||||
inputLoop();
|
||||
}
|
||||
|
||||
|
||||
#ifdef _dmxin
|
||||
DMXCheck();
|
||||
#endif
|
||||
@@ -1061,6 +1212,7 @@ void modbusIdle(void) {
|
||||
}
|
||||
|
||||
void inputLoop(void) {
|
||||
if (!inputs) return;
|
||||
if (millis() > nextInputCheck) {
|
||||
aJsonObject *input = inputs->child;
|
||||
while (input) {
|
||||
@@ -1121,7 +1273,7 @@ void thermoLoop(void) {
|
||||
mqttClient.publish("/alarm/snsr", item->name);
|
||||
|
||||
}
|
||||
if (curtemp > itemTempSetting + THERMO_OVERHEAT_CELSIUS) mqttClient.publish("/alarm/ovrht", item->name);
|
||||
if (curtemp > THERMO_OVERHEAT_CELSIUS) mqttClient.publish("/alarm/ovrht", item->name);
|
||||
|
||||
thermostatCheckPrinted = true;
|
||||
Serial.print(item->name);
|
||||
|
||||
@@ -40,8 +40,8 @@
|
||||
#include "stdarg.h"
|
||||
#include "item.h"
|
||||
#include "inputs.h"
|
||||
#include "Dhcp.h"
|
||||
#include "FastLED.h"
|
||||
#include "Dns.h"
|
||||
//#include "hsv2rgb.h"
|
||||
|
||||
#if defined(__SAM3X8E__)
|
||||
@@ -81,9 +81,7 @@
|
||||
#ifdef Wiz5500
|
||||
#include <Ethernet2.h>
|
||||
#else
|
||||
|
||||
#include <Ethernet.h>
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef _artnet
|
||||
@@ -92,13 +90,17 @@
|
||||
|
||||
#ifdef SD_CARD_INSERTED
|
||||
#include "sd_card_w5100.h"
|
||||
#endif
|
||||
#endif //SD_CARD_INSERTED
|
||||
|
||||
#ifdef DHT_ENABLE
|
||||
#include <DHT.h>
|
||||
#endif //DHT_ENABLE/**/
|
||||
|
||||
#ifdef _artnet
|
||||
extern Artnet *artnet;
|
||||
#endif
|
||||
|
||||
void watchdogSetup(void);
|
||||
//void watchdogSetup(void);
|
||||
|
||||
void mqttCallback(char *topic, byte *payload, unsigned int length);
|
||||
|
||||
@@ -142,11 +144,15 @@ void cmdFunctionGet(int arg_cnt, char **args);
|
||||
|
||||
void printBool(bool arg);
|
||||
|
||||
void saveFlash(short n, char *str);
|
||||
void saveStringToFlash(short n, char *str);
|
||||
|
||||
void loadFlash(short n, char *str);
|
||||
int loadStringFromFlash(short offset, char *str, short numBytes = 32);
|
||||
|
||||
int getConfig(int arg_cnt, char **args);
|
||||
void saveIPAddressToFlash(short n, IPAddress &ip);
|
||||
|
||||
int loadIPAddressFromFlash(short n, IPAddress &ip);
|
||||
|
||||
int getConfig(int arg_cnt=0, char **args=NULL);
|
||||
|
||||
void preTransmission();
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Configuration of drivers enabled
|
||||
#ifndef PIO_SRC_REV
|
||||
#define PIO_SRC_REV v0.994
|
||||
#define PIO_SRC_REV v0.999
|
||||
#endif
|
||||
|
||||
#define TXEnablePin 13
|
||||
@@ -9,21 +9,46 @@
|
||||
#define IET_TEMP 0
|
||||
#define IET_ATTEMPTS 1
|
||||
|
||||
#define THERMO_GIST_CELSIUS 2
|
||||
#define THERMO_OVERHEAT_CELSIUS 5
|
||||
#define FM_OVERHEAT_CELSIUS 5.
|
||||
#define MQTT_SUBJECT_LENGTH 20
|
||||
#define MQTT_TOPIC_LENGTH 20
|
||||
|
||||
#define EEPROM_offset 32+6
|
||||
#define THERMO_GIST_CELSIUS 2
|
||||
#define THERMO_OVERHEAT_CELSIUS 38
|
||||
#define FM_OVERHEAT_CELSIUS 40.
|
||||
|
||||
|
||||
#define OFFSET_MAC 0
|
||||
#define OFFSET_IP OFFSET_MAC+6
|
||||
#define OFFSET_DNS OFFSET_IP+4
|
||||
#define OFFSET_GW OFFSET_DNS+4
|
||||
#define OFFSET_MASK OFFSET_GW+4
|
||||
#define OFFSET_CONFIGSERVER OFFSET_MASK+4
|
||||
#define OFFSET_MQTT_PWD OFFSET_CONFIGSERVER+32
|
||||
#define EEPROM_offset OFFSET_MQTT_PWD+16
|
||||
|
||||
#define INTERVAL_CHECK_INPUT 50
|
||||
#define INTERVAL_CHECK_MODBUS 2000
|
||||
#define INTERVAL_POLLING 100
|
||||
#define THERMOSTAT_CHECK_PERIOD 5000
|
||||
|
||||
#define CONFIG_SERVER_ADDRESS_LENGTH 32
|
||||
#define CONFIG_URI_LENGTH 40
|
||||
#define CONFIG_SERVER_RESPONSE_TIMEOUT 4000
|
||||
#define CONFIG_SERVER_PORT 80
|
||||
|
||||
#ifndef MY_CONFIG_SERVER
|
||||
#define CONFIG_SERVER "lazyhome.ru"
|
||||
#else
|
||||
#define CONFIG_SERVER QUOTE(MY_CONFIG_SERVER)
|
||||
#endif
|
||||
|
||||
#ifndef MODBUS_SERIAL_BAUD
|
||||
#define MODBUS_SERIAL_BAUD 9600
|
||||
#endif
|
||||
|
||||
#define dimPar SERIAL_8E1
|
||||
#define fmPar SERIAL_8N1
|
||||
|
||||
#ifndef SERIAL_BAUD
|
||||
#define SERIAL_BAUD 115200
|
||||
#endif
|
||||
@@ -32,6 +57,11 @@
|
||||
#define DEFAULT_FIRMWARE_MAC {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0}
|
||||
#endif
|
||||
|
||||
#ifndef MY_CONFIG_SERVER
|
||||
#define CONFIG_SERVER "lazyhome.ru"
|
||||
#else
|
||||
#define CONFIG_SERVER QUOTE(MY_CONFIG_SERVER)
|
||||
#endif
|
||||
|
||||
#ifndef OUTTOPIC
|
||||
#define OUTTOPIC "/myhome/s_out/"
|
||||
@@ -41,6 +71,9 @@
|
||||
#define INTOPIC "/myhome/in/"
|
||||
#endif
|
||||
|
||||
#define MQTT_SUBJECT_LENGTH 20
|
||||
#define MQTT_TOPIC_LENGTH 20
|
||||
|
||||
#ifndef DMX_DISABLE
|
||||
#define _dmxin
|
||||
#define _dmxout
|
||||
@@ -64,7 +97,11 @@
|
||||
|
||||
#if defined(__AVR__)
|
||||
//All options available
|
||||
#ifdef CONTROLLINO
|
||||
#define modbusSerial Serial3
|
||||
#else
|
||||
#define modbusSerial Serial2
|
||||
#endif
|
||||
#define dmxin DMXSerial
|
||||
#define dmxout DmxSimple
|
||||
#endif
|
||||
|
||||
@@ -131,7 +131,7 @@ net = new OneWire (USE_1W_PIN);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
Serial.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
|
||||
|
||||
@@ -199,5 +199,3 @@ void owAdd(DeviceAddress addr) {
|
||||
}
|
||||
t_count++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -25,17 +25,21 @@ lib_deps =
|
||||
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
||||
https://github.com/anklimov/DS2482_OneWire
|
||||
https://github.com/anklimov/DmxDue
|
||||
https://github.com/arduino-libraries/ArduinoHttpClient
|
||||
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/anklimov/Ethernet2
|
||||
; https://github.com/PaulStoffregen/SPI.git
|
||||
https://github.com/knolleary/pubsubclient.git
|
||||
https://github.com/anklimov/Artnet.git
|
||||
FastLED
|
||||
161
|
||||
322
|
||||
SD
|
||||
SdFat
|
||||
https://github.com/adafruit/Adafruit_Sensor.git
|
||||
; DHT sensor library@1.3.0
|
||||
https://github.com/adafruit/DHT-sensor-library
|
||||
|
||||
|
||||
[env:megaatmega2560]
|
||||
@@ -54,58 +58,23 @@ lib_deps =
|
||||
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
|
||||
|
||||
[env:due-5500]
|
||||
platform = atmelsam
|
||||
framework = arduino
|
||||
board = due
|
||||
build_flags = -D Wiz5500
|
||||
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/arduino-libraries/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
|
||||
FastLED
|
||||
|
||||
[env:megaatmega2560-5500]
|
||||
platform = atmelavr
|
||||
board = megaatmega2560
|
||||
framework = arduino
|
||||
lib_ldf_mode = chain+
|
||||
build_flags = -D Wiz5500
|
||||
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
|
||||
SD
|
||||
SdFat
|
||||
https://github.com/adafruit/Adafruit_Sensor.git
|
||||
; DHT sensor library@1.3.0
|
||||
https://github.com/adafruit/DHT-sensor-library
|
||||
|
||||
[env:esp8266]
|
||||
platform = espressif8266
|
||||
framework = arduino
|
||||
board = nodemcuv2
|
||||
build_flags = !echo -n "-DPIO_SRC_REV="$(git rev-parse --short HEAD)
|
||||
lib_ldf_mode = chain+
|
||||
lib_deps =
|
||||
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
||||
|
||||
106
platformio.txt
106
platformio.txt
@@ -1,106 +0,0 @@
|
||||
; PlatformIO Project Configuration File (for copy and paste)
|
||||
;
|
||||
; Build options: build flags, source filter
|
||||
; Upload options: custom upload port, speed and extra flags
|
||||
; Library options: dependencies, extra library storages
|
||||
; Advanced options: extra scripting
|
||||
;
|
||||
; Please visit documentation for the other options and examples
|
||||
; http://docs.platformio.org/page/projectconf.html
|
||||
[platformio]
|
||||
src_dir = lighthub
|
||||
|
||||
[env:due]
|
||||
platform = atmelsam
|
||||
framework = arduino
|
||||
board = due
|
||||
lib_deps =
|
||||
https://github.com/sebnil/DueFlashStorage
|
||||
; https://github.com/livello/Arduino-Temperature-Control-Library.git#1306c49
|
||||
https://github.com/anklimov/Arduino-Temperature-Control-Library.git
|
||||
https://github.com/anklimov/DS2482_OneWire
|
||||
https://github.com/anklimov/DmxDue
|
||||
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/Ethernet
|
||||
https://github.com/PaulStoffregen/SPI.git
|
||||
https://github.com/knolleary/pubsubclient.git
|
||||
https://github.com/anklimov/Artnet.git
|
||||
FastLED
|
||||
|
||||
[env:due-5500]
|
||||
platform = atmelsam
|
||||
framework = arduino
|
||||
board = due
|
||||
build_flags = -D Wiz5500
|
||||
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/arduino-libraries/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
|
||||
|
||||
[env:megaatmega2560]
|
||||
platform = atmelavr
|
||||
board = megaatmega2560
|
||||
framework = arduino
|
||||
lib_deps =
|
||||
; https://github.com/livello/Arduino-Temperature-Control-Library.git#1306c49
|
||||
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
|
||||
|
||||
[env:megaatmega2560-5500]
|
||||
platform = atmelavr
|
||||
board = megaatmega2560
|
||||
framework = arduino
|
||||
build_flags = -D Wiz5500
|
||||
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
|
||||
|
||||
[env:espressif8266]
|
||||
platform = espressif8266
|
||||
framework = arduino
|
||||
board = nodemcuv2
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user