add function that gets called before homie initialization

This commit is contained in:
Ronald Schaten 2016-05-21 19:19:24 +02:00
parent 6d0cf8f786
commit bfd74e61a1
5 changed files with 21 additions and 0 deletions

View File

@ -28,3 +28,17 @@ Device* devices[] = {
&deviceLedW2, &deviceLedW2,
&deviceRgb, &deviceRgb,
}; };
void hardwareSetup() {
pinMode(PIN_LED1, OUTPUT);
pinMode(PIN_LED2, OUTPUT);
pinMode(PIN_RGB_RED, OUTPUT);
pinMode(PIN_RGB_GREEN, OUTPUT);
pinMode(PIN_RGB_BLUE, OUTPUT);
analogWrite(PIN_LED1, 100);
analogWrite(PIN_LED2, 0);
analogWrite(PIN_RGB_RED, 0);
analogWrite(PIN_RGB_GREEN, 0);
analogWrite(PIN_RGB_BLUE, 0);
deviceLedW1.ledBrightnessHandler("{\"brightness\":100}");
}

View File

@ -28,3 +28,5 @@ Device* devices[] = {
&deviceLdr, &deviceLdr,
&deviceButton, &deviceButton,
}; };
void hardwareSetup() {};

View File

@ -35,3 +35,5 @@ Device* devices[] = {
&deviceButton, &deviceButton,
&deviceDht, &deviceDht,
}; };
void hardwareSetup() {};

View File

@ -46,3 +46,5 @@ Device* devices[] = {
&deviceIrRx, &deviceIrRx,
&deviceIrTx, &deviceIrTx,
}; };
void hardwareSetup() {};

View File

@ -20,6 +20,7 @@ void loopHandler() {
} }
void setup() { void setup() {
hardwareSetup();
Homie.setFirmware(FWNAME, FWVERSION); Homie.setFirmware(FWNAME, FWVERSION);
for (int i = 0; i < sizeof(devices) / sizeof(*devices); i++) { for (int i = 0; i < sizeof(devices) / sizeof(*devices); i++) {
devices[i]->deviceRegister(); devices[i]->deviceRegister();