Browse Source

Merge branch 'my9291' into dev

Conflicts:
	code/platformio.ini
fastled
Xose Pérez 7 years ago
parent
commit
d76d2a7fc1
11 changed files with 450 additions and 60 deletions
  1. +2
    -2
      code/espurna/config/data.h
  2. +22
    -0
      code/espurna/config/general.h
  3. +13
    -0
      code/espurna/config/hardware.h
  4. BIN
      code/espurna/data/index.html.gz
  5. +159
    -45
      code/espurna/relay.ino
  6. +14
    -1
      code/espurna/web.ino
  7. +28
    -0
      code/html/custom.js
  8. +19
    -12
      code/html/index.html
  9. +13
    -0
      code/html/jquery.wheelcolorpicker-3.0.2.min.js
  10. +158
    -0
      code/html/wheelcolorpicker.css
  11. +22
    -0
      code/platformio.ini

+ 2
- 2
code/espurna/config/data.h
File diff suppressed because it is too large
View File


+ 22
- 0
code/espurna/config/general.h View File

@ -56,6 +56,14 @@
#define RELAY_PULSE_OFF 1 #define RELAY_PULSE_OFF 1
#define RELAY_PULSE_ON 2 #define RELAY_PULSE_ON 2
#define RELAY_PROVIDER_RELAY 0
#define RELAY_PROVIDER_DUAL 1
#define RELAY_PROVIDER_MY9291 2
#ifndef RELAY_PROVIDER
#define RELAY_PROVIDER RELAY_PROVIDER_RELAY
#endif
// Pulse time in seconds // Pulse time in seconds
#define RELAY_PULSE_TIME 1 #define RELAY_PULSE_TIME 1
@ -143,6 +151,7 @@
#define MQTT_ACTION_TOPIC "/action" #define MQTT_ACTION_TOPIC "/action"
#define MQTT_RELAY_TOPIC "/relay" #define MQTT_RELAY_TOPIC "/relay"
#define MQTT_LED_TOPIC "/led" #define MQTT_LED_TOPIC "/led"
#define MQTT_COLOR_TOPIC "/color"
#define MQTT_BUTTON_TOPIC "/button" #define MQTT_BUTTON_TOPIC "/button"
#define MQTT_IP_TOPIC "/ip" #define MQTT_IP_TOPIC "/ip"
#define MQTT_VERSION_TOPIC "/version" #define MQTT_VERSION_TOPIC "/version"
@ -169,6 +178,19 @@
#define I2C_CLOCK_STRETCH_TIME 200 #define I2C_CLOCK_STRETCH_TIME 200
#define I2C_SCL_FREQUENCY 1000 #define I2C_SCL_FREQUENCY 1000
// -----------------------------------------------------------------------------
// MY9291
// -----------------------------------------------------------------------------
#define MY9291_DI_PIN 13
#define MY9291_DCKI_PIN 15
#define MY9291_COMMAND MY9291_COMMAND_DEFAULT
#define MY9291_COLOR_RED 0
#define MY9291_COLOR_GREEN 0
#define MY9291_COLOR_BLUE 0
#define MY9291_COLOR_WHITE 192
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// DOMOTICZ // DOMOTICZ
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------


+ 13
- 0
code/espurna/config/hardware.h View File

@ -142,6 +142,8 @@
#define LED1_PIN_INVERSE 1 #define LED1_PIN_INVERSE 1
#undef SERIAL_BAUDRATE #undef SERIAL_BAUDRATE
#define SERIAL_BAUDRATE 19230 #define SERIAL_BAUDRATE 19230
#undef RELAY_PROVIDER
#define RELAY_PROVIDER RELAY_PROVIDER_DUAL
#elif defined(SONOFF_4CH) #elif defined(SONOFF_4CH)
@ -240,6 +242,17 @@
#define LED1_PIN 2 #define LED1_PIN 2
#define LED1_PIN_INVERSE 0 #define LED1_PIN_INVERSE 0
// -----------------------------------------------------------------------------
// AI Thinker
// -----------------------------------------------------------------------------
#elif defined(AI_LIGHT)
#define MANUFACTURER "AI THINKER"
#define DEVICE "AI LIGHT"
#undef RELAY_PROVIDER
#define RELAY_PROVIDER RELAY_PROVIDER_MY9291
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Jan Goedeke Wifi Relay // Jan Goedeke Wifi Relay
// https://github.com/JanGoe/esp8266-wifi-relay // https://github.com/JanGoe/esp8266-wifi-relay


BIN
code/espurna/data/index.html.gz View File


+ 159
- 45
code/espurna/relay.ino View File

@ -18,13 +18,101 @@ typedef struct {
unsigned char led; unsigned char led;
} relay_t; } relay_t;
std::vector<relay_t> _relays; std::vector<relay_t> _relays;
Ticker pulseTicker;
bool recursive = false;
#ifdef SONOFF_DUAL
unsigned char dualRelayStatus = 0;
#if RELAY_PROVIDER == RELAY_PROVIDER_DUAL
unsigned char _dual_status = 0;
#endif #endif
Ticker pulseTicker;
bool recursive = false;
#if RELAY_PROVIDER == RELAY_PROVIDER_MY9291
#include <my9291.h>
my9291 _my9291 = my9291(MY9291_DI_PIN, MY9291_DCKI_PIN, MY9291_COMMAND);
Ticker colorTicker;
#endif
// -----------------------------------------------------------------------------
// PROVIDER
// -----------------------------------------------------------------------------
#if RELAY_PROVIDER == RELAY_PROVIDER_MY9291
void setLightColor(unsigned char red, unsigned char green, unsigned char blue, unsigned char white) {
// Set new color (if light is open it will automatically change)
_my9291.setColor((my9291_color_t) { red, green, blue, white });
// Delay saving to EEPROM 5 seconds to avoid wearing it out unnecessarily
colorTicker.once(5, saveLightColor);
}
String getLightColor() {
char buffer[16];
my9291_color_t color = _my9291.getColor();
sprintf(buffer, "%d,%d,%d,%d", color.red, color.green, color.blue, color.white);
return String(buffer);
}
void saveLightColor() {
my9291_color_t color = _my9291.getColor();
setSetting("colorRed", color.red);
setSetting("colorGreen", color.green);
setSetting("colorBlue", color.blue);
setSetting("colorWhite", color.white);
saveSettings();
}
void retrieveLightColor() {
unsigned int red = getSetting("colorRed", MY9291_COLOR_RED).toInt();
unsigned int green = getSetting("colorGreen", MY9291_COLOR_GREEN).toInt();
unsigned int blue = getSetting("colorBlue", MY9291_COLOR_BLUE).toInt();
unsigned int white = getSetting("colorWhite", MY9291_COLOR_WHITE).toInt();
_my9291.setColor((my9291_color_t) { red, green, blue, white });
}
#endif
void relayProviderStatus(unsigned char id, bool status) {
#if RELAY_PROVIDER == RELAY_PROVIDER_DUAL
_dual_status ^= (1 << id);
Serial.flush();
Serial.write(0xA0);
Serial.write(0x04);
Serial.write(_dual_status);
Serial.write(0xA1);
Serial.flush();
#endif
#if RELAY_PROVIDER == RELAY_PROVIDER_MY9291
_my9291.setState(status);
#endif
#if RELAY_PROVIDER == RELAY_PROVIDER_RELAY
digitalWrite(_relays[id].pin, _relays[id].reverse ? !status : status);
#endif
}
bool relayProviderStatus(unsigned char id) {
#if RELAY_PROVIDER == RELAY_PROVIDER_DUAL
if (id >= 2) return false;
return ((_dual_status & (1 << id)) > 0);
#endif
#if RELAY_PROVIDER == RELAY_PROVIDER_MY9291
return _my9291.getState();
#endif
#if RELAY_PROVIDER == RELAY_PROVIDER_RELAY
if (id >= _relays.size()) return false;
bool status = (digitalRead(_relays[id].pin) == HIGH);
return _relays[id].reverse ? !status : status;
#endif
}
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// RELAY // RELAY
@ -43,14 +131,7 @@ String relayString() {
} }
bool relayStatus(unsigned char id) { bool relayStatus(unsigned char id) {
#ifdef SONOFF_DUAL
if (id >= 2) return false;
return ((dualRelayStatus & (1 << id)) > 0);
#else
if (id >= _relays.size()) return false;
bool status = (digitalRead(_relays[id].pin) == HIGH);
return _relays[id].reverse ? !status : status;
#endif
return relayProviderStatus(id);
} }
void relayPulse(unsigned char id) { void relayPulse(unsigned char id) {
@ -120,19 +201,7 @@ bool relayStatus(unsigned char id, bool status, bool report) {
DEBUG_MSG("[RELAY] %d => %s\n", id, status ? "ON" : "OFF"); DEBUG_MSG("[RELAY] %d => %s\n", id, status ? "ON" : "OFF");
changed = true; changed = true;
#ifdef SONOFF_DUAL
dualRelayStatus ^= (1 << id);
Serial.flush();
Serial.write(0xA0);
Serial.write(0x04);
Serial.write(dualRelayStatus);
Serial.write(0xA1);
Serial.flush();
#else
digitalWrite(_relays[id].pin, _relays[id].reverse ? !status : status);
#endif
relayProviderStatus(id, status);
if (_relays[id].led > 0) { if (_relays[id].led > 0) {
ledStatus(_relays[id].led - 1, status); ledStatus(_relays[id].led - 1, status);
@ -370,42 +439,78 @@ void relayMQTTCallback(unsigned int type, const char * topic, const char * paylo
if (type == MQTT_CONNECT_EVENT) { if (type == MQTT_CONNECT_EVENT) {
relayMQTT(); relayMQTT();
char buffer[strlen(MQTT_RELAY_TOPIC) + mqttSetter.length() + 10];
char buffer[strlen(MQTT_RELAY_TOPIC) + mqttSetter.length() + 20];
sprintf(buffer, "%s/+%s", MQTT_RELAY_TOPIC, mqttSetter.c_str()); sprintf(buffer, "%s/+%s", MQTT_RELAY_TOPIC, mqttSetter.c_str());
mqttSubscribe(buffer); mqttSubscribe(buffer);
#if RELAY_PROVIDER == RELAY_PROVIDER_MY9291
sprintf(buffer, "%s%s", MQTT_COLOR_TOPIC, mqttSetter.c_str());
mqttSubscribe(buffer);
#endif
} }
if (type == MQTT_MESSAGE_EVENT) { if (type == MQTT_MESSAGE_EVENT) {
// Match topic // Match topic
char * t = mqttSubtopic((char *) topic); char * t = mqttSubtopic((char *) topic);
if (strncmp(t, MQTT_RELAY_TOPIC, strlen(MQTT_RELAY_TOPIC)) != 0) return;
int len = mqttSetter.length(); int len = mqttSetter.length();
if (strncmp(t + strlen(t) - len, mqttSetter.c_str(), len) != 0) return; if (strncmp(t + strlen(t) - len, mqttSetter.c_str(), len) != 0) return;
// Get value
unsigned int value = (char)payload[0] - '0';
// Color topic
#if RELAY_PROVIDER == RELAY_PROVIDER_MY9291
if (strncmp(t, MQTT_COLOR_TOPIC, strlen(MQTT_COLOR_TOPIC)) == 0) {
// Pulse topic
if (strncmp(t + strlen(MQTT_RELAY_TOPIC) + 1, "pulse", 5) == 0) {
relayPulseMode(value, !sameSetGet);
return;
}
unsigned char red, green, blue = 0;
// Get relay ID
unsigned int relayID = topic[strlen(topic) - mqttSetter.length() - 1] - '0';
if (relayID >= relayCount()) {
DEBUG_MSG("[RELAY] Wrong relayID (%d)\n", relayID);
return;
}
char * p;
p = strtok((char *) payload, ",");
red = atoi(p);
p = strtok(NULL, ",");
if (p != NULL) {
green = atoi(p);
p = strtok(NULL, ",");
if (p != NULL) blue = atoi(p);
} else {
green = blue = red;
}
if ((red == green) && (green == blue)) {
setLightColor(0, 0, 0, red);
} else {
setLightColor(red, green, blue, 0);
}
return;
}
#endif
// Relay topic
if (strncmp(t, MQTT_RELAY_TOPIC, strlen(MQTT_RELAY_TOPIC)) == 0) {
// Get value
unsigned int value = (char)payload[0] - '0';
// Pulse topic
if (strncmp(t + strlen(MQTT_RELAY_TOPIC) + 1, "pulse", 5) == 0) {
relayPulseMode(value, !sameSetGet);
return;
}
// Get relay ID
unsigned int relayID = topic[strlen(topic) - mqttSetter.length() - 1] - '0';
if (relayID >= relayCount()) {
DEBUG_MSG("[RELAY] Wrong relayID (%d)\n", relayID);
return;
}
// Action to perform
if (value == 2) {
relayToggle(relayID);
} else {
relayStatus(relayID, value > 0, !sameSetGet);
}
// Action to perform
if (value == 2) {
relayToggle(relayID);
} else {
relayStatus(relayID, value > 0, !sameSetGet);
} }
} }
@ -428,6 +533,11 @@ void relaySetup() {
_relays.push_back((relay_t) {0, 0}); _relays.push_back((relay_t) {0, 0});
_relays.push_back((relay_t) {0, 0}); _relays.push_back((relay_t) {0, 0});
#elif AI_LIGHT
// One dummy relay for the AI Thinker Light
_relays.push_back((relay_t) {0, 0});
#else #else
#ifdef RELAY1_PIN #ifdef RELAY1_PIN
@ -448,6 +558,10 @@ void relaySetup() {
EEPROM.begin(4096); EEPROM.begin(4096);
byte relayMode = getSetting("relayMode", RELAY_MODE).toInt(); byte relayMode = getSetting("relayMode", RELAY_MODE).toInt();
#if RELAY_PROVIDER == RELAY_PROVIDER_MY9291
retrieveLightColor();
#endif
for (unsigned int i=0; i < _relays.size(); i++) { for (unsigned int i=0; i < _relays.size(); i++) {
pinMode(_relays[i].pin, OUTPUT); pinMode(_relays[i].pin, OUTPUT);
if (relayMode == RELAY_MODE_OFF) relayStatus(i, false); if (relayMode == RELAY_MODE_OFF) relayStatus(i, false);


+ 14
- 1
code/espurna/web.ino View File

@ -101,7 +101,7 @@ void _wsParse(uint32_t client_id, uint8_t * payload, size_t length) {
EEPROM.write(i, 0xFF); EEPROM.write(i, 0xFF);
} }
for (auto element : data){
for (auto element : data) {
if (strcmp(element.key, "app") == 0) continue; if (strcmp(element.key, "app") == 0) continue;
if (strcmp(element.key, "version") == 0) continue; if (strcmp(element.key, "version") == 0) continue;
setSetting(element.key, element.value.as<char*>()); setSetting(element.key, element.value.as<char*>());
@ -121,6 +121,13 @@ void _wsParse(uint32_t client_id, uint8_t * payload, size_t length) {
if (action.equals("on")) relayStatus(relayID, true); if (action.equals("on")) relayStatus(relayID, true);
if (action.equals("off")) relayStatus(relayID, false); if (action.equals("off")) relayStatus(relayID, false);
#if RELAY_PROVIDER == RELAY_PROVIDER_MY9291
if (action.equals("color") && root.containsKey("data")) {
JsonArray& data = root["data"];
setLightColor(data[0], data[1], data[2], data[3]);
}
#endif
}; };
// Check config // Check config
@ -381,6 +388,12 @@ void _wsStart(uint32_t client_id) {
for (unsigned char relayID=0; relayID<relayCount(); relayID++) { for (unsigned char relayID=0; relayID<relayCount(); relayID++) {
relay.add(relayStatus(relayID)); relay.add(relayStatus(relayID));
} }
#if RELAY_PROVIDER == RELAY_PROVIDER_MY9291
root["colorVisible"] = 1;
root["color"] = getLightColor();
#endif
root["relayMode"] = getSetting("relayMode", RELAY_MODE); root["relayMode"] = getSetting("relayMode", RELAY_MODE);
root["relayPulseMode"] = getSetting("relayPulseMode", RELAY_PULSE_MODE); root["relayPulseMode"] = getSetting("relayPulseMode", RELAY_PULSE_MODE);
root["relayPulseTime"] = getSetting("relayPulseTime", RELAY_PULSE_TIME); root["relayPulseTime"] = getSetting("relayPulseTime", RELAY_PULSE_TIME);


+ 28
- 0
code/html/custom.js View File

@ -31,6 +31,24 @@ function validateForm(form) {
} }
function doColor() {
var color = $(this).wheelColorPicker('getColor');
var data = [];
if ((color.r == color.g) && (color.g == color.b)) {
data.push(0);
data.push(0);
data.push(0);
data.push(parseInt(color.r * 255));
} else {
data.push(parseInt(color.r * 255));
data.push(parseInt(color.g * 255));
data.push(parseInt(color.b * 255));
data.push(0);
}
websock.send(JSON.stringify({'action': 'color', 'data' : data}));
}
function doUpdate() { function doUpdate() {
var form = $("#formSave"); var form = $("#formSave");
if (validateForm(form)) { if (validateForm(form)) {
@ -274,6 +292,13 @@ function processData(data) {
} }
if (key == "color") {
var color = data[key].split(",");
if (color[3] > 0) color[0] = color[1] = color[2] = color[3];
$("input[name='color']").wheelColorPicker('setRgb', color[0] / 255, color[1] / 255, color[2] / 255, true);
return;
}
if (key == "maxNetworks") { if (key == "maxNetworks") {
maxNetworks = parseInt(data.maxNetworks); maxNetworks = parseInt(data.maxNetworks);
return; return;
@ -441,6 +466,9 @@ function init() {
$(".button-add-network").on('click', function() { $(".button-add-network").on('click', function() {
$("div.more", addNetwork()).toggle(); $("div.more", addNetwork()).toggle();
}); });
$('input[name="color"]').wheelColorPicker({
sliders: 'wsvp'
}).on('sliderup', doColor);
var host = window.location.hostname; var host = window.location.hostname;
var port = location.port; var port = location.port;


+ 19
- 12
code/html/index.html View File

@ -13,6 +13,7 @@
<link rel="stylesheet" href="grids-responsive-min.css" /> <link rel="stylesheet" href="grids-responsive-min.css" />
<link rel="stylesheet" href="checkboxes.css" /> <link rel="stylesheet" href="checkboxes.css" />
<link rel="stylesheet" href="custom.css" /> <link rel="stylesheet" href="custom.css" />
<link rel="stylesheet" href="wheelcolorpicker.css" />
<!-- endbuild --> <!-- endbuild -->
</head> </head>
@ -225,6 +226,11 @@
<div id="relays"> <div id="relays">
</div> </div>
<div class="pure-g">
<label class="pure-u-1 pure-u-sm-1-4">Color</label>
<input class="pure-u-1 pure-u-sm-1-4" data-wcp-layout="block" name="color" readonly />
</div>
</fieldset> </fieldset>
</form> </form>
@ -254,7 +260,7 @@
</div> </div>
<div class="pure-g"> <div class="pure-g">
<label class="pure-u-1 pure-u-md-1-4" for="relayMode">Relay boot mode</label>
<label class="pure-u-1 pure-u-md-1-4" for="relayMode">Switch boot mode</label>
<div class="pure-u-1 pure-u-md-3-4"> <div class="pure-u-1 pure-u-md-3-4">
<select name="relayMode" class="pure-u-3-4" tabindex="2"> <select name="relayMode" class="pure-u-3-4" tabindex="2">
<option value="0">Always OFF</a> <option value="0">Always OFF</a>
@ -264,25 +270,25 @@
</select> </select>
</div> </div>
<div class="pure-u-0 pure-u-md-1-4">&nbsp;</div> <div class="pure-u-0 pure-u-md-1-4">&nbsp;</div>
<div class="pure-u-1 pure-u-md-3-4 hint">Here you can define what will be the status of the relay after a reboot.</div>
<div class="pure-u-1 pure-u-md-3-4 hint">Here you can define what will be the status of the switch after a reboot.</div>
</div> </div>
<div class="pure-g module module-multirelay"> <div class="pure-g module module-multirelay">
<label class="pure-u-1 pure-u-md-1-4" for="relaySync">Relay sync mode</label>
<label class="pure-u-1 pure-u-md-1-4" for="relaySync">Switch sync mode</label>
<div class="pure-u-1 pure-u-md-3-4"> <div class="pure-u-1 pure-u-md-3-4">
<select name="relaySync" class="pure-u-3-4" tabindex="3"> <select name="relaySync" class="pure-u-3-4" tabindex="3">
<option value="0">No synchonisation</a> <option value="0">No synchonisation</a>
<option value="1">Zero or one relays active</a>
<option value="2">One and just one relay active</a>
<option value="1">Zero or one switches active</a>
<option value="2">One and just one switches active</a>
<option value="3">All synchonised</a> <option value="3">All synchonised</a>
</select> </select>
</div> </div>
<div class="pure-u-0 pure-u-md-1-4">&nbsp;</div> <div class="pure-u-0 pure-u-md-1-4">&nbsp;</div>
<div class="pure-u-1 pure-u-md-3-4 hint">Define how the different relays should be synchronized.</div>
<div class="pure-u-1 pure-u-md-3-4 hint">Define how the different switches should be synchronized.</div>
</div> </div>
<div class="pure-g"> <div class="pure-g">
<label class="pure-u-1 pure-u-md-1-4" for="relayPulseMode">Relay pulse mode</label>
<label class="pure-u-1 pure-u-md-1-4" for="relayPulseMode">Switch pulse mode</label>
<div class="pure-u-1 pure-u-md-3-4"> <div class="pure-u-1 pure-u-md-3-4">
<select name="relayPulseMode" class="pure-u-3-4" tabindex="4"> <select name="relayPulseMode" class="pure-u-3-4" tabindex="4">
<option value="0">Don't pulse</a> <option value="0">Don't pulse</a>
@ -291,11 +297,11 @@
</select> </select>
</div> </div>
<div class="pure-u-0 pure-u-md-1-4">&nbsp;</div> <div class="pure-u-0 pure-u-md-1-4">&nbsp;</div>
<div class="pure-u-1 pure-u-md-3-4 hint">When pulse mode is enabled the relay will automatically switch back to its normal state after the pulse time (below).</div>
<div class="pure-u-1 pure-u-md-3-4 hint">When pulse mode is enabled the switch will automatically switch back to its normal state after the pulse time (below).</div>
</div> </div>
<div class="pure-g"> <div class="pure-g">
<label class="pure-u-1 pure-u-md-1-4" for="relayPulseTime">Relay pulse time</label>
<label class="pure-u-1 pure-u-md-1-4" for="relayPulseTime">Switch pulse time</label>
<input name="relayPulseTime" class="pure-u-1 pure-u-md-3-4" type="number" min="1" tabindex="5" /> <input name="relayPulseTime" class="pure-u-1 pure-u-md-3-4" type="number" min="1" tabindex="5" />
<div class="pure-u-0 pure-u-md-1-4">&nbsp;</div> <div class="pure-u-0 pure-u-md-1-4">&nbsp;</div>
<div class="pure-u-1 pure-u-md-3-4 hint">Pulse time in seconds.</div> <div class="pure-u-1 pure-u-md-3-4 hint">Pulse time in seconds.</div>
@ -435,7 +441,7 @@
<div class="pure-u-0 pure-u-md-1-4">&nbsp;</div> <div class="pure-u-0 pure-u-md-1-4">&nbsp;</div>
<div class="pure-u-1 pure-u-md-3-4 hint"> <div class="pure-u-1 pure-u-md-3-4 hint">
This is the root topic for this device. The {identifier} placeholder will be replaces by the device hostname.<br /> This is the root topic for this device. The {identifier} placeholder will be replaces by the device hostname.<br />
- <strong>&lt;root&gt;/relay/#</strong> Send a 0 or a 1 as a payload to this topic to switch it on or off. You can also send a 2 to toggle its current state. Replace # with the relay ID (starting from 0). If the board has only one relay it will be 0.<br />
- <strong>&lt;root&gt;/relay/#</strong> Send a 0 or a 1 as a payload to this topic to switch it on or off. You can also send a 2 to toggle its current state. Replace # with the switch ID (starting from 0). If the board has only one switch it will be 0.<br />
- <strong>&lt;root&gt;/led/#</strong> Send a 0 or a 1 as a payload to this topic to set the onboard LED to the given state, send a 3 to turn it back to WIFI indicator. Replace # with the LED ID (starting from 0). If the board has only one LED it will be 0.<br /> - <strong>&lt;root&gt;/led/#</strong> Send a 0 or a 1 as a payload to this topic to set the onboard LED to the given state, send a 3 to turn it back to WIFI indicator. Replace # with the LED ID (starting from 0). If the board has only one LED it will be 0.<br />
- <strong>&lt;root&gt;/button/#</strong> For each button in the board subscribe to this topic to know when it is pressed (payload 1) or released (payload 0).<br /> - <strong>&lt;root&gt;/button/#</strong> For each button in the board subscribe to this topic to know when it is pressed (payload 1) or released (payload 0).<br />
- <strong>&lt;root&gt;/ip</strong> The device will report to this topic its IP.<br /> - <strong>&lt;root&gt;/ip</strong> The device will report to this topic its IP.<br />
@ -617,14 +623,14 @@
<div id="relayTemplate" class="template"> <div id="relayTemplate" class="template">
<div class="pure-g"> <div class="pure-g">
<label class="pure-u-1 pure-u-sm-1-4">Relay<span class="relay_id"></span> Status</label>
<label class="pure-u-1 pure-u-sm-1-4">Switch<span class="relay_id"></span> Status</label>
<div class="pure-u-1 pure-u-sm-1-4"><input type="checkbox" class="relayStatus" data="0" /></div> <div class="pure-u-1 pure-u-sm-1-4"><input type="checkbox" class="relayStatus" data="0" /></div>
</div> </div>
</div> </div>
<div id="idxTemplate" class="template"> <div id="idxTemplate" class="template">
<div class="pure-g"> <div class="pure-g">
<label class="pure-u-1 pure-u-sm-1-4" for="dczRelayIdx">Relay<span class="id"></span> IDX</label>
<label class="pure-u-1 pure-u-sm-1-4" for="dczRelayIdx">Switch<span class="id"></span> IDX</label>
<div class="pure-u-1 pure-u-sm-1-8"><input class="pure-u-sm-23-24 dczRelayIdx" name="dczRelayIdx" type="number" min="0" tabindex="0" data="0" /></div> <div class="pure-u-1 pure-u-sm-1-8"><input class="pure-u-sm-23-24 dczRelayIdx" name="dczRelayIdx" type="number" min="0" tabindex="0" data="0" /></div>
<div class="pure-u-1 pure-u-sm-5-8 hint center">Set to 0 to disable notifications.</div> <div class="pure-u-1 pure-u-sm-5-8 hint center">Set to 0 to disable notifications.</div>
</div> </div>
@ -639,6 +645,7 @@
<script src="jquery-1.12.3.min.js"></script> <script src="jquery-1.12.3.min.js"></script>
<script src="checkboxes.js"></script> <script src="checkboxes.js"></script>
<script src="custom.js"></script> <script src="custom.js"></script>
<script src="jquery.wheelcolorpicker-3.0.2.min.js"></script>
<!-- endbuild --> <!-- endbuild -->
</html> </html>

+ 13
- 0
code/html/jquery.wheelcolorpicker-3.0.2.min.js
File diff suppressed because it is too large
View File


+ 158
- 0
code/html/wheelcolorpicker.css View File

@ -0,0 +1,158 @@
/**
* jQuery Wheel Color Picker
* Base Stylesheet
*
* http://www.jar2.net/projects/jquery-wheelcolorpicker
*
* Copyright © 2011-2016 Fajar Chandra. All rights reserved.
* Released under MIT License.
* http://www.opensource.org/licenses/mit-license.php
*
* Note: Width, height, left, and top properties are handled by the
* plugin. These values might change on the fly.
*/
.jQWCP-wWidget {
position: absolute;
width: 250px;
height: 180px;
background: #eee;
box-shadow: 1px 1px 4px rgba(0,0,0,.5);
border-radius: 4px;
border: solid 1px #aaa;
padding: 10px;
z-index: 1001;
}
.jQWCP-wWidget.jQWCP-block {
position: relative;
border-color: #aaa;
box-shadow: inset 1px 1px 1px #ccc;
}
.jQWCP-wWheel {
background-size: contain;
position: relative;
float: left;
width: 180px;
height: 180px;
-webkit-border-radius: 90px;
-moz-border-radius: 50%;
border-radius: 50%;
border: solid 1px #aaa;
margin: -1px;
margin-right: 10px;
transition: border .15s;
cursor: crosshair;
}
.jQWCP-wWheel:hover {
border-color: #666;
}
.jQWCP-wWheelOverlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: #000;
opacity: 0;
-webkit-border-radius: 90px;
-moz-border-radius: 50%;
border-radius: 50%;
}
.jQWCP-wWheelCursor {
width: 8px;
height: 8px;
position: absolute;
top: 50%;
left: 50%;
margin: -6px -6px;
cursor: crosshair;
border: solid 2px #fff;
box-shadow: 1px 1px 2px #000;
border-radius: 50%;
}
.jQWCP-slider-wrapper,
.jQWCP-wPreview {
position: relative;
width: 20px;
height: 180px;
float: left;
margin-right: 10px;
}
.jQWCP-wWheel:last-child,
.jQWCP-slider-wrapper:last-child,
.jQWCP-wPreview:last-child {
margin-right: 0;
}
.jQWCP-slider,
.jQWCP-wPreviewBox {
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0;
box-sizing: border-box;
border: solid 1px #aaa;
margin: -1px;
-moz-border-radius: 4px;
border-radius: 4px;
transition: border .15s;
}
.jQWCP-slider {
cursor: crosshair;
}
.jQWCP-slider-wrapper:hover .jQWCP-slider {
border-color: #666;
}
.jQWCP-scursor {
position: absolute;
left: 0;
top: 0;
right: 0;
height: 6px;
margin: -5px -1px -5px -3px;
cursor: crosshair;
border: solid 2px #fff;
box-shadow: 1px 1px 2px #000;
border-radius: 4px;
}
.jQWCP-wAlphaSlider,
.jQWCP-wPreviewBox {
background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEVAQEB/f39eaJUuAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3QYRBDgK9dKdMgAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAAARSURBVAjXY/jPwIAVYRf9DwB+vw/x6vMT1wAAAABJRU5ErkJggg==') center center;
}
.jQWCP-overlay {
position: fixed;
top: 0;
left: 0;
bottom: 0;
right: 0;
z-index: 1000;
}
/*********************/
/* Mobile layout */
.jQWCP-mobile.jQWCP-wWidget {
position: fixed;
bottom: 0;
left: 0 !important;
top: auto !important;
width: 100%;
height: 75%;
max-height: 240px;
box-sizing: border-box;
border-radius: 0;
}

+ 22
- 0
code/platformio.ini View File

@ -26,6 +26,7 @@ lib_deps =
https://bitbucket.org/xoseperez/nofuss.git https://bitbucket.org/xoseperez/nofuss.git
https://bitbucket.org/xoseperez/emonliteesp.git https://bitbucket.org/xoseperez/emonliteesp.git
https://bitbucket.org/xoseperez/debounceevent.git#dev https://bitbucket.org/xoseperez/debounceevent.git#dev
https://github.com/xoseperez/my9291#1.0.0
https://github.com/xoseperez/RemoteSwitch-arduino-library.git https://github.com/xoseperez/RemoteSwitch-arduino-library.git
lib_ignore = lib_ignore =
@ -384,3 +385,24 @@ build_flags = ${common.build_flags_1m128} -DWIFI_RELAYS_BOARD_KIT
upload_speed = 115200 upload_speed = 115200
upload_port = "192.168.4.1" upload_port = "192.168.4.1"
upload_flags = --auth=fibonacci --port 8266 upload_flags = --auth=fibonacci --port 8266
[env:ai-light-debug]
platform = espressif8266
framework = arduino
board = esp8285
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
extra_script = pio_hooks.py
build_flags = ${common.build_flags_1m128} -DAI_LIGHT
[env:ai-light-debug-ota]
platform = espressif8266
framework = arduino
board = esp8285
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
extra_script = pio_hooks.py
build_flags = ${common.build_flags_1m128} -DAI_LIGHT
upload_speed = 115200
upload_port = "192.168.4.1"
upload_flags = --auth=fibonacci --port 8266

Loading…
Cancel
Save