From 2e82359fa5bf7c34e9cbb3436fe9da0289710399 Mon Sep 17 00:00:00 2001 From: Sebastian Reichel Date: Sun, 26 Feb 2012 19:25:42 +0100 Subject: initial code import --- demo.vala | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 demo.vala (limited to 'demo.vala') diff --git a/demo.vala b/demo.vala new file mode 100644 index 0000000..0262edb --- /dev/null +++ b/demo.vala @@ -0,0 +1,46 @@ +/* demo.vala + * Copyright (c) 2012, Sebastian Reichel + * + * 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. + */ + +public static int main(string[] args) { + var station = new Weather.Station(); + + if(station == null) { + stderr.printf("weather station not found!\n"); + return 1; + } + + var header = station.read_header(); + var data = station.read_data(header.history_data_stack); + + /* print some infos from the header */ + stdout.printf("interval: %d\n", header.sampling_interval); + stdout.printf("stack addr: 0x%04x\n", header.history_data_stack); + stdout.printf("stack size: %d\n\n", header.history_data_sets); + + /* print content of the current data set */ + stdout.printf("Valid: %s\n", (data.status & Weather.Status.INVALID_DATA) == 0 ? "yes" : "no"); + stdout.printf("Temperature Indoor: %.1f°C\n", data.temperature_indoor/10.0); + stdout.printf("Humidity Indoor: %d%%\n", data.humidity_indoor); + stdout.printf("Temperature Outdoor: %.1f°C\n", data.temperature_outdoor/10.0); + stdout.printf("Humidity Outdoor: %d%%\n", data.humidity_outdoor); + stdout.printf("Pressure: %.1f hPa\n", data.pressure/10.0); + stdout.printf("Wind Direction: %s\n", data.wind_direction.to_string()); + stdout.printf("Wind Speed: %.1f m/s\n", data.avg_wind_speed/10.0); + stdout.printf("Wind Gust: %.1f m/s\n", data.gust_wind_speed/10.0); + stdout.printf("Total Rain: %.1f mm\n", data.rain*0.3); + + return 0; +} -- cgit v1.2.3