├── espArtnetNode_2.0.0_b5g.bin ├── schematics ├── node_pix_only_v2.png ├── node_dmx_and_pix_v2.png ├── convert_max485_to_pix.png ├── esp_Artnet_RDM_isolated_v2.jpg └── esp_Artnet_RDM_isolated_v2_BOM.txt ├── espArtnetNode_2.0.0_b5g_ESP01.bin ├── espArtnetNode_2.0.0_b5g_WEMOS.bin ├── espArtnetNode_2.0.0_b5g_NO_RESET.bin ├── libs ├── readme.txt ├── espDMX_RDM │ ├── rdmFIFO.h │ ├── keywords.txt │ ├── rdmDataTypes.h │ ├── rdmFIFO.cpp │ ├── README.md │ └── espDMX_RDM.h └── espArtnetRDM │ ├── e131.h │ ├── rdmDataTypes.h │ ├── artnet.h │ └── espArtNetRDM.h ├── prizes.md ├── source ├── ws2812Driver.h ├── wsFX.h ├── firmUpdate.ino ├── store.h ├── wsFX.cpp ├── startFunctions.ino ├── ws2812Driver.cpp ├── ajax.ino └── LICENSE ├── README.md ├── style.css └── LICENSE /espArtnetNode_2.0.0_b5g.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mtongnz/ESP8266_ArtNetNode_v2/HEAD/espArtnetNode_2.0.0_b5g.bin -------------------------------------------------------------------------------- /schematics/node_pix_only_v2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mtongnz/ESP8266_ArtNetNode_v2/HEAD/schematics/node_pix_only_v2.png -------------------------------------------------------------------------------- /espArtnetNode_2.0.0_b5g_ESP01.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mtongnz/ESP8266_ArtNetNode_v2/HEAD/espArtnetNode_2.0.0_b5g_ESP01.bin -------------------------------------------------------------------------------- /espArtnetNode_2.0.0_b5g_WEMOS.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mtongnz/ESP8266_ArtNetNode_v2/HEAD/espArtnetNode_2.0.0_b5g_WEMOS.bin -------------------------------------------------------------------------------- /schematics/node_dmx_and_pix_v2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mtongnz/ESP8266_ArtNetNode_v2/HEAD/schematics/node_dmx_and_pix_v2.png -------------------------------------------------------------------------------- /espArtnetNode_2.0.0_b5g_NO_RESET.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mtongnz/ESP8266_ArtNetNode_v2/HEAD/espArtnetNode_2.0.0_b5g_NO_RESET.bin -------------------------------------------------------------------------------- /schematics/convert_max485_to_pix.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mtongnz/ESP8266_ArtNetNode_v2/HEAD/schematics/convert_max485_to_pix.png -------------------------------------------------------------------------------- /schematics/esp_Artnet_RDM_isolated_v2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mtongnz/ESP8266_ArtNetNode_v2/HEAD/schematics/esp_Artnet_RDM_isolated_v2.jpg -------------------------------------------------------------------------------- /libs/readme.txt: -------------------------------------------------------------------------------- 1 | Install these libraries into your Arduino libraries folder and restart the IDE. 2 | 3 | Note that they aren't quite finished yet & I'm short on time which is why they don't have their own git. This will happen eventually. 4 | -------------------------------------------------------------------------------- /libs/espDMX_RDM/rdmFIFO.h: -------------------------------------------------------------------------------- 1 | #ifndef rdmFIFO_h 2 | #define rdmFIFO_h 3 | 4 | #include "Arduino.h" 5 | #include "rdm.h" 6 | #include "rdmDataTypes.h" 7 | 8 | #define RDM_MAX_RDM_QUEUE 30 9 | 10 | class rdmFIFO { 11 | public: 12 | rdmFIFO(); 13 | void init(); 14 | bool push(rdm_data* a); 15 | rdm_data* peek(void); 16 | bool pop(rdm_data* a); 17 | bool isEmpty(void); 18 | bool notEmpty(void); 19 | bool isFull(void); 20 | uint8_t count(void); 21 | uint8_t space(void); 22 | void empty(void); 23 | 24 | private: 25 | rdm_data* resize(uint8_t s); 26 | 27 | rdm_data* content[RDM_MAX_RDM_QUEUE]; 28 | uint8_t RDMfifoMaxSize; 29 | uint8_t RDMfifoAllocated; 30 | uint8_t RDMfifoSize; 31 | }; 32 | 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /libs/espDMX_RDM/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map espDMX 3 | ####################################### 4 | ####################################### 5 | # Datatypes (KEYWORD1) 6 | ####################################### 7 | espDMX KEYWORD1 8 | dmxA KEYWORD1 9 | dmxB KEYWORD1 10 | ####################################### 11 | # Methods and Functions (KEYWORD2) 12 | ####################################### 13 | begin KEYWORD2 14 | end KEYWORD2 15 | pause KEYWORD2 16 | unPause KEYWORD2 17 | ledIntensity KEYWORD2 18 | setChans KEYWORD2 19 | getChans KEYWORD2 20 | clearChans KEYWORD2 21 | numChans KEYWORD2 22 | 23 | handler KEYWORD2 24 | 25 | rdmEnable KEYWORD2 26 | rdmDiscovery KEYWORD2 27 | rdmSetCallBack KEYWORD2 28 | rdmSendCommand KEYWORD2 29 | todStatus KEYWORD2 30 | todCount KEYWORD2 31 | todMan KEYWORD2 32 | todDev KEYWORD2 33 | todSetCallBack KEYWORD2 -------------------------------------------------------------------------------- /prizes.md: -------------------------------------------------------------------------------- 1 | # ESP8266_ArtNetNode_v2 2 | ## Code Fix Prizes 3 | 4 | I am offering some prizes for people who can fix some of the known bugs and missing features. I have just started a new job and will have limited time for this project. Rather than make you all wait on the code, I thought I'd share it as is and ask for a bit of help. 5 | 6 | ## Details: 7 | 8 | I am giving away a few of my first batch of prototype PCBs. They may have a couple of minor errors (I already found one 9 | error due to incorrect pin mapping in an Eagle part). They will be fully populated - valued at over $30 just for parts. 10 | They feature full optical and electrical isolation, an ESP100 with 8M flash, and 3x WS2812 status LEDs. Postage is included. 11 | 12 | In order to receive one, please complete one of the following tasks. You can "win" multiple boards. 13 | 14 | 1 - Fix the WDT reset issue (https://github.com/mtongnz/ESP8266_ArtNetNode_v2/issues/41) 15 | 16 | 2 - Implement stored scenes function. I want it to allow for static scenes or for chases to run. 17 | 18 | 3 - Most bug fixes, code improvements, feature additions & helpful submissions. 19 | 20 | eg. Fixing the flickering WS2812 (https://github.com/mtongnz/ESP8266_ArtNetNode_v2/issues/36) 21 | 22 | Adding other pixel strips (https://github.com/mtongnz/ESP8266_ArtNetNode_v2/issues/42) 23 | 24 | Creating new web UI theme (https://github.com/mtongnz/ESP8266_ArtNetNode_v2/issues/22) 25 | 26 | These prizes will be based on the first person to submit a solution that I judge to be adequate. My decision is final. 27 | 28 | As stated above, I am quite short on time so it might take a while for me to test any relevant fixes. 29 | 30 | Thanks heaps for the support. 31 | -------------------------------------------------------------------------------- /libs/espDMX_RDM/rdmDataTypes.h: -------------------------------------------------------------------------------- 1 | #ifndef rdmDataTypes_h 2 | #define rdmDataTypes_h 3 | 4 | #define byte uint8_t 5 | 6 | enum rdm_tod_state { 7 | RDM_TOD_NOT_READY, 8 | RDM_TOD_READY, 9 | RDM_TOD_ERROR 10 | }; 11 | 12 | union rdm_data_ { 13 | struct { 14 | uint16_t StartCode; // Start Code 0xCC01 for RDM 15 | byte Length; // packet length 16 | uint16_t DestMan; 17 | uint32_t DestDev; 18 | uint16_t SourceMan; 19 | uint32_t SourceDev; 20 | byte TransNo; // transaction number, not checked 21 | byte ResponseType; // ResponseType 22 | byte MsgCount; // Message count 23 | uint16_t SubDev; // sub device number (root = 0) 24 | byte CmdClass; // command class 25 | uint16_t PID; // parameter ID 26 | byte DataLength; // parameter data length in bytes 27 | byte Data[231]; // data byte field 28 | } __attribute__((packed)) packet; 29 | 30 | struct { 31 | byte headerFE; 32 | byte headerAA; 33 | byte maskedDevID[12]; 34 | byte maskedChecksum[4]; 35 | } __attribute__((packed)) discovery; 36 | 37 | byte buffer[255]; 38 | 39 | void endianFlip(void) { 40 | // 16 bit flips 41 | packet.StartCode = (packet.StartCode << 8) | (packet.StartCode >> 8); 42 | packet.DestMan = (packet.DestMan << 8) | (packet.DestMan >> 8); 43 | packet.SourceMan = (packet.SourceMan << 8) | (packet.SourceMan >> 8); 44 | packet.SubDev = (packet.SubDev << 8) | (packet.SubDev >> 8); 45 | packet.PID = (packet.PID << 8) | (packet.PID >> 8); 46 | 47 | // 32 bit flips 48 | packet.DestDev = __builtin_bswap32 (packet.DestDev); 49 | packet.SourceDev = __builtin_bswap32 (packet.SourceDev); 50 | } 51 | 52 | void clear(void) { 53 | memset(&buffer, 0, 255); 54 | //for (uint8_t x = 0; x < 255; x++) 55 | // buffer[x] = 0; 56 | } 57 | }; 58 | typedef union rdm_data_ rdm_data; 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /libs/espDMX_RDM/rdmFIFO.cpp: -------------------------------------------------------------------------------- 1 | #include "rdmFIFO.h" 2 | 3 | rdmFIFO::rdmFIFO(void) { 4 | init(); 5 | } 6 | 7 | void rdmFIFO::init() { 8 | RDMfifoMaxSize = RDM_MAX_RDM_QUEUE; 9 | RDMfifoAllocated = 0; 10 | RDMfifoSize = 0; 11 | } 12 | 13 | bool rdmFIFO::push(rdm_data* a) { 14 | rdm_data* b; 15 | b = resize(RDMfifoSize + 1); 16 | 17 | if (b == NULL) 18 | return false; 19 | 20 | memcpy(b, a, sizeof(rdm_data)); 21 | 22 | // Do endian flip if its backwards 23 | if (b->buffer[0] == E120_SC_SUB_MESSAGE && b->buffer[1] == E120_SC_RDM) { 24 | b->endianFlip(); 25 | } 26 | 27 | 28 | return true; 29 | } 30 | 31 | rdm_data* rdmFIFO::peek() { 32 | if (isEmpty()) 33 | return NULL; 34 | 35 | return content[0]; 36 | } 37 | 38 | bool rdmFIFO::pop(rdm_data* a) { 39 | if (isEmpty()) 40 | return false; 41 | 42 | // Data stored in buffer big endian - esp8266 is little endian 43 | content[0]->endianFlip(); 44 | 45 | memcpy(a, content[0], sizeof(rdm_data)); 46 | 47 | resize(RDMfifoSize - 1); 48 | 49 | return true; 50 | } 51 | 52 | bool rdmFIFO::isEmpty() { 53 | return (RDMfifoSize == 0); 54 | } 55 | 56 | bool rdmFIFO::notEmpty() { 57 | return (RDMfifoSize != 0); 58 | } 59 | 60 | bool rdmFIFO::isFull() { 61 | return (RDMfifoSize == RDMfifoMaxSize); 62 | } 63 | 64 | uint8_t rdmFIFO::count() { 65 | return RDMfifoSize; 66 | } 67 | 68 | uint8_t rdmFIFO::space() { 69 | return (RDMfifoMaxSize - RDMfifoSize); 70 | } 71 | 72 | rdm_data* rdmFIFO::resize(uint8_t s) { 73 | if (s > RDMfifoMaxSize) 74 | return NULL; 75 | 76 | if (s < RDMfifoSize) { 77 | //free(content[0]); 78 | rdm_data* a = content[0]; 79 | 80 | for (uint8_t x = 1; x < RDMfifoSize; x++) 81 | content[x-1] = content[x]; 82 | 83 | content[RDMfifoSize-1] = a; 84 | } 85 | 86 | 87 | if (s > RDMfifoAllocated) { // RDMfifoSize) { 88 | if (!(content[s-1] = (rdm_data*)malloc(sizeof(rdm_data)))) 89 | return false; 90 | RDMfifoAllocated = s; 91 | } 92 | 93 | RDMfifoSize = s; 94 | 95 | return (content[s-1]); 96 | } 97 | 98 | void rdmFIFO::empty() { 99 | RDMfifoSize = 0; 100 | } 101 | -------------------------------------------------------------------------------- /libs/espArtnetRDM/e131.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | espArtNetRDM v1 (pre-release) library 4 | Copyright (c) 2016, Matthew Tong 5 | https://github.com/mtongnz/ 6 | Modified from https://github.com/forkineye/E131/blob/master/E131.h 7 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public 8 | License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any 9 | later version. 10 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied 11 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 12 | You should have received a copy of the GNU General Public License along with this program. 13 | If not, see http://www.gnu.org/licenses/ 14 | */ 15 | 16 | 17 | 18 | 19 | #ifndef e131_data_h 20 | #define e131_data_h 21 | 22 | 23 | #define E131_PORT 5568 24 | #define E131_BUFFER_MAX 638 25 | 26 | /* E1.31 Packet Structure */ 27 | typedef union { 28 | struct { 29 | /* Root Layer */ 30 | uint16_t preamble_size; 31 | uint16_t postamble_size; 32 | uint8_t acn_id[12]; 33 | uint16_t root_flength; 34 | uint32_t root_vector; 35 | uint8_t cid[16]; 36 | 37 | /* Frame Layer */ 38 | uint16_t frame_flength; 39 | uint32_t frame_vector; 40 | uint8_t source_name[64]; 41 | uint8_t priority; 42 | uint16_t reserved; 43 | uint8_t sequence_number; 44 | uint8_t options; 45 | uint16_t universe; 46 | 47 | /* DMP Layer */ 48 | uint16_t dmp_flength; 49 | uint8_t dmp_vector; 50 | uint8_t type; 51 | uint16_t first_address; 52 | uint16_t address_increment; 53 | uint16_t property_value_count; 54 | uint8_t property_values[513]; 55 | } __attribute__((packed)); 56 | 57 | uint8_t raw[E131_BUFFER_MAX]; 58 | } e131_packet_t; 59 | 60 | /* Constants for packet validation */ 61 | static const uint8_t ACN_ID[12] = { 0x41, 0x53, 0x43, 0x2d, 0x45, 0x31, 0x2e, 0x31, 0x37, 0x00, 0x00, 0x00 }; 62 | static const uint32_t VECTOR_ROOT = 4; 63 | static const uint32_t VECTOR_FRAME = 2; 64 | static const uint8_t VECTOR_DMP = 2; 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /libs/espDMX_RDM/README.md: -------------------------------------------------------------------------------- 1 | # esp8266DMX 2 | Initial version by Matthew Tong, June 2016. This library is derived from the HardwareSerial library. 3 | 4 | This library will transmit up to 2 DMX universes from an ESP8266 module. It utilizes the hardware UARTs and is entirely interupt driven meaning the DMX output has very precise timing. 5 | 6 | The DMX will refresh at a minimum rate of 44Hz. The library will detect how many channels have been set, outputting less than 512 if possible to increase the refresh rate. This increases the responsiveness of fixtures. It will still output a full 512 channels at least once per second. 7 | 8 | View my Instructable for an ESP8266 Artnet to DMX device: http://www.instructables.com/id/ESP8266-Artnet-to-DMX/ 9 | 10 | ##USAGE: 11 | 12 | dmxA uses the same uart as *Serial*, dmxB uses the same uart as *Serial1*. If you wish to use a serial port, dont call the .begin() function of the relevant dmx port. 13 | 14 | espDMX is driven entirely by the TX FIFO empty interupts. To ensure constant output and accurate timing, ensure that global interupts aren't stopped for too long. 15 | 16 | **Note:** I will be using dmxN in place of dmxA or dmxB as the commands for each are identical. 17 | 18 | Include the following code in setup. ledPin is the pin to put status LED on, ledIntensity is the intensity (0 - 255) allowing the LEDs to be dimmed. Neither parameter is required. 19 | ``` 20 | // No status LED 21 | dmxN.begin(); 22 | 23 | // Status LED at full intensity 24 | dmxN.begin(ledPin); 25 | 26 | // Status LED at specified intensity 27 | dmxN.begin(ledPin, ledIntensity); 28 | ``` 29 | To change the LED intensity later, use the following: 30 | ``` 31 | dmxN.ledIntensity(newIntensity); 32 | ``` 33 | Now set some channels. data is a byte array up to 512 length, numChans is the number of channels you're setting, startChan is the channel number (1 - 512) of the first item in data. 34 | ``` 35 | dmxN.setChans(data, numChans, startChan); 36 | 37 | // assume startChan = 1 38 | dmxN.setChans(data, numChans); 39 | 40 | // assume 512 channels starting at channel 1 41 | dmxN.setChans(data); 42 | ``` 43 | **Note:** No data will be sent until the first setChans() function is called. This is to ensure no "zero" data is sent on power up or reboot. 44 | 45 | To stop DMX transmission, use the following function. It will leave the DMX line in an idle (HIGH) state. 46 | ``` 47 | dmxN.end(); 48 | ``` 49 | -------------------------------------------------------------------------------- /source/ws2812Driver.h: -------------------------------------------------------------------------------- 1 | /* 2 | ESP8266_ArtNetNode v2.0.0 3 | Copyright (c) 2016, Matthew Tong 4 | https://github.com/mtongnz/ESP8266_ArtNetNode_v2 5 | 6 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public 7 | License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any 8 | later version. 9 | 10 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied 11 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 12 | You should have received a copy of the GNU General Public License along with this program. 13 | If not, see http://www.gnu.org/licenses/ 14 | */ 15 | 16 | 17 | #ifndef ws2812Driver_h 18 | #define ws2812Driver_h 19 | 20 | #include 21 | 22 | #define PIX_MAX_BUFFER_SIZE 2040 23 | 24 | #define PIX_LATCH_TIME 25 // 25 works for most 25 | 26 | enum conf_type { 27 | WS2812_800KHZ, 28 | WS2812_400KHZ 29 | }; 30 | 31 | class ws2812Driver { 32 | public: 33 | 34 | ws2812Driver(void); 35 | 36 | void setStrip(uint8_t port, uint8_t pin, uint16_t size, uint16_t config); 37 | void updateStrip(uint8_t port, uint16_t size, uint16_t config); 38 | 39 | uint8_t* getBuffer(uint8_t port); 40 | void clearBuffer(uint8_t port, uint16_t start); 41 | void clearBuffer(uint8_t port) { 42 | clearBuffer(port, 0); 43 | } 44 | void setBuffer(uint8_t port, uint16_t startChan, uint8_t* data, uint16_t size); 45 | 46 | byte setPixel(uint8_t port, uint16_t pixel, uint8_t r, uint8_t g, uint8_t b); 47 | byte setPixel(uint8_t port, uint16_t pixel, uint32_t colour); 48 | uint32_t getPixel(uint8_t port); 49 | 50 | bool show() __attribute__ ((optimize(0))); 51 | 52 | uint16_t numPixels(uint8_t port); 53 | 54 | byte buffer[2][PIX_MAX_BUFFER_SIZE]; 55 | 56 | bool allowInterruptSingle = true; 57 | bool allowInterruptDouble = true; 58 | 59 | void doAPA106(byte* data, uint8_t pin, uint16_t numBytes); 60 | void doPixel(byte* data, uint8_t pin, uint16_t numBytes); 61 | 62 | private: 63 | void doPixelDouble(byte* data1, uint8_t pin1, byte* data2, uint8_t pin2, uint16_t numBytes); 64 | 65 | uint8_t _pin[2]; 66 | uint16_t _pixels[2]; 67 | uint16_t _config[2]; 68 | uint32_t _nextPix = 0; 69 | }; 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /libs/espArtnetRDM/rdmDataTypes.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | espArtNetRDM v1 (pre-release) library 4 | Copyright (c) 2016, Matthew Tong 5 | https://github.com/mtongnz/ 6 | Modified from https://github.com/forkineye/E131/blob/master/E131.h 7 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public 8 | License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any 9 | later version. 10 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied 11 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 12 | You should have received a copy of the GNU General Public License along with this program. 13 | If not, see http://www.gnu.org/licenses/ 14 | */ 15 | 16 | 17 | 18 | #ifndef rdmDataTypes_h 19 | #define rdmDataTypes_h 20 | 21 | #define byte uint8_t 22 | 23 | enum rdm_tod_state { 24 | RDM_TOD_NOT_READY, 25 | RDM_TOD_READY, 26 | RDM_TOD_ERROR 27 | }; 28 | 29 | union rdm_data_ { 30 | struct { 31 | uint16_t StartCode; // Start Code 0xCC01 for RDM 32 | byte Length; // packet length 33 | uint16_t DestMan; 34 | uint32_t DestDev; 35 | uint16_t SourceMan; 36 | uint32_t SourceDev; 37 | byte TransNo; // transaction number, not checked 38 | byte ResponseType; // ResponseType 39 | byte MsgCount; // Message count 40 | uint16_t SubDev; // sub device number (root = 0) 41 | byte CmdClass; // command class 42 | uint16_t PID; // parameter ID 43 | byte DataLength; // parameter data length in bytes 44 | byte Data[231]; // data byte field 45 | } __attribute__((packed)) packet; 46 | 47 | struct { 48 | byte headerFE; 49 | byte headerAA; 50 | byte maskedDevID[12]; 51 | byte maskedChecksum[4]; 52 | } __attribute__((packed)) discovery; 53 | 54 | byte buffer[255]; 55 | 56 | void endianFlip(void) { 57 | // 16 bit flips 58 | packet.StartCode = (packet.StartCode << 8) | (packet.StartCode >> 8); 59 | packet.DestMan = (packet.DestMan << 8) | (packet.DestMan >> 8); 60 | packet.SourceMan = (packet.SourceMan << 8) | (packet.SourceMan >> 8); 61 | packet.SubDev = (packet.SubDev << 8) | (packet.SubDev >> 8); 62 | packet.PID = (packet.PID << 8) | (packet.PID >> 8); 63 | 64 | // 32 bit flips 65 | packet.DestDev = __builtin_bswap32 (packet.DestDev); 66 | packet.SourceDev = __builtin_bswap32 (packet.SourceDev); 67 | } 68 | }; 69 | typedef union rdm_data_ rdm_data; 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /source/wsFX.h: -------------------------------------------------------------------------------- 1 | /* 2 | ESP8266_ArtNetNode v2.0.0 3 | Copyright (c) 2016, Matthew Tong 4 | https://github.com/mtongnz/ESP8266_ArtNetNode_v2 5 | 6 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public 7 | License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any 8 | later version. 9 | 10 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied 11 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 12 | You should have received a copy of the GNU General Public License along with this program. 13 | If not, see http://www.gnu.org/licenses/ 14 | */ 15 | 16 | 17 | #ifndef WS_FX 18 | #define WS_FX 19 | 20 | #include "ws2812Driver.h" 21 | 22 | enum pattern { STATIC, RAINBOW_CYCLE, THEATER_CHASE, TWINKLE }; 23 | 24 | class pixPatterns { 25 | public: 26 | pattern ActivePattern; // which pattern is running 27 | 28 | unsigned long Interval; // milliseconds between updates 29 | unsigned long lastUpdate; // last update of position 30 | 31 | uint32_t Colour1, Colour2; // What colours are in use 32 | uint32_t Colour1Raw, Colour2Raw; // Colours pre-intensity 33 | uint16_t TotalSteps; // total number of steps in the pattern 34 | uint16_t Index; // current step within the pattern 35 | uint8_t Speed; // speed of effect (0 = stop, -ve is reverse, +ve is forwards) 36 | uint8_t Size1, Size, Fade, Pos; // size, fading & position for static looks 37 | uint8_t Intensity; 38 | bool NewData; 39 | 40 | uint8_t Port; // port number. 41 | ws2812Driver* pixDriver; // the pixel driver 42 | 43 | pixPatterns(uint8_t port, ws2812Driver* p); 44 | bool Update(void); 45 | void Increment(void); 46 | void setSpeed(uint8_t s); 47 | void setIntensity(uint8_t i); 48 | void setColour1(uint32_t c); 49 | void setColour2(uint32_t c); 50 | void setFX(uint8_t fx); 51 | void Static(void); 52 | void StaticUpdate(void); 53 | void RainbowCycle(void); 54 | void RainbowCycleUpdate(void); 55 | void TheaterChase(void); 56 | void TheaterChaseUpdate(void); 57 | void Twinkle(void); 58 | void TwinkleUpdate(void); 59 | uint32_t DimColour(uint32_t colour); 60 | uint32_t Colour(uint8_t r, uint8_t g, uint8_t b); 61 | uint8_t Red(uint32_t colour); 62 | uint8_t Green(uint32_t colour); 63 | uint8_t Blue(uint32_t colour); 64 | uint32_t Wheel(byte WheelPos); 65 | }; 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /source/firmUpdate.ino: -------------------------------------------------------------------------------- 1 | /* 2 | ESP8266_ArtNetNode v2.0.0 3 | Copyright (c) 2016, Matthew Tong 4 | https://github.com/mtongnz/ESP8266_ArtNetNode_v2 5 | 6 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public 7 | License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any 8 | later version. 9 | 10 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied 11 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 12 | You should have received a copy of the GNU General Public License along with this program. 13 | If not, see http://www.gnu.org/licenses/ 14 | */ 15 | 16 | 17 | 18 | /* webFirmwareUpdate() 19 | * display update status after firmware upload and restart 20 | */ 21 | void webFirmwareUpdate() { 22 | // Generate the webpage from the variables above 23 | String fail = "{\"success\":0,\"message\":\"Unknown Error\"}"; 24 | String ok = "{\"success\":1,\"message\":\"Success: Device restarting\"}"; 25 | 26 | // Send to the client 27 | webServer.sendHeader("Connection", "close"); 28 | webServer.sendHeader("Access-Control-Allow-Origin", "*"); 29 | webServer.send(200, "application/json", (Update.hasError()) ? fail : ok); 30 | 31 | doReboot = true; 32 | } 33 | 34 | 35 | 36 | /* webFirmwareUpload() 37 | * handle firmware upload and update 38 | */ 39 | void webFirmwareUpload() { 40 | String reply = ""; 41 | HTTPUpload& upload = webServer.upload(); 42 | 43 | if(upload.status == UPLOAD_FILE_START){ 44 | uint32_t maxSketchSpace = (ESP.getFreeSketchSpace() - 0x1000) & 0xFFFFF000; 45 | if(!Update.begin(maxSketchSpace)){//start with max available size 46 | reply = "{\"success\":0,\"message\":\"Insufficient space.\"}"; 47 | } 48 | } else if(upload.status == UPLOAD_FILE_WRITE){ 49 | if(Update.write(upload.buf, upload.currentSize) != upload.currentSize){ 50 | reply = "{\"success\":0,\"message\":\"Failed to save\"}"; 51 | } 52 | 53 | } else if(upload.status == UPLOAD_FILE_END){ 54 | if(Update.end(true)){ //true to set the size to the current progress 55 | reply = "{\"success\":1,\"message\":\"Success: Device Restarting\"}"; 56 | } else { 57 | reply = "{\"success\":0,\"message\":\"Unknown Error\"}"; 58 | } 59 | } 60 | yield(); 61 | 62 | // Send to the client 63 | if (reply.length() > 0) { 64 | webServer.sendHeader("Connection", "close"); 65 | webServer.sendHeader("Access-Control-Allow-Origin", "*"); 66 | webServer.send(200, "application/json", reply); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /schematics/esp_Artnet_RDM_isolated_v2_BOM.txt: -------------------------------------------------------------------------------- 1 | esp_Artnet_RDM_isolated_v2_BOM 2 | 3 | This is the bill of materials. Please see https://github.com/mtongnz/ESP8266_ArtNetNode_v2 4 | for more details on this project. 5 | 6 | 7 | Part Value Device Package 8 | 9 | 5V_IN M02POLAR_LOCK MOLEX-1X2_LOCK 10 | 485A MAX485DIL MAX485DIL DIL08 11 | 485B MAX485DIL MAX485DIL DIL08 12 | C1 100uF CAP0805 0805 13 | C2 100uF CAP0805 0805 14 | C3 10uF CAP0805 0805 15 | C4 100uF CAP0805 0805 16 | C5 10uF CAP0805 0805 17 | C6 100uF CAP0805 0805 18 | C7 10uF 35V CAP_POLPTH1 CPOL-RADIAL-10UF-35V 19 | C8 10uF 35V CAP_POLPTH1 CPOL-RADIAL-10UF-35V 20 | C9 100uF CAP0805 0805 21 | C10 100uF CAP0805 0805 22 | C11 100uF CAP0805 0805 23 | C12 100uF CAP0805 0805 24 | C13 100uF CAP0805 0805 25 | DC1 5V-5V NMA NMA 26 | DC2 5V-5V NMA NMA 27 | DMX_A NC3FAH2 NC3FAH2 NC3FAH2 28 | DMX_B NC3FAH2 NC3FAH2 NC3FAH2 29 | ESP8266 ESP07-16PIN ESP07-16PIN ESP07-16PIN 30 | JP1 M08LONGPADS 1X08_LONGPADS 31 | LED_A 5MM_WS2812_RGB_LED 5MM_WS2812_RGB_LED 4PIN_LED 32 | LED_B 5MM_WS2812_RGB_LED 5MM_WS2812_RGB_LED 4PIN_LED 33 | LED_P 5MM_WS2812_RGB_LED 5MM_WS2812_RGB_LED 4PIN_LED 34 | OK1 HCPL2630 HCPL2630 DIL08 35 | OK2 HCPL2630 HCPL2630 DIL08 36 | OK3 HCPL2630 HCPL2630 DIL08 37 | R1 3.3K RESISTOR0805-RES 0805 38 | R2 3.3K RESISTOR0805-RES 0805 39 | R3 470 RESISTOR0805-RES 0805 40 | R4 130 RESISTOR0805-RES 0805 41 | R5 560 RESISTOR0805-RES 0805 42 | R6 560 RESISTOR0805-RES 0805 43 | R7 560 RESISTOR0805-RES 0805 44 | R8 560 RESISTOR0805-RES 0805 45 | R9 130 RESISTOR0805-RES 0805 46 | R10 3.3K RESISTOR0805-RES 0805 47 | R11 4.7K RESISTOR0805-RES 0805 48 | R12 4.7K RESISTOR0805-RES 0805 49 | R13 470 RESISTOR0805-RES 0805 50 | R14 470 RESISTOR0805-RES 0805 51 | U1 3.3V Reg V_REG_LDOSMD SOT23-5 52 | U2 5V Reg V_REG_LDOSMD SOT23-5 53 | -------------------------------------------------------------------------------- /libs/espArtnetRDM/artnet.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | espArtNetRDM v1 (pre-release) library 4 | Copyright (c) 2016, Matthew Tong 5 | https://github.com/mtongnz/ 6 | Modified from https://github.com/forkineye/E131/blob/master/E131.h 7 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public 8 | License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any 9 | later version. 10 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied 11 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 12 | You should have received a copy of the GNU General Public License along with this program. 13 | If not, see http://www.gnu.org/licenses/ 14 | */ 15 | 16 | 17 | 18 | #ifndef artnet_data_h 19 | #define artnet_data_h 20 | 21 | #define ARTNET_PORT 6454 22 | #define ARTNET_BUFFER_MAX 600 23 | #define ARTNET_REPLY_SIZE 239 24 | #define ARTNET_IP_PROG_REPLY_SIZE 34 25 | #define ARTNET_RDM_REPLY_SIZE 24 26 | #define ARTNET_TOD_DATA_SIZE 28 27 | #define ARTNET_ADDRESS_OFFSET 18 28 | #define ARTNET_SHORT_NAME_LENGTH 18 29 | #define ARTNET_LONG_NAME_LENGTH 64 30 | #define ARTNET_NODE_REPORT_LENGTH 64 31 | #define ARTNET_CANCEL_MERGE_TIMEOUT 2500 32 | #define DMX_BUFFER_SIZE 512 33 | #define DMX_MAX_CHANS 512 34 | 35 | // Artnet Op Codes 36 | #define ARTNET_ARTPOLL 0x2000 37 | #define ARTNET_ARTPOLL_REPLY 0x2100 38 | #define ARTNET_DIAG_DATA 0x2300 39 | #define ARTNET_COMMAND 0x2400 40 | #define ARTNET_ARTDMX 0x5000 41 | #define ARTNET_NZS 0x5100 42 | #define ARTNET_SYNC 0x5200 43 | #define ARTNET_ADDRESS 0x6000 44 | #define ARTNET_INPUT 0x7000 45 | #define ARTNET_TOD_REQUEST 0x8000 46 | #define ARTNET_TOD_DATA 0x8100 47 | #define ARTNET_TOD_CONTROL 0x8200 48 | #define ARTNET_RDM 0x8300 49 | #define ARTNET_RDM_SUB 0x8400 50 | #define ARTNET_FIRMWARE_MASTER 0xF200 51 | #define ARTNET_FIRMWARE_REPLY 0xF300 52 | #define ARTNET_IP_PROG 0xF800 53 | #define ARTNET_IP_PROG_REPLY 0xF900 54 | 55 | // Artnet Node Report Codes 56 | #define ARTNET_RC_DEBUG 0x0000 57 | #define ARTNET_RC_POWER_OK 0x0001 58 | #define ARTNET_RC_POWER_FAIL 0x0002 59 | #define ARTNET_RC_SH_NAME_OK 0x0006 60 | #define ARTNET_RC_LO_NAME_OK 0x0007 61 | #define ARTNET_RC_FIRMWARE_FAIL 0x000E 62 | 63 | // Artnet Command Codes 64 | #define ARTNET_AC_NONE 0x00 65 | #define ARTNET_AC_CANCEL_MERGE 0x01 66 | #define ARTNET_AC_LED_NORMAL 0x02 67 | #define ARTNET_AC_LED_MUTE 0x03 68 | #define ARTNET_AC_LED_LOCATE 0x04 69 | #define ARTNET_AC_RESET_RX_FLAGS 0x05 70 | #define ARTNET_AC_MERGE_LTP_0 0x10 71 | #define ARTNET_AC_MERGE_LTP_1 0x11 72 | #define ARTNET_AC_MERGE_LTP_2 0x12 73 | #define ARTNET_AC_MERGE_LTP_3 0x13 74 | #define ARTNET_AC_MERGE_HTP_0 0x50 75 | #define ARTNET_AC_MERGE_HTP_1 0x51 76 | #define ARTNET_AC_MERGE_HTP_2 0x52 77 | #define ARTNET_AC_MERGE_HTP_3 0x53 78 | #define ARTNET_AC_CLEAR_OP_0 0x90 79 | #define ARTNET_AC_CLEAR_OP_1 0x91 80 | #define ARTNET_AC_CLEAR_OP_2 0x92 81 | #define ARTNET_AC_CLEAR_OP_3 0x93 82 | #define ARTNET_AC_ARTNET_SEL_0 0x60 83 | #define ARTNET_AC_ARTNET_SEL_1 0x61 84 | #define ARTNET_AC_ARTNET_SEL_2 0x62 85 | #define ARTNET_AC_ARTNET_SEL_3 0x63 86 | #define ARTNET_AC_ACN_SEL_0 0x70 87 | #define ARTNET_AC_ACN_SEL_1 0x71 88 | #define ARTNET_AC_ACN_SEL_2 0x72 89 | #define ARTNET_AC_ACN_SEL_3 0x73 90 | 91 | #endif 92 | -------------------------------------------------------------------------------- /source/store.h: -------------------------------------------------------------------------------- 1 | /* 2 | ESP8266_ArtNetNode v2.0.0 3 | Copyright (c) 2016, Matthew Tong 4 | https://github.com/mtongnz/ESP8266_ArtNetNode_v2 5 | 6 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public 7 | License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any 8 | later version. 9 | 10 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied 11 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 12 | You should have received a copy of the GNU General Public License along with this program. 13 | If not, see http://www.gnu.org/licenses/ 14 | */ 15 | 16 | 17 | // Change this if the settings structure changes 18 | #define CONFIG_VERSION "b5g" 19 | 20 | // Dont change this 21 | #define CONFIG_START 0 22 | 23 | enum fx_mode { 24 | FX_MODE_PIXEL_MAP = 0, 25 | FX_MODE_12 = 1 26 | }; 27 | 28 | enum p_type { 29 | TYPE_DMX_OUT = 0, 30 | TYPE_RDM_OUT = 1, 31 | TYPE_DMX_IN = 2, 32 | TYPE_WS2812 = 3 33 | }; 34 | 35 | enum p_protocol { 36 | PROT_ARTNET = 0, 37 | PROT_ARTNET_SACN = 1 38 | }; 39 | 40 | enum p_merge { 41 | MERGE_LTP = 0, 42 | MERGE_HTP = 1 43 | }; 44 | 45 | struct StoreStruct { 46 | // StoreStruct version 47 | char version[4]; 48 | 49 | // Device settings: 50 | IPAddress ip, subnet, gateway, broadcast, hotspotIp, hotspotSubnet, hotspotBroadcast, dmxInBroadcast; 51 | bool dhcpEnable, standAloneEnable; 52 | char nodeName[18], longName[64], wifiSSID[40], wifiPass[40], hotspotSSID[20], hotspotPass[20]; 53 | uint16_t hotspotDelay; 54 | uint8_t portAmode, portBmode, portAprot, portBprot, portAmerge, portBmerge; 55 | uint8_t portAnet, portAsub, portAuni[4], portBnet, portBsub, portBuni[4], portAsACNuni[4], portBsACNuni[4]; 56 | uint16_t portAnumPix, portBnumPix, portApixConfig, portBpixConfig; 57 | bool doFirmwareUpdate; 58 | uint8_t portApixMode, portBpixMode; 59 | uint16_t portApixFXstart, portBpixFXstart; 60 | uint8_t resetCounter, wdtCounter; 61 | 62 | } deviceSettings = { 63 | CONFIG_VERSION, 64 | 65 | // The default values 66 | IPAddress(2,0,0,1), IPAddress(255,0,0,0), IPAddress(2,0,0,1), IPAddress(2,255,255,255), IPAddress(2,0,0,1), IPAddress(255,0,0,0), IPAddress(2,255,255,255), IPAddress(2,255,255,255), 67 | true, false, 68 | "espArtNetNode", "espArtNetNode by Matthew Tong", "", "", "espArtNetNode", "byMtongnz2017", 69 | 15, 70 | TYPE_DMX_OUT, TYPE_DMX_OUT, PROT_ARTNET, PROT_ARTNET, MERGE_HTP, MERGE_HTP, 71 | 0, 0, {0, 1, 2, 3}, 0, 0, {4, 5, 6, 7}, {1, 2, 3, 4}, {5, 6, 7, 8}, 72 | 680, 680, 0, 0, 73 | false, 74 | FX_MODE_PIXEL_MAP, FX_MODE_PIXEL_MAP, 75 | 1, 1, 76 | 0, 0 77 | }; 78 | 79 | 80 | void eepromSave() { 81 | for (uint16_t t = 0; t < sizeof(deviceSettings); t++) 82 | EEPROM.write(CONFIG_START + t, *((char*)&deviceSettings + t)); 83 | 84 | EEPROM.commit(); 85 | } 86 | 87 | void eepromLoad() { 88 | // To make sure there are settings, and they are YOURS! 89 | // If nothing is found it will use the default settings. 90 | if (EEPROM.read(CONFIG_START + 0) == CONFIG_VERSION[0] && 91 | EEPROM.read(CONFIG_START + 1) == CONFIG_VERSION[1] && 92 | EEPROM.read(CONFIG_START + 2) == CONFIG_VERSION[2]) { 93 | 94 | // Store defaults for if we need them 95 | StoreStruct tmpStore; 96 | tmpStore = deviceSettings; 97 | 98 | // Copy data to deviceSettings structure 99 | for (uint16_t t = 0; t < sizeof(deviceSettings); t++) 100 | *((char*)&deviceSettings + t) = EEPROM.read(CONFIG_START + t); 101 | 102 | // If we want to restore all our settings 103 | if (deviceSettings.resetCounter >= 5 || deviceSettings.wdtCounter >= 10) { 104 | deviceSettings.wdtCounter = 0; 105 | deviceSettings.resetCounter = 0; 106 | 107 | // Store defaults back into main settings 108 | deviceSettings = tmpStore; 109 | } 110 | 111 | 112 | // If config files dont match, save defaults then erase the ESP config to clear away any residue 113 | } else { 114 | eepromSave(); 115 | delay(500); 116 | 117 | ESP.eraseConfig(); 118 | while(1); 119 | } 120 | } 121 | 122 | -------------------------------------------------------------------------------- /libs/espDMX_RDM/espDMX_RDM.h: -------------------------------------------------------------------------------- 1 | /* 2 | espDMX v2 library 3 | Copyright (c) 2016, Matthew Tong 4 | https://github.com/mtongnz/espDMX 5 | 6 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public 7 | License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any 8 | later version. 9 | 10 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied 11 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 12 | 13 | You should have received a copy of the GNU General Public License along with this program. 14 | If not, see http://www.gnu.org/licenses/ 15 | */ 16 | 17 | #ifndef espDMX_h 18 | #define espDMX_h 19 | 20 | #define DMX_MAX_BYTES_PER_INT 3 // How many bytes to send per interrupt 21 | #define DMX_TX_CONF 0x3c // SERIAL_8N2 22 | #define DMX_TX_BAUD 250000 23 | #define DMX_FULL_UNI_TIMING 800 // How often to output full 512 channel universe (in milliseconds) 24 | #define DMX_NO_LED 200 25 | #define DMX_MIN_CHANS 30 // Minimum channels output = this + DMX_ADD_CHANS 26 | #define DMX_ADD_CHANS 30 // Add extra buffer to the number of channels output 27 | #define UART_TX_FIFO_SIZE 0x80 28 | 29 | #define RDM_DISCOVERY_INC_TIME 700 // How often to run incremental discovery 30 | #define RDM_DISCOVERY_INCREMENTAL 0 31 | #define RDM_DISCOVERY_FULL 1 32 | #define RDM_DISCOVERY_TOD_WIPE 2 33 | 34 | 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include "Arduino.h" 40 | extern "C" { 41 | #include "osapi.h" 42 | #include "ets_sys.h" 43 | #include "mem.h" 44 | #include "user_interface.h" 45 | } 46 | #include 47 | #include "Stream.h" 48 | 49 | 50 | #include "rdm.h" 51 | #include "rdmDataTypes.h" 52 | #include "rdmFIFO.h" 53 | 54 | 55 | typedef void (*rdmCallBackFunc)(rdm_data*); 56 | typedef void (*todCallBackFunc)(void); 57 | typedef void (*inputCallBackFunc)(uint16_t); 58 | 59 | 60 | // DMX states 61 | enum dmx_state { 62 | DMX_STOP, 63 | DMX_START, 64 | DMX_TX, 65 | DMX_NOT_INIT, 66 | RDM_START, 67 | RDM_TX, 68 | RDM_RX, 69 | DMX_RX_BREAK, 70 | DMX_RX_DATA, 71 | DMX_RX_IDLE 72 | }; 73 | 74 | union byte_uint64 { 75 | byte b[8]; 76 | uint64_t u; 77 | }; 78 | 79 | 80 | struct dmx_ { 81 | uint8_t dmx_nr; 82 | uint8_t txPin; 83 | uint8_t dirPin; 84 | uint8_t ledIntensity; 85 | uint8_t state = DMX_NOT_INIT; 86 | 87 | uint16_t numChans; 88 | uint16_t txChan; 89 | uint16_t txSize; 90 | 91 | long full_uni_time; 92 | long last_dmx_time; 93 | long led_timer; 94 | bool newDMX = false; 95 | bool started = false; 96 | 97 | byte* data; 98 | byte* data1; 99 | bool ownBuffer = 0; 100 | 101 | bool isInput = false; 102 | inputCallBackFunc inputCallBack = NULL; 103 | 104 | bool rdm_enable = false; 105 | rdmFIFO rdm_queue; 106 | rdm_data rdm_response; 107 | uint16_t rx_pos = 0; 108 | uint16_t rdm_source_man; 109 | uint32_t rdm_source_dev; 110 | uint8_t rdm_trans_no = 0; 111 | bool rdm_discovery = false; 112 | uint32_t rdm_last_discovery = 0; 113 | uint16_t* todManID = NULL; 114 | uint32_t* todDevID = NULL; 115 | uint16_t tod_size = 0; 116 | uint8_t tod_status = RDM_TOD_NOT_READY; 117 | uint16_t rdm_discovery_pos = 0; 118 | bool tod_changed = false; 119 | 120 | rdmCallBackFunc rdmCallBack = NULL; 121 | todCallBackFunc todCallBack = NULL; 122 | }; 123 | typedef struct dmx_ dmx_t; 124 | 125 | class espDMX { 126 | public: 127 | espDMX(uint8_t dmx_nr); 128 | ~espDMX(); 129 | 130 | void begin(uint8_t dir, byte* buf); 131 | void begin(uint8_t dir) { 132 | begin(dir, NULL); 133 | }; 134 | void begin(byte* buf) { 135 | begin(255, buf); 136 | }; 137 | void begin(void) { 138 | begin(255, NULL); 139 | }; 140 | 141 | void setBuffer(byte*); 142 | void setBuffer(void) { 143 | setBuffer(NULL); 144 | }; 145 | void pause(); 146 | void unPause(); 147 | void end(); 148 | void ledIntensity(uint8_t); 149 | 150 | void setChans(byte *data) { 151 | setChans(data, 512, 1); 152 | } 153 | void setChans(byte *data, uint16_t numChans) { 154 | setChans(data, numChans, 1); 155 | } 156 | void setChans(byte*, uint16_t, uint16_t); 157 | 158 | 159 | void chanUpdate(uint16_t); 160 | void clearChans(); 161 | byte *getChans(); 162 | uint16_t numChans(); 163 | 164 | /* from stream class 165 | int available(void) override; 166 | int peek(void) override; 167 | int read(void) override; 168 | void flush(void) override; 169 | size_t write(uint8_t) override; 170 | operator bool() const; 171 | */ 172 | 173 | void rdmEnable(uint16_t, uint32_t); 174 | void rdmDisable(void); 175 | void rdmDiscovery(uint8_t); 176 | void rdmDiscovery() { 177 | rdmDiscovery(RDM_DISCOVERY_TOD_WIPE); 178 | }; 179 | 180 | void rdmSetCallBack(void (*rdmCallBackFunc)(rdm_data*)); 181 | void todSetCallBack(void (*todCallBackFunc)(void)); 182 | 183 | bool rdmSendCommand(rdm_data*); 184 | bool rdmSendCommand(uint8_t, uint16_t, uint16_t, uint32_t, byte*, uint16_t, uint16_t); 185 | bool rdmSendCommand(uint8_t cmdClass, uint16_t pid, uint16_t manID, uint32_t devID, byte* data, uint16_t dataLength) { 186 | return rdmSendCommand(cmdClass, pid, manID, devID, data, dataLength, 0); 187 | }; 188 | bool rdmSendCommand(uint8_t cmdClass, uint16_t pid, uint16_t manID, uint32_t devID) { 189 | return rdmSendCommand(cmdClass, pid, manID, devID, NULL, 0, 0); 190 | }; 191 | 192 | bool rdmEnabled(void); 193 | uint8_t todStatus(void); 194 | uint16_t todCount(void); 195 | 196 | uint16_t* todMan(void); 197 | uint32_t* todDev(void); 198 | uint16_t todMan(uint16_t n); 199 | uint32_t todDev(uint16_t n); 200 | 201 | void handler(void); 202 | 203 | void dmxIn(bool doIn); 204 | 205 | void setInputCallback(void (*inputCallBackFunc)(uint16_t)); 206 | 207 | private: 208 | friend void dmx_interrupt_handler(void); 209 | friend void rdm_timer_handler(void); 210 | friend void rdm_interrupt_disarm(dmx_t* dmx); 211 | friend void rdmPause(bool); 212 | 213 | void _transmit(void); 214 | void fillTX(void); 215 | 216 | void inputBreak(void); 217 | void dmxReceived(uint8_t); 218 | 219 | void rdmRXTimeout(void); 220 | void rdmBreakDetect(void); 221 | 222 | void rdmReceived(void); 223 | void rdmMuteResponse(rdm_data*); 224 | void rdmDiscoveryResponse(rdm_data*); 225 | 226 | bool rdmDiscConfirm(); 227 | 228 | bool rdmDiscoverBranch(uint16_t, uint32_t, uint16_t, uint32_t, bool); 229 | bool rdmDiscoverBranch(void) { 230 | return rdmDiscoverBranch(0x0000, 0x00000000, 0xFFFF, 0xFFFFFFFF, false); 231 | }; 232 | 233 | uint8_t _dmx_nr; 234 | dmx_t* _dmx; 235 | }; 236 | 237 | 238 | extern espDMX dmxA; 239 | extern espDMX dmxB; 240 | extern void rdmPause(bool); 241 | #endif 242 | 243 | -------------------------------------------------------------------------------- /libs/espArtnetRDM/espArtNetRDM.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | espArtNetRDM v1 (pre-release) library 4 | Copyright (c) 2016, Matthew Tong 5 | https://github.com/mtongnz/ 6 | Modified from https://github.com/forkineye/E131/blob/master/E131.h 7 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public 8 | License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any 9 | later version. 10 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied 11 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 12 | You should have received a copy of the GNU General Public License along with this program. 13 | If not, see http://www.gnu.org/licenses/ 14 | */ 15 | 16 | 17 | 18 | #ifndef espArtNetRDM_h 19 | #define espArtNetRDM_h 20 | 21 | #include 22 | #include 23 | extern "C" { 24 | #include "mem.h" 25 | } 26 | #include "rdmDataTypes.h" 27 | #include "artnet.h" 28 | #include "e131.h" 29 | 30 | 31 | typedef void (*artDMXCallBack)(uint8_t, uint8_t, uint16_t, bool); 32 | typedef void (*artSyncCallBack)(void); 33 | typedef void (*artRDMCallBack)(uint8_t, uint8_t, rdm_data*); 34 | typedef void (*artIPCallBack)(void); 35 | typedef void (*artAddressCallBack)(void); 36 | typedef void (*artTodRequestCallBack)(uint8_t, uint8_t); 37 | typedef void (*artTodFlushCallBack)(uint8_t, uint8_t); 38 | 39 | enum port_type { 40 | DMX_OUT = 0, 41 | RDM_OUT = 1, 42 | DMX_IN = 2 43 | }; 44 | 45 | struct _port_def { 46 | // DMX out/in or RDM out 47 | uint8_t portType; 48 | 49 | // sACN settings 50 | bool e131; 51 | uint16_t e131Uni; 52 | uint16_t e131Sequence; 53 | uint8_t e131Priority; 54 | 55 | // Port universe 56 | byte portUni; 57 | 58 | // DMX final values buffer 59 | byte* dmxBuffer; 60 | uint16_t dmxChans; 61 | bool ownBuffer; 62 | bool mergeHTP; 63 | bool merging; 64 | 65 | // ArtDMX input buffers for 2 IPs 66 | byte* ipBuffer; 67 | uint16_t ipChans[2]; 68 | 69 | // IPs for current data + time of last packet 70 | IPAddress senderIP[2]; 71 | unsigned long lastPacketTime[2]; 72 | 73 | // IPs for the last 5 RDM commands 74 | IPAddress rdmSenderIP[5]; 75 | unsigned long rdmSenderTime[5]; 76 | 77 | // RDM Variables 78 | bool todAvailable; 79 | uint16_t uidTotal; 80 | uint16_t uidMan[50]; 81 | uint32_t uidSerial[50]; 82 | unsigned long lastTodCommand; 83 | }; 84 | 85 | typedef struct _port_def port_def; 86 | 87 | struct _group_def { 88 | // Port Address 89 | byte netSwitch = 0x00; 90 | byte subnet = 0x00; 91 | 92 | port_def* ports[4] = {0,0,0,0}; 93 | byte numPorts = 0; 94 | 95 | IPAddress cancelMergeIP; 96 | bool cancelMerge; 97 | unsigned long cancelMergeTime; 98 | }; 99 | 100 | typedef struct _group_def group_def; 101 | 102 | struct _artnet_def { 103 | 104 | IPAddress deviceIP; 105 | IPAddress subnet; 106 | IPAddress broadcastIP; 107 | IPAddress rdmIP[5]; 108 | uint8_t rdmIPcount; 109 | 110 | IPAddress syncIP; 111 | unsigned long lastSync; 112 | 113 | uint8_t deviceMAC[6]; 114 | bool dhcp = true; 115 | 116 | char shortName[ARTNET_SHORT_NAME_LENGTH]; 117 | char longName[ARTNET_LONG_NAME_LENGTH]; 118 | 119 | byte oemHi; 120 | byte oemLo; 121 | byte estaHi; 122 | byte estaLo; 123 | 124 | group_def* group[16]; 125 | uint8_t numGroups; 126 | uint32_t lastIPProg; 127 | uint32_t nextPollReply; 128 | 129 | uint16_t firmWareVersion; 130 | uint32_t nodeReportCounter; 131 | uint16_t nodeReportCode; 132 | char nodeReport[ARTNET_NODE_REPORT_LENGTH]; 133 | 134 | // callback functions 135 | artDMXCallBack dmxCallBack = 0; 136 | artSyncCallBack syncCallBack = 0; 137 | artRDMCallBack rdmCallBack = 0; 138 | artIPCallBack ipCallBack = 0; 139 | artAddressCallBack addressCallBack = 0; 140 | artTodRequestCallBack todRequestCallBack = 0; 141 | artTodFlushCallBack todFlushCallBack = 0; 142 | }; 143 | 144 | typedef struct _artnet_def artnet_device; 145 | 146 | 147 | 148 | 149 | class esp8266ArtNetRDM { 150 | public: 151 | // init fuctions 152 | esp8266ArtNetRDM(); 153 | ~esp8266ArtNetRDM(); 154 | 155 | void init(IPAddress, IPAddress, bool, char*, char*, uint16_t, uint16_t, uint8_t*); 156 | void init(IPAddress ip, IPAddress sub, bool dhcp, uint16_t oem, uint16_t esta, uint8_t* mac) { 157 | init(ip, sub, dhcp, "espArtNetNode", "espArtNetNode", oem, esta, mac); 158 | }; 159 | void init(char* shortName, char* longName, uint16_t oem, uint16_t esta, uint8_t* mac) { 160 | init(INADDR_NONE, INADDR_NONE, false, shortName, longName, oem, esta, mac); 161 | setDefaultIP(); 162 | }; 163 | void init(char* shortName, uint16_t oem, uint16_t esta, uint8_t* mac) { 164 | init(INADDR_NONE, INADDR_NONE, false, shortName, shortName, oem, esta, mac); 165 | setDefaultIP(); 166 | }; 167 | void init(uint16_t oem, uint16_t esta, uint8_t* mac) { 168 | init(INADDR_NONE, INADDR_NONE, false, "espArtNetNode", "espArtNetNode", oem, esta, mac); 169 | setDefaultIP(); 170 | }; 171 | 172 | void setFirmwareVersion(uint16_t); 173 | void setDefaultIP(); 174 | 175 | uint8_t addGroup(byte, byte); 176 | 177 | uint8_t addPort(byte, byte, byte, uint8_t, bool, byte*); 178 | uint8_t addPort(byte group, byte port, byte universe, uint8_t type, bool htp) { 179 | return addPort(group, port, universe, type, htp, 0); 180 | }; 181 | uint8_t addPort(byte group, byte port, byte universe, uint8_t type) { 182 | return addPort(group, port, universe, type, true, 0); 183 | }; 184 | uint8_t addPort(byte group, byte port, byte universe) { 185 | return addPort(group, port, universe, DMX_OUT, true, 0); 186 | }; 187 | 188 | bool closePort(uint8_t, uint8_t); 189 | void begin(); 190 | void end(); 191 | void pause(); 192 | byte* getDMX(uint8_t, uint8_t); 193 | uint16_t numChans(uint8_t, uint8_t); 194 | 195 | // sACN functions 196 | void setE131(uint8_t, uint8_t, bool); 197 | bool getE131(uint8_t, uint8_t); 198 | void setE131Uni(uint8_t, uint8_t, uint16_t); 199 | 200 | // handler function for including in loop() 201 | void handler(); 202 | 203 | // set callback functions 204 | void setArtDMXCallback(void (*dmxCallBack)(uint8_t, uint8_t, uint16_t, bool)); 205 | void setArtRDMCallback(void (*rdmCallBack)(uint8_t, uint8_t, rdm_data*)); 206 | void setArtSyncCallback(void (*syncCallBack)()); 207 | void setArtIPCallback(void (*ipCallBack)()); 208 | void setArtAddressCallback(void (*addressCallBack)()); 209 | void setTODRequestCallback(void (*artTodRequestCallBack)(uint8_t, uint8_t)); 210 | void setTODFlushCallback(void (*artTodFlushCallBack)(uint8_t, uint8_t)); 211 | 212 | // set ArtNet uni settings 213 | void setNet(uint8_t, uint8_t); 214 | void setSubNet(uint8_t, uint8_t); 215 | void setUni(uint8_t, uint8_t, uint8_t); 216 | void setPortType(uint8_t, uint8_t, uint8_t); 217 | 218 | // get ArtNet uni settings 219 | byte getNet(uint8_t); 220 | byte getSubNet(uint8_t); 221 | byte getUni(uint8_t, uint8_t); 222 | 223 | // set network settings 224 | void setIP(IPAddress, IPAddress); 225 | void setIP(IPAddress ip) { 226 | setIP(ip, INADDR_NONE); 227 | } 228 | void setDHCP(bool); 229 | 230 | // Set Merge & node name 231 | void setMerge(uint8_t, uint8_t, bool); 232 | bool getMerge(uint8_t, uint8_t); 233 | void setShortName(char*); 234 | char* getShortName(); 235 | void setLongName(char*); 236 | char* getLongName(); 237 | 238 | // RDM functions 239 | void rdmResponse(rdm_data*, uint8_t, uint8_t); 240 | void artTODData(uint8_t, uint8_t, uint16_t*, uint32_t*, uint16_t, uint8_t); 241 | 242 | // get network settings 243 | IPAddress getIP(); 244 | IPAddress getSubnetMask(); 245 | bool getDHCP(); 246 | 247 | void setNodeReport(char*, uint16_t); 248 | void artPollReply(); 249 | 250 | void sendDMX(uint8_t, uint8_t, IPAddress, uint8_t*, uint16_t); 251 | 252 | private: 253 | artnet_device* _art = 0; 254 | 255 | int _artOpCode(unsigned char*); 256 | void _artIPProgReply(); 257 | 258 | // handlers for received packets 259 | void _artPoll(void); 260 | void _artDMX(unsigned char*); 261 | void _saveDMX(unsigned char*, uint16_t, uint8_t, uint8_t, IPAddress, uint16_t); 262 | void _artIPProg(unsigned char*); 263 | void _artAddress(unsigned char*); 264 | void _artSync(unsigned char*); 265 | void _artFirmwareMaster(unsigned char*); 266 | void _artTODRequest(unsigned char*); 267 | void _artTODControl(unsigned char*); 268 | void _artRDM(unsigned char*, uint16_t); 269 | void _artRDMSub(unsigned char*); 270 | 271 | void _e131Receive(e131_packet_t*); 272 | 273 | uint8_t _dmxSeqID = 0; 274 | uint8_t e131Count = 0; // the number of e131 ports currently open 275 | 276 | WiFiUDP eUDP; 277 | WiFiUDP fUDP; 278 | }; 279 | 280 | 281 | #endif 282 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ESP8266_ArtNetNode_v2 2 | ESP8266 based WiFi ArtNet V4 to DMX, RDM and LED Pixels 3 | 4 | This is a complete rewrite of my previous project found here: http://www.instructables.com/id/ESP8266-Artnet-to-DMX/ 5 | 6 | An Instructable detailing how to setup pixel mapping using Jinx can be found here: https://www.instructables.com/id/Artnet-LED-Pixels-With-ESP8266/ 7 | 8 | If you find this helpful and you're feeling generous, I'd love for you to buy me a beer or some gear: https://www.paypal.me/mtongnz. Thanks heaps to all those who have donated. It's really appreciated 9 | 10 | ## Prizes for Fixing Stuff 11 | There are 3 prizes up for grabs for people who fix/add some of the issues/features I haven't had time to finish yet. 12 | 13 | Have a look here for details: https://github.com/mtongnz/ESP8266_ArtNetNode_v2/blob/master/prizes.md 14 | 15 | ## Which file to flash 16 | If you have a larger ESP with access to all the pins in the schematic, then download the standard bin file to ensure you get both outputs with RDM and also the settings reset function. 17 | 18 | ESP01: This disables the second output and puts the DIR_A onto pin GPIO2. 19 | 20 | NO_RESET: This disables the startup "reset of settings" funtionality. It is not recommended and is only provided for compatibility with devices without GPIO14 available or for those of you with an older version of my hardware. 21 | 22 | WEMOS: This is compiled for Wemos D1 and similar boards. It uses the 4M (3M SPIFFS) compiler option. 23 | 24 | ## Known Issues & Feedback 25 | Please see the issues tab for known issues or to submit bugs or suggestions 26 | 27 | ## Schematic notes 28 | esp_Artnet_RDM_isolated_v2.jpg is the latest version. It uses APA106 LEDs for status. This frees up more pins for future use - possibly with an LCD or more outputs. You could modify the source if you wish to use normal LEDs instead. 29 | 30 | The following notes are for the older schematic but some may apply to the current schematic so I've left it here: 31 | - Pin numbers used are ESP8266 GPIO numbers. NodeMCU & Wemos boards use a different numbering system. See below for details 32 | - The ESP01 allows for one full DMX/RDM/Pixel port only. Use pin GPIO2 instead of GPIO5 for the RDM direction pin. 33 | - GPIO14 is used to reset default settings. Tie to 3.3V with a resistor for normal operation. Hold to GND while the device is booting to wipe the settings and restore the defaults. This feauture isn't available for ESP01 and a NO_RESET firmware is available also. 34 | - The node_dmx_and_pix schematic is recommended as it allows for DMX with RDM & also ws2812(b) strips by using the convert_max485_to_pix 35 | - The convert_max485_to_pix schematic is not a DMX driver for the strips! It simply converts the logic back to the ws2812(b) logic. 36 | - The node_pix_only schematic is for those of you who don't want DMX. Note that all the DMX options are still in the firmware and may cause the pixel strips to do wierd things if selected. 37 | - I have excluded any voltage convertion as I've found the ESP8266 has 5V tolerant pins. See here: http://ba0sh1.com/blog/2016/08/03/is-esp8266-io-really-5v-tolerant/ 38 | - The outputs are not isolated electrically or optically at this point. 39 | - C1 - 5 can be any caps and are used to ensure each component has a stable power supply. I use 100nF. 40 | - You can use just one output if desired. Simply don't connect the second MAX485 and associated components. 41 | - The MAX485 can be substituted for any compatible RS-485 transeiver. 42 | 43 | ## Flashing firmware 44 | Please note that the device will generally need a power cycle after updating the firmware. 45 | 46 | ### Web UI OTA from my previous project 47 | Flash https://github.com/mtongnz/ESP8266_ArtNetNode_DMX to your device (if not already on there) using the Arduino IDE and then use the Web UI to upload the .bin available in this git. 48 | ### Direct bin flash 49 | Follow instructions here: http://www.instructables.com/id/Intro-Esp-8266-firmware-update/ 50 | ### Arduino IDE 51 | You can also use the "WebUpdate" found in Examples->ESP8266WebServer. Make sure you change the Flash Size in the Tools menu to match your ESP8266s flash. You'll need to allow about 700K for the sketch and upload or OTA will fail - this means that with a 1M unit, select the 1M(256K SPIFFS). 52 | 53 | Instructions to find out your flash size (if unknown) are on my Instructable linked at the top of this page. 54 | 55 | ## Getting Started 56 | ### First Boot 57 | On your first boot, the device will start a hotspot called "espArtNetNode" with a password of "byMtongnz2017" (case sensitive). Login to the hotspot and goto 2.0.0.1 in a browser. 58 | 59 | Note that the hotspot is, by default, only for accessing the settings page. You'll need to enable Stand Alone mode in the web UI if you want to send ArtNet to the device in hotspot mode. 60 | ### Web UI 61 | In hotspot mode, goto 2.0.0.1 and in Wifi mode goto whatever the device IP might be - either static or assigned by DHCP. 62 | 63 | In the Wifi tab, enter your SSID and password. Click save (it should go green and say Settings Saved). Now click reboot and the device should connect to your Wifi. 64 | 65 | If the device can't connect to the wifi or get a DHCP assigned address within (Start Delay) seconds, it will start the hotspot and wait for 30 seconds for you to connect. If a client doesn't connect to the hotspot in time, the device will restart and try again. 66 | 67 | ### Restore Factory Defaults 68 | I have allowed for 2 methods to restore the factory default settings: using a dedicated factory reset button on GPIO14 or multiple power cycles. 69 | 70 | Method 1: Hold GPIO14 to GND while the device boots. This method isn't available for the ESP01 or NO_RESET builds. 71 | 72 | Method 2: Allow the esp8266 about 1-4 seconds to start, then reset it (or power cycle). Do this at least 5 times to restore factory default settings. 73 | 74 | ### DMX Workshop 75 | I have implemented as many DMX Workshop/ArtNet V4 features as I possibly could. You can change settings such as merge mode, IP address, DHCP, port addresses, node name... Most of these are also available via the web UI. 76 | 77 | ## Features 78 | - sACN and ArtNet V4 support 79 | - 2 full universes of DMX output with full RDM support for both outputs 80 | - Up to 1360 ws2812(b) pixels - 8 full universes 81 | - DMX/RDM out one port, ws2812(b) out the other 82 | - DMX in - send to any ArtNet device 83 | - Web UI with mobile support 84 | - Web UI uses AJAX & JSON to minimize network traffic used & decrease latency 85 | - Full DMX Workshop support 86 | - Pixel FX - a 12 channel mode for ws2812 LED pixel control 87 | 88 | ## To be done 89 | ### Scene storage 90 | I have not yet implemented the Scene Storage feature from my previous project. I wish to improve on it and allow for making chases or effects. 91 | ### Handle artRdmSub packets 92 | I haven't yet implemented the artRdmSub messages. This doesn't affect usability as they are optional and all devices must support artRdm packets. The artRdmSub messages do provide a smaller network load and this should be coming shortly. 93 | ### Pixels other than WS2812 94 | A few people have asked for this and it shouldn't be too hard, except for the Pixel FX engine integration. 95 | 96 | ## Pixel FX 97 | To enable this mode, select WS2812 in the port settings and enter the number of pixels you wish to control. Select '12 Channel FX'. 'Start Channel' is the DMX address of the first channel below. 98 | 99 | Note: You still need to set the Artnet net, subnet and universe correctly. 100 | 101 | | DMX Channel | Function | Values (0-255) | | 102 | |----|----|----|----| 103 | | 1 | Intensity | 0 - 255 | | 104 | | 2 | FX Select | 0 - 49 | Static | 105 | | | | 50 - 74 | Rainbow | 106 | | | | 75 - 99 | Theatre Chase | 107 | | | | 100 - 124 | Twinkle | 108 | | 3 | Speed | 0 - 19 | Stop - Index Reset | 109 | | | | 20 - 122 | Slow - Fast CW | 110 | | | | 123 - 130 | Stop | 111 | | | | 131 - 234 | Fast - Slow CCW | 112 | | | | 235 - 255 | Stop | 113 | | 4 | Position | 0 - 127 - 255 | Left - Centre - Right | 114 | | 5 | Size | 0 - 255 | Small - Big | 115 | | 6 | Colour 1 | 0 - 255 | Red | 116 | | 7 | | 0 - 255 | Green | 117 | | 8 | | 0 - 255 | Blue | 118 | | 9 | Colour 2 | 0 - 255 | Red | 119 | | 10 | | 0 - 255 | Green | 120 | | 11 | | 0 - 255 | Blue | 121 | | 12 | Modify | 0 - 255 | *Modify FX | 122 | 123 | Modify FX is only currently used for the Static effect and is used to resize colour 1 within the overall size. 124 | 125 | ## NodeMCU & Wemos Pins 126 | These boards use strange numbering that doesn't match the ESP8266 numbering. Here are the main hookups needed: 127 | 128 | | NodeMCU & Wemos | ESP8266 GPIO | Purpose | 129 | |-----------------|--------------|---------| 130 | | TX | GPIO1 | DMX_TX_A | 131 | | D4 | GPIO2 | DMX_TX_B | 132 | | RX | GPIO3 | DMX_RX (for A & B) | 133 | | D1 | GPIO5 | DMX_DIR_A | 134 | | D0 | GPIO16 | DMX_DIR_B | 135 | 136 | ## Special Thanks To 137 | I'd like to thank these people. They have either contributed with donations, a large amount of testing and feedback, or with their own code/projects that have been of assistance or inspiration. 138 | 139 | - Tristan Thiltges 140 | - Cyprien Leduc 141 | - Jochen Schefe 142 | - Jan Raeymaekers 143 | - Wiktor Kaluzny 144 | - Jean-Michel Blouin 145 | - Tobias Schulz 146 | - Ben Small 147 | - Harald Müller 148 | - Volodymyr Bereza 149 | - Felix Hartmann 150 | - Ruud Leemans 151 | - Bogumil palewicz 152 | - Anton Manchenko 153 | - Bogumil Palewicz 154 | - Marcel Dolnak 155 | - Paul Lim 156 | - Geo Karavasilis 157 | - [Claude Heintz](https://github.com/claudeheintz/) 158 | - [Shelby Merrick (Forkineye)](https://github.com/forkineye) 159 | -------------------------------------------------------------------------------- /source/wsFX.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ESP8266_ArtNetNode v2.0.0 3 | Copyright (c) 2016, Matthew Tong 4 | https://github.com/mtongnz/ESP8266_ArtNetNode_v2 5 | 6 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public 7 | License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any 8 | later version. 9 | 10 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied 11 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 12 | You should have received a copy of the GNU General Public License along with this program. 13 | If not, see http://www.gnu.org/licenses/ 14 | */ 15 | 16 | 17 | #include "wsFX.h" 18 | 19 | pixPatterns::pixPatterns(uint8_t port, ws2812Driver* p) { 20 | pixDriver = p; 21 | Port = port; 22 | NewData = 0; 23 | lastUpdate = 0; 24 | Intensity = 0; 25 | Speed = 0; 26 | TotalSteps = 100; 27 | } 28 | 29 | // Update the pattern 30 | bool pixPatterns::Update(void) { 31 | if((millis() - lastUpdate) > Interval) { // time to update 32 | lastUpdate = millis(); 33 | 34 | switch(ActivePattern) { 35 | case RAINBOW_CYCLE: 36 | RainbowCycleUpdate(); 37 | break; 38 | case THEATER_CHASE: 39 | TheaterChaseUpdate(); 40 | break; 41 | case TWINKLE: 42 | TwinkleUpdate(); 43 | break; 44 | 45 | case STATIC: 46 | default: 47 | StaticUpdate(); 48 | break; 49 | } 50 | return 1; 51 | } 52 | return 0; 53 | } 54 | 55 | // Increment the Index and reset at the end 56 | void pixPatterns::Increment(void) { 57 | if (Speed < 20 || Speed > 235) 58 | return; 59 | 60 | else if (Speed > 131) { 61 | Index++; 62 | 63 | if (Index >= TotalSteps) 64 | Index = 0; 65 | 66 | } else if (Speed < 123) { 67 | if (Index == 0 || Index > TotalSteps) 68 | Index = TotalSteps - 1; 69 | else 70 | Index--; 71 | } 72 | } 73 | 74 | void pixPatterns::setSpeed(uint8_t s) { 75 | // Index reset mode 76 | if (s < 20) { 77 | if (Speed != s) 78 | Index = 0; 79 | Speed = s; 80 | Interval = 1; 81 | 82 | // Indexed non-reset mode 83 | } else if (s > 235) { 84 | Interval = 1; 85 | Speed = s; 86 | 87 | // Chase mode 88 | } else { 89 | Speed = s; 90 | if (Speed > 127) 91 | Interval = map(Speed, 131, 235, 1, 60); 92 | else 93 | Interval = map(Speed, 20, 123, 60, 1); 94 | } 95 | } 96 | 97 | void pixPatterns::setIntensity(uint8_t i) { 98 | Intensity = i; 99 | setColour1(Colour1Raw); 100 | setColour2(Colour2Raw); 101 | } 102 | 103 | void pixPatterns::setColour1(uint32_t c) { 104 | Colour1Raw = c; 105 | Colour1 = Colour(map(Red(Colour1Raw), 0, 255, 0, Intensity), map(Green(Colour1Raw), 0, 255, 0, Intensity), map(Blue(Colour1Raw), 0, 255, 0, Intensity)); 106 | } 107 | 108 | void pixPatterns::setColour2(uint32_t c) { 109 | Colour2Raw = c; 110 | Colour2 = Colour(map(Red(Colour2Raw), 0, 255, 0, Intensity), map(Green(Colour2Raw), 0, 255, 0, Intensity), map(Blue(Colour2Raw), 0, 255, 0, Intensity)); 111 | } 112 | 113 | void pixPatterns::setFX(uint8_t fx) { 114 | if (fx < 50) 115 | Static(); 116 | else if (fx < 75) 117 | RainbowCycle(); 118 | else if (fx < 100) 119 | TheaterChase(); 120 | else if (fx < 125) 121 | Twinkle(); 122 | } 123 | 124 | // Initialize static looks 125 | void pixPatterns::Static(void) { 126 | if (ActivePattern == STATIC) 127 | return; 128 | 129 | ActivePattern = STATIC; 130 | Index = 0; 131 | } 132 | 133 | // Update the static look 134 | void pixPatterns::StaticUpdate(void) { 135 | TotalSteps = pixDriver->numPixels(Port); 136 | 137 | // Calculate the values to use mapped to the number of pixels we have 138 | uint16_t mSize = map(Size, 0, 255, 2, TotalSteps); // Overall size 139 | uint16_t mSize1 = map(Size1, 0, 255, 0, mSize); // Colour1 size 140 | // uint16_t mFade = map(Fade, 0, 255, 0, (mSize/2)); // Colour fade size 141 | 142 | // Calculate the position offset - the shapes are centered using Pos 143 | uint16_t midPoint = map(Pos, 0, 255, 0, TotalSteps); 144 | uint16_t mPos = mSize - (midPoint - (mSize/2) - (uint16_t)((midPoint - (mSize/2)) / mSize) * mSize) + Index; 145 | /* 146 | // Calculate the colour components 147 | uint8_t r1 = Red(Colour1); 148 | uint8_t g1 = Green(Colour1); 149 | uint8_t b1 = Blue(Colour1); 150 | uint8_t r2 = Red(Colour2); 151 | uint8_t g2 = Green(Colour2); 152 | uint8_t b2 = Blue(Colour2); 153 | int16_t r3, g3, b3; 154 | 155 | // Calculate fade values 156 | if (mFade) { 157 | r3 = (r2 - r1) / mFade; 158 | g3 = (g2 - g1) / mFade; 159 | b3 = (b2 - b1) / mFade; 160 | } 161 | */ 162 | 163 | for(uint16_t p = 0; p < TotalSteps; p++) { 164 | uint16_t i = (p + mPos) % mSize; 165 | uint32_t c; 166 | /* 167 | // Left faded area 168 | if (mFade && i < mFade) { 169 | uint8_t r = (r3 * i) + r1; 170 | uint8_t g = (g3 * i) + g1; 171 | uint8_t b = (b3 * i) + b1; 172 | 173 | c = Colour(r, g, b); 174 | 175 | // Middle faded area 176 | } else if (mFade && i > (mSize1 - mFade) && i < (mSize1 + mFade)) { 177 | i -= (mSize1 - mFade); 178 | uint8_t r = (r3 * i) + r1; 179 | uint8_t g = (g3 * i) + g1; 180 | uint8_t b = (b3 * i) + b1; 181 | 182 | c = Colour(r, g, b); 183 | 184 | // Middle faded area 185 | } else if (mFade && i < (mSize1 + mFade)) { 186 | i = (mSize1 + mFade) - i; 187 | uint8_t r = (r3 * i) + r2; 188 | uint8_t g = (g3 * i) + g2; 189 | uint8_t b = (b3 * i) + b2; 190 | 191 | c = Colour(r, g, b); 192 | 193 | // Right faded area 194 | } else if (mFade && i > (mSize - mFade)) { 195 | i -= (mSize - mFade); 196 | uint8_t r = (r3 * i) + r2; 197 | uint8_t g = (g3 * i) + g2; 198 | uint8_t b = (b3 * i) + b2; 199 | 200 | c = Colour(r, g, b); 201 | 202 | // Out of faded area 203 | } else 204 | */ 205 | if (i < mSize1) 206 | c = Colour1; 207 | else 208 | c = Colour2; 209 | 210 | pixDriver->setPixel(Port, p, c); 211 | } 212 | Increment(); 213 | } 214 | 215 | // Initialize for a RainbowCycle 216 | void pixPatterns::RainbowCycle(void) { 217 | if (ActivePattern == RAINBOW_CYCLE) 218 | return; 219 | 220 | ActivePattern = RAINBOW_CYCLE; 221 | Index = 0; 222 | } 223 | 224 | // Update the Rainbow Cycle Pattern 225 | void pixPatterns::RainbowCycleUpdate(void) { 226 | TotalSteps = 255; 227 | 228 | uint16_t mSize = map(Size, 0, 255, 2, pixDriver->numPixels(Port)); 229 | 230 | for(uint16_t p = 0; p < pixDriver->numPixels(Port);) { 231 | for (uint16_t i = 0; i < mSize && p < pixDriver->numPixels(Port); i++, p++) { 232 | uint32_t c = Wheel(((i * 256 / mSize) + Index + Pos) & 255); 233 | uint8_t r = map(Red(c), 0, 255, 0, Intensity); 234 | uint8_t g = map(Green(c), 0, 255, 0, Intensity); 235 | uint8_t b = map(Blue(c), 0, 255, 0, Intensity); 236 | 237 | pixDriver->setPixel(Port, p, Colour(r, g, b)); 238 | } 239 | } 240 | Increment(); 241 | } 242 | 243 | // Initialize for a Theater Chase 244 | void pixPatterns::TheaterChase(void) { 245 | if (ActivePattern == THEATER_CHASE) 246 | return; 247 | 248 | ActivePattern = THEATER_CHASE; 249 | Index = 0; 250 | } 251 | 252 | // Update the Theater Chase Pattern 253 | void pixPatterns::TheaterChaseUpdate(void) { 254 | TotalSteps = pixDriver->numPixels(Port); 255 | 256 | uint8_t mSize = map(Size, 0, 255, 3, 50); 257 | uint8_t a = (Index / map(mSize, 3, 50, 8, 2)) + map(Pos, 0, 255, mSize, 0); 258 | 259 | for(int i = 0; i < pixDriver->numPixels(Port); i++) { 260 | if ((i + a) % mSize == 0) 261 | pixDriver->setPixel(Port, i, Colour1); 262 | else 263 | pixDriver->setPixel(Port, i, Colour2); 264 | } 265 | Increment(); 266 | } 267 | 268 | // Initialize for Twinkle 269 | void pixPatterns::Twinkle(void) { 270 | if (ActivePattern == TWINKLE) 271 | return; 272 | 273 | ActivePattern = TWINKLE; 274 | Index = 0; 275 | 276 | randomSeed(analogRead(0)); 277 | } 278 | 279 | // Update the Twinkle Pattern 280 | void pixPatterns::TwinkleUpdate(void) { 281 | TotalSteps = 3; 282 | 283 | // Clear strip 284 | if (Index % 3 == 0 || Speed < 20 || Speed > 235) { 285 | for (uint16_t i = 0; i < pixDriver->numPixels(Port); i++) 286 | pixDriver->setPixel(Port, i, Colour1); 287 | } 288 | 289 | // Make twinkles 290 | if (Index % 3 == 0 && Speed > 20 && Speed < 235) { 291 | uint16_t numTwinks = map(Size, 0, 255, 1, (pixDriver->numPixels(Port) / 10)); 292 | for (uint8_t n = 0; n < numTwinks; n++) 293 | pixDriver->setPixel(Port, random(0, pixDriver->numPixels(Port)), Colour2); 294 | } 295 | 296 | Increment(); 297 | } 298 | 299 | // Calculate 50% dimmed version of a colour (used by ScannerUpdate) 300 | uint32_t pixPatterns::DimColour(uint32_t colour) { 301 | return ((colour & 0xFEFEFE) >> 1); 302 | } 303 | 304 | // Returns 32-bit colour from components 305 | uint32_t pixPatterns::Colour(uint8_t r, uint8_t g, uint8_t b) { 306 | return ((r << 16) | (g << 8) | b); 307 | } 308 | 309 | // Returns the Red component of a 32-bit colour 310 | uint8_t pixPatterns::Red(uint32_t colour) { 311 | return (colour >> 16) & 0xFF; 312 | } 313 | 314 | // Returns the Green component of a 32-bit colour 315 | uint8_t pixPatterns::Green(uint32_t colour) { 316 | return (colour >> 8) & 0xFF; 317 | } 318 | 319 | // Returns the Blue component of a 32-bit colour 320 | uint8_t pixPatterns::Blue(uint32_t colour) { 321 | return colour & 0xFF; 322 | } 323 | 324 | // Input a value 0 to 255 to get a colour value. 325 | // The colours are a transition r - g - b - back to r. 326 | uint32_t pixPatterns::Wheel(byte WheelPos) { 327 | WheelPos = 255 - WheelPos; 328 | if(WheelPos < 85) 329 | return Colour(255 - WheelPos * 3, 0, WheelPos * 3); 330 | else if(WheelPos < 170) { 331 | WheelPos -= 85; 332 | return Colour(0, WheelPos * 3, 255 - WheelPos * 3); 333 | } else { 334 | WheelPos -= 170; 335 | return Colour(WheelPos * 3, 255 - WheelPos * 3, 0); 336 | } 337 | } 338 | 339 | -------------------------------------------------------------------------------- /style.css: -------------------------------------------------------------------------------- 1 | .author, 2 | .title, 3 | ul.nav a { 4 | text-align: center 5 | } 6 | 7 | .author i, 8 | .show, 9 | .title h1, 10 | ul.nav a { 11 | display: block 12 | } 13 | 14 | input, 15 | ul.nav a:hover { 16 | background-color: #DADADA 17 | } 18 | 19 | a, 20 | abbr, 21 | acronym, 22 | address, 23 | applet, 24 | b, 25 | big, 26 | blockquote, 27 | body, 28 | caption, 29 | center, 30 | cite, 31 | code, 32 | dd, 33 | del, 34 | dfn, 35 | div, 36 | dl, 37 | dt, 38 | em, 39 | fieldset, 40 | font, 41 | form, 42 | h1, 43 | h2, 44 | h3, 45 | h4, 46 | h5, 47 | h6, 48 | html, 49 | i, 50 | iframe, 51 | img, 52 | ins, 53 | kbd, 54 | label, 55 | legend, 56 | li, 57 | object, 58 | ol, 59 | p, 60 | pre, 61 | q, 62 | s, 63 | samp, 64 | small, 65 | span, 66 | strike, 67 | strong, 68 | sub, 69 | sup, 70 | table, 71 | tbody, 72 | td, 73 | tfoot, 74 | th, 75 | thead, 76 | tr, 77 | tt, 78 | u, 79 | ul, 80 | var { 81 | margin: 0; 82 | padding: 0; 83 | border: 0; 84 | outline: 0; 85 | font-size: 100%; 86 | vertical-align: baseline; 87 | background: 0 0 88 | } 89 | 90 | .main h2, 91 | li.last { 92 | border-bottom: 1px solid #888583 93 | } 94 | 95 | body { 96 | line-height: 1; 97 | background: #E4E4E4; 98 | color: #292929; 99 | color: rgba(0, 0, 0, .82); 100 | font: 400 100% Cambria, Georgia, serif; 101 | -moz-text-shadow: 0 1px 0 rgba(255, 255, 255, .8); 102 | } 103 | 104 | ol, 105 | ul { 106 | list-style: none 107 | } 108 | 109 | a { 110 | color: #890101; 111 | text-decoration: none; 112 | -moz-transition: .2s color linear; 113 | -webkit-transition: .2s color linear; 114 | transition: .2s color linear 115 | } 116 | 117 | a:hover { 118 | color: #DF3030 119 | } 120 | 121 | #page { 122 | padding: 0 123 | } 124 | 125 | .inner { 126 | margin: 0 auto; 127 | width: 91% 128 | } 129 | 130 | .amp { 131 | font-family: Baskerville, Garamond, Palatino, 'Palatino Linotype', 'Hoefler Text', 'Times New Roman', serif; 132 | font-style: italic; 133 | font-weight: 400 134 | } 135 | 136 | .mast { 137 | float: left; 138 | width: 31.875% 139 | } 140 | 141 | .title { 142 | font: semi 700 16px/1.2 Baskerville, Garamond, Palatino, 'Palatino Linotype', 'Hoefler Text', 'Times New Roman', serif; 143 | padding-top: 0 144 | } 145 | 146 | .title h1 { 147 | font: 700 20px/1.2 'Book Antiqua', 'Palatino Linotype', Georgia, serif; 148 | padding-top: 0 149 | } 150 | 151 | .author { 152 | font: 400 100% Cambria, Georgia, serif 153 | } 154 | 155 | .author i { 156 | font: 400 12px Baskerville, Garamond, Palatino, 'Palatino Linotype', 'Hoefler Text', 'Times New Roman', serif; 157 | letter-spacing: .05em; 158 | padding-top: .7em 159 | } 160 | 161 | .footer, 162 | .main { 163 | float: right; 164 | width: 65.9375% 165 | } 166 | 167 | ul.nav { 168 | margin: 1em auto 0; 169 | width: 11em 170 | } 171 | 172 | ul.nav a { 173 | font: 700 14px/1.2 'Book Antiqua', 'Palatino Linotype', Georgia, serif; 174 | letter-spacing: .1em; 175 | padding: .7em .5em; 176 | margin-bottom: 0; 177 | text-transform: uppercase 178 | } 179 | 180 | input[type=button], 181 | input[type=button]:focus { 182 | background-color: #E4E4E4; 183 | color: #890101 184 | } 185 | 186 | li { 187 | border-top: 1px solid #888583 188 | } 189 | 190 | .hide { 191 | display: none 192 | } 193 | 194 | .main h2 { 195 | font-size: 1.4em; 196 | text-align: left; 197 | margin: 0 0 1em; 198 | padding: 0 0 .3em 199 | } 200 | 201 | .main { 202 | position: relative 203 | } 204 | 205 | p.left { 206 | clear: left; 207 | float: left; 208 | width: 20%; 209 | min-width: 120px; 210 | max-width: 300px; 211 | margin: 0 0 .6em; 212 | padding: 0; 213 | text-align: right 214 | } 215 | 216 | p.right, 217 | select { 218 | min-width: 200px 219 | } 220 | 221 | p.right { 222 | overflow: auto; 223 | margin: 0 0 .6em .4em; 224 | padding-left: .6em; 225 | text-align: left 226 | } 227 | 228 | p.center, 229 | p.spacer { 230 | padding: 0; 231 | display: block 232 | } 233 | 234 | .footer, 235 | p.center { 236 | text-align: center 237 | } 238 | 239 | p.center { 240 | float: left; 241 | clear: both; 242 | margin: 3em 0 3em 15%; 243 | width: 70% 244 | } 245 | 246 | p.spacer { 247 | float: left; 248 | clear: both; 249 | margin: 0; 250 | width: 100%; 251 | height: 20px 252 | } 253 | 254 | input { 255 | margin: 0; 256 | border: 0; 257 | color: #890101; 258 | outline: 0; 259 | font: 400 100% Cambria, Georgia, serif 260 | } 261 | 262 | input[type=text] { 263 | width: 70%; 264 | min-width: 200px; 265 | padding: 0 5px 266 | } 267 | 268 | input[type=number] { 269 | min-width: 50px; 270 | width: 50px 271 | } 272 | 273 | input:focus { 274 | background-color: silver; 275 | color: #000 276 | } 277 | 278 | input[type=checkbox] { 279 | -webkit-appearance: none; 280 | background-color: #fafafa; 281 | border: 1px solid #cacece; 282 | box-shadow: 0 1px 2px rgba(0, 0, 0, .05), inset 0 -15px 10px -12px rgba(0, 0, 0, .05); 283 | padding: 9px; 284 | border-radius: 5px; 285 | display: inline-block; 286 | position: relative 287 | } 288 | 289 | input[type=checkbox]:active, 290 | input[type=checkbox]:checked:active { 291 | box-shadow: 0 1px 2px rgba(0, 0, 0, .05), inset 0 1px 3px rgba(0, 0, 0, .1) 292 | } 293 | 294 | input[type=checkbox]:checked { 295 | background-color: #fafafa; 296 | border: 1px solid #adb8c0; 297 | box-shadow: 0 1px 2px rgba(0, 0, 0, .05), inset 0 -15px 10px -12px rgba(0, 0, 0, .05), inset 15px 10px -12px rgba(255, 255, 255, .1); 298 | color: #99a1a7 299 | } 300 | 301 | input[type=checkbox]:checked:after { 302 | content: '\2714'; 303 | font-size: 14px; 304 | position: absolute; 305 | top: 0; 306 | left: 3px; 307 | color: #890101 308 | } 309 | 310 | input[type=button], 311 | input[type=file]+label { 312 | font: 700 16px/1.2 'Book Antiqua', 'Palatino Linotype', Georgia, serif; 313 | margin: 17px 0 0 314 | } 315 | 316 | input[type=button] { 317 | position: absolute; 318 | right: 0; 319 | display: block; 320 | border: 1px solid #adb8c0; 321 | float: right; 322 | border-radius: 12px; 323 | padding: 5px 20px 2px 23px; 324 | -webkit-transition-duration: .3s; 325 | transition-duration: .3s 326 | } 327 | 328 | input[type=button]:hover { 329 | background-color: #909090; 330 | color: #fff; 331 | padding: 5px 62px 2px 65px 332 | } 333 | 334 | input.submit { 335 | float: left; 336 | position: relative 337 | } 338 | 339 | input.showMessage, 340 | input.showMessage:focus, 341 | input.showMessage:hover { 342 | background-color: #6F0; 343 | color: #000; 344 | padding: 5px 62px 2px 65px 345 | } 346 | 347 | input[type=file] { 348 | width: .1px; 349 | height: .1px; 350 | opacity: 0; 351 | overflow: hidden; 352 | position: absolute; 353 | z-index: -1 354 | } 355 | 356 | input[type=file]+label { 357 | float: left; 358 | clear: both; 359 | cursor: pointer; 360 | border: 1px solid #adb8c0; 361 | border-radius: 12px; 362 | padding: 5px 20px 2px 23px; 363 | display: inline-block; 364 | background-color: #E4E4E4; 365 | color: #890101; 366 | overflow: hidden; 367 | -webkit-transition-duration: .3s; 368 | transition-duration: .3s 369 | } 370 | 371 | input[type=file]+label:hover, 372 | input[type=file]:focus+label { 373 | background-color: #909090; 374 | color: #fff; 375 | padding: 5px 40px 2px 43px 376 | } 377 | 378 | input[type=file]+label svg { 379 | width: 1em; 380 | height: 1em; 381 | vertical-align: middle; 382 | fill: currentColor; 383 | margin-top: -.25em; 384 | margin-right: .25em 385 | } 386 | 387 | select { 388 | margin: 0; 389 | border: 0; 390 | background-color: #DADADA; 391 | color: #890101; 392 | outline: 0; 393 | font: 400 100% Cambria, Georgia, serif; 394 | width: 50%; 395 | padding: 0 5px 396 | } 397 | 398 | .footer { 399 | border-top: 1px solid #888583; 400 | display: block; 401 | font-size: 12px; 402 | margin-top: 20px; 403 | padding: .7em 0 20px 404 | } 405 | 406 | .footer p { 407 | margin-bottom: .5em 408 | } 409 | 410 | @media (min-width:600px) { 411 | .inner { 412 | min-width: 600px 413 | } 414 | } 415 | 416 | @media (max-width:600px) { 417 | .inner, 418 | .page { 419 | min-width: 300px; 420 | width: 100%; 421 | overflow-x: hidden 422 | } 423 | .footer, 424 | .main, 425 | .mast { 426 | float: left; 427 | width: 100% 428 | } 429 | .mast { 430 | border-top: 1px solid #888583; 431 | border-bottom: 1px solid #888583 432 | } 433 | .main { 434 | margin-top: 4px; 435 | width: 98% 436 | } 437 | ul.nav { 438 | margin: 0 auto; 439 | width: 100% 440 | } 441 | ul.nav li { 442 | float: left; 443 | min-width: 100px; 444 | width: 33% 445 | } 446 | ul.nav a { 447 | font: 12px Helvetica, Arial, sans-serif; 448 | letter-spacing: 0; 449 | padding: .8em 450 | } 451 | .title, 452 | .title h1 { 453 | padding: 0; 454 | text-align: center 455 | } 456 | ul.nav a:focus, 457 | ul.nav a:hover { 458 | background-position: 0 100% 459 | } 460 | .author { 461 | display: none 462 | } 463 | .title { 464 | border-bottom: 1px solid #888583; 465 | width: 100%; 466 | display: block; 467 | font: 400 15px Baskerville, Garamond, Palatino, 'Palatino Linotype', 'Hoefler Text', 'Times New Roman', serif 468 | } 469 | .title h1 { 470 | font: 600 15px Baskerville, Garamond, Palatino, 'Palatino Linotype', 'Hoefler Text', 'Times New Roman', serif; 471 | display: inline 472 | } 473 | p.left, 474 | p.right { 475 | clear: both; 476 | float: left; 477 | margin-right: 1em 478 | } 479 | li, 480 | li.first, 481 | li.last { 482 | border: 0 483 | } 484 | p.left { 485 | width: 100%; 486 | text-align: left; 487 | margin-left: .4em; 488 | font-weight: 600 489 | } 490 | p.right { 491 | margin-left: 1em; 492 | width: 100% 493 | } 494 | p.center { 495 | margin: 1em 0; 496 | width: 100% 497 | } 498 | p.spacer { 499 | display: none 500 | } 501 | input[type=text], 502 | select { 503 | width: 85%; 504 | } 505 | @media (min-width:1300px) { 506 | .page { 507 | width: 1300px 508 | } 509 | } -------------------------------------------------------------------------------- /source/startFunctions.ino: -------------------------------------------------------------------------------- 1 | /* 2 | ESP8266_ArtNetNode v2.0.0 3 | Copyright (c) 2016, Matthew Tong 4 | https://github.com/mtongnz/ESP8266_ArtNetNode_v2 5 | 6 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public 7 | License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any 8 | later version. 9 | 10 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied 11 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 12 | You should have received a copy of the GNU General Public License along with this program. 13 | If not, see http://www.gnu.org/licenses/ 14 | */ 15 | 16 | 17 | void doNodeReport() { 18 | if (nextNodeReport > millis()) 19 | return; 20 | 21 | char c[ARTNET_NODE_REPORT_LENGTH]; 22 | 23 | if (nodeErrorTimeout > millis()) 24 | nextNodeReport = millis() + 2000; 25 | else 26 | nextNodeReport = millis() + 5000; 27 | 28 | if (nodeError[0] != '\0' && !nodeErrorShowing && nodeErrorTimeout > millis()) { 29 | 30 | nodeErrorShowing = true; 31 | strcpy(c, nodeError); 32 | 33 | } else { 34 | nodeErrorShowing = false; 35 | 36 | strcpy(c, "OK: PortA:"); 37 | 38 | switch (deviceSettings.portAmode) { 39 | case TYPE_DMX_OUT: 40 | sprintf(c, "%s DMX Out", c); 41 | break; 42 | 43 | case TYPE_RDM_OUT: 44 | sprintf(c, "%s RDM Out", c); 45 | break; 46 | 47 | case TYPE_DMX_IN: 48 | sprintf(c, "%s DMX In", c); 49 | break; 50 | 51 | case TYPE_WS2812: 52 | if (deviceSettings.portApixMode == FX_MODE_12) 53 | sprintf(c, "%s 12chan", c); 54 | sprintf(c, "%s WS2812 %ipixels", c, deviceSettings.portAnumPix); 55 | break; 56 | } 57 | 58 | #ifndef ONE_PORT 59 | sprintf(c, "%s. PortB:", c); 60 | 61 | switch (deviceSettings.portBmode) { 62 | case TYPE_DMX_OUT: 63 | sprintf(c, "%s DMX Out", c); 64 | break; 65 | 66 | case TYPE_RDM_OUT: 67 | sprintf(c, "%s RDM Out", c); 68 | break; 69 | 70 | case TYPE_WS2812: 71 | if (deviceSettings.portBpixMode == FX_MODE_12) 72 | sprintf(c, "%s 12chan", c); 73 | sprintf(c, "%s WS2812 %ipixels", c, deviceSettings.portBnumPix); 74 | break; 75 | } 76 | #endif 77 | } 78 | 79 | artRDM.setNodeReport(c, ARTNET_RC_POWER_OK); 80 | } 81 | 82 | void portSetup() { 83 | if (deviceSettings.portAmode == TYPE_DMX_OUT || deviceSettings.portAmode == TYPE_RDM_OUT) { 84 | #ifndef ESP_01 85 | setStatusLed(STATUS_LED_A, BLUE); 86 | #endif 87 | 88 | dmxA.begin(DMX_DIR_A, artRDM.getDMX(portA[0], portA[1])); 89 | if (deviceSettings.portAmode == TYPE_RDM_OUT && !dmxA.rdmEnabled()) { 90 | dmxA.rdmEnable(ESTA_MAN, ESTA_DEV); 91 | dmxA.rdmSetCallBack(rdmReceivedA); 92 | dmxA.todSetCallBack(sendTodA); 93 | } 94 | 95 | } else if (deviceSettings.portAmode == TYPE_DMX_IN) { 96 | #ifndef ESP_01 97 | setStatusLed(STATUS_LED_A, CYAN); 98 | #endif 99 | 100 | dmxA.begin(DMX_DIR_A, artRDM.getDMX(portA[0], portA[1])); 101 | dmxA.dmxIn(true); 102 | dmxA.setInputCallback(dmxIn); 103 | 104 | dataIn = (byte*) os_malloc(sizeof(byte) * 512); 105 | memset(dataIn, 0, 512); 106 | 107 | } else if (deviceSettings.portAmode == TYPE_WS2812) { 108 | #ifndef ESP_01 109 | setStatusLed(STATUS_LED_A, GREEN); 110 | #endif 111 | 112 | digitalWrite(DMX_DIR_A, HIGH); 113 | pixDriver.setStrip(0, DMX_TX_A, deviceSettings.portAnumPix, deviceSettings.portApixConfig); 114 | } 115 | 116 | #ifndef ONE_PORT 117 | if (deviceSettings.portBmode == TYPE_DMX_OUT || deviceSettings.portBmode == TYPE_RDM_OUT) { 118 | setStatusLed(STATUS_LED_B, BLUE); 119 | 120 | dmxB.begin(DMX_DIR_B, artRDM.getDMX(portB[0], portB[1])); 121 | if (deviceSettings.portBmode == TYPE_RDM_OUT && !dmxB.rdmEnabled()) { 122 | dmxB.rdmEnable(ESTA_MAN, ESTA_DEV); 123 | dmxB.rdmSetCallBack(rdmReceivedB); 124 | dmxB.todSetCallBack(sendTodB); 125 | } 126 | 127 | } else if (deviceSettings.portBmode == TYPE_WS2812) { 128 | setStatusLed(STATUS_LED_B, GREEN); 129 | 130 | digitalWrite(DMX_DIR_B, HIGH); 131 | pixDriver.setStrip(1, DMX_TX_B, deviceSettings.portBnumPix, deviceSettings.portBpixConfig); 132 | } 133 | #endif 134 | 135 | pixDriver.allowInterruptSingle = WS2812_ALLOW_INT_SINGLE; 136 | pixDriver.allowInterruptDouble = WS2812_ALLOW_INT_DOUBLE; 137 | } 138 | 139 | void artStart() { 140 | // Initialise out ArtNet 141 | if (isHotspot) 142 | artRDM.init(deviceSettings.hotspotIp, deviceSettings.hotspotSubnet, true, deviceSettings.nodeName, deviceSettings.longName, ARTNET_OEM, ESTA_MAN, MAC_array); 143 | else 144 | artRDM.init(deviceSettings.ip, deviceSettings.subnet, deviceSettings.dhcpEnable, deviceSettings.nodeName, deviceSettings.longName, ARTNET_OEM, ESTA_MAN, MAC_array); 145 | 146 | // Set firmware 147 | artRDM.setFirmwareVersion(ART_FIRM_VERSION); 148 | 149 | // Add Group 150 | portA[0] = artRDM.addGroup(deviceSettings.portAnet, deviceSettings.portAsub); 151 | 152 | bool e131 = (deviceSettings.portAprot == PROT_ARTNET_SACN) ? true : false; 153 | 154 | // WS2812 uses TYPE_DMX_OUT - the rest use the value assigned 155 | if (deviceSettings.portAmode == TYPE_WS2812) 156 | portA[1] = artRDM.addPort(portA[0], 0, deviceSettings.portAuni[0], TYPE_DMX_OUT, deviceSettings.portAmerge); 157 | else 158 | portA[1] = artRDM.addPort(portA[0], 0, deviceSettings.portAuni[0], deviceSettings.portAmode, deviceSettings.portAmerge); 159 | 160 | artRDM.setE131(portA[0], portA[1], e131); 161 | artRDM.setE131Uni(portA[0], portA[1], deviceSettings.portAsACNuni[0]); 162 | 163 | // Add extra Artnet ports for WS2812 164 | if (deviceSettings.portAmode == TYPE_WS2812 && deviceSettings.portApixMode == FX_MODE_PIXEL_MAP) { 165 | if (deviceSettings.portAnumPix > 170) { 166 | portA[2] = artRDM.addPort(portA[0], 1, deviceSettings.portAuni[1], TYPE_DMX_OUT, deviceSettings.portAmerge); 167 | 168 | artRDM.setE131(portA[0], portA[2], e131); 169 | artRDM.setE131Uni(portA[0], portA[2], deviceSettings.portAsACNuni[1]); 170 | } 171 | if (deviceSettings.portAnumPix > 340) { 172 | portA[3] = artRDM.addPort(portA[0], 2, deviceSettings.portAuni[2], TYPE_DMX_OUT, deviceSettings.portAmerge); 173 | 174 | artRDM.setE131(portA[0], portA[3], e131); 175 | artRDM.setE131Uni(portA[0], portA[3], deviceSettings.portAsACNuni[2]); 176 | } 177 | if (deviceSettings.portAnumPix > 510) { 178 | portA[4] = artRDM.addPort(portA[0], 3, deviceSettings.portAuni[3], TYPE_DMX_OUT, deviceSettings.portAmerge); 179 | 180 | artRDM.setE131(portA[0], portA[4], e131); 181 | artRDM.setE131Uni(portA[0], portA[4], deviceSettings.portAsACNuni[3]); 182 | } 183 | } 184 | 185 | 186 | #ifndef ONE_PORT 187 | // Add Group 188 | portB[0] = artRDM.addGroup(deviceSettings.portBnet, deviceSettings.portBsub); 189 | e131 = (deviceSettings.portBprot == PROT_ARTNET_SACN) ? true : false; 190 | 191 | // WS2812 uses TYPE_DMX_OUT - the rest use the value assigned 192 | if (deviceSettings.portBmode == TYPE_WS2812) 193 | portB[1] = artRDM.addPort(portB[0], 0, deviceSettings.portBuni[0], TYPE_DMX_OUT, deviceSettings.portBmerge); 194 | else 195 | portB[1] = artRDM.addPort(portB[0], 0, deviceSettings.portBuni[0], deviceSettings.portBmode, deviceSettings.portBmerge); 196 | 197 | artRDM.setE131(portB[0], portB[1], e131); 198 | artRDM.setE131Uni(portB[0], portB[1], deviceSettings.portBsACNuni[0]); 199 | 200 | // Add extra Artnet ports for WS2812 201 | if (deviceSettings.portBmode == TYPE_WS2812 && deviceSettings.portBpixMode == FX_MODE_PIXEL_MAP) { 202 | if (deviceSettings.portBnumPix > 170) { 203 | portB[2] = artRDM.addPort(portB[0], 1, deviceSettings.portBuni[1], TYPE_DMX_OUT, deviceSettings.portBmerge); 204 | 205 | artRDM.setE131(portB[0], portB[2], e131); 206 | artRDM.setE131Uni(portB[0], portB[2], deviceSettings.portBsACNuni[1]); 207 | } 208 | if (deviceSettings.portBnumPix > 340) { 209 | portB[3] = artRDM.addPort(portB[0], 2, deviceSettings.portBuni[2], TYPE_DMX_OUT, deviceSettings.portBmerge); 210 | 211 | artRDM.setE131(portB[0], portB[3], e131); 212 | artRDM.setE131Uni(portB[0], portB[3], deviceSettings.portBsACNuni[2]); 213 | } 214 | if (deviceSettings.portBnumPix > 510) { 215 | portB[4] = artRDM.addPort(portB[0], 3, deviceSettings.portBuni[3], TYPE_DMX_OUT, deviceSettings.portBmerge); 216 | 217 | artRDM.setE131(portB[0], portB[4], e131); 218 | artRDM.setE131Uni(portB[0], portB[4], deviceSettings.portBsACNuni[3]); 219 | } 220 | } 221 | #endif 222 | 223 | // Add required callback functions 224 | artRDM.setArtDMXCallback(dmxHandle); 225 | artRDM.setArtRDMCallback(rdmHandle); 226 | artRDM.setArtSyncCallback(syncHandle); 227 | artRDM.setArtIPCallback(ipHandle); 228 | artRDM.setArtAddressCallback(addressHandle); 229 | artRDM.setTODRequestCallback(todRequest); 230 | artRDM.setTODFlushCallback(todFlush); 231 | 232 | 233 | switch (resetInfo.reason) { 234 | case REASON_DEFAULT_RST: // normal start 235 | case REASON_EXT_SYS_RST: 236 | case REASON_SOFT_RESTART: 237 | artRDM.setNodeReport("OK: Device started", ARTNET_RC_POWER_OK); 238 | nextNodeReport = millis() + 4000; 239 | break; 240 | 241 | case REASON_WDT_RST: 242 | artRDM.setNodeReport("ERROR: (HWDT) Unexpected device restart", ARTNET_RC_POWER_FAIL); 243 | strcpy(nodeError, "Restart error: HWDT"); 244 | nextNodeReport = millis() + 10000; 245 | nodeErrorTimeout = millis() + 30000; 246 | break; 247 | case REASON_EXCEPTION_RST: 248 | artRDM.setNodeReport("ERROR: (EXCP) Unexpected device restart", ARTNET_RC_POWER_FAIL); 249 | strcpy(nodeError, "Restart error: EXCP"); 250 | nextNodeReport = millis() + 10000; 251 | nodeErrorTimeout = millis() + 30000; 252 | break; 253 | case REASON_SOFT_WDT_RST: 254 | artRDM.setNodeReport("ERROR: (SWDT) Unexpected device restart", ARTNET_RC_POWER_FAIL); 255 | strcpy(nodeError, "Error on Restart: SWDT"); 256 | nextNodeReport = millis() + 10000; 257 | nodeErrorTimeout = millis() + 30000; 258 | break; 259 | case REASON_DEEP_SLEEP_AWAKE: 260 | // not used 261 | break; 262 | } 263 | 264 | // Start artnet 265 | artRDM.begin(); 266 | 267 | yield(); 268 | } 269 | 270 | void webStart() { 271 | webServer.on("/", [](){ 272 | artRDM.pause(); 273 | webServer.send_P(200, typeHTML, mainPage); 274 | webServer.sendHeader("Connection", "close"); 275 | yield(); 276 | artRDM.begin(); 277 | }); 278 | 279 | webServer.on("/style.css", [](){ 280 | artRDM.pause(); 281 | 282 | File f = SPIFFS.open("/style.css", "r"); 283 | 284 | // If no style.css in SPIFFS, send default 285 | if (!f) 286 | webServer.send_P(200, typeCSS, css); 287 | else 288 | size_t sent = webServer.streamFile(f, typeCSS); 289 | 290 | f.close(); 291 | webServer.sendHeader("Connection", "close"); 292 | 293 | yield(); 294 | artRDM.begin(); 295 | }); 296 | 297 | webServer.on("/ajax", HTTP_POST, ajaxHandle); 298 | 299 | webServer.on("/upload", HTTP_POST, webFirmwareUpdate, webFirmwareUpload); 300 | 301 | webServer.on("/style", [](){ 302 | webServer.send_P(200, typeHTML, cssUploadPage); 303 | webServer.sendHeader("Connection", "close"); 304 | }); 305 | 306 | webServer.on("/style_delete", [](){ 307 | if (SPIFFS.exists("/style.css")) 308 | SPIFFS.remove("/style.css"); 309 | 310 | webServer.send(200, "text/plain", "style.css deleted. The default style is now in use."); 311 | webServer.sendHeader("Connection", "close"); 312 | }); 313 | 314 | webServer.on("/style_upload", HTTP_POST, [](){ 315 | webServer.send(200, "text/plain", "Upload successful!"); 316 | }, [](){ 317 | HTTPUpload& upload = webServer.upload(); 318 | 319 | if(upload.status == UPLOAD_FILE_START){ 320 | String filename = upload.filename; 321 | if(!filename.startsWith("/")) filename = "/"+filename; 322 | fsUploadFile = SPIFFS.open(filename, "w"); 323 | filename = String(); 324 | 325 | } else if(upload.status == UPLOAD_FILE_WRITE){ 326 | if(fsUploadFile) 327 | fsUploadFile.write(upload.buf, upload.currentSize); 328 | 329 | } else if(upload.status == UPLOAD_FILE_END){ 330 | if(fsUploadFile) { 331 | fsUploadFile.close(); 332 | 333 | if (upload.filename != "/style.css") 334 | SPIFFS.rename(upload.filename, "/style.css"); 335 | } 336 | } 337 | }); 338 | 339 | webServer.onNotFound([]() { 340 | webServer.send(404, "text/plain", "Page not found"); 341 | }); 342 | 343 | webServer.begin(); 344 | 345 | yield(); 346 | } 347 | 348 | void wifiStart() { 349 | // If it's the default WiFi SSID, make it unique 350 | if (strcmp(deviceSettings.hotspotSSID, "espArtNetNode") == 0 || deviceSettings.hotspotSSID[0] == '\0') 351 | sprintf(deviceSettings.hotspotSSID, "espArtNetNode_%05u", (ESP.getChipId() & 0xFF)); 352 | 353 | if (deviceSettings.standAloneEnable) { 354 | startHotspot(); 355 | 356 | deviceSettings.ip = deviceSettings.hotspotIp; 357 | deviceSettings.subnet = deviceSettings.hotspotSubnet; 358 | deviceSettings.broadcast = {~deviceSettings.subnet[0] | (deviceSettings.ip[0] & deviceSettings.subnet[0]), ~deviceSettings.subnet[1] | (deviceSettings.ip[1] & deviceSettings.subnet[1]), ~deviceSettings.subnet[2] | (deviceSettings.ip[2] & deviceSettings.subnet[2]), ~deviceSettings.subnet[3] | (deviceSettings.ip[3] & deviceSettings.subnet[3])}; 359 | 360 | return; 361 | } 362 | 363 | if (deviceSettings.wifiSSID[0] != '\0') { 364 | WiFi.begin(deviceSettings.wifiSSID, deviceSettings.wifiPass); 365 | WiFi.mode(WIFI_STA); 366 | WiFi.hostname(deviceSettings.nodeName); 367 | 368 | unsigned long endTime = millis() + (deviceSettings.hotspotDelay * 1000); 369 | 370 | if (deviceSettings.dhcpEnable) { 371 | while (WiFi.status() != WL_CONNECTED && endTime > millis()) 372 | yield(); 373 | 374 | if (millis() >= endTime) 375 | startHotspot(); 376 | 377 | deviceSettings.ip = WiFi.localIP(); 378 | deviceSettings.subnet = WiFi.subnetMask(); 379 | 380 | if (deviceSettings.gateway == INADDR_NONE) 381 | deviceSettings.gateway = WiFi.gatewayIP(); 382 | 383 | deviceSettings.broadcast = {~deviceSettings.subnet[0] | (deviceSettings.ip[0] & deviceSettings.subnet[0]), ~deviceSettings.subnet[1] | (deviceSettings.ip[1] & deviceSettings.subnet[1]), ~deviceSettings.subnet[2] | (deviceSettings.ip[2] & deviceSettings.subnet[2]), ~deviceSettings.subnet[3] | (deviceSettings.ip[3] & deviceSettings.subnet[3])}; 384 | } else 385 | WiFi.config(deviceSettings.ip, deviceSettings.gateway, deviceSettings.subnet); 386 | 387 | //sprintf(wifiStatus, "Wifi connected. Signal: %ld
SSID: %s", WiFi.RSSI(), deviceSettings.wifiSSID); 388 | sprintf(wifiStatus, "Wifi connected.
SSID: %s", deviceSettings.wifiSSID); 389 | WiFi.macAddress(MAC_array); 390 | 391 | } else 392 | startHotspot(); 393 | 394 | yield(); 395 | } 396 | 397 | void startHotspot() { 398 | yield(); 399 | 400 | WiFi.mode(WIFI_AP); 401 | WiFi.softAP(deviceSettings.hotspotSSID, deviceSettings.hotspotPass); 402 | WiFi.softAPConfig(deviceSettings.hotspotIp, deviceSettings.hotspotIp, deviceSettings.hotspotSubnet); 403 | 404 | sprintf(wifiStatus, "No Wifi. Hotspot started.
\nHotspot SSID: %s", deviceSettings.hotspotSSID); 405 | WiFi.macAddress(MAC_array); 406 | 407 | isHotspot = true; 408 | 409 | if (deviceSettings.standAloneEnable) 410 | return; 411 | 412 | webStart(); 413 | 414 | unsigned long endTime = millis() + 30000; 415 | 416 | // Stay here if not in stand alone mode - no dmx or artnet 417 | while (endTime > millis() || wifi_softap_get_station_num() > 0) { 418 | webServer.handleClient(); 419 | yield(); 420 | } 421 | 422 | ESP.restart(); 423 | isHotspot = false; 424 | } 425 | -------------------------------------------------------------------------------- /source/ws2812Driver.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ESP8266_ArtNetNode v2.0.0 3 | Copyright (c) 2016, Matthew Tong 4 | https://github.com/mtongnz/ESP8266_ArtNetNode_v2 5 | 6 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public 7 | License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any 8 | later version. 9 | 10 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied 11 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 12 | You should have received a copy of the GNU General Public License along with this program. 13 | If not, see http://www.gnu.org/licenses/ 14 | */ 15 | 16 | 17 | 18 | // Timings from here: 19 | // https://wp.josh.com/2014/05/13/ws2812-neopixels-are-not-so-finicky-once-you-get-to-know-them/ 20 | 21 | #include "ws2812Driver.h" 22 | 23 | 24 | ws2812Driver::ws2812Driver() { 25 | _pixels[0] = 0; 26 | _pixels[1] = 0; 27 | } 28 | 29 | void ws2812Driver::setStrip(uint8_t port, uint8_t pin, uint16_t size, uint16_t config) { 30 | _pin[port] = pin; 31 | _pixels[port] = size * 3; 32 | _config[port] = config; 33 | 34 | pinMode(_pin[port], OUTPUT); 35 | digitalWrite(_pin[port], LOW); 36 | 37 | clearBuffer(port); 38 | 39 | // Clear the strip 40 | byte* b = buffer[port]; 41 | //doPixel(b, _pin[port], PIX_MAX_BUFFER_SIZE); 42 | } 43 | 44 | void ws2812Driver::updateStrip(uint8_t port, uint16_t size, uint16_t config) { 45 | size = size * 3; 46 | 47 | // Clear the strip if it's shorter than our current strip 48 | if (size < _pixels[port] || _config[port] != config) { 49 | clearBuffer(port, size); 50 | 51 | // Wait for last pixel packet to finish it's latch time 52 | while (_nextPix > millis()) 53 | yield(); 54 | 55 | byte* b = buffer[port]; 56 | //doPixel(b, _pin[port], _pixels[port]); 57 | 58 | // Allow at least 50 us with LOW to make LEDs latch data 59 | _nextPix = millis() + 5; 60 | } 61 | 62 | _pixels[port] = size; 63 | _config[port] = config; 64 | } 65 | 66 | uint8_t* ws2812Driver::getBuffer(uint8_t port) { 67 | return buffer[port]; 68 | } 69 | 70 | void ws2812Driver::clearBuffer(uint8_t port, uint16_t start) { 71 | memset(&buffer[port][start], 0, PIX_MAX_BUFFER_SIZE - start); 72 | } 73 | 74 | void ws2812Driver::setBuffer(uint8_t port, uint16_t startChan, uint8_t* data, uint16_t size) { 75 | uint8_t* a = buffer[port]; 76 | 77 | memcpy(&a[startChan], data, size); 78 | } 79 | 80 | byte ws2812Driver::setPixel(uint8_t port, uint16_t pixel, uint8_t r, uint8_t g, uint8_t b) { 81 | uint8_t* a = buffer[port]; 82 | 83 | uint16_t chan = pixel * 3; 84 | 85 | // ws2812 is GRB ordering 86 | a[chan + 1] = r; 87 | a[chan] = g; 88 | a[chan + 2] = b; 89 | } 90 | 91 | byte ws2812Driver::setPixel(uint8_t port, uint16_t pixel, uint32_t colour) { 92 | setPixel(port, pixel, ((colour >> 16) & 0xFF), ((colour >> 8) & 0xFF), (colour & 0xFF)); 93 | } 94 | 95 | uint32_t ws2812Driver::getPixel(uint8_t port) { 96 | uint8_t* b = buffer[port]; 97 | uint16_t chan = _pixels[port] * 3; 98 | 99 | // ws2812 is GRB ordering - return RGB 100 | return ((b[chan + 1] << 16) | (b[chan] << 8) | (b[chan+2])); 101 | } 102 | 103 | uint16_t ws2812Driver::numPixels(uint8_t port) { 104 | return _pixels[port] / 3; 105 | } 106 | 107 | 108 | bool ws2812Driver::show() { 109 | if (_nextPix > millis()) 110 | return 0; 111 | 112 | if (_pixels[0] == 0 && _pixels[1] == 0) 113 | return 1; 114 | 115 | yield(); 116 | 117 | byte* b0 = buffer[0]; 118 | byte* b1 = buffer[1]; 119 | 120 | if (_pixels[0] == 0) 121 | doPixel(b1, _pin[1], _pixels[1]); 122 | else if (_pixels[1] == 0) 123 | doPixel(b0, _pin[0], _pixels[0]); 124 | else if (_pixels[1] > _pixels[0]) 125 | doPixelDouble(b0, _pin[0], b1, _pin[1], _pixels[1]); 126 | else 127 | doPixelDouble(b0, _pin[0], b1, _pin[1], _pixels[0]); 128 | 129 | _nextPix = millis() + PIX_LATCH_TIME; 130 | 131 | return 1; 132 | } 133 | 134 | void ICACHE_RAM_ATTR ws2812Driver::doPixel(byte* data, uint8_t pin, uint16_t numBytes) { 135 | uint8_t a, b, c, d, f; 136 | uint32_t cc1, cc2; 137 | pin = (1 << pin); 138 | 139 | asm volatile ( 140 | "MOVI %[r_set], 0x60000304;" 141 | 142 | "RSIL %[r_int], 15;" // disable interrupts 143 | 144 | "doNextByteSingle:" 145 | "BEQZ %[r_num_bytes], doExitSingle;" // exit if all bytes sent 146 | 147 | "L8UI %[r_data], %[r_data_array], 0;" // Load array element 148 | "ADDI.N %[r_data_array], %[r_data_array], 1;" // Move pointer to next array element 149 | "ADDI.N %[r_num_bytes], %[r_num_bytes], -1;" // Decrement number of bytes left 150 | "MOVI %[r_bit], 0x80;" // Set our bitmask 151 | 152 | 153 | "sendNextBitSingle:" 154 | "BALL %[r_data], %[r_bit], doOne;" // check if bit is one -> doOne 155 | "j doZero;" // doZero if it's not 156 | 157 | 158 | "doNextBitSingle:" 159 | "SRLI %[r_bit], %[r_bit], 1;" // shift bitmask right 160 | "BEQZ %[r_bit], doNextByteSingle;" // get the next byte if all bits done 161 | "j sendNextBitSingle;" // send the next bit 162 | 163 | "SingleLoop:" 164 | "RSR %[r_cc2], CCOUNT;" // Get clock cycles 165 | "BGE %[r_cc1], %[r_cc2], SingleLoop;" // If finishtime >= nowtime -> loop again 166 | "j doNextBitSingle;" // otherwise do the next bit 167 | 168 | 169 | "doOne:" 170 | "S16I %[r_pin], %[r_set], 0;" // set 171 | "MEMW;" 172 | 173 | "RSR %[r_cc1], CCOUNT;" // get clock cycles 174 | "ADDI %[r_cc1], %[r_cc1], 95;" // add to cycles for delay - works at 100 175 | 176 | "SingleOneLoop:" 177 | "RSR %[r_cc2], CCOUNT;" // Get clock cycles 178 | "BGE %[r_cc1], %[r_cc2], SingleOneLoop;" // If finishtime >= nowtime -> loop again 179 | 180 | "S16I %[r_pin], %[r_set], 4;" // clear 181 | "MEMW;" 182 | 183 | "RSR %[r_cc1], CCOUNT;" // get clock cycles 184 | "ADDI %[r_cc1], %[r_cc1], 61;" // add to cycles for delay - works at 67 185 | "BEQZ %[r_allow_int], SingleLoop;" // if allowInt equals false, jump without enabling interrupts 186 | "RSIL %[r_int], 0;" // enable interrupts again 187 | "NOP;" // 1 clock for any interrupts to run 188 | "RSIL %[r_int], 15;" // disable interrupts 189 | "j SingleLoop;" 190 | 191 | 192 | 193 | "doZero:" 194 | "S16I %[r_pin], %[r_set], 0;" // set 195 | "MEMW;" 196 | 197 | "RSR %[r_cc1], CCOUNT;" // get clock cycles 198 | "ADDI %[r_cc1], %[r_cc1], 40;" // add to cycles for delay - works at 50 199 | 200 | "SingleZeroLoop:" 201 | "RSR %[r_cc2], CCOUNT;" // Get clock cycles 202 | "BGE %[r_cc1], %[r_cc2], SingleZeroLoop;" // If finishtime >= nowtime -> loop again 203 | 204 | "S16I %[r_pin], %[r_set], 4;" // clear 205 | "MEMW;" 206 | 207 | "RSR %[r_cc1], CCOUNT;" // get clock cycles 208 | "ADDI %[r_cc1], %[r_cc1], 85;" // add to cycles for delay - works at 105 209 | "BEQZ %[r_allow_int], SingleLoop;" // if allowInt equals false, jump without enabling interrupts 210 | "RSIL %[r_int], 0;" // enable interrupts again 211 | "NOP;" // 1 clock for any interrupts to run 212 | "RSIL %[r_int], 15;" // disable interrupts 213 | "j SingleLoop;" 214 | 215 | 216 | // Our exit point 217 | "doExitSingle:" 218 | "RSIL %[r_int], 0;" // enable interrupts again 219 | 220 | : [r_allow_int] "+r" (allowInterruptSingle), [r_int] "+r" (f), [r_cc1] "+r" (cc1), [r_cc2] "+r" (cc2), [r_set] "+r" (a), [r_bit] "+r" (b), [r_byte_count] "+r" (c), [r_data] "+r" (d), [r_pin] "+r" (pin), [r_data_array] "+r" (&data[0]), [r_num_bytes] "+r" (numBytes) 221 | ); 222 | } 223 | 224 | void ICACHE_RAM_ATTR ws2812Driver::doPixelDouble(byte* data1, uint8_t pin1, byte* data2, uint8_t pin2, uint16_t numBytes) { 225 | uint8_t a, b, c, d, e, f; 226 | uint32_t cc1, cc2; 227 | pin1 = (1 << pin1); 228 | pin2 = (1 << pin2); 229 | 230 | asm volatile ( 231 | "MOVI %[r_set], 0x60000304;" 232 | 233 | "RSIL %[r_int], 15;" // disable interrupts 234 | 235 | "doNextByteDouble:" 236 | "BEQZ %[r_num_bytes], doExitDouble;" // exit if all bytes sent 237 | 238 | "L8UI %[r_data1], %[r_data_array1], 0;" // Load array elements 239 | "L8UI %[r_data2], %[r_data_array2], 0;" 240 | 241 | "ADDI.N %[r_data_array1], %[r_data_array1], 1;" // Move pointer to next array element 242 | "ADDI.N %[r_data_array2], %[r_data_array2], 1;" 243 | 244 | "ADDI.N %[r_num_bytes], %[r_num_bytes], -1;" // Decrement number of bytes left 245 | "MOVI %[r_bit], 0x80;" // Set our bitmask 246 | 247 | 248 | "sendNextBitDouble:" 249 | "BALL %[r_data1], %[r_bit], doOne1Check2;" // check if bit is one -> doOne 250 | "j doZero1Check2;" // doZero if it's not 251 | 252 | 253 | "doNextBitDouble:" 254 | "SRLI %[r_bit], %[r_bit], 1;" // shift bitmask right 255 | "BEQZ %[r_bit], doNextByteDouble;" // get the next byte if all bits done 256 | "j sendNextBitDouble;" // send the next bit 257 | 258 | 259 | "doOne1Check2:" 260 | "BALL %[r_data2], %[r_bit], doOneOne;" // Both bits are one -> doOneOne 261 | "j doOneZero;" // data1 is one, data2 is zero -> doOneZero 262 | 263 | 264 | "doZero1Check2:" 265 | "BALL %[r_data2], %[r_bit], doZeroOne;" // data1 is zero, data2 is one -> doZeroOne 266 | "j doZeroZero;" // both bits are zero -> doZeroZero 267 | 268 | 269 | "DoubleLoop:" 270 | "RSR %[r_cc2], CCOUNT;" // Get clock cycles 271 | "BGE %[r_cc1], %[r_cc2], DoubleLoop;" // If finishtime >= nowtime -> loop again 272 | "j doNextBitDouble;" // otherwise do the next bit 273 | 274 | 275 | "doOneOne:" 276 | "S16I %[r_pin1], %[r_set], 0;" // set 277 | "S16I %[r_pin2], %[r_set], 0;" // set 278 | "MEMW;" 279 | 280 | "_nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; " 281 | "_nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; " 282 | "_nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; " 283 | "_nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; " 284 | "_nop; _nop; _nop; _nop; _nop;" 285 | 286 | "S16I %[r_pin1], %[r_set], 4;" // clear 287 | "S16I %[r_pin2], %[r_set], 4;" // clear 288 | "MEMW;" 289 | 290 | "RSR %[r_cc1], CCOUNT;" // get clock cycles 291 | "ADDI %[r_cc1], %[r_cc1], 65;" // add to cycles for delay 292 | "BEQZ %[r_allow_int], DoubleLoop;" // if allowInt equals false, jump without enabling interrupts 293 | "RSIL %[r_int], 0;" // enable interrupts again 294 | "NOP;" // 1 clock for any interrupts to run 295 | "RSIL %[r_int], 15;" // disable interrupts 296 | "j DoubleLoop;" 297 | 298 | 299 | "doZeroZero:" 300 | "S16I %[r_pin1], %[r_set], 0;" // set 301 | "S16I %[r_pin2], %[r_set], 0;" // set 302 | "MEMW;" 303 | 304 | "_nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; " 305 | "_nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; " 306 | 307 | "S16I %[r_pin1], %[r_set], 4;" // clear 308 | "S16I %[r_pin2], %[r_set], 4;" // clear 309 | "MEMW;" 310 | 311 | "RSR %[r_cc1], CCOUNT;" // get clock cycles 312 | "ADDI %[r_cc1], %[r_cc1], 105;" // add to cycles for delay 313 | "BEQZ %[r_allow_int], DoubleLoop;" // if allowInt equals false, jump without enabling interrupts 314 | "RSIL %[r_int], 0;" // enable interrupts again 315 | "NOP;" // 1 clock for any interrupts to run 316 | "RSIL %[r_int], 15;" // disable interrupts 317 | "j DoubleLoop;" 318 | 319 | 320 | "doOneZero:" 321 | "S16I %[r_pin1], %[r_set], 0;" // set 322 | "S16I %[r_pin2], %[r_set], 0;" // set 323 | "MEMW;" 324 | 325 | "_nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; " 326 | "_nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; " 327 | 328 | "S16I %[r_pin2], %[r_set], 4;" // clear 329 | 330 | "_nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; " 331 | "_nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; " 332 | "_nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; " 333 | 334 | "S16I %[r_pin1], %[r_set], 4;" // clear 335 | "MEMW;" 336 | 337 | "RSR %[r_cc1], CCOUNT;" // get clock cycles 338 | "ADDI %[r_cc1], %[r_cc1], 65;" // add to cycles for delay 339 | "BEQZ %[r_allow_int], DoubleLoop;" // if allowInt equals false, jump without enabling interrupts 340 | "RSIL %[r_int], 0;" // enable interrupts again 341 | "NOP;" // 1 clock for any interrupts to run 342 | "RSIL %[r_int], 15;" // disable interrupts 343 | "j DoubleLoop;" 344 | 345 | 346 | "doZeroOne:" 347 | "S16I %[r_pin1], %[r_set], 0;" // set 348 | "S16I %[r_pin2], %[r_set], 0;" // set 349 | "MEMW;" 350 | 351 | "_nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; " 352 | "_nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; " 353 | 354 | "S16I %[r_pin1], %[r_set], 4;" // clear 355 | 356 | "_nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; " 357 | "_nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; " 358 | "_nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; _nop; " 359 | 360 | "S16I %[r_pin2], %[r_set], 4;" // clear 361 | "MEMW;" 362 | 363 | "RSR %[r_cc1], CCOUNT;" // get clock cycles 364 | "ADDI %[r_cc1], %[r_cc1], 65;" // add to cycles for delay 365 | "BEQZ %[r_allow_int], DoubleLoop;" // if allowInt equals false, jump without enabling interrupts 366 | "RSIL %[r_int], 0;" // enable interrupts again 367 | "NOP;" // 1 clock for any interrupts to run 368 | "RSIL %[r_int], 15;" // disable interrupts 369 | "j DoubleLoop;" 370 | 371 | 372 | 373 | // Our exit point 374 | "doExitDouble:" 375 | "RSIL %[r_int], 15;" // disable interrupts 376 | 377 | : [r_allow_int] "+r" (allowInterruptDouble), [r_int] "+r" (f), [r_cc1] "+r" (cc1), [r_cc2] "+r" (cc2), [r_set] "+r" (a), [r_bit] "+r" (b), [r_byte_count] "+r" (c), [r_data1] "+r" (d), [r_pin1] "+r" (pin1), [r_data_array1] "+r" (&data1[0]), [r_data2] "+r" (e), [r_pin2] "+r" (pin2), [r_data_array2] "+r" (&data2[0]), [r_num_bytes] "+r" (numBytes) 378 | ); 379 | } 380 | 381 | void ICACHE_RAM_ATTR ws2812Driver::doAPA106(byte* data, uint8_t pin, uint16_t numBytes) { 382 | uint8_t a, b, c, d, f; 383 | uint32_t cc1, cc2, cc3; 384 | pin = (1 << pin); 385 | 386 | asm volatile ( 387 | "MOVI %[r_set], 0x60000304;" 388 | 389 | "RSIL %[r_int], 15;" // disable interrupts 390 | 391 | "doNextByte106:" 392 | "BEQZ %[r_num_bytes], doExit106;" // exit if all bytes sent 393 | 394 | "L8UI %[r_data], %[r_data_array], 0;" // Load array element 395 | "ADDI.N %[r_data_array], %[r_data_array], 1;" // Move pointer to next array element 396 | "ADDI.N %[r_num_bytes], %[r_num_bytes], -1;" // Decrement number of bytes left 397 | "MOVI %[r_bit], 0x80;" // Set our bitmask 398 | 399 | 400 | "sendNextBit106:" 401 | "RSR %[r_cc3], CCOUNT;" // Get clock cycles 402 | "ADDI %[r_cc3], %[r_cc3], 230;" // add to cycles - total bit length 403 | "BALL %[r_data], %[r_bit], doOne106;" // check if bit is one -> doOne 404 | "j doZero106;" // doZero if it's not 405 | 406 | 407 | "doNextBit106:" 408 | "SRLI %[r_bit], %[r_bit], 1;" // shift bitmask right 409 | "BEQZ %[r_bit], doNextByte106;" // get the next byte if all bits done 410 | "j sendNextBit106;" // send the next bit 411 | 412 | "Loop106:" 413 | "RSR %[r_cc2], CCOUNT;" // Get clock cycles 414 | "BGE %[r_cc3], %[r_cc2], Loop106;" // If finishtime >= nowtime -> loop again 415 | "j doNextBit106;" // otherwise do the next bit 416 | 417 | 418 | "doOne106:" 419 | "S16I %[r_pin], %[r_set], 0;" // set pin 420 | "MEMW;" 421 | 422 | "RSR %[r_cc1], CCOUNT;" // get clock cycles 423 | "ADDI %[r_cc1], %[r_cc1], 185;" // add to cycles for delay 424 | 425 | "OneLoop106:" 426 | "RSR %[r_cc2], CCOUNT;" // Get clock cycles 427 | "BGE %[r_cc1], %[r_cc2], OneLoop106;" // If finishtime >= nowtime -> loop again 428 | 429 | "S16I %[r_pin], %[r_set], 4;" // clear pin 430 | "MEMW;" 431 | 432 | "j Loop106;" 433 | 434 | 435 | 436 | "doZero106:" 437 | "S16I %[r_pin], %[r_set], 0;" // set pin 438 | "MEMW;" 439 | 440 | "RSR %[r_cc1], CCOUNT;" // get clock cycles 441 | "ADDI %[r_cc1], %[r_cc1], 40;" // add to cycles for delay 442 | 443 | "ZeroLoop106:" 444 | "RSR %[r_cc2], CCOUNT;" // Get clock cycles 445 | "BGE %[r_cc1], %[r_cc2], ZeroLoop106;" // If finishtime >= nowtime -> loop again 446 | 447 | "S16I %[r_pin], %[r_set], 4;" // clear pin 448 | "MEMW;" 449 | 450 | "j Loop106;" 451 | 452 | 453 | // Our exit point 454 | "doExit106:" 455 | "RSIL %[r_int], 0;" // enable interrupts again 456 | 457 | : [r_int] "+r" (f), [r_cc1] "+r" (cc1), [r_cc2] "+r" (cc2), [r_cc3] "+r" (cc3), [r_set] "+r" (a), [r_bit] "+r" (b), [r_byte_count] "+r" (c), [r_data] "+r" (d), [r_pin] "+r" (pin), [r_data_array] "+r" (&data[0]), [r_num_bytes] "+r" (numBytes) 458 | ); 459 | } 460 | -------------------------------------------------------------------------------- /source/ajax.ino: -------------------------------------------------------------------------------- 1 | /* 2 | ESP8266_ArtNetNode v2.0.0 3 | Copyright (c) 2016, Matthew Tong 4 | https://github.com/mtongnz/ESP8266_ArtNetNode_v2 5 | 6 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public 7 | License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any 8 | later version. 9 | 10 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied 11 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 12 | You should have received a copy of the GNU General Public License along with this program. 13 | If not, see http://www.gnu.org/licenses/ 14 | */ 15 | 16 | void ajaxHandle() { 17 | JsonObject& json = jsonBuffer.parseObject(webServer.arg("plain")); 18 | JsonObject& jsonReply = jsonBuffer.createObject(); 19 | 20 | String reply; 21 | 22 | // Handle request to reboot into update mode 23 | if (json.containsKey("success") && json["success"] == 1 && json.containsKey("doUpdate")) { 24 | artRDM.end(); 25 | 26 | jsonReply["success"] = 1; 27 | jsonReply["doUpdate"] = 1; 28 | 29 | jsonReply.printTo(reply); 30 | webServer.send(200, "application/json", reply); 31 | 32 | if (json["doUpdate"] == 1) { 33 | // Turn pixel strips off if they're on 34 | pixDriver.updateStrip(0, 0, deviceSettings.portApixConfig); 35 | pixDriver.updateStrip(1, 0, deviceSettings.portBpixConfig); 36 | 37 | deviceSettings.doFirmwareUpdate = true; 38 | eepromSave(); 39 | 40 | doReboot = true; 41 | } 42 | 43 | // Handle load and save of data 44 | } else if (json.containsKey("success") && json["success"] == 1 && json.containsKey("page")) { 45 | if (ajaxSave((uint8_t)json["page"], json)) { 46 | ajaxLoad((uint8_t)json["page"], jsonReply); 47 | 48 | if (json.size() > 2) 49 | jsonReply["message"] = "Settings Saved"; 50 | 51 | } else { 52 | jsonReply["success"] = 0; 53 | jsonReply["message"] = "Failed to save data. Reload page and try again."; 54 | } 55 | 56 | // Handle reboots 57 | } else if (json.containsKey("success") && json.containsKey("reboot") && json["reboot"] == 1) { 58 | jsonReply["success"] = 1; 59 | jsonReply["message"] = "Device Restarting."; 60 | 61 | // Turn pixel strips off if they're on 62 | pixDriver.updateStrip(0, 0, deviceSettings.portApixConfig); 63 | pixDriver.updateStrip(1, 0, deviceSettings.portBpixConfig); 64 | 65 | doReboot = true; 66 | 67 | // Handle errors 68 | } 69 | 70 | jsonReply.printTo(reply); 71 | webServer.send(200, "application/json", reply); 72 | } 73 | 74 | bool ajaxSave(uint8_t page, JsonObject& json) { 75 | // This is a load request, not a save 76 | if (json.size() == 2) 77 | return true; 78 | 79 | switch (page) { 80 | case 1: // Device Status 81 | // We don't need to save anything for this. Go straight to load 82 | return true; 83 | break; 84 | 85 | case 2: // Wifi 86 | json.get("wifiSSID").toCharArray(deviceSettings.wifiSSID, 40); 87 | json.get("wifiPass").toCharArray(deviceSettings.wifiPass, 40); 88 | json.get("hotspotSSID").toCharArray(deviceSettings.hotspotSSID, 20); 89 | json.get("hotspotPass").toCharArray(deviceSettings.hotspotPass, 20); 90 | deviceSettings.hotspotDelay = (uint8_t)json["hotspotDelay"]; 91 | deviceSettings.standAloneEnable = (bool)json["standAloneEnable"]; 92 | 93 | eepromSave(); 94 | return true; 95 | break; 96 | 97 | case 3: // IP Address & Node Name 98 | deviceSettings.ip = IPAddress(json["ipAddress"][0],json["ipAddress"][1],json["ipAddress"][2],json["ipAddress"][3]); 99 | deviceSettings.subnet = IPAddress(json["subAddress"][0],json["subAddress"][1],json["subAddress"][2],json["subAddress"][3]); 100 | deviceSettings.gateway = IPAddress(json["gwAddress"][0],json["gwAddress"][1],json["gwAddress"][2],json["gwAddress"][3]); 101 | deviceSettings.broadcast = deviceSettings.ip | (~deviceSettings.subnet); 102 | //deviceSettings.broadcast = {~deviceSettings.subnet[0] | (deviceSettings.ip[0] & deviceSettings.subnet[0]), ~deviceSettings.subnet[1] | (deviceSettings.ip[1] & deviceSettings.subnet[1]), ~deviceSettings.subnet[2] | (deviceSettings.ip[2] & deviceSettings.subnet[2]), ~deviceSettings.subnet[3] | (deviceSettings.ip[3] & deviceSettings.subnet[3])}; 103 | 104 | json.get("nodeName").toCharArray(deviceSettings.nodeName, 18); 105 | json.get("longName").toCharArray(deviceSettings.longName, 64); 106 | 107 | if (!isHotspot && (bool)json["dhcpEnable"] != deviceSettings.dhcpEnable) { 108 | 109 | if ((bool)json["dhcpEnable"]) { 110 | /* 111 | // Re-enable DHCP 112 | WiFi.begin(deviceSettings.wifiSSID, deviceSettings.wifiPass); 113 | 114 | // Wait for an IP 115 | while (WiFi.status() != WL_CONNECTED) 116 | yield(); 117 | 118 | // Save settings to struct 119 | deviceSettings.ip = WiFi.localIP(); 120 | deviceSettings.subnet = WiFi.subnetMask(); 121 | deviceSettings.broadcast = {~deviceSettings.subnet[0] | (deviceSettings.ip[0] & deviceSettings.subnet[0]), ~deviceSettings.subnet[1] | (deviceSettings.ip[1] & deviceSettings.subnet[1]), ~deviceSettings.subnet[2] | (deviceSettings.ip[2] & deviceSettings.subnet[2]), ~deviceSettings.subnet[3] | (deviceSettings.ip[3] & deviceSettings.subnet[3])}; 122 | */ 123 | 124 | deviceSettings.gateway = INADDR_NONE; 125 | 126 | } 127 | /* 128 | else { 129 | // Set static IP 130 | WiFi.config(deviceSettings.ip,deviceSettings.ip,deviceSettings.ip,deviceSettings.subnet); 131 | } 132 | 133 | // Add any changes to artnet settings - this will send correct artpollreply 134 | artRDM.setIP(deviceSettings.ip, deviceSettings.subnet); 135 | artRDM.setDHCP(deviceSettings.dhcpEnable); 136 | */ 137 | 138 | doReboot = true; 139 | } 140 | 141 | if (!isHotspot) { 142 | artRDM.setShortName(deviceSettings.nodeName); 143 | artRDM.setLongName(deviceSettings.longName); 144 | } 145 | 146 | deviceSettings.dhcpEnable = (bool)json["dhcpEnable"]; 147 | 148 | eepromSave(); 149 | return true; 150 | break; 151 | 152 | case 4: // Port A 153 | { 154 | deviceSettings.portAprot = (uint8_t)json["portAprot"]; 155 | bool e131 = (deviceSettings.portAprot == PROT_ARTNET_SACN) ? true : false; 156 | 157 | deviceSettings.portAmerge = (uint8_t)json["portAmerge"]; 158 | 159 | if ((uint8_t)json["portAnet"] < 128) 160 | deviceSettings.portAnet = (uint8_t)json["portAnet"]; 161 | 162 | if ((uint8_t)json["portAsub"] < 16) 163 | deviceSettings.portAsub = (uint8_t)json["portAsub"]; 164 | 165 | for (uint8_t x = 0; x < 4; x++) { 166 | if ((uint8_t)json["portAuni"][x] < 16) 167 | deviceSettings.portAuni[x] = (uint8_t)json["portAuni"][x]; 168 | 169 | if ((uint16_t)json["portAsACNuni"][x] > 0 && (uint16_t)json["portAsACNuni"][x] < 64000) 170 | deviceSettings.portAsACNuni[x] = (uint16_t)json["portAsACNuni"][x]; 171 | 172 | artRDM.setE131(portA[0], portA[x+1], e131); 173 | artRDM.setE131Uni(portA[0], portA[x+1], deviceSettings.portAsACNuni[x]); 174 | } 175 | 176 | uint8_t newMode = json["portAmode"]; 177 | uint8_t oldMode = deviceSettings.portAmode; 178 | bool updatePorts = false; 179 | 180 | #ifndef ONE_PORT 181 | // RDM and DMX input can't run together 182 | if (newMode == TYPE_DMX_IN && deviceSettings.portBmode == TYPE_RDM_OUT) { 183 | deviceSettings.portBmode = TYPE_DMX_OUT; 184 | dmxB.rdmDisable(); 185 | } 186 | #endif 187 | 188 | if (newMode == TYPE_DMX_IN && json.containsKey("dmxInBroadcast")) 189 | deviceSettings.dmxInBroadcast = IPAddress(json["dmxInBroadcast"][0],json["dmxInBroadcast"][1],json["dmxInBroadcast"][2],json["dmxInBroadcast"][3]); 190 | 191 | 192 | if (newMode != oldMode) { 193 | 194 | // Store the nem mode to settings 195 | deviceSettings.portAmode = newMode; 196 | 197 | doReboot = true; 198 | /* 199 | if (oldMode == TYPE_WS2812) { 200 | doReboot = true; 201 | 202 | // Set pixel strip length to zero 203 | pixDriver.updateStrip(0, 0, deviceSettings.portApixConfig); 204 | 205 | // Close ports from pixels - library handles if they dont exist 206 | for (uint8_t x = 2; x <= 4; x++) 207 | artRDM.closePort(portA[0], portA[x]); 208 | 209 | // Start our DMX port 210 | dmxA.begin(DMX_DIR_A, artRDM.getDMX(portA[0], portA[1])); 211 | 212 | } else if (oldMode == TYPE_DMX_IN) 213 | dmxA.dmxIn(false); 214 | else if (oldMode == TYPE_RDM_OUT) 215 | dmxA.rdmDisable(); 216 | 217 | // Start DMX output with no DMX 218 | if (newMode == TYPE_DMX_OUT) { 219 | 220 | 221 | artRDM.setPortType(portA[0], portA[1], DMX_OUT); 222 | 223 | // Start DMX output with RDM 224 | } else if (newMode == TYPE_RDM_OUT) { 225 | dmxA.rdmEnable(ESTA_MAN, ESTA_DEV); 226 | dmxA.rdmSetCallBack(rdmReceivedA); 227 | dmxA.todSetCallBack(sendTodA); 228 | artRDM.setPortType(portA[0], portA[1], RDM_OUT); 229 | 230 | // Start DMX input 231 | } else if (newMode == TYPE_DMX_IN) { 232 | dmxA.dmxIn(true); 233 | dmxA.setInputCallback(dmxIn); 234 | 235 | artRDM.setPortType(portA[0], portA[1], DMX_IN); 236 | 237 | // Start WS2812 output 238 | } else if (newMode == TYPE_WS2812) { 239 | doReboot = true; 240 | 241 | dmxA.end(); 242 | 243 | artRDM.setPortType(portA[0], portA[1], TYPE_DMX_OUT); 244 | updatePorts = true; 245 | 246 | // Initialize the pixel strip 247 | pixDriver.setStrip(0, DMX_TX_A, deviceSettings.portAnumPix, deviceSettings.portApixConfig); 248 | 249 | } 250 | */ 251 | } 252 | 253 | // Update the Artnet class 254 | artRDM.setNet(portA[0], deviceSettings.portAnet); 255 | artRDM.setSubNet(portA[0], deviceSettings.portAsub); 256 | artRDM.setUni(portA[0], portA[1], deviceSettings.portAuni[0]); 257 | artRDM.setMerge(portA[0], portA[1], deviceSettings.portAmerge); 258 | 259 | // Lengthen or shorten our pixel strip & handle required Artnet ports 260 | if (newMode == TYPE_WS2812 && !doReboot) { 261 | // Get the new & old lengths of pixel strip 262 | uint16_t newLen = (json.containsKey("portAnumPix")) ? (uint16_t)json["portAnumPix"] : deviceSettings.portAnumPix; 263 | if (newLen > 680) 264 | newLen = 680; 265 | 266 | uint16_t oldLen = deviceSettings.portAnumPix; 267 | bool lenChanged = false; 268 | 269 | // If pixel size has changed 270 | if (newLen <= 680 && oldLen != newLen) { 271 | // Update our pixel strip 272 | deviceSettings.portAnumPix = newLen; 273 | pixDriver.updateStrip(1, deviceSettings.portAnumPix, deviceSettings.portApixConfig); 274 | 275 | lenChanged = true; 276 | 277 | // If the old mode was pixel map then update the Artnet ports 278 | if (deviceSettings.portApixMode == FX_MODE_PIXEL_MAP) 279 | updatePorts = true; 280 | } 281 | 282 | // If the old mode was 12 channel FX, update oldLen to represent the number of channels we used 283 | if (deviceSettings.portApixMode == FX_MODE_12) 284 | oldLen = 12; 285 | 286 | // If our mode changes then update the Artnet ports 287 | if (deviceSettings.portApixMode != (uint8_t)json["portApixMode"]) 288 | updatePorts = true; 289 | 290 | // Store the new pixel mode 291 | deviceSettings.portApixMode = (uint8_t)json["portApixMode"]; 292 | 293 | // If our new mode is FX12 then we need 12 channels & store the start address 294 | if (deviceSettings.portApixMode == FX_MODE_12) { 295 | if ((uint16_t)json["portApixFXstart"] <= 501 && (uint16_t)json["portApixFXstart"] > 0) 296 | deviceSettings.portApixFXstart = (uint16_t)json["portApixFXstart"]; 297 | newLen = 12; 298 | } 299 | 300 | // If needed, open and close Artnet ports 301 | if (updatePorts) { 302 | for (uint8_t x = 1, y = 2; x < 4; x++, y++) { 303 | uint16_t c = (x * 170); 304 | if (newLen > c) 305 | portA[y] = artRDM.addPort(portA[0], x, deviceSettings.portAuni[x], TYPE_DMX_OUT, deviceSettings.portAmerge); 306 | else if (oldLen > c) 307 | artRDM.closePort(portA[0], portA[y]); 308 | } 309 | } 310 | 311 | // Set universe and merge settings (port 1 is done above for all port types) 312 | for (uint8_t x = 1, y = 2; x < 4; x++, y++) { 313 | if (newLen > (x * 170)) { 314 | artRDM.setUni(portA[0], portA[y], deviceSettings.portAuni[x]); 315 | artRDM.setMerge(portA[0], portA[y], deviceSettings.portAmerge); 316 | } 317 | } 318 | } 319 | 320 | artRDM.artPollReply(); 321 | 322 | eepromSave(); 323 | return true; 324 | } 325 | break; 326 | 327 | case 5: // Port B 328 | #ifndef ONE_PORT 329 | { 330 | deviceSettings.portBprot = (uint8_t)json["portBprot"]; 331 | bool e131 = (deviceSettings.portBprot == PROT_ARTNET_SACN) ? true : false; 332 | 333 | deviceSettings.portBmerge = (uint8_t)json["portBmerge"]; 334 | 335 | if ((uint8_t)json["portBnet"] < 128) 336 | deviceSettings.portBnet = (uint8_t)json["portBnet"]; 337 | 338 | if ((uint8_t)json["portBsub"] < 16) 339 | deviceSettings.portBsub = (uint8_t)json["portBsub"]; 340 | 341 | for (uint8_t x = 0; x < 4; x++) { 342 | if ((uint8_t)json["portBuni"][x] < 16) 343 | deviceSettings.portBuni[x] = (uint8_t)json["portBuni"][x]; 344 | 345 | if ((uint16_t)json["portBsACNuni"][x] > 0 && (uint16_t)json["portBsACNuni"][x] < 64000) 346 | deviceSettings.portBsACNuni[x] = (uint16_t)json["portBsACNuni"][x]; 347 | 348 | artRDM.setE131(portB[0], portB[x+1], e131); 349 | artRDM.setE131Uni(portB[0], portB[x+1], deviceSettings.portBsACNuni[x]); 350 | } 351 | 352 | uint8_t newMode = json["portBmode"]; 353 | uint8_t oldMode = deviceSettings.portBmode; 354 | bool updatePorts = false; 355 | 356 | // RDM and DMX input can't run together 357 | if (newMode == TYPE_RDM_OUT && deviceSettings.portAmode == TYPE_DMX_IN) 358 | newMode = TYPE_DMX_OUT; 359 | 360 | if (newMode != oldMode) { 361 | 362 | // Store the nem mode to settings 363 | deviceSettings.portBmode = newMode; 364 | 365 | doReboot = true; 366 | 367 | /* 368 | if (oldMode == TYPE_WS2812) { 369 | doReboot = true; 370 | 371 | // Set pixel strip length to zero 372 | pixDriver.updateStrip(1, 0, deviceSettings.portBpixConfig); 373 | 374 | // Close ports from pixels - library handles if they dont exist 375 | for (uint8_t x = 2; x <= 4; x++) 376 | artRDM.closePort(portB[0], portB[x]); 377 | 378 | // Start our DMX port 379 | dmxB.begin(DMX_DIR_B, artRDM.getDMX(portB[0], portB[1])); 380 | 381 | 382 | } else if (oldMode == TYPE_RDM_OUT) 383 | dmxB.rdmDisable(); 384 | 385 | 386 | 387 | // Start DMX output with no DMX 388 | if (newMode == TYPE_DMX_OUT) { 389 | artRDM.setPortType(portB[0], portB[1], DMX_OUT); 390 | 391 | // Start DMX output with RDM 392 | } else if (newMode == TYPE_RDM_OUT) { 393 | dmxB.rdmEnable(ESTA_MAN, ESTA_DEV); 394 | dmxB.rdmSetCallBack(rdmReceivedB); 395 | dmxB.todSetCallBack(sendTodB); 396 | artRDM.setPortType(portB[0], portB[1], RDM_OUT); 397 | 398 | // Start WS2812 output 399 | } else if (newMode == TYPE_WS2812) { 400 | doReboot = true; 401 | 402 | 403 | //dmxB.end(); 404 | artRDM.setPortType(portB[0], portB[1], TYPE_DMX_OUT); 405 | updatePorts = true; 406 | 407 | // Initialize the pixel strip 408 | pixDriver.setStrip(1, DMX_TX_B, deviceSettings.portBnumPix, deviceSettings.portBpixConfig); 409 | 410 | } 411 | */ 412 | } 413 | 414 | // Update the Artnet class 415 | artRDM.setNet(portB[0], deviceSettings.portBnet); 416 | artRDM.setSubNet(portB[0], deviceSettings.portBsub); 417 | artRDM.setUni(portB[0], portB[1], deviceSettings.portBuni[0]); 418 | artRDM.setMerge(portB[0], portB[1], deviceSettings.portBmerge); 419 | 420 | // Lengthen or shorten our pixel strip & handle required Artnet ports 421 | if (newMode == TYPE_WS2812 && !doReboot) { 422 | // Get the new & old lengths of pixel strip 423 | uint16_t newLen = (json.containsKey("portBnumPix")) ? (uint16_t)json["portBnumPix"] : deviceSettings.portBnumPix; 424 | if (newLen > 680) 425 | newLen = 680; 426 | 427 | uint16_t oldLen = deviceSettings.portBnumPix; 428 | bool lenChanged = false; 429 | 430 | // If pixel size has changed 431 | if (newLen <= 680 && oldLen != newLen) { 432 | // Update our pixel strip 433 | deviceSettings.portBnumPix = newLen; 434 | pixDriver.updateStrip(1, deviceSettings.portBnumPix, deviceSettings.portBpixConfig); 435 | 436 | lenChanged = true; 437 | 438 | // If the old mode was pixel map then update the Artnet ports 439 | if (deviceSettings.portBpixMode == FX_MODE_PIXEL_MAP) 440 | updatePorts = true; 441 | } 442 | 443 | // If the old mode was 12 channel FX, update oldLen to represent the number of channels we used 444 | if (deviceSettings.portBpixMode == FX_MODE_12) 445 | oldLen = 12; 446 | 447 | // If our mode changes then update the Artnet ports 448 | if (deviceSettings.portBpixMode != (uint8_t)json["portBpixMode"]) 449 | updatePorts = true; 450 | 451 | // Store the new pixel mode 452 | deviceSettings.portBpixMode = (uint8_t)json["portBpixMode"]; 453 | 454 | // If our new mode is FX12 then we need 12 channels & store the start address 455 | if (deviceSettings.portBpixMode == FX_MODE_12) { 456 | if ((uint16_t)json["portBpixFXstart"] <= 501 && (uint16_t)json["portBpixFXstart"] > 0) 457 | deviceSettings.portBpixFXstart = (uint16_t)json["portBpixFXstart"]; 458 | newLen = 12; 459 | } 460 | 461 | // If needed, open and close Artnet ports 462 | if (updatePorts) { 463 | for (uint8_t x = 1, y = 2; x < 4; x++, y++) { 464 | uint16_t c = (x * 170); 465 | if (newLen > c) 466 | portB[y] = artRDM.addPort(portB[0], x, deviceSettings.portBuni[x], TYPE_DMX_OUT, deviceSettings.portBmerge); 467 | else if (oldLen > c) 468 | artRDM.closePort(portB[0], portB[y]); 469 | } 470 | } 471 | 472 | // Set universe and merge settings (port 1 is done above for all port types) 473 | for (uint8_t x = 1, y = 2; x < 4; x++, y++) { 474 | if (newLen > (x * 170)) { 475 | artRDM.setUni(portB[0], portB[y], deviceSettings.portBuni[x]); 476 | artRDM.setMerge(portB[0], portB[y], deviceSettings.portBmerge); 477 | } 478 | } 479 | } 480 | 481 | artRDM.artPollReply(); 482 | 483 | eepromSave(); 484 | return true; 485 | } 486 | #endif 487 | break; 488 | 489 | case 6: // Scenes 490 | // Not yet implemented 491 | 492 | return true; 493 | break; 494 | 495 | case 7: // Firmware 496 | // Doesn't come here 497 | 498 | break; 499 | 500 | default: 501 | // Catch errors 502 | return false; 503 | } 504 | } 505 | 506 | void ajaxLoad(uint8_t page, JsonObject& jsonReply) { 507 | 508 | // Create the needed arrays here - doesn't work within the switch below 509 | JsonArray& ipAddress = jsonReply.createNestedArray("ipAddress"); 510 | JsonArray& subAddress = jsonReply.createNestedArray("subAddress"); 511 | JsonArray& gwAddress = jsonReply.createNestedArray("gwAddress"); 512 | JsonArray& bcAddress = jsonReply.createNestedArray("bcAddress"); 513 | JsonArray& portAuni = jsonReply.createNestedArray("portAuni"); 514 | JsonArray& portBuni = jsonReply.createNestedArray("portBuni"); 515 | JsonArray& portAsACNuni = jsonReply.createNestedArray("portAsACNuni"); 516 | JsonArray& portBsACNuni = jsonReply.createNestedArray("portBsACNuni"); 517 | JsonArray& dmxInBroadcast = jsonReply.createNestedArray("dmxInBroadcast"); 518 | 519 | // Get MAC Address 520 | char MAC_char[30] = ""; 521 | sprintf(MAC_char, "%02X", MAC_array[0]); 522 | for (int i = 1; i < 6; ++i) 523 | sprintf(MAC_char, "%s:%02X", MAC_char, MAC_array[i]); 524 | 525 | jsonReply["macAddress"] = String(MAC_char); 526 | 527 | switch (page) { 528 | case 1: // Device Status 529 | jsonReply.remove("ipAddress"); 530 | jsonReply.remove("subAddress"); 531 | jsonReply.remove("gwAddress"); 532 | jsonReply.remove("bcAddress"); 533 | jsonReply.remove("portAuni"); 534 | jsonReply.remove("portBuni"); 535 | jsonReply.remove("portAsACNuni"); 536 | jsonReply.remove("portBsACNuni"); 537 | jsonReply.remove("dmxInBroadcast"); 538 | 539 | jsonReply["nodeName"] = deviceSettings.nodeName; 540 | jsonReply["wifiStatus"] = wifiStatus; 541 | 542 | if (isHotspot) { 543 | jsonReply["ipAddressT"] = deviceSettings.hotspotIp.toString(); 544 | jsonReply["subAddressT"] = deviceSettings.hotspotSubnet.toString(); 545 | } else { 546 | jsonReply["ipAddressT"] = deviceSettings.ip.toString(); 547 | jsonReply["subAddressT"] = deviceSettings.subnet.toString(); 548 | } 549 | 550 | if (isHotspot && !deviceSettings.standAloneEnable) { 551 | jsonReply["portAStatus"] = "Disabled in hotspot mode"; 552 | jsonReply["portBStatus"] = "Disabled in hotspot mode"; 553 | } else { 554 | switch (deviceSettings.portAmode) { 555 | case TYPE_DMX_OUT: 556 | jsonReply["portAStatus"] = "DMX output"; 557 | break; 558 | 559 | case TYPE_RDM_OUT: 560 | jsonReply["portAStatus"] = "DMX/RDM output"; 561 | break; 562 | 563 | case TYPE_DMX_IN: 564 | jsonReply["portAStatus"] = "DMX input"; 565 | break; 566 | 567 | case TYPE_WS2812: 568 | jsonReply["portAStatus"] = "WS2812 mode"; 569 | break; 570 | } 571 | switch (deviceSettings.portBmode) { 572 | case TYPE_DMX_OUT: 573 | jsonReply["portBStatus"] = "DMX output"; 574 | break; 575 | 576 | case TYPE_RDM_OUT: 577 | jsonReply["portBStatus"] = "DMX/RDM output"; 578 | break; 579 | 580 | case TYPE_DMX_IN: 581 | jsonReply["portBStatus"] = "DMX input"; 582 | break; 583 | 584 | case TYPE_WS2812: 585 | jsonReply["portBStatus"] = "WS2812 mode"; 586 | break; 587 | } 588 | } 589 | 590 | jsonReply["sceneStatus"] = "Not outputting
0 Scenes Recorded
0 of 250KB used"; 591 | jsonReply["firmwareStatus"] = FIRMWARE_VERSION; 592 | 593 | jsonReply["success"] = 1; 594 | break; 595 | 596 | case 2: // Wifi 597 | jsonReply.remove("ipAddress"); 598 | jsonReply.remove("subAddress"); 599 | jsonReply.remove("gwAddress"); 600 | jsonReply.remove("bcAddress"); 601 | jsonReply.remove("portAuni"); 602 | jsonReply.remove("portBuni"); 603 | jsonReply.remove("portAsACNuni"); 604 | jsonReply.remove("portBsACNuni"); 605 | jsonReply.remove("dmxInBroadcast"); 606 | 607 | jsonReply["wifiSSID"] = deviceSettings.wifiSSID; 608 | jsonReply["wifiPass"] = deviceSettings.wifiPass; 609 | jsonReply["hotspotSSID"] = deviceSettings.hotspotSSID; 610 | jsonReply["hotspotPass"] = deviceSettings.hotspotPass; 611 | jsonReply["hotspotDelay"] = deviceSettings.hotspotDelay; 612 | jsonReply["standAloneEnable"] = deviceSettings.standAloneEnable; 613 | 614 | jsonReply["success"] = 1; 615 | break; 616 | 617 | case 3: // IP Address & Node Name 618 | jsonReply.remove("portAuni"); 619 | jsonReply.remove("portBuni"); 620 | jsonReply.remove("portAsACNuni"); 621 | jsonReply.remove("portBsACNuni"); 622 | jsonReply.remove("dmxInBroadcast"); 623 | 624 | jsonReply["dhcpEnable"] = deviceSettings.dhcpEnable; 625 | 626 | for (uint8_t x = 0; x < 4; x++) { 627 | ipAddress.add(deviceSettings.ip[x]); 628 | subAddress.add(deviceSettings.subnet[x]); 629 | gwAddress.add(deviceSettings.gateway[x]); 630 | bcAddress.add(deviceSettings.broadcast[x]); 631 | } 632 | 633 | jsonReply["nodeName"] = deviceSettings.nodeName; 634 | jsonReply["longName"] = deviceSettings.longName; 635 | 636 | jsonReply["success"] = 1; 637 | break; 638 | 639 | case 4: // Port A 640 | jsonReply.remove("ipAddress"); 641 | jsonReply.remove("subAddress"); 642 | jsonReply.remove("gwAddress"); 643 | jsonReply.remove("bcAddress"); 644 | jsonReply.remove("portBuni"); 645 | jsonReply.remove("portBsACNuni"); 646 | 647 | jsonReply["portAmode"] = deviceSettings.portAmode; 648 | 649 | // Only Artnet supported for receiving right now 650 | if (deviceSettings.portAmode == TYPE_DMX_IN) 651 | jsonReply["portAprot"] = PROT_ARTNET; 652 | else 653 | jsonReply["portAprot"] = deviceSettings.portAprot; 654 | 655 | jsonReply["portAmerge"] = deviceSettings.portAmerge; 656 | jsonReply["portAnet"] = deviceSettings.portAnet; 657 | jsonReply["portAsub"] = deviceSettings.portAsub; 658 | jsonReply["portAnumPix"] = deviceSettings.portAnumPix; 659 | 660 | jsonReply["portApixMode"] = deviceSettings.portApixMode; 661 | jsonReply["portApixFXstart"] = deviceSettings.portApixFXstart; 662 | 663 | for (uint8_t x = 0; x < 4; x++) { 664 | portAuni.add(deviceSettings.portAuni[x]); 665 | portAsACNuni.add(deviceSettings.portAsACNuni[x]); 666 | dmxInBroadcast.add(deviceSettings.dmxInBroadcast[x]); 667 | } 668 | 669 | jsonReply["success"] = 1; 670 | break; 671 | 672 | case 5: // Port B 673 | jsonReply.remove("ipAddress"); 674 | jsonReply.remove("subAddress"); 675 | jsonReply.remove("gwAddress"); 676 | jsonReply.remove("bcAddress"); 677 | jsonReply.remove("portAuni"); 678 | jsonReply.remove("portAsACNuni"); 679 | 680 | jsonReply["portBmode"] = deviceSettings.portBmode; 681 | jsonReply["portBprot"] = deviceSettings.portBprot; 682 | jsonReply["portBmerge"] = deviceSettings.portBmerge; 683 | jsonReply["portBnet"] = deviceSettings.portBnet; 684 | jsonReply["portBsub"] = deviceSettings.portBsub; 685 | jsonReply["portBnumPix"] = deviceSettings.portBnumPix; 686 | 687 | jsonReply["portBpixMode"] = deviceSettings.portBpixMode; 688 | jsonReply["portBpixFXstart"] = deviceSettings.portBpixFXstart; 689 | 690 | for (uint8_t x = 0; x < 4; x++) { 691 | portBuni.add(deviceSettings.portBuni[x]); 692 | portBsACNuni.add(deviceSettings.portBsACNuni[x]); 693 | dmxInBroadcast.add(deviceSettings.dmxInBroadcast[x]); 694 | } 695 | 696 | jsonReply["success"] = 1; 697 | break; 698 | 699 | case 6: // Scenes 700 | jsonReply.remove("ipAddress"); 701 | jsonReply.remove("subAddress"); 702 | jsonReply.remove("gwAddress"); 703 | jsonReply.remove("bcAddress"); 704 | jsonReply.remove("portAuni"); 705 | jsonReply.remove("portBuni"); 706 | jsonReply.remove("portAsACNuni"); 707 | jsonReply.remove("portBsACNuni"); 708 | jsonReply.remove("dmxInBroadcast"); 709 | 710 | 711 | jsonReply["success"] = 1; 712 | break; 713 | 714 | case 7: // Firmware 715 | jsonReply.remove("ipAddress"); 716 | jsonReply.remove("subAddress"); 717 | jsonReply.remove("gwAddress"); 718 | jsonReply.remove("bcAddress"); 719 | jsonReply.remove("portAuni"); 720 | jsonReply.remove("portBuni"); 721 | jsonReply.remove("portAsACNuni"); 722 | jsonReply.remove("portBsACNuni"); 723 | jsonReply.remove("dmxInBroadcast"); 724 | 725 | jsonReply["firmwareStatus"] = FIRMWARE_VERSION; 726 | jsonReply["success"] = 1; 727 | break; 728 | 729 | default: 730 | jsonReply.remove("ipAddress"); 731 | jsonReply.remove("subAddress"); 732 | jsonReply.remove("gwAddress"); 733 | jsonReply.remove("bcAddress"); 734 | jsonReply.remove("portAuni"); 735 | jsonReply.remove("portBuni"); 736 | jsonReply.remove("portAsACNuni"); 737 | jsonReply.remove("portBsACNuni"); 738 | jsonReply.remove("dmxInBroadcast"); 739 | 740 | jsonReply["success"] = 0; 741 | jsonReply["message"] = "Invalid or incomplete data received."; 742 | } 743 | } 744 | 745 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | {one line to give the program's name and a brief idea of what it does.} 635 | Copyright (C) {year} {name of author} 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | {project} Copyright (C) {year} {fullname} 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /source/LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | {one line to give the program's name and a brief idea of what it does.} 635 | Copyright (C) {year} {name of author} 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | {project} Copyright (C) {year} {fullname} 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------