summaryrefslogtreecommitdiffstats
path: root/libweatherstation.vapi
blob: 62ea82d9ebd8b79b76a5d17510ef7a9e90115039 (plain)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
/* libweatherstation.vapi
 * Copyright (c) 2012, Sebastian Reichel <sre@ring0.de>
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

[CCode (cprefix = "weather_", cheader_filename = "weatherstation.h")]
namespace Weather {
	[CCode (cname = "enum weather_wind_direction", cprefix = "")]
	public enum WindDirection {
		NORTH,
		NORTH_EAST_NORTH,
		NORTH_EAST,
		EAST_NORTH_EAST,
		EAST,
		EAST_SOUTH_EAST,
		SOUTH_EAST,
		SOUTH_EAST_SOUTH,
		SOUTH,
		SOUTH_WEST_SOUTH,
		SOUTH_WEST,
		WEST_SOUTH_WEST,
		WEST,
		WEST_NORTH_WEST,
		NORTH_WEST,
		NORTH_WEST_NORTH;

		[CCode (cname = "weather_wind_direction_to_string")]
		public unowned string to_string();
	}

	[Flag]
	[CCode (cname = "enum weather_flag_status", cprefix = "WEATHER_STATUS_")]
	public enum Status {
		INVALID_DATA,
		RAIN_OVERFLOW;
	}

	[CCode (cname = "struct weather_data")]
	public struct Data {
		uint8  sample_time;
		uint8  humidity_indoor;
		int16 temperature_indoor;
		uint8  humidity_outdoor;
		int16 temperature_outdoor;
		uint16 pressure;
		uint8  avg_wind_speed;
		uint8  gust_wind_speed;
		uint8  high_nibble_wind_speed;
		[CCode (ctype = "uint8_t")]
		WindDirection wind_direction;
		uint16 rain;
		[CCode (ctype = "uint8_t")]
		Status status;
	}

	[Flag]
	[CCode (cname = "enum weather_flag_unit_setting1", cprefix = "WEATHER_UNIT_")]
	public enum UnitSetting1 {
		IN_TEMP_FAHRENHEIT,
		OUT_TEMP_FAHRENHEIT,
		RAIN_INCH,
		PRESSURE_HPA,
		PRESSURE_INHG,
		PRESSURE_MMHG;
	}

	[Flag]
	[CCode (cname = "enum weather_flag_unit_setting2", cprefix = "WEATHER_UNIT_")]
	public enum UnitSetting2 {
		WIND_SPEED_MS,
		WIND_SPEED_KMH,
		WIND_SPEED_KNOT,
		WIND_SPEED_MH,
		WIND_SPEED_BFT;
	}

	[Flag]
	[CCode (cname = "enum weather_flag_display_format1", cprefix = "WEATHER_DISPLAY_FORMAT_")]
	public enum DisplayFormat1 {
		PRESSURE_RELATIVE,
		WIND_SPEED_GUST,
		TIME_12H,
		TIME_MMDDYY,
		TIME_24H_SCALE,
		COMPLETE_DATE,
		DATE_WEEK,
		ALARM;
	}

	[Flag]
	[CCode (cname = "enum weather_flag_display_format2", cprefix = "WEATHER_DISPLAY_FORMAT_")]
	public enum DisplayFormat2 {
		OUT_TEMP,
		OUT_WINDCHILL,
		OUT_DEW_POINT,
		RAIN_1H,
		RAIN_24H,
		RAIN_WEEK,
		RAIN_MONTH,
		RAIN_TOTAL;
	}

	[Flag]
	[CCode (cname = "enum weather_flag_alarm1", cprefix = "WEATHER_ALARM_")]
	public enum AlarmFlags1 {
		TIME,
		WIND_DIRECTION,
		IN_HUMIDITY_LOW,
		IN_HUMIDITY_HIGH,
		OUT_HUMIDITY_LOW,
		OUT_HUMIDITY_HIGH;
	}

	[Flag]
	[CCode (cname = "enum weather_flag_alarm2", cprefix = "WEATHER_ALARM_")]
	public enum AlarmFlags2 {
		AVERAGE_WIND_SPEED,
		GUST_WIND_SPEED,
		RAIN_1H,
		RAIN_24H,
		ABS_PRESSURE_LOW,
		ABS_PRESSURE_HIGH,
		REL_PRESSURE_LOW,
		REL_PRESSURE_HIGH;
	}

	[Flag]
	[CCode (cname = "enum weather_flag_alarm3", cprefix = "WEATHER_ALARM_")]
	public enum AlarmFlags3 {
		IN_TEMP_LOW,
		IN_TEMP_HIGH,
		OUT_TEMP_LOW,
		OUT_TEMP_HIGH,
		WINDCHILL_LOW,
		WINDCHILL_HIGH,
		DEW_POINT_LOW,
		DRW_POINT_HIGH;
	}

	[CCode (cname = "struct weather_header_alarms")]
	public struct Alarms {
		uint8  in_humidity_high;
		uint8  in_humidity_low;
		uint16 inemp_high;
		uint16 inemp_low;
		uint8  out_humidity_high;
		uint8  out_humidity_low;
		uint16 outemp_high;
		uint16 outemp_low;
		uint16 wind_chill_high;
		uint16 wind_chill_low;
		uint16 dew_point_high;
		uint16 dew_point_low;
		uint16 absolute_pressure_high;
		uint16 absolute_pressure_low;
		uint16 relative_pressure_high;
		uint16 relative_pressure_low;
		uint8  average_bft_high;
		uint16 average_wsp_high;
		uint8  gust_bft_high;
		uint16 gust_wsp_high;
		uint8  wind_direction;
		uint16 rain_1h_high;
		uint16 rain_24h_high;
		uint8  hour;
		uint8  minute;
	}

	[CCode (cname = "struct weather_header_records")]
	public struct Records {
		uint8  in_humidity_max;
		uint8  in_humidity_min;
		uint8  out_humidity_max;
		uint8  out_humidity_min;
		uint16 inemp_max;
		uint16 inemp_min;
		uint16 outemp_max;
		uint16 outemp_min;
		uint16 windchill_max;
		uint16 windchill_min;
		uint16 dew_point_max;
		uint16 dew_point_min;
		uint16 absolute_pressure_max;
		uint16 absolute_pressure_min;
		uint16 relative_pressure_max;
		uint16 relative_pressure_min;
		uint16 wsp_average_max;
		uint16 wsp_gust_max;
		uint16 rain_1h_max;
		uint16 rain_24h_max;
		uint16 rain_week_max;
		uint16 rain_month_max;
		uint16 rainotal_max;
		uint8  nibble;
	}

	[CCode (cname = "struct weather_time")]
	public struct Time {
		uint8 year;
		uint8 month;
		uint8 date;
		uint8 hour;
		uint8 minute;
	}

	[CCode (cname = "struct weather_header_timestamps")]
	public struct Timestamps {
		Time in_humidity_max;
		Time in_humidity_min;
		Time out_humidity_max;
		Time out_humidity_min;
		Time in_temp_max;
		Time in_temp_min;
		Time out_temp_max;
		Time out_temp_min;
		Time wind_chill_max;
		Time wind_chill_min;
		Time dew_point_max;
		Time dew_point_min;
		Time absolute_pressure_max;
		Time absolute_pressure_min;
		Time relative_pressure_max;
		Time relative_pressure_min;
		Time wsp_average_max;
		Time wsp_gust_max;
		Time rain_1h_max;
		Time rain_24h_max;
		Time rain_week_max;
		Time rain_month_max;
		Time rain_total_max;
	}

	[CCode (cname = "struct weather_header")]
	public struct Header {
		uint8  sampling_interval;

		[CCode (ctype = "uint8_t")]
		UnitSetting1 unit_setting1;

		[CCode (ctype = "uint8_t")]
		UnitSetting2 unit_setting2;

		[CCode (ctype = "uint8_t")]
		DisplayFormat1 display_format1;

		[CCode (ctype = "uint8_t")]
		DisplayFormat2 display_format2;

		[CCode (ctype = "uint8_t")]
		AlarmFlags1 alarm_enable1;

		[CCode (ctype = "uint8_t")]
		AlarmFlags2 alarm_enable2;

		[CCode (ctype = "uint8_t")]
		AlarmFlags3 alarm_enable3;

		uint8  timezone;

		uint16 history_data_sets;
		uint16 history_data_stack;

		uint16 relative_pressure;
		uint16 absolute_pressure;

		Alarms alarm;
		Records record;
		Timestamps timestamp;
	}

	[Compact]
	[CCode (cname = "struct weather_station")]
	public class Station {
		[CCode (cname = "weather_station_init")]
		public Station();
		public Data   read_data(uint16 addr);
		public Header read_header();
		public void   write(uint16 addr, uint8 byte);
	}
}