Fri, 02 May 2014 23:24:44 +0200
wirinPi code is now conditional
lib/lcd-pcf8574.c | file | annotate | diff | comparison | revisions | |
lib/mbselib.h | file | annotate | diff | comparison | revisions | |
thermometers/main.c | file | annotate | diff | comparison | revisions |
--- a/lib/lcd-pcf8574.c Fri May 02 23:14:50 2014 +0200 +++ b/lib/lcd-pcf8574.c Fri May 02 23:24:44 2014 +0200 @@ -26,42 +26,7 @@ #include "../config.h" #include "mbselib.h" -//#include <stdio.h> -//#include <stdlib.h> -//#include <unistd.h> -//#include <stdint.h> - -//#include <string.h> -//#include <time.h> - -//#include <wiringPi.h> -//#include <pcf8574.h> -//#include <lcd.h> - -//#ifndef TRUE -//# define TRUE (1==1) -//# define FALSE (1==2) -//#endif - - -// Defines for the pcf8574 Pi LCD interface board - -//#define AF_BASE 100 - -//#define AF_RS (AF_BASE + 0) -//#define AF_RW (AF_BASE + 1) -//#define AF_E (AF_BASE + 2) -//#define AF_BACKLIGHT (AF_BASE + 3) - -//#define AF_DB4 (AF_BASE + 4) -//#define AF_DB5 (AF_BASE + 5) -//#define AF_DB6 (AF_BASE + 6) -//#define AF_DB7 (AF_BASE + 7) - - -// User-Defined character test - -// Global lcd handle: +#ifdef HAVE_WIRINGPI_H int lcdHandle; @@ -119,3 +84,6 @@ lcdClear (lcdHandle) ; return 0 ; } + +#endif +
--- a/lib/mbselib.h Fri May 02 23:14:50 2014 +0200 +++ b/lib/mbselib.h Fri May 02 23:24:44 2014 +0200 @@ -19,11 +19,14 @@ /* mosquitto */ #include <mosquitto.h> +#ifdef HAVE_WIRINGPI_H /* wiringPi */ #include <wiringPi.h> #include <pcf8574.h> #include <lcd.h> +#endif + #define TRUE 1 #define FALSE 0 @@ -69,6 +72,7 @@ char *xstrcat(char *, char *); +#ifdef HAVE_WIRINGPI_H /* lcd-pcf8574.c */ // Defines for the pcf8574 Pi LCD interface board @@ -88,3 +92,6 @@ #endif + +#endif +
--- a/thermometers/main.c Fri May 02 23:14:50 2014 +0200 +++ b/thermometers/main.c Fri May 02 23:24:44 2014 +0200 @@ -42,7 +42,9 @@ extern bool debug; extern sys_config Config; +#ifdef HAVE_WIRINGPI_H extern int lcdHandle; +#endif int server(void); void help(void); @@ -123,11 +125,13 @@ +#ifdef HAVE_WIRINGPI_H void stopLCD(void) { lcdClear(lcdHandle); setBacklight(0); } +#endif @@ -135,7 +139,9 @@ { int rc, c, i; pid_t frk; +#ifdef HAVE_WIRINGPI_H char buf[80]; +#endif while (1) { int option_index = 0; @@ -178,6 +184,7 @@ signal(i, (void (*))die); } +#ifdef HAVE_WIRINGPI_H if ((rc = initLCD (16, 2))) { fprintf(stderr, "Cannot initialize LCD display, rc=%d\n", rc); return 1; @@ -188,6 +195,7 @@ lcdPosition(lcdHandle, 0, 1); sprintf(buf, "Version %s", VERSION); lcdPuts(lcdHandle, buf); +#endif if (debug) { /* @@ -213,7 +221,9 @@ case -1: syslog(LOG_NOTICE, "Daemon fork failed: %s", strerror(errno)); syslog(LOG_NOTICE, "Finished, rc=1"); +#ifdef HAVE_WIRINGPI_H stopLCD(); +#endif exit(1); case 0: /* * Run the daemon @@ -258,7 +268,10 @@ char *id = NULL, *state = NULL; struct mosquitto *mosq = NULL; char hostname[256], buf[1024]; - int temp, rc, deviation, keepalive = 60, lcdupdate; + int temp, rc, deviation, keepalive = 60; +#ifdef HAVE_WIRINGPI_H + int lcdupdate; +#endif unsigned int max_inflight = 20; char err[1024]; w1_therm *tmp1, *old1; @@ -378,7 +391,9 @@ do { if (status == STATUS_CONNACK_RECVD) { +#ifdef HAVE_WIRINGPI_H lcdupdate = FALSE; +#endif /* * Here send our 1-wire sensors values @@ -451,7 +466,9 @@ } } tmp1->lastval = temp; +#ifdef HAVE_WIRINGPI_H lcdupdate = TRUE; +#endif } } else { syslog(LOG_NOTICE, "sensor %s/%s CRC error", tmp1->master, tmp1->name); @@ -470,6 +487,7 @@ alias = NULL; } +#ifdef HAVE_WIRINGPI_H if (lcdupdate) { lcdPosition(lcdHandle, 0, 0); tmp1 = Config.w1therms; @@ -481,6 +499,7 @@ snprintf(buf, 16, "%5.1f %cC %s ", tmp1->lastval / 1000.0, 0xdf, tmp1->alias); lcdPuts(lcdHandle, buf); } +#endif if (shutdown) { /* @@ -490,9 +509,11 @@ mosquitto_publish(mosq, &mid_sent, state, strlen(buf), buf, qos, true); last_mid = mid_sent; status = STATUS_WAITING; +#ifdef HAVE_WIRINGPI_H lcdClear(lcdHandle); lcdPosition(lcdHandle, 0, 0); lcdPuts(lcdHandle, "Shuting down ..."); +#endif } usleep(100000); @@ -517,7 +538,9 @@ mosquitto_destroy(mosq); mosquitto_lib_cleanup(); +#ifdef HAVE_WIRINGPI_H stopLCD(); +#endif return rc; }