From 9cffc34073334694269f32c46876dd12767946d9 Mon Sep 17 00:00:00 2001 From: Ronald Schaten Date: Wed, 18 May 2016 08:53:58 +0200 Subject: [PATCH] split hardware configuration to modules --- things/HardwareH801wifi.h | 25 +++++++++++++++++++++ things/HardwareWitty.h | 28 ++++++++++++++++++++++++ things/things.ino | 46 +++------------------------------------ 3 files changed, 56 insertions(+), 43 deletions(-) create mode 100644 things/HardwareH801wifi.h create mode 100644 things/HardwareWitty.h diff --git a/things/HardwareH801wifi.h b/things/HardwareH801wifi.h new file mode 100644 index 0000000..7496119 --- /dev/null +++ b/things/HardwareH801wifi.h @@ -0,0 +1,25 @@ +/* + * H801 WiFi + * off-the-shelf RGBWW led wifi controller + * + * Settings in IDE: + * - Board: "Generic ESP8266 Module" + * - Flash Size: "1M (64k SPIFFS)" + * - Upload Speed: "1152200" + */ + +#include "DeviceLed.h" +#include "DeviceRgb.h" + +const byte PIN_LED = 14; +DeviceLed deviceLed(PIN_LED); + +const byte PIN_RGB_RED = 15; +const byte PIN_RGB_GREEN = 13; +const byte PIN_RGB_BLUE = 12; +DeviceRgb deviceRgb(PIN_RGB_RED, PIN_RGB_GREEN, PIN_RGB_BLUE); + +Device* devices[] = { + &deviceLed, + &deviceRgb, +}; diff --git a/things/HardwareWitty.h b/things/HardwareWitty.h new file mode 100644 index 0000000..9f68b04 --- /dev/null +++ b/things/HardwareWitty.h @@ -0,0 +1,28 @@ +/* + * Witty Cloud + * development board, featuring RGB LED, LDR and a button + * + * Settings in IDE: + * - Board: "WeMos D1 R2 & mini" + */ + +#include "DeviceRgb.h" +#include "DeviceLdr.h" +#include "DeviceButton.h" + +const byte PIN_RGB_RED = D8; +const byte PIN_RGB_GREEN = D6; +const byte PIN_RGB_BLUE = D7; +DeviceRgb deviceRgb(PIN_RGB_RED, PIN_RGB_GREEN, PIN_RGB_BLUE); + +const byte PIN_LDR = A0; +DeviceLdr deviceLdr(PIN_LDR); + +const byte PIN_BUTTON = D2; +DeviceButton deviceButton(PIN_BUTTON); + +Device* devices[] = { + &deviceRgb, + &deviceLdr, + &deviceButton, +}; diff --git a/things/things.ino b/things/things.ino index fd0deda..bdd9905 100644 --- a/things/things.ino +++ b/things/things.ino @@ -1,47 +1,7 @@ #include // https://github.com/marvinroger/homie-esp8266 -#include "DeviceLed.h" -#include "DeviceRgb.h" -#include "DeviceLdr.h" -#include "DeviceDht.h" -#include "DeviceIrRx.h" -#include "DeviceIrTx.h" -#include "DeviceButton.h" - -const byte PIN_LED = D8; -DeviceLed deviceLed(PIN_LED); - -const byte PIN_RGB_RED = D8; -const byte PIN_RGB_GREEN = D6; -const byte PIN_RGB_BLUE = D7; -DeviceRgb deviceRgb(PIN_RGB_RED, PIN_RGB_GREEN, PIN_RGB_BLUE); - -const byte PIN_LDR = A0; -DeviceLdr deviceLdr(PIN_LDR); - -const byte PIN_DHT = D5; -const byte TYPE_DHT = DHT22; -DeviceDht deviceDht(PIN_DHT, TYPE_DHT); - -const byte PIN_IRRX = D1; -const byte PIN_POWER = D0; -DeviceIrRx deviceIrRx(PIN_IRRX, PIN_POWER); - -const byte PIN_IRTX = D2; -DeviceIrTx deviceIrTx(PIN_IRTX); - -const byte PIN_BUTTON = D2; -DeviceButton deviceButton(PIN_BUTTON); - -Device* devices[] = { - &deviceLed, - &deviceRgb, - &deviceLdr, - &deviceDht, - &deviceIrRx, - &deviceIrTx, - &deviceButton, -}; +#include "HardwareWitty.h" +//#include "HardwareH801wifi.h" void setupHandler() { for (int i = 0; i < sizeof(devices) / sizeof(*devices); i++) { @@ -56,7 +16,7 @@ void loopHandler() { } void setup() { - Homie.setFirmware("things", "1.0.0"); + Homie.setFirmware("things", "1.0.1"); for (int i = 0; i < sizeof(devices) / sizeof(*devices); i++) { devices[i]->deviceRegister(); }