-
Notifications
You must be signed in to change notification settings - Fork 0
/
SchmalerFlurGarderobe.cpp
58 lines (47 loc) · 1.73 KB
/
SchmalerFlurGarderobe.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
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <NeoPixelBus.h>
#include "IoT/Device.hpp"
#include "IoT/Input.hpp"
#include "IoT/IoT.hpp"
#include "IoT/SceneManager.hpp"
#include "ledgraph/fill_animation.hpp"
#include "ledgraph/ledbuffer.hpp"
#include "ledgraph/warp_animation.hpp"
NeoPixelBus< NeoGrbFeature, NeoEsp8266AsyncUart0800KbpsMethod > neoPixelBus( 134 );
NeoPixelBuffer< NeoGrbFeature, NeoEsp8266AsyncUart0800KbpsMethod > neoPixelBuffer( neoPixelBus );
unsigned neoPixelState;
auto onAnimation = fillAnimation( neoPixelBuffer, 0xffffff );
auto buntAnimation = warpAnimation< 10, 40, 20, 25, 100, 25 >( neoPixelBuffer );
IoTClass IoT( "akvsoft", "sacomoco02047781", "192.168.178.28", 1883 );
//Device ledstreifenWeiss( "SchmalerFlur/GarderobeWeiss" ); // command -> name
//Device ledstreifenBunt( "SchmalerFlur/GarderobeBunt" );
SceneManager sceneManager( "SchmalerFlur" );
bool lastMotion;
void setup()
{
neoPixelBus.Begin();
sceneManager.addSceneEvent( Scene::SLEEP, [] { neoPixelState = 0; } );
sceneManager.addSceneEvent( Scene::OFF, [] { neoPixelState = 1; } );
sceneManager.addSceneEvent( Scene::SCENE1, [] { neoPixelState = 2; } );
sceneManager.addSceneEvent( Scene::SCENE2, [] { neoPixelState = 2; } );
sceneManager.addSceneDevice( ledstreifenWeiss, { Scene::SCENE1, Scene::SCENE2 } );
sceneManager.addSceneDevice( ledstreifenBunt, { Scene::OFF } );
IoT.loopEvent += [] {
switch ( neoPixelState ) {
case 0:
neoPixelBus.ClearTo( 0 );
break;
case 1:
buntAnimation.animate();
break;
case 2:
onAnimation.animate();
break;
}
neoPixelBus.Show();
};
IoT.begin();
}
void loop()
{
IoT.loop();
}