-
Notifications
You must be signed in to change notification settings - Fork 0
/
Storage-Light-Ceiling.cpp
45 lines (36 loc) · 1012 Bytes
/
Storage-Light-Ceiling.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "IoT/Debounce.hpp"
#include "IoT/Device.hpp"
#include "IoT/Gpio.hpp"
#include "IoT/Input.hpp"
#include "IoT/IoT.hpp"
#include "IoT/Logger.hpp"
#include "IoT/PushButton.hpp"
#include "IoT/SceneManager.hpp"
IoTClass IoT( "Storage/Light/Ceiling", "akvsoft", "sacomoco02047781", "192.168.178.28", 1883 );
PushButton button1( debounce( gpioInput( 14 )));
Device output1( "POWER1", gpioOutput( 4 ));
PushButton button2( debounce( gpioInput( 12 )));
Device output2( "POWER2", gpioOutput( 5 ));
Input motionInput( gpioInput( 13, false ));
Device motionDevice( "MOTION", "NO", "YES" );
void setup()
{
button1.clickedEvent += []( unsigned clicked ) {
if ( clicked == 1 ) {
output1.toggle();
}
};
button2.clickedEvent += []( unsigned clicked ) {
if ( clicked == 1 ) {
output2.toggle();
}
};
motionInput.changeEvent += []( bool value ) {
motionDevice.set( value );
};
IoT.begin();
}
void loop()
{
IoT.loop();
}