split hardware configuration to modules
This commit is contained in:
parent
7a79f1ca12
commit
9cffc34073
25
things/HardwareH801wifi.h
Normal file
25
things/HardwareH801wifi.h
Normal file
@ -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,
|
||||
};
|
28
things/HardwareWitty.h
Normal file
28
things/HardwareWitty.h
Normal file
@ -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,
|
||||
};
|
@ -1,47 +1,7 @@
|
||||
#include <Homie.h> // 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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user