# HG changeset patch # User Michiel Broek # Date 1447964246 -3600 # Node ID e54611453d297805500c0b920e6ca9efc251f85f # Parent c51265b518ce6ff6a42afd53a69c07a4514084a1 Moved global bit defines to config.h diff -r c51265b518ce -r e54611453d29 brewpanel/slcd.c --- a/brewpanel/slcd.c Thu Nov 19 20:45:09 2015 +0100 +++ b/brewpanel/slcd.c Thu Nov 19 21:17:26 2015 +0100 @@ -31,21 +31,6 @@ #ifdef HAVE_SDL_SDL_H -// HD44780U Commands - -//#define SLCD_CLEAR 0x01 -//#define SLCD_HOME 0x02 -//#define SLCD_ENTRY 0x04 -//#define SLCD_CTRL 0x08 -//#define SLCD_CDSHIFT 0x10 -//#define SLCD_FUNC 0x20 -//#define SLCD_CGRAM 0x40 -//#define SLCD_DGRAM 0x80 - -// // Bits in the entry register -// -// #define LCD_ENTRY_SH 0x01 -// #define LCD_ENTRY_ID 0x02 // Bits in the control register #define SLCD_BLINK_CTRL 0x01 diff -r c51265b518ce -r e54611453d29 brewpanel/sockio.c --- a/brewpanel/sockio.c Thu Nov 19 20:45:09 2015 +0100 +++ b/brewpanel/sockio.c Thu Nov 19 21:17:26 2015 +0100 @@ -27,21 +27,6 @@ #ifdef HAVE_SDL_SDL_H -#define SLCD_NULL 0x0000 -#define SLCD_CLEAR 0x0001 -#define SLCD_MCLEAR 0x1fff -#define SLCD_HOME 0x0002 -#define SLCD_MHOME 0x1ffe -#define SLCD_DGRAM 0x0080 -#define SLCD_MDGRAM 0x1f80 -#define SLCD_DATA 0x0200 -#define SLCD_MDATA 0x1e00 -#define SLCD_LEDS 0x0400 -#define SLCD_MLEDS 0x1c00 -#define SLCD_KEYS 0x0800 -#define SLCD_MKEYS 0x1800 -#define SLCD_MDEV 0xe000 - int sock = -1; /* Unix datagram socket */ struct sockaddr_in servaddr; /* Server socket address */ diff -r c51265b518ce -r e54611453d29 config.h.in --- a/config.h.in Thu Nov 19 20:45:09 2015 +0100 +++ b/config.h.in Thu Nov 19 21:17:26 2015 +0100 @@ -3,6 +3,40 @@ #undef COPYRIGHT #undef VERSION +/* + * Socket LCD protocol bits + */ +#define SLCD_NULL 0x0000 +#define SLCD_CLEAR 0x0001 +#define SLCD_MCLEAR 0x1fff +#define SLCD_HOME 0x0002 +#define SLCD_MHOME 0x1ffe +#define SLCD_DGRAM 0x0080 +#define SLCD_MDGRAM 0x1f80 +#define SLCD_DATA 0x0200 +#define SLCD_MDATA 0x1e00 +#define SLCD_LEDS 0x0400 +#define SLCD_MLEDS 0x1c00 +#define SLCD_KEYS 0x0800 +#define SLCD_MKEYS 0x1800 +#define SLCD_MDEV 0xe000 + +/* + * Socket LEDs bits + */ +#define SLED_LCD 0x0001 /* LCD backlight */ +#define SLED_TFLED 0x0002 /* Thermferm LED */ +#define SLED_HLTH 0x0004 /* HLT heater LED */ +#define SLED_MLTH 0x0008 /* MLT heater LED */ +#define SLED_MLTP 0x0010 /* MLT pump/mixer */ +#define SLED_BUZZER 0x0080 /* Buzzer */ + +/* + * Network + */ +#define SEND_PORT 6554 + + /* Compile experimental code (may not be present) */ #undef USE_EXPERIMENT diff -r c51265b518ce -r e54611453d29 thermferm/lcd-pcf8574.c --- a/thermferm/lcd-pcf8574.c Thu Nov 19 20:45:09 2015 +0100 +++ b/thermferm/lcd-pcf8574.c Thu Nov 19 21:17:26 2015 +0100 @@ -44,20 +44,26 @@ extern struct lcdDataStruct *lcds [MAX_LCDS]; #endif extern sys_config Config; - +extern uint16_t leds; /* * setBacklight: ********************************************************************************* */ -#ifdef HAVE_WIRINGPI_H -void setBacklight (int value) +void setBacklight(int value) { - pinMode (AF_BACKLIGHT, OUTPUT) ; - digitalWrite (AF_BACKLIGHT, (value & 1)) ; +#ifdef HAVE_WIRINGPI_H + pinMode (AF_BACKLIGHT, OUTPUT) ; + digitalWrite (AF_BACKLIGHT, (value & 1)) ; +#endif + if (value) { + leds |= SLED_LCD; + } else { + leds &= ~SLED_LCD; + } + slcdLEDs(slcdHandle); } -#endif /* @@ -65,7 +71,7 @@ ********************************************************************************* */ -int initLCD (int cols, int rows) +int initLCD(int cols, int rows) { if (!((rows == 1) || (rows == 2) || (rows == 4))) { fprintf (stderr, "rows must be 1, 2 or 4\n") ; @@ -92,7 +98,6 @@ } lcdClear (lcdHandle) ; - setBacklight (1) ; #endif slcdHandle = slcdInit(0, rows, cols); @@ -101,6 +106,7 @@ return -1; } slcdClear(slcdHandle); + setBacklight(1); return 0 ; } diff -r c51265b518ce -r e54611453d29 thermferm/lcd-pcf8574.h --- a/thermferm/lcd-pcf8574.h Thu Nov 19 20:45:09 2015 +0100 +++ b/thermferm/lcd-pcf8574.h Thu Nov 19 21:17:26 2015 +0100 @@ -16,9 +16,9 @@ #define AF_DB6 (AF_BASE + 6) #define AF_DB7 (AF_BASE + 7) -void setBacklight (int); #endif +void setBacklight (int); int initLCD (int, int); diff -r c51265b518ce -r e54611453d29 thermferm/panel.c --- a/thermferm/panel.c Thu Nov 19 20:45:09 2015 +0100 +++ b/thermferm/panel.c Thu Nov 19 21:17:26 2015 +0100 @@ -178,7 +178,9 @@ */ #ifdef HAVE_WIRINGPI_H piLock(LOCK_LCD); +#endif setBacklight(1); +#ifdef HAVE_WIRINGPI_H piUnlock(LOCK_LCD); #endif Backlight = LCD_SLEEP; @@ -198,7 +200,9 @@ if (Backlight == 1) { #ifdef HAVE_WIRINGPI_H piLock(LOCK_LCD); +#endif setBacklight(0); +#ifdef HAVE_WIRINGPI_H piUnlock(LOCK_LCD); #endif } diff -r c51265b518ce -r e54611453d29 thermferm/slcd.c --- a/thermferm/slcd.c Thu Nov 19 20:45:09 2015 +0100 +++ b/thermferm/slcd.c Thu Nov 19 21:17:26 2015 +0100 @@ -26,27 +26,11 @@ #include "xutil.h" -#define SLCD_NULL 0x0000 -#define SLCD_CLEAR 0x0001 -#define SLCD_MCLEAR 0x1fff -#define SLCD_HOME 0x0002 -#define SLCD_MHOME 0x1ffe -#define SLCD_DGRAM 0x0080 -#define SLCD_MDGRAM 0x1f80 -#define SLCD_DATA 0x0200 -#define SLCD_MDATA 0x1e00 -#define SLCD_LEDS 0x0400 -#define SLCD_MLEDS 0x1c00 -#define SLCD_KEYS 0x0800 -#define SLCD_MKEYS 0x1800 -#define SLCD_MDEV 0xe000 - -#define SEND_PORT 6554 - struct sockaddr_in sendaddr; /* Server send socket */ int sock = -1; uint16_t keys = 0x0000; +uint16_t leds = 0x0400; /* LED's, buzzer, LCD backlight */ extern int debug; @@ -94,6 +78,13 @@ } + +void slcdLEDs(int fd) +{ + putLCDsocket(fd, leds); +} + + //void slcdHome(int fd) //{ //} diff -r c51265b518ce -r e54611453d29 thermferm/slcd.h --- a/thermferm/slcd.h Thu Nov 19 20:45:09 2015 +0100 +++ b/thermferm/slcd.h Thu Nov 19 21:17:26 2015 +0100 @@ -3,6 +3,7 @@ void slcdDummy(int fd); +void slcdLEDs(int fd); void slcdClear(int fd); void slcdPosition(int fd, int x, int y); void slcdPutchar(int fd, unsigned char c); diff -r c51265b518ce -r e54611453d29 thermferm/thermferm.c --- a/thermferm/thermferm.c Thu Nov 19 20:45:09 2015 +0100 +++ b/thermferm/thermferm.c Thu Nov 19 21:17:26 2015 +0100 @@ -352,9 +352,9 @@ #ifdef HAVE_WIRINGPI_H piLock(LOCK_LCD); lcdClear(lcdHandle); - setBacklight(0); #endif slcdClear(slcdHandle); + setBacklight(0); #ifdef HAVE_WIRINGPI_H piUnlock(LOCK_LCD); #endif