DMX Modbus OneWire support now can be disabled

This commit is contained in:
livello
2018-03-23 13:35:52 +03:00
parent ca44c66387
commit 642f20de8c
6 changed files with 86 additions and 74 deletions

View File

@@ -125,6 +125,9 @@ platformio device monitor -b 115200
* Wiz5500 //Use Wiznet 5500 library instead Wiznet 5100 * Wiz5500 //Use Wiznet 5500 library instead Wiznet 5100
* DISABLE_FREERAM_PRINT // disable printing free Ram in bytes * DISABLE_FREERAM_PRINT // disable printing free Ram in bytes
* CUSTOM_FIRMWARE_MAC=de:ad:be:ef:fe:00 //set firmware macaddress * CUSTOM_FIRMWARE_MAC=de:ad:be:ef:fe:00 //set firmware macaddress
* DMX_DISABLE //disable DMX support
* MODBUS_DISABLE // disable Modbus support
* OWIRE_DISABLE // disable OneWire support
Look at build_flags_template.sh for customizing. Look at build_flags_template.sh for customizing.
@@ -137,3 +140,6 @@ Look at build_flags_template.sh for customizing.
* Wiznet 5100 (for MEGA & DUE) * Wiznet 5100 (for MEGA & DUE)
* Free Ram printing enabled * Free Ram printing enabled
* de:ad:be:ef:fe:00 * de:ad:be:ef:fe:00
* DMX support enabled
* Modbus support enabled
* OneWire support enabled

View File

@@ -14,5 +14,8 @@
export FLAGS="$FLAGS -DWiz5500" export FLAGS="$FLAGS -DWiz5500"
export FLAGS="$FLAGS -DDISABLE_FREERAM_PRINT" export FLAGS="$FLAGS -DDISABLE_FREERAM_PRINT"
export FLAGS="$FLAGS -DCUSTOM_FIRMWARE_MAC=de:ad:be:ef:fe:00" 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" export PLATFORMIO_BUILD_FLAGS="$FLAGS"
unset FLAGS unset FLAGS

View File

@@ -122,9 +122,10 @@ DueFlashStorage EEPROM;
#define wdt_en() #define wdt_en()
#define wdt_dis() #define wdt_dis()
#else #else
#include "Dhcp.h"
#ifdef Wiz5500 #ifdef Wiz5500
#include <Ethernet2.h> #include <Ethernet2.h>
#else #else
@@ -447,31 +448,24 @@ if((wifiMulti.run() == WL_CONNECTED)) lanStatus=1;
wdt_dis(); wdt_dis();
if (lanStatus > 0) if (lanStatus > 0)
switch (Ethernet.maintain()) { switch (Ethernet.maintain()) {
case 1: case DHCP_CHECK_RENEW_FAIL:
//renewed fail //renewed fail
Serial.println(F("Error: renewed fail")); Serial.println(F("Error: renewed fail"));
lanStatus = -10; lanStatus = -10;
break; break;
case 2: case DHCP_CHECK_RENEW_OK:
//renewed success
Serial.println(F("Renewed success")); Serial.println(F("Renewed success"));
//print your local IP address:
printIPAddress(); printIPAddress();
break; break;
case 3: case DHCP_CHECK_REBIND_FAIL:
//rebind fail
Serial.println(F("Error: rebind fail")); Serial.println(F("Error: rebind fail"));
lanStatus = -10; lanStatus = -10;
break; break;
case 4: case DHCP_CHECK_REBIND_OK:
//rebind success
Serial.println(F("Rebind success")); Serial.println(F("Rebind success"));
//print your local IP address:
printIPAddress(); printIPAddress();
break; break;

View File

@@ -1,8 +1,17 @@
// Configuration of drivers enabled // Configuration of drivers enabled
#ifndef DMX_DISABLE
#define _dmxin #define _dmxin
#define _dmxout #define _dmxout
#endif
#ifndef OWIRE_DISABLE
#define _owire #define _owire
#define _modbus #endif
#ifndef MODBUS_DISABLE
#define _modbus
#endif
#define _artnet #define _artnet
#if defined(ESP8266) #if defined(ESP8266)

View File

@@ -19,6 +19,7 @@ e-mail anklimov@gmail.com
*/ */
#include "utils.h" #include "utils.h"
#if defined(__SAM3X8E__) #if defined(__SAM3X8E__)
#include <malloc.h> #include <malloc.h>
#endif #endif
@@ -29,63 +30,62 @@ extern "C" {
} }
#endif #endif
void PrintBytes(uint8_t* addr, uint8_t count, bool newline) { void PrintBytes(uint8_t *addr, uint8_t count, bool newline) {
for (uint8_t i = 0; i < count; i++) { for (uint8_t i = 0; i < count; i++) {
Serial.print(addr[i]>>4, HEX); Serial.print(addr[i] >> 4, HEX);
Serial.print(addr[i]&0x0f, HEX); Serial.print(addr[i] & 0x0f, HEX);
} }
if (newline) if (newline)
Serial.println(); Serial.println();
} }
const char HEXSTR[]="0123456789ABCDEF"; const char HEXSTR[] = "0123456789ABCDEF";
void SetBytes(uint8_t *addr, uint8_t count, char *out) {
// Serial.println("SB:");
for (uint8_t i = 0; i < count; i++) {
*(out++) = HEXSTR[(addr[i] >> 4)];
*(out++) = HEXSTR[(addr[i] & 0x0f)];
}
*out = 0;
void SetBytes(uint8_t* addr, uint8_t count, char * out) {
// Serial.println("SB:");
for (uint8_t i = 0; i < count; i++) {
*(out++)=HEXSTR[(addr[i]>>4)];
*(out++)=HEXSTR[(addr[i]&0x0f)];
}
*out=0;
} }
byte HEX2DEC(char i) byte HEX2DEC(char i) {
{ byte v; byte v;
if ('a' <= i && i <='f') { v=i-97+10; } if ('a' <= i && i <= 'f') { v = i - 97 + 10; }
else if ('A' <= i && i <='F') { v=i-65+10; } else if ('A' <= i && i <= 'F') { v = i - 65 + 10; }
else if ('0' <= i && i <='9') { v=i-48; } else if ('0' <= i && i <= '9') { v = i - 48; }
return v; return v;
} }
void SetAddr(char * out, uint8_t* addr) { void SetAddr(char *out, uint8_t *addr) {
for (uint8_t i = 0; i < 8; i++) { for (uint8_t i = 0; i < 8; i++) {
*addr=HEX2DEC(*out++)<<4; *addr = HEX2DEC(*out++) << 4;
*addr++|=HEX2DEC(*out++); *addr++ |= HEX2DEC(*out++);
} }
} }
int getInt(char ** chan) int getInt(char **chan) {
{ int ch = atoi(*chan);
int ch = atoi(*chan); *chan = strchr(*chan, ',');
*chan=strchr(*chan,',');
if (*chan) *chan += 1;
if (*chan) *chan+=1; //Serial.print(F("Par:")); Serial.println(ch);
//Serial.print(F("Par:")); Serial.println(ch); return ch;
return ch;
} }
#if defined(ESP8266) #if defined(ESP8266)
unsigned long freeRam () unsigned long freeRam ()
{return system_get_free_heap_size();} {return system_get_free_heap_size();}
#endif #endif
#if defined(__AVR__) #if defined(__AVR__)
unsigned long freeRam () unsigned long freeRam ()
{ {
extern int __heap_start, *__brkval; extern int __heap_start, *__brkval;
@@ -98,25 +98,25 @@ unsigned long freeRam ()
extern char _end; extern char _end;
extern "C" char *sbrk(int i); extern "C" char *sbrk(int i);
unsigned long freeRam() unsigned long freeRam() {
{ char *ramstart = (char *) 0x20070000;
char *ramstart = (char *) 0x20070000; char *ramend = (char *) 0x20088000;
char *ramend = (char *) 0x20088000; char *heapend = sbrk(0);
char *heapend = sbrk(0); register char *stack_ptr asm( "sp" );
register char * stack_ptr asm( "sp" ); struct mallinfo mi = mallinfo();
struct mallinfo mi = mallinfo();
return stack_ptr - heapend + mi.fordblks;
}
#endif
void parseBytes(const char* str, char separator, byte* bytes, int maxBytes, int base) { return stack_ptr - heapend + mi.fordblks;
for (int i = 0; i < maxBytes; i++) { }
bytes[i] = strtoul(str, NULL, base); // Convert byte
str = strchr(str, separator); // Find next separator #endif
if (str == NULL || *str == '\0') {
break; // No more separators, exit 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
str = strchr(str, separator); // Find next separator
if (str == NULL || *str == '\0') {
break; // No more separators, exit
}
str++; // Point to next character after separator
} }
str++; // Point to next character after separator
}
} }

View File

@@ -10,8 +10,8 @@
[platformio] [platformio]
src_dir = lighthub src_dir = lighthub
env_default = env_default =
megaatmega2560 ; megaatmega2560
; due due
; esp8266 ; esp8266
[env:due] [env:due]