forked from rene0/dcf77pi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bits1to14.c
76 lines (68 loc) · 1.36 KB
/
bits1to14.c
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
// Copyright 2014-2018 René Ladan
// SPDX-License-Identifier: BSD-2-Clause
#include "bits1to14.h"
#include "input.h"
static unsigned tpbuf[TPBUFLEN];
static enum eTP tptype = eTP_unknown;
void
fill_thirdparty_buffer(int minute, int bitpos, struct GB_result bit)
{
static unsigned tpstat;
switch (minute % 3) {
case 0:
/* copy third party data */
if (bitpos > 1 && bitpos < 8) {
tpbuf[bitpos - 2] = bit.bitval == ebv_1 ? 1 : 0;
/* 2..7 -> 0..5 */
}
if (bitpos > 8 && bitpos < 15) {
tpbuf[bitpos - 3] = bit.bitval == ebv_1 ? 1 : 0;
/* 9..14 -> 6..11 */
}
/* copy third party type */
if (bitpos == 1) {
tpstat = bit.bitval == ebv_1 ? 2 : 0;
}
if (bitpos == 8) {
if (bit.bitval == ebv_1) {
tpstat++;
}
switch (tpstat) {
case 0:
tptype = eTP_weather;
break;
case 3:
tptype = eTP_alarm;
break;
default:
tptype = eTP_unknown;
break;
}
}
break;
case 1:
/* copy third party data */
if (bitpos > 0 && bitpos < 15) {
tpbuf[bitpos + 11] = bit.bitval == ebv_1 ? 1 : 0;
/* 1..14 -> 12..25 */
}
break;
case 2:
/* copy third party data */
if (bitpos > 0 && bitpos < 15) {
tpbuf[bitpos + 25] = bit.bitval == ebv_1 ? 1 : 0;
/* 1..14 -> 26..39 */
}
break;
}
}
const unsigned * const
get_thirdparty_buffer(void)
{
return tpbuf;
}
enum eTP
get_thirdparty_type(void)
{
return tptype;
}