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