/*
* Linux Interfece for Arexx Data Loggers
*
- * (c) 2011 Martin Mares <mj@ucw.cz>
+ * (c) 2011-2012 Martin Mares <mj@ucw.cz>
*/
#include <stdio.h>
static int data_point_counter;
+static double correct_point(int id, double val)
+{
+ /*
+ * Manually calculated corrections for my sensors.
+ * Replace with your formulae.
+ */
+ switch (id) {
+ case 10415:
+ return val - 0.93;
+ case 19246:
+ return val + 0.49;
+ case 12133:
+ return val + 0.44;
+ default:
+ return val;
+ }
+}
+
static void cooked_point(time_t t, int id, double val, char *unit, int q)
{
+ double val2 = correct_point(id, val);
+
if (debug_raw_data) {
struct tm tm;
localtime_r(&t, &tm);
char tbuf[64];
strftime(tbuf, sizeof(tbuf), "%Y-%m-%d %H:%M:%S", &tm);
- printf("== %s id=%d val=%.3f unit=%s q=%d\n", tbuf, id, val, unit, q);
+ printf("== %s id=%d val=%.3f val2=%.3f unit=%s q=%d\n", tbuf, id, val, val2, unit, q);
}
data_point_counter++;
- rrd_point(t, id, val, unit);
+ rrd_point(t, id, val2, unit);
}
static void raw_point(int t, int id, int raw, int q)