elegant array handling
This commit is contained in:
parent
c145154f3b
commit
7cafe6cccb
@ -19,26 +19,23 @@ DeviceLdr deviceLdr(PIN_LDR);
|
||||
#define TYPE_DHT DHT22
|
||||
DeviceDht deviceDht(PIN_DHT, TYPE_DHT);
|
||||
|
||||
Device * devices[3];
|
||||
Device* devices[] = { &deviceLed, &deviceLdr };
|
||||
|
||||
void setupHandler() {
|
||||
for (int i = 0; i < 2; i++) {
|
||||
for (int i = 0; i < sizeof(devices) / sizeof(*devices); i++) {
|
||||
devices[i]->deviceSetup();
|
||||
}
|
||||
}
|
||||
|
||||
void loopHandler() {
|
||||
for (int i = 0; i < 2; i++) {
|
||||
for (int i = 0; i < sizeof(devices) / sizeof(*devices); i++) {
|
||||
devices[i]->deviceLoop();
|
||||
}
|
||||
}
|
||||
|
||||
void setup() {
|
||||
Homie.setFirmware("things", "1.0.0");
|
||||
devices[0] = &deviceLed;
|
||||
devices[1] = &deviceLdr;
|
||||
//devices[2] = &deviceDht;
|
||||
for (int i = 0; i < 2; i++) {
|
||||
for (int i = 0; i < sizeof(devices) / sizeof(*devices); i++) {
|
||||
devices[i]->deviceRegister();
|
||||
}
|
||||
Homie.setSetupFunction(setupHandler);
|
||||
|
Loading…
Reference in New Issue
Block a user