1 /*----------------------------------------------------------------------------+
2  |                                                                            |
3  |                  Oregon Sensor Support for HEYU                            |
4  |                Copyright 2008 Charles W. Sullivan                          |
5  |                                                                            |
6  |                                                                            |
7  | As used herein, HEYU is a trademark of Daniel B. Suthers.                  |
8  | X10, CM11A, and ActiveHome are trademarks of X-10 (USA) Inc.               |
9  | The author is not affiliated with either entity.                           |
10  |                                                                            |
11  | Charles W. Sullivan                                                        |
12  | Co-author and Maintainer                                                   |
13  | Greensboro, North Carolina                                                 |
14  | Email ID: cwsulliv01                                                       |
15  | Email domain: -at- heyu -dot- org                                          |
16  |                                                                            |
17  +----------------------------------------------------------------------------*/
18 
19 /*
20  *   This program is free software: you can redistribute it and/or modify
21  *   it under the terms of the GNU General Public License as published by
22  *   the Free Software Foundation, either version 3 of the License, or
23  *   (at your option) any later version.
24  *
25  *   This program is distributed in the hope that it will be useful,
26  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
27  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
28  *   GNU General Public License for more details.
29  *
30  *   You should have received a copy of the GNU General Public License
31  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
32  *
33  */
34 
35 /* Formats for Oregon data */
36 #define  FMT_ORET       "%.1f"  /* Temperature */
37 #define  FMT_OREBP      "%.4g"  /* Barometric Pressure */
38 #define  FMT_OREWGT     "%.1f"  /* Weight */
39 #define  FMT_OREWSP     "%.1f"  /* Wind Speed */
40 #define  FMT_OREWDIR    "%.1f"  /* Wind Direction */
41 #define  FMT_ORERTOT    "%.2f"  /* Total Rainfall */
42 #define  FMT_ORERRATE   "%.2f"  /* Rainfall Rate */
43 
44 /* Scale parameters for OWL CM119 */
45 #define OWLPSC  1.0       /* Power */
46 #define OWLESC  0.044843  /* Energy */
47 #define OWLVREF 230.0     /* Ref Voltage */
48 
49 /* Don't change anything below */
50 #define ORE_VALID   0x00000001u
51 #define ORE_WGTNUM  0x00000006u  /* Shared */
52 #define ORE_FCAST   0x0000000eu  /* Shared */
53 #define ORE_NEGTEMP 0x00000020u
54 #define ORE_BATLVL  0x00000040u
55 #define ORE_LOBAT   0x00000080u
56 #define ORE_DATAMSK 0x00ffff00u
57 #define ORE_CHANMSK 0xf0000000u
58 #define ORE_BATMSK  0x0f000000u
59 
60 #define ORE_DATASHFT   8
61 #define ORE_BATSHFT   24
62 #define ORE_CHANSHFT  28
63 #define ORE_WGTNUMSHFT 1
64 #define ORE_FCASTSHFT  1
65 
66 /* Oregon subtypes */
67 enum {
68    OreTemp1, OreTemp2, OreTemp3,
69    OreTH1, OreTH2, OreTH3, OreTH4, OreTH5, OreTH6,
70    OreTHB1, OreTHB2,
71    OreTemu, OreTHemu, OreTHBemu,
72    OreRain1, OreRain2, OreRain3,
73    OreWind1, OreWind2, OreWind3,
74    OreUV1, OreUV2,
75    OreDT1, OreElec1, OreElec2,
76    OreWeight1, OreWeight2
77 };
78 
79 unsigned char oretype ( unsigned char *, unsigned char *, unsigned char *, unsigned char *, unsigned long *, int * );
80 char *translate_gen_longdata ( unsigned char *, unsigned char *, int * );
81 char *translate_ore_emu ( unsigned char *, unsigned char *, int * );
82 char *translate_oregon( unsigned char *, unsigned char *, int * );
83 int is_ore_ignored ( unsigned int );
84