Fixed parameters pasing between different layers.

Fri, 20 Nov 2015 20:49:58 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Fri, 20 Nov 2015 20:49:58 +0100
changeset 428
d64c4c1edd78
parent 427
e8e548922e31
child 429
2d7f427b2f74

Fixed parameters pasing between different layers.

brewpanel/Makefile file | annotate | diff | comparison | revisions
brewpanel/dlgBrew.c file | annotate | diff | comparison | revisions
brewpanel/sdlgui.c file | annotate | diff | comparison | revisions
brewpanel/sdlgui.h file | annotate | diff | comparison | revisions
brewpanel/slcd.c file | annotate | diff | comparison | revisions
brewpanel/slcd.h file | annotate | diff | comparison | revisions
brewpanel/sockio.c file | annotate | diff | comparison | revisions
brewpanel/sockio.h file | annotate | diff | comparison | revisions
--- a/brewpanel/Makefile	Thu Nov 19 22:50:17 2015 +0100
+++ b/brewpanel/Makefile	Fri Nov 20 20:49:58 2015 +0100
@@ -54,10 +54,10 @@
 
 # DO NOT DELETE THIS LINE - MAKE DEPEND RELIES ON IT
 # Dependencies generated by make depend
-slcd.o: brewpanel.h slcd.h sdlgui.h
+slcd.o: brewpanel.h sdlgui.h slcd.h dlgBrew.h
 futil.o: brewpanel.h futil.h
-sockio.o: brewpanel.h slcd.h futil.h sockio.h
-dlgBrew.o: brewpanel.h sockio.h dlgBrew.h sdlgui.h slcd.h
+sockio.o: brewpanel.h sdlgui.h slcd.h futil.h sockio.h
+dlgBrew.o: brewpanel.h dlgBrew.h sdlgui.h slcd.h sockio.h
 brewpanel.o: brewpanel.h sdlgui.h dlgBrew.h
 sdlgui.o: brewpanel.h sdlgui.h sockio.h lcdfont10x16.h
 # End of generated dependencies
--- a/brewpanel/dlgBrew.c	Thu Nov 19 22:50:17 2015 +0100
+++ b/brewpanel/dlgBrew.c	Fri Nov 20 20:49:58 2015 +0100
@@ -24,10 +24,10 @@
  *****************************************************************************/
 
 #include "brewpanel.h"
-#include "sockio.h"
 #include "dlgBrew.h"
 #include "sdlgui.h"
 #include "slcd.h"
+#include "sockio.h"
 
 
 #ifdef HAVE_SDL_SDL_H
@@ -51,23 +51,26 @@
 /* The main dialog: */
 static SGOBJ maindlg[] =
 {
-/*        type      flags     state   x    y    w    h  txt  */
-	{ SGBOX,    0,           0,   0,   0, 374, 470, NULL },
-	{ SGLCD,    0,           0,  -1,  44,  20,   4, NULL },
-	{ SGBUTTON, 0,           0, 147, 430,  80,  20, (char *)"Quit" },
-	{ SGBUTTON, 0,           0,  80, 135,  30,  30, (char *)"1" },
-	{ SGTTF,    0,           0,  85, 170,  20,  20, (char *)"Up" },
-	{ SGBUTTON, 0,           0, 140, 135,  30,  30, (char *)"2" },
-	{ SGTTF,    0,           0, 135, 170,  20,  20, (char *)"Down" },
-	{ SGBUTTON, 0,           0, 200, 135,  30,  30, (char *)"3" },
-	{ SGTTF,    0,           0, 203, 170,  20,  20, (char *)"Ret" },
-	{ SGBUTTON, 0,           0, 260, 135,  30,  30, (char *)"4" },
-	{ SGTTF,    0,           0, 258, 170,  20,  20, (char *)"Enter" },
-	{ SGBUTTON, 0,           0, 110, 195,  30,  30, (char *)"12" },
-	{ SGBUTTON, 0,           0, 170, 195,  30,  30, (char *)"23" },
-	{ SGBUTTON, 0,           0, 230, 195,  30,  30, (char *)"34" },
-	{ SGBUTTON, 0,           0, 170, 255,  30,  30, (char *)"All" },
-	{ -1,       0,           0,   0,   0,   0,   0, NULL }
+/*        type         flags     state   x    y    w    h  txt  */
+	{ SGBOX,       0,           0,   0,   0, 374, 470, NULL },
+	{ SGLCD,       0,           0,  -1,  44,  20,   4, NULL },
+	{ SGBUTTON,    0,           0, 147, 430,  80,  20, (char *)"Quit" },
+	{ SGBUTTON,    0,           0,  80, 135,  30,  30, (char *)"1" },
+	{ SGTTF,       0,           0,  85, 170,  20,  20, (char *)"Up" },
+	{ SGBUTTON,    0,           0, 140, 135,  30,  30, (char *)"2" },
+	{ SGTTF,       0,           0, 135, 170,  20,  20, (char *)"Down" },
+	{ SGBUTTON,    0,           0, 200, 135,  30,  30, (char *)"3" },
+	{ SGTTF,       0,           0, 203, 170,  20,  20, (char *)"Ret" },
+	{ SGBUTTON,    0,           0, 260, 135,  30,  30, (char *)"4" },
+	{ SGTTF,       0,           0, 258, 170,  20,  20, (char *)"Enter" },
+	{ SGBUTTON,    0,           0, 110, 195,  30,  30, (char *)"12" },
+	{ SGBUTTON,    0,           0, 170, 195,  30,  30, (char *)"23" },
+	{ SGBUTTON,    0,           0, 230, 195,  30,  30, (char *)"34" },
+	{ SGBUTTON,    0,           0, 170, 255,  30,  30, (char *)"All" },
+	{ SGLEDRED,    0,           0, 110, 300,  12,   0, NULL },
+	{ SGLEDBLUE,   0,           0, 170, 300,  12,   0, NULL },
+	{ SGLEDYELLOW, 0,           0, 230, 300,  12,   0, NULL },
+	{ -1,          0,           0,   0,   0,   0,   0, NULL }
 };
 
 
@@ -106,7 +109,7 @@
     if (fermenter == 1) {
     	maindlg[1].w = 16;
     	maindlg[1].h = 2;
-	maindlg[7].type = SGLEDRED;
+	maindlg[7].type = SGLEDGREEN;
 	maindlg[7].x = 218;
 	maindlg[7].y = 153;
 	maindlg[7].w = 12;
@@ -119,7 +122,7 @@
     fd = Dialog_LCDinit(&x, &y, &w, &h, &cols, &rows, 0);
     fprintf(stdout, "Dialog_LCDinit(%d, %d, %d, %d, %d, %d, 0) = %d\n", x, y, w, h, cols, rows, fd);
     socket_connect();
-    slcdInit(fd, x, y, w, h, cols, rows);
+    slcdInit(maindlg, fd, x, y, w, h, cols, rows);
 
     do {
 	retbut = SDLGui_DoDialogLoop(maindlg);
--- a/brewpanel/sdlgui.c	Thu Nov 19 22:50:17 2015 +0100
+++ b/brewpanel/sdlgui.c	Fri Nov 20 20:49:58 2015 +0100
@@ -44,6 +44,7 @@
 extern int		my_shutdown;
 
 
+
 /*-----------------------------------------------------------------------*/
 /*
  * Load an 1 plane XBM into a 8 planes SDL_Surface.
@@ -226,7 +227,7 @@
 /*
  * Draw the cursor
  */
-void SDLGui_Cursor(int x, int y, int on, int blink)
+void SDLGui_Cursor(SGOBJ *dlg, int fd, int x, int y, int on, int blink)
 {
     SDL_Rect	dr;
     Uint32      color = SDL_MapRGB(pSdlGuiScrn->format, 53, 59, 61);
@@ -247,15 +248,16 @@
 /*
  * Draw a text character
  */
-void SDLGui_Char(int x, int y, Uint8 c, int bLight)
+void SDLGui_Char(SGOBJ *dlg, int fd, int x, int y, Uint8 c)
 {
     SDL_Rect    sr, dr;
     Uint32	bg;
 
-    if (bLight)
+    if (dlg[1].state & SG_SELECTED) {
 	bg = LCDbg1;
-    else
+    } else {
 	bg = LCDbg0;
+    }
 
     sr.x=fontwidth*(c%16);
     sr.y=fontheight*(c/16);
@@ -315,7 +317,7 @@
 /*
  * Draw a dialog LCD object.
  */
-static void SDLGui_DrawLCD(const SGOBJ *bdlg, int objnum)
+void SDLGui_DrawLCD(SGOBJ *bdlg, int objnum)
 {
     SDL_Rect    rect;
     int         x, y, w, h, offset, border = 4;
@@ -606,10 +608,43 @@
 
 
 
+void SDLGui_LED(SGOBJ *dlg, int fd, int LED, int on)
+{
+    int	i;
+
+    for (i = 0; dlg[i].type != -1; i++) {
+	if (dlg[i].type == LED) {
+		fprintf(stdout, "SDLGui_LED LED=%d on=%d\n", LED, on);
+	    if (on) {
+		dlg[i].state |= SG_SELECTED;
+	    } else {
+		dlg[i].state &= ~SG_SELECTED;
+	    }
+	    switch (dlg[i].type) {
+		case SGLEDRED:
+				SDLGUI_DrawLEDRed(dlg, i);
+				break;
+		case SGLEDBLUE:
+				SDLGUI_DrawLEDBlue(dlg, i);
+				break;
+		case SGLEDGREEN:
+				SDLGUI_DrawLEDGreen(dlg, i);
+				break;
+		case SGLEDYELLOW:
+				SDLGUI_DrawLEDYellow(dlg, i);
+				break;
+	    }
+	    SDL_UpdateRect(pSdlGuiScrn, dlg[i].x - dlg[i].w, dlg[i].y - dlg[i].w, dlg[i].w * 2, dlg[i].w * 2);
+	}
+    }
+}
+
+
+
 /*
  * Draw a whole dialog.
  */
-void SDLGui_DrawDialog(const SGOBJ *dlg)
+void SDLGui_DrawDialog(SGOBJ *dlg)
 {
     int i;
 	
@@ -732,7 +767,7 @@
 	/*
 	 * Poll network for data
 	 */
-	socket_recv();
+	socket_recv(dlg);
 
 	if (SDL_PollEvent(&sdlEvent) == 1) { /* Wait for events */
 	    switch (sdlEvent.type) {
@@ -844,30 +879,4 @@
 }
 
 
-/*
-void SDLGui_LCDwrite(SGOBJ *dlg, int x, int y, Uint8 c, int lcdindex)
-{
-    int		i, index;
-
-    fprintf(stdout, "SDLGui_LCDwrite( , %d, %d, %c, %d)\n", x, y, c, lcdindex);
-
-    i = index = 0;
-    for (;;) {
-	if (dlg[i].type == -1) {
-	    syslog(LOG_NOTICE, "SDLGui_LCDwrite() lcdindex=%d not found", lcdindex);
-	    return;
-	}
-	if (dlg[i].type == SGLCD) {
-	    if (index == lcdindex)
-		break;
-	    index++;
-	}
-	i++;
-    }
-    fprintf(stdout, "SDLGui_LCDwrite i=%d LCD=%dx%d\n", i, dlg[i].w, dlg[i].h);
-
-}
-*/
-
 #endif
-
--- a/brewpanel/sdlgui.h	Thu Nov 19 22:50:17 2015 +0100
+++ b/brewpanel/sdlgui.h	Fri Nov 20 20:49:58 2015 +0100
@@ -49,18 +49,20 @@
 
 
 
-void SDLGui_Cursor(int x, int y, int on, int blink);
-void SDLGui_Char(int x, int y, Uint8 c, int);
+void SDLGui_LED(SGOBJ *dlg, int fd, int LED, int on);
+void SDLGui_Cursor(SGOBJ *dlg, int fd, int x, int y, int on, int blink);
+void SDLGui_Char(SGOBJ *dlg, int fd, int x, int y, Uint8 c);
+void SDLGui_DrawLCD(SGOBJ *bdlg, int objnum);
 int  SDLGui_Init(void);
 int  SDLGui_UnInit(void);
 int  SDLGui_SetScreen(SDL_Surface *pScrn);
-void SDLGui_DrawDialog(const SGOBJ *dlg);
+void SDLGui_DrawDialog(SGOBJ *dlg);
 int  SDLGui_DoDialogInit(SGOBJ *dlg);
 int  SDLGui_DoDialogLoop(SGOBJ *dlg);
 void SDLGui_DoDialogEnd(void);
 void SDLGui_CenterDlg(SGOBJ *dlg);
 int  SDLGui_LCDinit(SGOBJ *dlg, int *x, int *y, int *w, int *h, int *cols, int *rows, int lcdindex);
-void SDLGui_LCDwrite(SGOBJ *dlg, int x, int y, Uint8 c, int lcdindex);
+void SDLGui_LCDwrite(SGOBJ *dlg, int fd, int x, int y, Uint8 c, int lcdindex);
 
 #endif
 
--- a/brewpanel/slcd.c	Thu Nov 19 22:50:17 2015 +0100
+++ b/brewpanel/slcd.c	Fri Nov 20 20:49:58 2015 +0100
@@ -25,9 +25,9 @@
  */
 
 #include "brewpanel.h"
+#include "sdlgui.h"
 #include "slcd.h"
-#include "sdlgui.h"
-
+#include "dlgBrew.h"
 
 #ifdef HAVE_SDL_SDL_H
 
@@ -50,38 +50,37 @@
     int		cy;		/* Cursor y position		*/
     Uint8	cgram[8][8];	/* Characters in CGRAM		*/
     int		control;	/* Control register		*/
-    int		backlight;	/* Backlight			*/
 };
 struct slcdDataStruct *slcds [MAX_SLCDS] ;
 
 
 
 
-void slcdHome(int fd)
+void slcdHome(SGOBJ *dlg, int fd)
 {
     struct slcdDataStruct *lcd = slcds [fd];
 
     lcd->cx = lcd->cy = 0;
-    SDLGui_Cursor(lcd->x + (lcd->cx * 12) + 12, lcd->y + (lcd->cy * 18) + 8, lcd->control & SLCD_CURSOR_CTRL, lcd->control & SLCD_BLINK_CTRL);
+    SDLGui_Cursor(dlg, fd, lcd->x + (lcd->cx * 12) + 12, lcd->y + (lcd->cy * 18) + 8, lcd->control & SLCD_CURSOR_CTRL, lcd->control & SLCD_BLINK_CTRL);
 }
 
 
 
-void slcdClear(int fd)
+void slcdClear(SGOBJ *dlg, int fd)
 {
     struct slcdDataStruct *lcd = slcds [fd];
     int	i;
 
     lcd->cx = lcd->cy = 0;
     for (i = 0; i < (lcd->cols * lcd->rows); i++)
-	slcdPutchar(fd, ' ');
+	slcdPutchar(dlg, fd, ' ');
     lcd->cx = lcd->cy = 0;
-    SDLGui_Cursor(lcd->x + (lcd->cx * 12) + 12, lcd->y + (lcd->cy * 18) + 8, lcd->control & SLCD_CURSOR_CTRL, lcd->control & SLCD_BLINK_CTRL);
+    SDLGui_Cursor(dlg, fd, lcd->x + (lcd->cx * 12) + 12, lcd->y + (lcd->cy * 18) + 8, lcd->control & SLCD_CURSOR_CTRL, lcd->control & SLCD_BLINK_CTRL);
 }
 
 
 
-void slcdDisplay(int fd, int state)
+void slcdDisplay(SGOBJ *dlg, int fd, int state)
 {
     struct slcdDataStruct *lcd = slcds [fd];
 
@@ -93,7 +92,7 @@
 
 
 
-void slcdCursor(int fd, int state)
+void slcdCursor(SGOBJ *dlg, int fd, int state)
 {
     struct slcdDataStruct *lcd = slcds [fd];
 
@@ -101,12 +100,12 @@
 	lcd->control |= SLCD_CURSOR_CTRL;
     else
 	lcd->control &= ~SLCD_CURSOR_CTRL;
-    SDLGui_Cursor(lcd->x + (lcd->cx * 12) + 12, lcd->y + (lcd->cy * 18) + 8, lcd->control & SLCD_CURSOR_CTRL, lcd->control & SLCD_BLINK_CTRL);
+    SDLGui_Cursor(dlg, fd, lcd->x + (lcd->cx * 12) + 12, lcd->y + (lcd->cy * 18) + 8, lcd->control & SLCD_CURSOR_CTRL, lcd->control & SLCD_BLINK_CTRL);
 }
 
 
 
-void slcdCursorBlink(int fd, int state)
+void slcdCursorBlink(SGOBJ *dlg, int fd, int state)
 {
     struct slcdDataStruct *lcd = slcds [fd];
 
@@ -114,12 +113,12 @@
 	lcd->control |= SLCD_BLINK_CTRL;
     else
 	lcd->control &= ~SLCD_BLINK_CTRL;
-    SDLGui_Cursor(lcd->x + (lcd->cx * 12) + 12, lcd->y + (lcd->cy * 18) + 8, lcd->control & SLCD_CURSOR_CTRL, lcd->control & SLCD_BLINK_CTRL);
+    SDLGui_Cursor(dlg, fd, lcd->x + (lcd->cx * 12) + 12, lcd->y + (lcd->cy * 18) + 8, lcd->control & SLCD_CURSOR_CTRL, lcd->control & SLCD_BLINK_CTRL);
 }
 
 
 
-void slcdPosition(int fd, int x, int y)
+void slcdPosition(SGOBJ *dlg, int fd, int x, int y)
 {
     struct slcdDataStruct *lcd = slcds [fd];
 
@@ -130,12 +129,12 @@
 
     lcd->cx = x ;
     lcd->cy = y ;
-    SDLGui_Cursor(lcd->x + (lcd->cx * 12) + 12, lcd->y + (lcd->cy * 18) + 8, lcd->control & SLCD_CURSOR_CTRL, lcd->control & SLCD_BLINK_CTRL);
+    SDLGui_Cursor(dlg, fd, lcd->x + (lcd->cx * 12) + 12, lcd->y + (lcd->cy * 18) + 8, lcd->control & SLCD_CURSOR_CTRL, lcd->control & SLCD_BLINK_CTRL);
 }
 
 
 
-void slcdCharDef(int fd, int index, Uint8 data[8])
+void slcdCharDef(SGOBJ *dlg, int fd, int index, Uint8 data[8])
 {
     struct slcdDataStruct *lcd = slcds [fd];
     int i;
@@ -147,31 +146,31 @@
 
 
 
-void slcdPutchar(int fd, Uint8 data)
+void slcdPutchar(SGOBJ *dlg, int fd, Uint8 data)
 {
     struct slcdDataStruct *lcd = slcds [fd];
 
-    SDLGui_Char(lcd->x + (lcd->cx * 12) + 12, lcd->y + (lcd->cy * 18) + 8, data, lcd->backlight);
+    SDLGui_Char(dlg, fd, lcd->x + (lcd->cx * 12) + 12, lcd->y + (lcd->cy * 18) + 8, data);
 
     if (++lcd->cx == lcd->cols) {
 	lcd->cx = 0;
 	if (++lcd->cy == lcd->rows)
 	    lcd->cy = 0;
     }
-    SDLGui_Cursor(lcd->x + (lcd->cx * 12) + 12, lcd->y + (lcd->cy * 18) + 8, lcd->control & SLCD_CURSOR_CTRL, lcd->control & SLCD_BLINK_CTRL);
+    SDLGui_Cursor(dlg, fd, lcd->x + (lcd->cx * 12) + 12, lcd->y + (lcd->cy * 18) + 8, lcd->control & SLCD_CURSOR_CTRL, lcd->control & SLCD_BLINK_CTRL);
 }
 
 
 
-void slcdPuts(int fd, const char *string)
+void slcdPuts(SGOBJ *dlg, int fd, const char *string)
 {
     while (*string)
-	slcdPutchar(fd, *string++);
+	slcdPutchar(dlg, fd, *string++);
 }
 
 
 
-void slcdPrintf(int fd, const char *message, ...)
+void slcdPrintf(SGOBJ *dlg, int fd, const char *message, ...)
 {
     va_list	argp;
     char	buffer[1024];
@@ -179,21 +178,31 @@
     va_start(argp, message);
     vsnprintf(buffer, 1023, message, argp);
     va_end(argp);
-    slcdPuts(fd, buffer);
+    slcdPuts(dlg, fd, buffer);
 }
 
 
 
-void slcdBacklight(int fd, int bl)
+void slcdBacklight(SGOBJ *dlg, int fd, int bl)
 {
-    struct slcdDataStruct *lcd = slcds [fd];
-
-    lcd->backlight = bl;
+    fprintf(stdout, "slcdBacklight %d\n", bl);
+    if (bl)
+	dlg[1].state |= SG_SELECTED;
+    else
+	dlg[1].state &= ~SG_SELECTED;
+    SDLGui_DrawLCD(dlg, 1);
 }
 
 
 
-int slcdInit(int fd, int x, int y, int w, int h, int cols, int rows)
+void slcdLED(SGOBJ *dlg, int fd, int color, int state)
+{
+    SDLGui_LED(dlg, fd, color, state);
+}
+
+
+
+int slcdInit(SGOBJ *dlg, int fd, int x, int y, int w, int h, int cols, int rows)
 {
     static int			initialised = 0;
     int				i, j;
@@ -234,25 +243,24 @@
 	for (j = 0; j < 8; j++)
 	    lcd->cgram[i][j] = 0;
     lcd->control = 0;
-    lcd->backlight = 0;
 
     slcds[fd] = lcd;
 
-    slcdDisplay(fd, TRUE);
-    slcdCursor(fd, FALSE);
-    slcdCursorBlink(fd, FALSE);
-    slcdClear(fd);
+    slcdDisplay(dlg, fd, TRUE);
+    slcdCursor(dlg, fd, FALSE);
+    slcdCursorBlink(dlg, fd, FALSE);
+    slcdClear(dlg, fd);
 
     /*
      * Most LCD's start with the top row filled with blocks.
      */
     for (i = 0; i < lcd->cols; i++)
-	slcdPutchar(fd, 0x0ff);
+	slcdPutchar(dlg, fd, 0x0ff);
 
-    slcdDisplay(fd, TRUE);
-    slcdCursor(fd, FALSE);
-    slcdCursorBlink(fd, FALSE);
-    slcdClear(fd);
+    slcdDisplay(dlg, fd, TRUE);
+    slcdCursor(dlg, fd, FALSE);
+    slcdCursorBlink(dlg, fd, FALSE);
+    slcdClear(dlg, fd);
 
     return fd;
 }
--- a/brewpanel/slcd.h	Thu Nov 19 22:50:17 2015 +0100
+++ b/brewpanel/slcd.h	Fri Nov 20 20:49:58 2015 +0100
@@ -4,20 +4,21 @@
 
 #define	MAX_SLCDS	8
 
-void slcdHome        (int fd) ;
-void slcdClear       (int fd) ;
-void slcdDisplay     (int fd, int state) ;
-void slcdCursor      (int fd, int state) ;
-void slcdCursorBlink (int fd, int state) ;
-void slcdSendCommand (int fd, unsigned char command) ;
-void slcdPosition    (int fd, int x, int y) ;
-void slcdCharDef     (int fd, int index, unsigned char data [8]) ;
-void slcdPutchar     (int fd, unsigned char data) ;
-void slcdPuts        (int fd, const char *string) ;
-void slcdPrintf      (int fd, const char *message, ...) ;
-void slcdBacklight   (int fd, int bl);
+void slcdHome        (SGOBJ *dlg, int fd) ;
+void slcdClear       (SGOBJ *dlg, int fd) ;
+void slcdDisplay     (SGOBJ *dlg, int fd, int state) ;
+void slcdCursor      (SGOBJ *dlg, int fd, int state) ;
+void slcdCursorBlink (SGOBJ *dlg, int fd, int state) ;
+void slcdSendCommand (SGOBJ *dlg, int fd, unsigned char command) ;
+void slcdPosition    (SGOBJ *dlg, int fd, int x, int y) ;
+void slcdCharDef     (SGOBJ *dlg, int fd, int index, unsigned char data [8]) ;
+void slcdPutchar     (SGOBJ *dlg, int fd, unsigned char data) ;
+void slcdPuts        (SGOBJ *dlg, int fd, const char *string) ;
+void slcdPrintf      (SGOBJ *dlg, int fd, const char *message, ...) ;
+void slcdBacklight   (SGOBJ *dlg, int fd, int bl);
+void slcdLED         (SGOBJ *dlg, int fd, int color, int state);
 
-int  slcdInit        (int fd, int x, int y, int w, int h, int cols, int rows) ;
+int  slcdInit        (SGOBJ *dlg, int fd, int x, int y, int w, int h, int cols, int rows) ;
 
 
 #endif
--- a/brewpanel/sockio.c	Thu Nov 19 22:50:17 2015 +0100
+++ b/brewpanel/sockio.c	Fri Nov 20 20:49:58 2015 +0100
@@ -21,6 +21,7 @@
  *****************************************************************************/
 
 #include "brewpanel.h"
+#include "sdlgui.h"
 #include "slcd.h"
 #include "futil.h"
 #include "sockio.h"
@@ -33,7 +34,7 @@
 uint16_t		keys = SLCD_KEYS;	/* Pressed keys bits		*/
 
 
-void socket_recv(void)
+void socket_recv(SGOBJ *dlg)
 {
     uint16_t		data;
     struct sockaddr_in	clntaddr;
@@ -50,18 +51,20 @@
 	if (fd)
 	    fprintf(stdout, "Device %d ", fd);
 	if ((data & SLCD_MCLEAR) == SLCD_CLEAR) {
-	    slcdClear(fd);
+	    slcdClear(dlg, fd);
 	} else if ((data & SLCD_MHOME) == SLCD_HOME) {
-	    slcdHome(fd);
+	    slcdHome(dlg, fd);
 	} else if ((data & SLCD_MDGRAM) == SLCD_DGRAM) {
-	    slcdPosition(fd, data & 0x001f, (data & 0x0060) >> 5);
+	    slcdPosition(dlg, fd, data & 0x001f, (data & 0x0060) >> 5);
 	} else if ((data & 0xfe00) == SLCD_DATA) {
-	    slcdPutchar(fd, data & 0x00ff);
+	    slcdPutchar(dlg, fd, data & 0x00ff);
 	} else if ((data & SLCD_MLEDS) == SLCD_LEDS) {
 	    fprintf(stdout, "socket_recv leds fd=%d bits=%02x\n", fd, (data & 0x00ff));
-	    // SLED_LCD backlight
-	    // SLED_TFLED red led
-	    slcdBacklight(fd, data & SLED_LCD);
+	    slcdBacklight(dlg, fd, data & SLED_LCD);
+	    slcdLED(dlg, fd, SGLEDGREEN,  data & SLED_TFLED);
+	    slcdLED(dlg, fd, SGLEDRED,    data & SLED_HLTH);
+	    slcdLED(dlg, fd, SGLEDBLUE,   data & SLED_MLTH);
+	    slcdLED(dlg, fd, SGLEDYELLOW, data & SLED_MLTP);
 
 	} else if (data != 0x0000) {
 	    fprintf(stdout, "socket_recv got %04x\n", data);
--- a/brewpanel/sockio.h	Thu Nov 19 22:50:17 2015 +0100
+++ b/brewpanel/sockio.h	Fri Nov 20 20:49:58 2015 +0100
@@ -3,7 +3,7 @@
 #ifdef	HAVE_SDL_SDL_H
 
 
-void socket_recv(void);
+void socket_recv(SGOBJ *dlg);
 int  socket_connect(void);
 
 

mercurial