This repository has been archived by the owner on Aug 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
monitoringExample.c
64 lines (46 loc) · 1.58 KB
/
monitoringExample.c
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
59
60
61
62
63
64
#include <avr/interrupt.h>
#include <avr/io.h>
#include <stdbool.h>
#include <util/delay.h>
#include <compat/twi.h>
#include "ElasticNodeMiddleware/ElasticNodeMiddleware.h"
#include "ElasticNodeMiddleware/ElasticNodeMiddlewareMonitoring.h"
typedef enum {
SLEEP_MODE = 0,
LED_0 = 1,
LED_0_1 = 2,
LED_0_1_2 = 3,
LED_0_1_2_3 = 4,
END_MEASUREMENT = 15,
} mcu_running_state;
int main(void) {
IIC_slave_init(MY_IIC_ADDRESS);
elasticnode_monitoring_change_running_state(SLEEP_MODE);
elasticnode_led_mcu_init();
while (true) {
//start delay
_delay_ms(2000);
elasticnode_monitoring_change_sample_rate(CURRENT_SAMPLE_TIME_40ms);
elasticnode_led_mcu_turnOn(0);
elasticnode_monitoring_change_running_state(LED_0);
_delay_ms(1000);
elasticnode_led_mcu_turnOn(1);
elasticnode_monitoring_change_running_state(LED_0_1);
_delay_ms(1000);
elasticnode_monitoring_change_sample_rate(CURRENT_SAMPLE_TIME_10ms);
elasticnode_led_mcu_turnOn(2);
elasticnode_monitoring_change_running_state(LED_0_1_2);
_delay_ms(1000);
elasticnode_led_mcu_turnOn(3);
elasticnode_monitoring_change_running_state(LED_0_1_2_3);
_delay_ms(1000);
elasticnode_led_mcu_turnOffAll();
elasticnode_monitoring_change_running_state(SLEEP_MODE);
elasticnode_monitoring_change_sample_rate(CURRENT_SAMPLE_TIME_5ms);
}
elasticnode_monitoring_change_running_state(END_MEASUREMENT);
return 0;
}
ISR(TWI_vect) {
elasticnode_monitoring_ISR();
}