diff -r e8e548922e31 -r d64c4c1edd78 brewpanel/slcd.c --- 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; }