# HG changeset patch # User Michiel Broek # Date 1447969817 -3600 # Node ID e8e548922e3159ca95cb5665a882104b269a0b0c # Parent e54611453d297805500c0b920e6ca9efc251f85f Initial part of LEDs and backlight implemented. diff -r e54611453d29 -r e8e548922e31 brewpanel/dlgBrew.c --- a/brewpanel/dlgBrew.c Thu Nov 19 21:17:26 2015 +0100 +++ b/brewpanel/dlgBrew.c Thu Nov 19 22:50:17 2015 +0100 @@ -111,7 +111,7 @@ maindlg[7].y = 153; maindlg[7].w = 12; maindlg[8].txt = (char *)""; - maindlg[11].type = -1; + maindlg[12].type = -1; } SDLGui_CenterDlg(maindlg); diff -r e54611453d29 -r e8e548922e31 brewpanel/sdlgui.c --- a/brewpanel/sdlgui.c Thu Nov 19 21:17:26 2015 +0100 +++ b/brewpanel/sdlgui.c Thu Nov 19 22:50:17 2015 +0100 @@ -38,6 +38,8 @@ static SDL_Rect dlgrect, bgrect; static int fontwidth, fontheight; /* Width & height of the actual font */ TTF_Font *pFont = NULL; /* TTF font for buttons etc. */ +static Uint32 LCDbg0 = 0; /* LCD background dark */ +static Uint32 LCDbg1 = 0; /* LCD background light */ extern int my_shutdown; @@ -251,9 +253,9 @@ Uint32 bg; if (bLight) - bg = SDL_MapRGB(pSdlGuiScrn->format,156,235, 4); + bg = LCDbg1; else - bg = SDL_MapRGB(pSdlGuiScrn->format, 94,147, 69); + bg = LCDbg0; sr.x=fontwidth*(c%16); sr.y=fontheight*(c/16); @@ -317,11 +319,11 @@ { SDL_Rect rect; int x, y, w, h, offset, border = 4; - Uint32 bg0 = SDL_MapRGB(pSdlGuiScrn->format, 94,147, 69); - Uint32 bg1 = SDL_MapRGB(pSdlGuiScrn->format,156,235, 4); Uint32 bc = SDL_MapRGB(pSdlGuiScrn->format, 32, 32, 32); Uint32 bg; + LCDbg0 = SDL_MapRGB(pSdlGuiScrn->format, 94,147, 69); + LCDbg1 = SDL_MapRGB(pSdlGuiScrn->format,156,235, 4); /* * Width and height are given in character columns and rows, * so calculate the display size in pixels. @@ -345,9 +347,9 @@ } if (bdlg[objnum].state & SG_SELECTED) { - bg = bg1; + bg = LCDbg1; } else { - bg = bg0; + bg = LCDbg0; } /* The root box should be bigger than the screen, so we disable the offset there: */ diff -r e54611453d29 -r e8e548922e31 brewpanel/slcd.c --- a/brewpanel/slcd.c Thu Nov 19 21:17:26 2015 +0100 +++ b/brewpanel/slcd.c Thu Nov 19 22:50:17 2015 +0100 @@ -50,6 +50,7 @@ int cy; /* Cursor y position */ Uint8 cgram[8][8]; /* Characters in CGRAM */ int control; /* Control register */ + int backlight; /* Backlight */ }; struct slcdDataStruct *slcds [MAX_SLCDS] ; @@ -150,7 +151,7 @@ { struct slcdDataStruct *lcd = slcds [fd]; - SDLGui_Char(lcd->x + (lcd->cx * 12) + 12, lcd->y + (lcd->cy * 18) + 8, data, 0); + SDLGui_Char(lcd->x + (lcd->cx * 12) + 12, lcd->y + (lcd->cy * 18) + 8, data, lcd->backlight); if (++lcd->cx == lcd->cols) { lcd->cx = 0; @@ -183,6 +184,15 @@ +void slcdBacklight(int fd, int bl) +{ + struct slcdDataStruct *lcd = slcds [fd]; + + lcd->backlight = bl; +} + + + int slcdInit(int fd, int x, int y, int w, int h, int cols, int rows) { static int initialised = 0; @@ -224,6 +234,7 @@ for (j = 0; j < 8; j++) lcd->cgram[i][j] = 0; lcd->control = 0; + lcd->backlight = 0; slcds[fd] = lcd; diff -r e54611453d29 -r e8e548922e31 brewpanel/slcd.h --- a/brewpanel/slcd.h Thu Nov 19 21:17:26 2015 +0100 +++ b/brewpanel/slcd.h Thu Nov 19 22:50:17 2015 +0100 @@ -15,6 +15,7 @@ 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); int slcdInit (int fd, int x, int y, int w, int h, int cols, int rows) ; diff -r e54611453d29 -r e8e548922e31 brewpanel/sockio.c --- a/brewpanel/sockio.c Thu Nov 19 21:17:26 2015 +0100 +++ b/brewpanel/sockio.c Thu Nov 19 22:50:17 2015 +0100 @@ -57,6 +57,12 @@ slcdPosition(fd, data & 0x001f, (data & 0x0060) >> 5); } else if ((data & 0xfe00) == SLCD_DATA) { slcdPutchar(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); + } else if (data != 0x0000) { fprintf(stdout, "socket_recv got %04x\n", data); } diff -r e54611453d29 -r e8e548922e31 thermferm/panel.c --- a/thermferm/panel.c Thu Nov 19 21:17:26 2015 +0100 +++ b/thermferm/panel.c Thu Nov 19 22:50:17 2015 +0100 @@ -49,6 +49,8 @@ extern int debug; extern int setupmenu; extern uint16_t keys; +extern uint16_t leds; +extern int slcdHandle; int Key_Enter = FALSE; int Key_Enter_Long = FALSE; @@ -137,12 +139,20 @@ Key_Enter = TRUE; if (Enter > PRESS_LONG) Key_Enter_Long = TRUE; + if (Enter == PRESS_LONG) { #ifdef HAVE_WIRINGPI_H - if (Enter == PRESS_LONG) digitalWrite(PANEL_LED, 1); - if (Enter == (PRESS_LONG + 10)) +#endif + leds |= SLED_TFLED; + slcdLEDs(slcdHandle); + } + if (Enter == (PRESS_LONG + 10)) { +#ifdef HAVE_WIRINGPI_H digitalWrite(PANEL_LED, 0); #endif + leds &= ~SLED_TFLED; + slcdLEDs(slcdHandle); + } } #ifdef HAVE_WIRINGPI_H diff -r e54611453d29 -r e8e548922e31 thermferm/slcd.c --- a/thermferm/slcd.c Thu Nov 19 21:17:26 2015 +0100 +++ b/thermferm/slcd.c Thu Nov 19 22:50:17 2015 +0100 @@ -31,6 +31,7 @@ int sock = -1; uint16_t keys = 0x0000; uint16_t leds = 0x0400; /* LED's, buzzer, LCD backlight */ +uint16_t oleds = 0x0400; extern int debug; @@ -81,7 +82,9 @@ void slcdLEDs(int fd) { - putLCDsocket(fd, leds); + if (leds != oleds) + putLCDsocket(fd, leds); + oleds = leds; }