Browse Source

Merge commit 'f165ab93390d87ff2fef7ce2d8694ed56c96a8a2' into ir_hsv

fastled
soif 7 years ago
parent
commit
0827bacd33
11 changed files with 245 additions and 46 deletions
  1. +6
    -0
      code/build.sh
  2. +92
    -11
      code/espurna/config/hardware.h
  3. +12
    -0
      code/espurna/config/sensors.h
  4. +1
    -1
      code/espurna/config/version.h
  5. +22
    -10
      code/espurna/ds18b20.ino
  6. +5
    -0
      code/espurna/espurna.ino
  7. +26
    -1
      code/espurna/hardware.ino
  8. +18
    -8
      code/espurna/relay.ino
  9. +9
    -5
      code/espurna/web.ino
  10. +6
    -6
      code/html/index.html
  11. +48
    -4
      code/platformio.ini

+ 6
- 0
code/build.sh View File

@ -28,6 +28,12 @@ echo "Building for version $version"
# Create output folder
mkdir -p firmware
if [ ! -e node_modules/gulp/bin/gulp.js ]; then
echo "--------------------------------------------------------------"
echo "Installing dependencies..."
npm install --only=dev
fi
# Recreate web interface
echo "--------------------------------------------------------------"
echo "Building web interface..."


+ 92
- 11
code/espurna/config/hardware.h View File

@ -63,26 +63,32 @@
// ESPurna
// -----------------------------------------------------------------------------
#elif defined(TINKERMAN_ESPURNA_H)
#elif defined(TINKERMAN_ESPURNA_H06)
// Info
#define MANUFACTURER "TINKERMAN"
#define DEVICE "ESPURNA_H"
#define DEVICE "ESPURNA_H06"
// Buttons
#define BUTTON1_PIN 4
#define BUTTON1_RELAY 1
// Normal pushbutton
//#define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
#ifdef USE_TOUCH_BUTTON
// Touch button
#define BUTTON1_MODE BUTTON_PUSHBUTTON
#define BUTTON1_PRESS BUTTON_MODE_TOGGLE
#define BUTTON1_CLICK BUTTON_MODE_NONE
#define BUTTON1_DBLCLICK BUTTON_MODE_NONE
#define BUTTON1_LNGCLICK BUTTON_MODE_NONE
#define BUTTON1_LNGLNGCLICK BUTTON_MODE_NONE
// Touch button
#define BUTTON1_MODE BUTTON_PUSHBUTTON
#define BUTTON1_PRESS BUTTON_MODE_TOGGLE
#define BUTTON1_CLICK BUTTON_MODE_NONE
#define BUTTON1_DBLCLICK BUTTON_MODE_NONE
#define BUTTON1_LNGCLICK BUTTON_MODE_NONE
#define BUTTON1_LNGLNGCLICK BUTTON_MODE_NONE
#else
// Normal pushbutton
#define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
#endif
// Relays
@ -99,6 +105,47 @@
#define HLW8012_CF1_PIN 13
#define HLW8012_CF_PIN 14
#elif defined(TINKERMAN_ESPURNA_H07)
// Info
#define MANUFACTURER "TINKERMAN"
#define DEVICE "ESPURNA_H07"
// Buttons
#define BUTTON1_PIN 4
#define BUTTON1_RELAY 1
#ifdef USE_TOUCH_BUTTON
// Touch button
#define BUTTON1_MODE BUTTON_PUSHBUTTON
#define BUTTON1_PRESS BUTTON_MODE_TOGGLE
#define BUTTON1_CLICK BUTTON_MODE_NONE
#define BUTTON1_DBLCLICK BUTTON_MODE_NONE
#define BUTTON1_LNGCLICK BUTTON_MODE_NONE
#define BUTTON1_LNGLNGCLICK BUTTON_MODE_NONE
#else
// Normal pushbutton
#define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
#endif
// Relays
#define RELAY1_PIN 12
#define RELAY1_TYPE RELAY_TYPE_NORMAL
// LEDs
#define LED1_PIN 2
#define LED1_PIN_INVERSE 0
// HLW8012
#define POWER_PROVIDER POWER_PROVIDER_HLW8012
#define HLW8012_SEL_PIN 5
#define HLW8012_CF1_PIN 13
#define HLW8012_CF_PIN 14
// -----------------------------------------------------------------------------
// Itead Studio boards
// -----------------------------------------------------------------------------
@ -980,6 +1027,40 @@
#define ECH1560_MISO_PIN 5
#define ECH1560_INVERTED 0
// -----------------------------------------------------------------------------
// ESPLive
// https://github.com/ManCaveMade/ESP-Live
// -----------------------------------------------------------------------------
#elif defined(MANCAVEMADE_ESPLIVE)
// Info
#define MANUFACTURER "MANCAVEMADE"
#define DEVICE "ESPLIVE"
// Buttons
#define BUTTON1_PIN 4
#define BUTTON2_PIN 5
#define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
#define BUTTON2_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
#define BUTTON1_RELAY 1
#define BUTTON2_RELAY 2
// Relays
#define RELAY1_PIN 12
#define RELAY2_PIN 13
#define RELAY1_TYPE RELAY_TYPE_NORMAL
#define RELAY2_TYPE RELAY_TYPE_NORMAL
// DB18B20
#define DS18B20_SUPPORT 1
#define DS18B20_PIN 2
#define DS18B20_UPDATE_INTERVAL 5000
#define DS18B20_UPDATE_ON_CHANGE 1.0
// -----------------------------------------------------------------------------
// Unknown hardware
// -----------------------------------------------------------------------------


+ 12
- 0
code/espurna/config/sensors.h View File

@ -77,9 +77,21 @@
#define DS18B20_SUPPORT 0
#endif
#ifndef DS18B20_PIN
#define DS18B20_PIN 14
#endif
#ifndef DS18B20_UPDATE_INTERVAL
#define DS18B20_UPDATE_INTERVAL 60000
#endif
#ifndef DS18B20_TEMPERATURE_TOPIC
#define DS18B20_TEMPERATURE_TOPIC "temperature"
#endif
#ifndef DS18B20_UPDATE_ON_CHANGE
#define DS18B20_UPDATE_ON_CHANGE 0.0
#endif
//--------------------------------------------------------------------------------
// Internal power montior


+ 1
- 1
code/espurna/config/version.h View File

@ -1,4 +1,4 @@
#define APP_NAME "ESPURNA"
#define APP_VERSION "1.9.5"
#define APP_VERSION "1.9.6b"
#define APP_AUTHOR "xose.perez@gmail.com"
#define APP_WEBSITE "http://tinkerman.cat"

+ 22
- 10
code/espurna/ds18b20.ino View File

@ -51,6 +51,10 @@ void dsLoop() {
// Check if we should read new data
static unsigned long last_update = 0;
static bool requested = false;
static double last_temperature = 0.0;
bool send_update = false;
if ((millis() - last_update > DS18B20_UPDATE_INTERVAL) || (last_update == 0)) {
if (!requested) {
ds18b20.requestTemperatures();
@ -80,6 +84,12 @@ void dsLoop() {
DEBUG_MSG_P(PSTR("[DS18B20] Error reading sensor\n"));
} else {
//If the new temperature is different from the last
if (fabs(t - last_temperature) >= DS18B20_UPDATE_ON_CHANGE) {
last_temperature = t;
send_update = true;
}
_dsTemperature = t;
@ -95,17 +105,19 @@ void dsLoop() {
getDSTemperatureStr(),
(_dsIsConnected ? ((tmpUnits == TMP_CELSIUS) ? "ºC" : "ºF") : ""));
// Send MQTT messages
mqttSend(getSetting("dsTmpTopic", DS18B20_TEMPERATURE_TOPIC).c_str(), _dsTemperatureStr);
if (send_update) {
// Send MQTT messages
mqttSend(getSetting("dsTmpTopic", DS18B20_TEMPERATURE_TOPIC).c_str(), _dsTemperatureStr);
// Send to Domoticz
#if DOMOTICZ_SUPPORT
domoticzSend("dczTmpIdx", 0, _dsTemperatureStr);
#endif
// Send to Domoticz
#if DOMOTICZ_SUPPORT
domoticzSend("dczTmpIdx", 0, _dsTemperatureStr);
#endif
#if INFLUXDB_SUPPORT
influxDBSend(getSetting("dsTmpTopic", DS18B20_TEMPERATURE_TOPIC).c_str(), _dsTemperatureStr);
#endif
#if INFLUXDB_SUPPORT
influxDBSend(getSetting("dsTmpTopic", DS18B20_TEMPERATURE_TOPIC).c_str(), _dsTemperatureStr);
#endif
}
// Update websocket clients
#if WEB_SUPPORT
@ -113,7 +125,7 @@ void dsLoop() {
snprintf_P(buffer, sizeof(buffer), PSTR("{\"dsVisible\": 1, \"dsTmp\": %s, \"tmpUnits\": %d}"), getDSTemperatureStr(), tmpUnits);
wsSend(buffer);
#endif
}
}


+ 5
- 0
code/espurna/espurna.ino View File

@ -44,6 +44,11 @@ void hardwareSetup() {
SPIFFS.begin();
#endif
#if defined(ESPLIVE)
//The ESPLive has an ADC MUX which needs to be configured.
pinMode(16, OUTPUT);
digitalWrite(16, HIGH); //Defualt CT input (pin B, solder jumper B)
#endif
}
void hardwareLoop() {


+ 26
- 1
code/espurna/hardware.ino View File

@ -269,7 +269,7 @@ void hwUpwardsCompatibility() {
setSetting("relayGPIO", 1, 12);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
#elif defined(TINKERMAN_ESPURNA_H)
#elif defined(TINKERMAN_ESPURNA_H06)
setSetting("board", 23);
setSetting("ledGPIO", 1, 5);
@ -459,6 +459,31 @@ void hwUpwardsCompatibility() {
setSetting("board", 38);
#elif defined(TINKERMAN_ESPURNA_H07)
setSetting("board", 39);
setSetting("ledGPIO", 1, 2);
setSetting("ledLogic", 1, 0);
setSetting("btnGPIO", 1, 4);
setSetting("btnRelay", 1, 1);
setSetting("relayGPIO", 1, 12);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
setSetting("selGPIO", 5);
setSetting("cf1GPIO", 13);
setSetting("cfGPIO", 14);
#elif defined(MANCAVEMADE_ESPLIVE)
setSetting("board", 40);
setSetting("btnGPIO", 1, 4);
setSetting("btnGPIO", 2, 5);
setSetting("btnRelay", 1, 1);
setSetting("btnRelay", 2, 2);
setSetting("relayGPIO", 1, 12);
setSetting("relayGPIO", 2, 13);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
setSetting("relayType", 2, RELAY_TYPE_NORMAL);
#else
#error "UNSUPPORTED HARDWARE!"


+ 18
- 8
code/espurna/relay.ino View File

@ -335,12 +335,14 @@ unsigned char relayParsePayload(const char * payload) {
value = 1;
} else if (strcmp(p, "toggle") == 0) {
value = 2;
} else if (strcmp(p, "query") == 0) {
value = 3;
} else {
value = p[0] - '0';
}
if (0 <= value && value <=2) return value;
return 0x99;
if (0 <= value && value <=3) return value;
return 0xFF;
}
//------------------------------------------------------------------------------
@ -365,16 +367,22 @@ void relaySetupAPI() {
snprintf_P(buffer, len, PSTR("%d"), relayStatus(relayID) ? 1 : 0);
},
[relayID](const char * payload) {
unsigned char value = relayParsePayload(payload);
if (value == 0xFF) {
DEBUG_MSG_P(PSTR("[RELAY] Wrong payload (%s)\n"), payload);
return;
}
if (value == 2) {
if (value == 0) {
relayStatus(relayID, false);
} else if (value == 1) {
relayStatus(relayID, true);
} else if (value == 2) {
relayToggle(relayID);
} else {
relayStatus(relayID, value == 1);
}
}
);
@ -460,10 +468,12 @@ void relayMQTTCallback(unsigned int type, const char * topic, const char * paylo
}
// Action to perform
if (value == 2) {
if (value == 0) {
relayStatus(relayID, false, mqttForward());
} else if (value == 1) {
relayStatus(relayID, true, mqttForward());
} else if (value == 2) {
relayToggle(relayID);
} else {
relayStatus(relayID, value == 1, mqttForward());
}
}


+ 9
- 5
code/espurna/web.ino View File

@ -143,11 +143,12 @@ void _wsParse(uint32_t client_id, uint8_t * payload, size_t length) {
if (data.containsKey("status")) {
unsigned char value = relayParsePayload(data["status"]);
if (value == 0xFF) {
if (value == 3) {
relayWS();
} else {
} else if (value < 3) {
unsigned int relayID = 0;
if (data.containsKey("id")) {
@ -155,10 +156,13 @@ void _wsParse(uint32_t client_id, uint8_t * payload, size_t length) {
relayID = value.toInt();
}
if (value == 2) {
// Action to perform
if (value == 0) {
relayStatus(relayID, false);
} else if (value == 1) {
relayStatus(relayID, true);
} else if (value == 2) {
relayToggle(relayID);
} else {
relayStatus(relayID, value == 1);
}
}


+ 6
- 6
code/html/index.html View File

@ -405,12 +405,6 @@
<div class="pure-u-1 pure-u-sm-1-4"><input type="radio" name="tmpUnits" tabindex="13" value="1"> Fahrenheit (&deg;F)</input></div>
</div>
<div class="pure-g">
<label class="pure-u-1 pure-u-sm-1-4">Settings</label>
<div class="pure-u-1 pure-u-sm-1-8"><button class="pure-button button-settings-backup pure-u-23-24">Backup</button></div>
<div class="pure-u-1 pure-u-sm-1-8"><button class="pure-button button-settings-restore pure-u-23-24">Restore</button></div>
</div>
</fieldset>
</div>
</div>
@ -479,6 +473,12 @@
<div class="pure-u-1 pure-u-md-3-4 hint">This name address of the NoFUSS server for automatic remote updates (see https://bitbucket.org/xoseperez/nofuss).</div>
</div>
<div class="pure-g">
<label class="pure-u-1 pure-u-sm-1-4">Settings</label>
<div class="pure-u-1 pure-u-sm-1-8"><button class="pure-button button-settings-backup pure-u-23-24">Backup</button></div>
<div class="pure-u-1 pure-u-sm-1-8"><button class="pure-button button-settings-restore pure-u-23-24">Restore</button></div>
</div>
<div class="pure-g">
<label class="pure-u-1 pure-u-md-1-4">Upgrade</label>
<input class="pure-u-1-2 pure-u-md-1-2" name="filename" type="text" readonly />


+ 48
- 4
code/platformio.ini View File

@ -102,23 +102,45 @@ monitor_baud = 115200
# ------------------------------------------------------------------------------
[env:tinkerman-espurna-h]
[env:tinkerman-espurna-h06]
platform = espressif8266
framework = arduino
board = esp12e
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
build_flags = ${common.build_flags} -DTINKERMAN_ESPURNA_H
build_flags = ${common.build_flags} -DTINKERMAN_ESPURNA_H06
upload_speed = 460800
monitor_baud = 115200
[env:tinkerman-espurna-h-ota]
[env:tinkerman-espurna-h06-ota]
platform = espressif8266
framework = arduino
board = esp12e
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
build_flags = ${common.build_flags} -DTINKERMAN_ESPURNA_H
build_flags = ${common.build_flags} -DTINKERMAN_ESPURNA_H06
upload_speed = 115200
upload_port = "192.168.4.1"
upload_flags = --auth=fibonacci --port 8266
monitor_baud = 115200
[env:tinkerman-espurna-h07]
platform = espressif8266
framework = arduino
board = esp12e
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
build_flags = ${common.build_flags} -DTINKERMAN_ESPURNA_H07
upload_speed = 460800
monitor_baud = 115200
[env:tinkerman-espurna-h07-ota]
platform = espressif8266
framework = arduino
board = esp12e
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
build_flags = ${common.build_flags} -DTINKERMAN_ESPURNA_H07
upload_speed = 115200
upload_port = "192.168.4.1"
upload_flags = --auth=fibonacci --port 8266
@ -911,6 +933,28 @@ upload_port = "192.168.4.1"
upload_flags = --auth=fibonacci --port 8266
monitor_baud = 115200
[env:mancavemade-esplive]
platform = espressif8266
framework = arduino
board = d1_mini
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
build_flags = ${common.build_flags} -DMANCAVEMADE_ESPLIVE
upload_speed = 460800
monitor_baud = 115200
[env:mancavemade-esplive-ota]
platform = espressif8266
framework = arduino
board = d1_mini
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
build_flags = ${common.build_flags} -DMANCAVEMADE_ESPLIVE
upload_speed = 460800
upload_port = "192.168.4.1"
upload_flags = --auth=fibonacci --port 8266
monitor_baud = 115200
# ------------------------------------------------------------------------------
# GENERIC OTA ENVIRONMENTS
# ------------------------------------------------------------------------------


Loading…
Cancel
Save