Skip to content

Commit

Permalink
1.13
Browse files Browse the repository at this point in the history
  • Loading branch information
klausahrenberg committed Jul 14, 2020
1 parent e7b3d2d commit 150c9c5
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 29 deletions.
21 changes: 4 additions & 17 deletions WNeoCoolcam/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
platform = espressif8266
board = esp12e
framework = arduino
board_build.flash_mode = dout
board_build.ldscript = eagle.flash.1m.ld
upload_resetmethod = nodemcu
upload_speed = 921600
build_flags =
-I /home/klausahrenberg/Projects/Atom/WAdapter/WAdapter
lib_deps =
Expand All @@ -24,20 +28,3 @@ lib_deps =
Time
Hash
Adafruit NeoPixel

[env:esp01_1m]
platform = espressif8266
board = esp01_1m
framework = arduino
build_flags =
-I /home/klausahrenberg/Projects/Atom/WAdapter/WAdapter
lib_deps =
ESP8266WiFi
ESP8266WebServer
ESP8266mDNS
DNSServer
EEPROM
NTPClient
Time
Hash
Adafruit NeoPixel
5 changes: 3 additions & 2 deletions WNeoCoolcam/src/WNeoCoolcam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@


#define APPLICATION "Neo Coolcam"
#define VERSION "1.11"
#define VERSION "1.13"
#define FLAG_SETTINGS 0x17
#define DEBUG false

WNetwork* network;
Expand All @@ -15,7 +16,7 @@ void setup() {
Serial.begin(9600);
}
//Network
network = new WNetwork(DEBUG, APPLICATION, VERSION, true, NO_LED);
network = new WNetwork(DEBUG, APPLICATION, VERSION, true, NO_LED, FLAG_SETTINGS);
//Device
device = new WNeoDevice(network);
network->addDevice(device);
Expand Down
39 changes: 29 additions & 10 deletions WNeoCoolcam/src/WNeoDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ struct SwitchDevices{
byte switchModes[COUNT_MAX_RELAIS];
};

static struct SwitchDevices supportedDevices [4] =
static struct SwitchDevices supportedDevices [5] =
{
//LED RELAY SWITCHES
{ 4, {12, NO_PIN, NO_PIN, NO_PIN}, {13, NO_PIN, NO_PIN, NO_PIN}, {MODE_BUTTON, NO_PIN, NO_PIN, NO_PIN}}, //Neo Coolcam
{13, {12, NO_PIN, NO_PIN, NO_PIN}, { 0, 4, NO_PIN, NO_PIN}, {MODE_BUTTON, MODE_SWITCH, NO_PIN, NO_PIN}}, //Sonoff Mini
{13, {12, NO_PIN, NO_PIN, NO_PIN}, { 0, NO_PIN, NO_PIN, NO_PIN}, {MODE_BUTTON, NO_PIN, NO_PIN, NO_PIN}}, //Sonoff Basic
//{13, {12, 5, 4, 15}, { 0, 9, 10, 14}, {MODE_BUTTON, MODE_BUTTON, MODE_BUTTON, MODE_BUTTON}}, //Sonoff 4-channel
{ 2, { 5, NO_PIN, NO_PIN, NO_PIN}, { 0, NO_PIN, NO_PIN, NO_PIN}, {MODE_BUTTON, NO_PIN, NO_PIN, NO_PIN}} //Wemos: Relay at D1, Switch at D3
//LED RELAY SWITCHES
{ 4, {12, NO_PIN, NO_PIN, NO_PIN}, {13, NO_PIN, NO_PIN, NO_PIN}, {MODE_BUTTON, NO_PIN, NO_PIN, NO_PIN}}, //Neo Coolcam
{13, {12, NO_PIN, NO_PIN, NO_PIN}, { 0, 4, NO_PIN, NO_PIN}, {MODE_BUTTON, MODE_SWITCH, NO_PIN, NO_PIN}}, //Sonoff Mini
{13, {12, NO_PIN, NO_PIN, NO_PIN}, { 0, NO_PIN, NO_PIN, NO_PIN}, {MODE_BUTTON, NO_PIN, NO_PIN, NO_PIN}}, //Sonoff Basic
{ 2, { 5, NO_PIN, NO_PIN, NO_PIN}, { 0, NO_PIN, NO_PIN, NO_PIN}, {MODE_BUTTON, NO_PIN, NO_PIN, NO_PIN}}, //Wemos: Relay at D1, Switch at D3
{ 2, { 5, 4, NO_PIN, NO_PIN}, {NO_PIN, NO_PIN, NO_PIN, NO_PIN}, {MODE_BUTTON, NO_PIN, NO_PIN, NO_PIN}} //Dimmable LED
};

class WNeoDevice: public WDevice {
Expand Down Expand Up @@ -68,17 +68,31 @@ class WNeoDevice: public WDevice {
}
for (int i = 0; i < COUNT_MAX_RELAIS; i++) {
if (supportedDevices[getDeviceType()].relayPins[i] != NO_PIN) {
String pN = "on";
String pD = "Switch";
if (i > 0) {
pN.concat(i + 1);
pD.concat(" ");
pD.concat(i + 1);
}
//Property
onOffProperty = WProperty::createOnOffProperty("on", "Switch");
onOffProperty = WProperty::createOnOffProperty(pN.c_str(), pD.c_str());
this->addProperty(onOffProperty);
if (getDeviceMode() != MODE_NO_RELAY_USAGE) {
//Relay
pN = "relay";
pD = "Relay";
if (i > 0) {
pN.concat(i + 1);
pD.concat(" ");
pD.concat(i + 1);
}
WRelay* relay = new WRelay(supportedDevices[getDeviceType()].relayPins[i], true);
if (isSupportingW8212()) {
mainLedRelay = WProperty::createOnOffProperty("relay", "Relay");
mainLedRelay = WProperty::createOnOffProperty(pN.c_str(), pD.c_str());
relay->setProperty(mainLedRelay);
} else if (getDeviceMode() == MODE_SEPARATE_RELAY_PROPERTY) {
WProperty* relayProperty = WProperty::createOnOffProperty("relay", "Relay");
WProperty* relayProperty = WProperty::createOnOffProperty(pN.c_str(), pD.c_str());
this->addProperty(relayProperty);
relay->setProperty(relayProperty);
} else {
Expand Down Expand Up @@ -146,6 +160,7 @@ class WNeoDevice: public WDevice {
page->printAndReplace(FPSTR(HTTP_COMBOBOX_ITEM), "2", (getDeviceType() == 2 ? "selected" : ""), "Sonoff Basic");
//page->printAndReplace(FPSTR(HTTP_COMBOBOX_ITEM), "3", (getDeviceType() == 3 ? "selected" : ""), "Sonoff 4-channel");
page->printAndReplace(FPSTR(HTTP_COMBOBOX_ITEM), "3", (getDeviceType() == 3 ? "selected" : ""), "Wemos: Relay at D1, Switch at D3");
page->printAndReplace(FPSTR(HTTP_COMBOBOX_ITEM), "4", (getDeviceType() == 4 ? "selected" : ""), "Dimmable LED: Relay 1 at Pin 5, Relay 2 at Pin 4, Switch at Pin 12");
page->print(FPSTR(HTTP_COMBOBOX_END));
//deviceMode
page->printAndReplace(FPSTR(HTTP_COMBOBOX_BEGIN), "Device Mode:", "dm");
Expand All @@ -169,6 +184,10 @@ class WNeoDevice: public WDevice {
this->supportingW2812->setBoolean(webServer->arg("sw") == "true");
}

virtual void loop(unsigned long now) {
WDevice::loop(now);
}

protected:

byte getDeviceType() {
Expand Down
Binary file added WNeoCoolcam_1.13.bin
Binary file not shown.

0 comments on commit 150c9c5

Please sign in to comment.