thermometers/thermometers.h

changeset 51
a03b6dac5398
parent 1
91065eba8e1b
child 144
3446371e0bdb
equal deleted inserted replaced
50:8b5e8f1e172d 51:a03b6dac5398
1 #ifndef _THERMOMETERS_H
2 #define _THERMOMETERS_H
3
4
5 #define TRUE 1
6 #define FALSE 0
7
8 #include "../config.h"
9
10 #include <stdlib.h>
11 #include <stdio.h>
12 #include <stdint.h>
13 #include <stdarg.h>
14 #include <string.h>
15 #include <ctype.h>
16 #include <sys/types.h>
17 #include <sys/stat.h>
18 #include <sys/time.h>
19 #include <time.h>
20 #include <fcntl.h>
21 #include <syslog.h>
22 #include <unistd.h>
23 #include <errno.h>
24 #include <signal.h>
25 #include <getopt.h>
26 #include <limits.h>
27 #include <sys/socket.h>
28 #include <arpa/inet.h>
29 #include <netdb.h>
30 #include <poll.h>
31
32
33 /* mosquitto */
34 #include <mosquitto.h>
35
36 #ifdef HAVE_WIRINGPI_H
37 /* wiringPi */
38 #include <wiringPi.h>
39 #include <pcf8574.h>
40 #include <lcd.h>
41
42 #endif
43
44 #define TRUE 1
45 #define FALSE 0
46
47 #define MBSE_SS(x) (x)?(x):"(null)"
48
49 /* rdconfig.c */
50 typedef struct _key_list {
51 char *key;
52 int (*prc)(char **);
53 char **dest;
54 } key_list;
55
56 typedef struct _w1_therm {
57 struct _w1_therm *next;
58 char *master; /* Master for this device */
59 int bus; /* Reserved for ds2482-800 */
60 char *name; /* Name of this device */
61 char *alias; /* Friendly name */
62 int present; /* 1=present, 0=absent */
63 int lastval; /* Last valid value */
64 int update; /* Value updated */
65 } w1_therm;
66
67 typedef struct _rc_switch {
68 struct _rc_switch *next;
69 char *address; /* Address code */
70 char *alias; /* Friendly name */
71 } rc_switch;
72
73 typedef struct _sys_config {
74 char *name; /* Configuration name */
75 char *mosq_host; /* mosquitto server hostname */
76 int mosq_port; /* mosquitto server port */
77 int my_port; /* my client/server port */
78 w1_therm *w1therms; /* 1-wire temp sensors */
79 #ifdef HAVE_WIRINGPI_H
80 int lcd_cols; /* LCD display columns */
81 int lcd_rows; /* LCD display rows */
82 int rx433; /* 433 MHz receiver pin */
83 int tx433; /* 433 MHz transmitter pin */
84 rc_switch *rcswitch; /* 433 MHz RC Power switches */
85 #endif
86 } sys_config;
87
88
89 void killconfig(void);
90 int rdconfig(char *);
91
92
93 /* xutil.c */
94 char *xmalloc(size_t);
95 char *xstrcpy(char *);
96 char *xstrcat(char *, char *);
97
98
99 #ifdef HAVE_WIRINGPI_H
100
101 /* lcd-pcf8574.c */
102 // Defines for the pcf8574 Pi LCD interface board
103 #define AF_BASE 100
104
105 #define AF_RS (AF_BASE + 0)
106 #define AF_RW (AF_BASE + 1)
107 #define AF_E (AF_BASE + 2)
108 #define AF_BACKLIGHT (AF_BASE + 3)
109 #define AF_DB4 (AF_BASE + 4)
110 #define AF_DB5 (AF_BASE + 5)
111 #define AF_DB6 (AF_BASE + 6)
112 #define AF_DB7 (AF_BASE + 7)
113
114 void setBacklight (int);
115 int initLCD (int, int);
116 void mb_lcdPutchar(const int, unsigned char);
117 void mb_lcdPuts(const int, const char *);
118 void mb_lcdClear(const int);
119
120
121 /* logger.c */
122 void logger(char *, char *, char *);
123
124
125 /* rc-switch.c */
126 int toggleSwitch(char *);
127 int toggleTypeA(char *, char *, bool);
128 int toggleTypeB(int, int, bool);
129 int toggleTypeC(char, int, int, bool);
130 int toggleTypeE(char, int, bool);
131
132 void enableReceiveIRQ(int interrupt);
133 void enableReceive(void);
134 void disableReceive(void);
135 bool available(void);
136 void resetAvailable(void);
137
138 unsigned long getReceivedValue(void);
139 unsigned int getReceivedBitlength(void);
140 unsigned int getReceivedDelay(void);
141 unsigned int getReceivedProtocol(void);
142 unsigned int *getReceivedRawdata(void);
143
144 void enableTransmit(int);
145 void disableTransmit(void);
146
147 char *dec2binWzerofill(unsigned long, unsigned int);
148
149
150 #endif
151
152
153 #endif
154

mercurial