mirror of
https://github.com/anklimov/lighthub
synced 2025-12-06 11:49:51 +03:00
Small fix
This commit is contained in:
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
.pioenvs
|
||||
.piolibdeps
|
||||
.clang_complete
|
||||
.gcc-flags.json
|
||||
67
.travis.yml
Normal file
67
.travis.yml
Normal file
@@ -0,0 +1,67 @@
|
||||
# Continuous Integration (CI) is the practice, in software
|
||||
# engineering, of merging all developer working copies with a shared mainline
|
||||
# several times a day < http://docs.platformio.org/page/ci/index.html >
|
||||
#
|
||||
# Documentation:
|
||||
#
|
||||
# * Travis CI Embedded Builds with PlatformIO
|
||||
# < https://docs.travis-ci.com/user/integration/platformio/ >
|
||||
#
|
||||
# * PlatformIO integration with Travis CI
|
||||
# < http://docs.platformio.org/page/ci/travis.html >
|
||||
#
|
||||
# * User Guide for `platformio ci` command
|
||||
# < http://docs.platformio.org/page/userguide/cmd_ci.html >
|
||||
#
|
||||
#
|
||||
# Please choice one of the following templates (proposed below) and uncomment
|
||||
# it (remove "# " before each line) or use own configuration according to the
|
||||
# Travis CI documentation (see above).
|
||||
#
|
||||
|
||||
|
||||
#
|
||||
# Template #1: General project. Test it using existing `platformio.ini`.
|
||||
#
|
||||
|
||||
# language: python
|
||||
# python:
|
||||
# - "2.7"
|
||||
#
|
||||
# sudo: false
|
||||
# cache:
|
||||
# directories:
|
||||
# - "~/.platformio"
|
||||
#
|
||||
# install:
|
||||
# - pip install -U platformio
|
||||
# - platformio update
|
||||
#
|
||||
# script:
|
||||
# - platformio run
|
||||
|
||||
|
||||
#
|
||||
# Template #2: The project is intended to by used as a library with examples
|
||||
#
|
||||
|
||||
# language: python
|
||||
# python:
|
||||
# - "2.7"
|
||||
#
|
||||
# sudo: false
|
||||
# cache:
|
||||
# directories:
|
||||
# - "~/.platformio"
|
||||
#
|
||||
# env:
|
||||
# - PLATFORMIO_CI_SRC=path/to/test/file.c
|
||||
# - PLATFORMIO_CI_SRC=examples/file.ino
|
||||
# - PLATFORMIO_CI_SRC=path/to/test/directory
|
||||
#
|
||||
# install:
|
||||
# - pip install -U platformio
|
||||
# - platformio update
|
||||
#
|
||||
# script:
|
||||
# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N
|
||||
@@ -28,6 +28,10 @@ e-mail anklimov@gmail.com
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__ESP__)
|
||||
DMXESPSerial dmxout;
|
||||
#endif
|
||||
|
||||
uint8_t * DMXin = NULL;
|
||||
int D_State=0;
|
||||
|
||||
@@ -225,6 +229,7 @@ void DMXoutSetup(int channels,int pin)
|
||||
|
||||
|
||||
#if defined(__ESP__)
|
||||
dmxout.init(channels);
|
||||
#endif
|
||||
|
||||
#if defined(__SAM3X8E__)
|
||||
|
||||
@@ -39,7 +39,9 @@ e-mail anklimov@gmail.com
|
||||
#endif
|
||||
|
||||
#if defined(__ESP__)
|
||||
#include <ESP-Dmx.h>
|
||||
#include <ESPDMX.h>
|
||||
extern DMXESPSerial dmxout;
|
||||
#define DmxWrite dmxout.write
|
||||
#endif
|
||||
|
||||
#if defined(__SAM3X8E__)
|
||||
|
||||
@@ -22,20 +22,6 @@ e-mail anklimov@gmail.com
|
||||
#include "aJSON.h"
|
||||
|
||||
#ifdef _dmxout
|
||||
|
||||
/*
|
||||
#if defined(__AVR__)
|
||||
#include <DmxSimple.h>
|
||||
#endif
|
||||
|
||||
#if defined(__ESP__)
|
||||
#include <ESP-Dmx.h>
|
||||
#endif
|
||||
|
||||
#if defined(__SAM3X8E__)
|
||||
#include <DmxDue.h>
|
||||
#endif
|
||||
*/
|
||||
#include "dmx.h"
|
||||
#include "FastLED.h"
|
||||
#endif
|
||||
@@ -223,20 +209,7 @@ int Item::Ctrl(short cmd, short n, int * Par, boolean send)
|
||||
{
|
||||
int t;
|
||||
case CMD_TOGGLE:
|
||||
switch (t=getCmd())
|
||||
{
|
||||
case CMD_ON:
|
||||
case CMD_SET:
|
||||
cmd=CMD_OFF;
|
||||
break;
|
||||
case CMD_OFF:
|
||||
case CMD_HALT:
|
||||
case 0:
|
||||
case -1: //No stored command yet
|
||||
cmd=CMD_ON;
|
||||
break;
|
||||
}//switch old cmd
|
||||
//Serial.print("Tog/oldcmd:");Serial.print(t);Serial.print(F(" new "));Serial.println(cmd);
|
||||
if (isActive()) cmd=CMD_OFF; else cmd=CMD_ON;
|
||||
break;
|
||||
|
||||
case CMD_RESTORE:
|
||||
@@ -269,14 +242,17 @@ int Item::Ctrl(short cmd, short n, int * Par, boolean send)
|
||||
st.s=Par[1];
|
||||
st.v=Par[2];
|
||||
setVal(st.aslong);
|
||||
//SendCmd(0,3,Par); // Send back triplet ?
|
||||
break;
|
||||
|
||||
case CH_DIMMER: //Everywhere, in flat VAL
|
||||
case CH_MODBUS:
|
||||
case CH_THERMO:
|
||||
case CH_PWM:
|
||||
case CH_VC:
|
||||
case CH_DIMMER:
|
||||
case CH_MODBUS:
|
||||
SendCmd(0,1,Par); // Send back parameter for channel above this line
|
||||
case CH_THERMO:
|
||||
case CH_VCTEMP:
|
||||
setVal(Par[0]);
|
||||
setVal(Par[0]); // Store value
|
||||
|
||||
}//itemtype
|
||||
|
||||
@@ -306,10 +282,13 @@ int Item::Ctrl(short cmd, short n, int * Par, boolean send)
|
||||
SendCmd(0,params,Par); // Send restored triplet
|
||||
break;
|
||||
|
||||
|
||||
case CH_DIMMER: //Everywhere, in flat VAL
|
||||
case CH_MODBUS:
|
||||
case CH_VC:
|
||||
case CH_VCTEMP:
|
||||
case CH_PWM:
|
||||
|
||||
Par[0]=st.aslong;
|
||||
params=1;
|
||||
SendCmd(0,params,Par); // Send restored parameter
|
||||
@@ -544,7 +523,12 @@ int Item::isActive()
|
||||
|
||||
if (!isValid()) return -1;
|
||||
//Serial.print(itemArr->name);
|
||||
|
||||
int cmd=getCmd();
|
||||
|
||||
|
||||
if (itemType!=CH_GROUP)
|
||||
// Simple check last command first
|
||||
switch (cmd)
|
||||
{
|
||||
case CMD_ON:
|
||||
@@ -552,19 +536,38 @@ switch (cmd)
|
||||
return 1;
|
||||
case CMD_OFF:
|
||||
case CMD_HALT:
|
||||
case -1: ///// No last command
|
||||
//Serial.println(" inactive");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Last time was not a command but parameters set. Looking inside
|
||||
st.aslong=getVal();
|
||||
|
||||
switch (itemType)
|
||||
{
|
||||
//case CH_GROUP:
|
||||
case CH_GROUP: //make recursive calculation - is it some active in group
|
||||
if (itemArg->type==aJson_Array)
|
||||
{
|
||||
Serial.println(F("Grp check: "));
|
||||
aJsonObject *i =itemArg->child;
|
||||
while (i)
|
||||
{
|
||||
Item it (i->valuestring);
|
||||
|
||||
if (it.isValid() && it.isActive()) {Serial.println(F("Active")); return 1;}
|
||||
i=i->next;
|
||||
} //while
|
||||
return 0;
|
||||
} //if
|
||||
break;
|
||||
|
||||
|
||||
case CH_RGBW:
|
||||
case CH_RGB:
|
||||
|
||||
val=st.v;
|
||||
|
||||
val=st.v; //Light volume
|
||||
break;
|
||||
|
||||
case CH_DIMMER: //Everywhere, in flat VAL
|
||||
|
||||
@@ -57,11 +57,14 @@ DMX-OUT deploy on USART1
|
||||
Config webserver
|
||||
|
||||
*/
|
||||
#if defined(__ESP__)
|
||||
#include <FS.h> //this needs to be first, or it all crashes and burns...
|
||||
#endif
|
||||
|
||||
// Configuration of drivers enabled
|
||||
#include "options.h"
|
||||
|
||||
#include <Ethernet.h>
|
||||
|
||||
#include <PubSubClient.h>
|
||||
#include <SPI.h>
|
||||
#include "utils.h"
|
||||
@@ -95,7 +98,16 @@ Config webserver
|
||||
#include <EEPROM.h>
|
||||
#endif
|
||||
|
||||
#if defined(ESP_PLATFORM)
|
||||
#if defined(__ESP__)
|
||||
#include "esp.h"
|
||||
#define wdt_res()
|
||||
#define wdt_en()
|
||||
#define wdt_dis()
|
||||
|
||||
|
||||
#else
|
||||
#include <Ethernet2.h>
|
||||
EthernetClient ethClient;
|
||||
#endif
|
||||
|
||||
#ifdef _owire
|
||||
@@ -152,7 +164,7 @@ ModbusMaster node;
|
||||
|
||||
byte mac[6];
|
||||
|
||||
EthernetClient ethClient;
|
||||
|
||||
PubSubClient client(ethClient);
|
||||
|
||||
|
||||
@@ -283,6 +295,12 @@ 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
|
||||
Serial.println(F("Starting lan"));
|
||||
wdt_dis();
|
||||
if (Ethernet.begin(mac,12000) == 0) {
|
||||
@@ -296,6 +314,7 @@ if (Ethernet.begin(mac,12000) == 0) {
|
||||
}
|
||||
wdt_en();
|
||||
wdt_res();
|
||||
#endif
|
||||
break;
|
||||
//Have IP address
|
||||
case 1:
|
||||
@@ -852,11 +871,22 @@ void postTransmission()
|
||||
}
|
||||
|
||||
void setup() {
|
||||
cmdInit(115200);
|
||||
|
||||
Serial.println(F("\nLazyhome.ru LightHub controller v0.96"));
|
||||
|
||||
cmdAdd("help", _handleHelp);
|
||||
cmdAdd("save", _saveConfig);
|
||||
cmdAdd("load", _loadConfig);
|
||||
cmdAdd("get", _getConfig);
|
||||
cmdAdd("set", _setConfig);
|
||||
cmdAdd("kill", _kill);
|
||||
cmdAdd("req", _mqttConfigReq);
|
||||
|
||||
|
||||
cmdInit(115200);
|
||||
|
||||
Serial.println(F("\nLazyhome.ru LightHub controller v0.96"));
|
||||
#ifdef __ESP__
|
||||
espSetup();
|
||||
#endif
|
||||
|
||||
short macvalid=0;
|
||||
byte defmac[6]={0xDE,0xAD,0xBE,0xEF,0xFE,0};
|
||||
@@ -905,14 +935,6 @@ void setup() {
|
||||
// checkForRemoteSketchUpdate();
|
||||
#endif
|
||||
|
||||
cmdAdd("help", _handleHelp);
|
||||
cmdAdd("save", _saveConfig);
|
||||
cmdAdd("load", _loadConfig);
|
||||
cmdAdd("get", _getConfig);
|
||||
cmdAdd("set", _setConfig);
|
||||
cmdAdd("kill", _kill);
|
||||
cmdAdd("req", _mqttConfigReq);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -952,6 +974,10 @@ if (owReady && owArr) owLoop();
|
||||
|
||||
if (inputs) inputLoop();
|
||||
|
||||
#if defined (_espdmx)
|
||||
dmxout.update();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
// Idle handlers
|
||||
@@ -972,6 +998,10 @@ if (lanLoop() == 1) client.loop();
|
||||
DMXCheck();
|
||||
#endif
|
||||
|
||||
#if defined (_espdmx)
|
||||
dmxout.update();
|
||||
#endif
|
||||
|
||||
//modbusLoop();
|
||||
}
|
||||
|
||||
@@ -993,6 +1023,11 @@ if (lanLoop() > 1)
|
||||
#ifdef _dmxin
|
||||
DMXCheck();
|
||||
#endif
|
||||
|
||||
#if defined (_espdmx)
|
||||
dmxout.update();
|
||||
#endif
|
||||
|
||||
//modbusloop();
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
#define _modbus
|
||||
#define _artnet
|
||||
|
||||
#if defined(ESP8266)
|
||||
#define __ESP__
|
||||
#endif
|
||||
|
||||
#if defined(__AVR__)
|
||||
//All options available
|
||||
@@ -19,10 +22,11 @@
|
||||
#define dmxin DmxDue1
|
||||
#endif
|
||||
|
||||
#if defined(ESP_PLATFORM)
|
||||
#if defined(__ESP__)
|
||||
#undef _dmxin
|
||||
#undef _dmxout
|
||||
#define modbusSerial Serial
|
||||
#undef _modbus
|
||||
#define _espdmx
|
||||
#define modbusSerial Serial1
|
||||
#endif
|
||||
|
||||
#ifndef _dmxout
|
||||
|
||||
@@ -23,6 +23,12 @@ e-mail anklimov@gmail.com
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
|
||||
#if defined(ESP8266)
|
||||
extern "C" {
|
||||
#include "user_interface.h"
|
||||
}
|
||||
#endif
|
||||
|
||||
void PrintBytes(uint8_t* addr, uint8_t count, bool newline) {
|
||||
for (uint8_t i = 0; i < count; i++) {
|
||||
Serial.print(addr[i]>>4, HEX);
|
||||
@@ -74,13 +80,13 @@ int getInt(char ** chan)
|
||||
}
|
||||
|
||||
|
||||
#if defined(ESP_PLATFORM)
|
||||
int freeRam ()
|
||||
#if defined(ESP8266)
|
||||
unsigned long freeRam ()
|
||||
{return system_get_free_heap_size();}
|
||||
#endif
|
||||
|
||||
#if defined(__AVR__)
|
||||
int freeRam ()
|
||||
unsigned long freeRam ()
|
||||
{
|
||||
extern int __heap_start, *__brkval;
|
||||
int v;
|
||||
@@ -92,7 +98,7 @@ int freeRam ()
|
||||
extern char _end;
|
||||
extern "C" char *sbrk(int i);
|
||||
|
||||
int freeRam()
|
||||
unsigned long freeRam()
|
||||
{
|
||||
char *ramstart = (char *) 0x20070000;
|
||||
char *ramend = (char *) 0x20088000;
|
||||
|
||||
@@ -24,4 +24,4 @@ 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);
|
||||
int freeRam ();
|
||||
unsigned long freeRam ();
|
||||
|
||||
Reference in New Issue
Block a user