-
Notifications
You must be signed in to change notification settings - Fork 0
/
iotDimmer.ino
50 lines (36 loc) · 1.11 KB
/
iotDimmer.ino
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
/**
* iotinator Dimmer Agent module
* Xavier Grosjean 2018
* Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Public License
*/
#if F_CPU != 160000000
CPU FREQUENCY MUST BE SET TO 160MHz !!
#endif
#include <stdio.h>
#include "DimmerModule.h"
#include "config.h"
#define API_VERSION "1.0" // modules can check API version to make sure they are compatible...
// Global object to store config
DimmerConfigClass *config;
XIOTModule* module;
int scl = 12;
int sda = 14;
void setup(){
int intPin = 13;
int ctrlPin = 5;
// After a reset, interrupt handlers may still be operating ??
detachInterrupt(digitalPinToInterrupt(intPin));
Serial.begin(9600);
delay(500); // time to connect serial
config = new DimmerConfigClass((unsigned int)CONFIG_VERSION, (char*)MODULE_NAME);
config->init();
module = new DimmerModule(config, 0x3C, sda, scl, intPin, ctrlPin);
}
/*********************************
* Main Loop
*********************************/
void loop() {
// Mandatory periodic call, to refresh display, Clock, check requests
// on the http API, ...
module->loop();
}