forked from ramin-zaghi/sourcecreator_smart_templates
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbarometer.scc
58 lines (38 loc) · 1.67 KB
/
barometer.scc
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
/*< + params_struct instanceregional />*/
/*< + climate_module_handler instanceregional />*/
/*< constants singleshot >*/
#define BAROMETER_UPDATE_SERVICE_INTERVAL (1 * 60 * 1000)
#define BAROMETER_UPDATE_NORMAL_INTERVAL (5 * 60 * 1000)
#define BAROMETER_TAG_PUB_NO_CHANGE_INTEVAL (15 * 60 * 1000)
#define BAROMETER_TAG_PUB_VALUE_CHANGE 20.0f
/*</ constants >*/
/*< params_struct_members instanceregional >*/
event_param_t /*<@bar_name/>*/;
/*</ params_struct_members >*/
/*< normal_mode singleshot instanceregional >*/
bc_module_climate_set_update_interval_barometer(BAROMETER_UPDATE_NORMAL_INTERVAL);
/*</ normal_mode >*/
/*< climate_module_init singleshot instanceregional >*/
bc_module_climate_set_update_interval_barometer(BAROMETER_UPDATE_SERVICE_INTERVAL);
/*</ climate_module_init >*/
/*< climate_module_event_handler_case singleshot instanceregional >*/
case BC_MODULE_CLIMATE_EVENT_UPDATE_BAROMETER:
if (bc_module_climate_get_pressure_pascal(&value))
{
/*< bar_event_handler_case_content broadcast />*/
}
break;
/*</ climate_module_event_handler_case >*/
/*< bar_event_handler_case_content instancelocal >*/
if ((fabs(value - params./*<@bar_name/>*/.value) >= BAROMETER_TAG_PUB_VALUE_CHANGE) || (params./*<@bar_name/>*/.next_pub < bc_scheduler_get_spin_tick()))
{
float meter;
if (!bc_module_climate_get_altitude_meter(&meter))
{
return;
}
bc_radio_pub_barometer(BC_RADIO_PUB_CHANNEL_R1_I2C0_ADDRESS_DEFAULT, &value, &meter);
params./*<@bar_name/>*/.value = value;
params./*<@bar_name/>*/.next_pub = bc_scheduler_get_spin_tick() + BAROMETER_TAG_PUB_NO_CHANGE_INTEVAL;
}
/*</ bar_event_handler_case_content >*/