# HG changeset patch # User Michiel Broek # Date 1448461828 -3600 # Node ID b3895cd6edd358a867f68c9d74fb5b65ad7d4522 # Parent 36ecc8bbb75d1c68bd9aec68ac0de1549b4e44cc Finished optional paneltype. Fixed all debug flags. diff -r 36ecc8bbb75d -r b3895cd6edd3 brewpanel/brewpanel.c --- a/brewpanel/brewpanel.c Fri Nov 20 23:29:55 2015 +0100 +++ b/brewpanel/brewpanel.c Wed Nov 25 15:30:28 2015 +0100 @@ -26,7 +26,6 @@ #ifdef HAVE_SDL_SDL_H -int DebugPanel = FALSE; /* Logfile debugging */ int debug = FALSE; /* Console debugging */ int my_shutdown = FALSE; /* Shutdown requested */ char *Paneltype = NULL; /* Panel to emulate */ @@ -44,7 +43,7 @@ fprintf(stdout, "Usage: brewpanel [-d] [-h] [-p ]\n"); fprintf(stdout, " -d --debug Debug on\n"); fprintf(stdout, " -h --help Display this help\n"); - fprintf(stdout, " -p --paneltype Select machine, default last used\n"); + fprintf(stdout, " -p --paneltype Select panel type\n"); } @@ -92,7 +91,7 @@ break; switch (c) { - case 'd': DebugPanel = TRUE; + case 'd': debug = TRUE; break; case 'h': help(); return 1; @@ -138,7 +137,8 @@ PAN_x = 384; PAN_y = 480; -fprintf(stdout, "Screen max X*Y: %d*%d panel X*Y: %d*%d\n", max_x, max_y, PAN_x, PAN_y); + if (debug) + fprintf(stdout, "Screen max X*Y: %d*%d panel X*Y: %d*%d\n", max_x, max_y, PAN_x, PAN_y); PAN_surface = SDL_SetVideoMode( PAN_x, PAN_y, 32, SDL_SWSURFACE|SDL_DOUBLEBUF ); if (PAN_surface == NULL) { @@ -151,7 +151,11 @@ SDL_WM_SetCaption(title, NULL); syslog(LOG_NOTICE, "Starting mainloop"); - Dialog_BrewDlg(1); + if (strlen(Paneltype) && !strcmp(Paneltype, (char *)"ferm") ) { + Dialog_BrewDlg(1); + } else { + Dialog_BrewDlg(0); + } syslog(LOG_NOTICE, "Out of mainloop, cleanup"); SDLGui_UnInit(); diff -r 36ecc8bbb75d -r b3895cd6edd3 brewpanel/dlgBrew.c --- a/brewpanel/dlgBrew.c Fri Nov 20 23:29:55 2015 +0100 +++ b/brewpanel/dlgBrew.c Wed Nov 25 15:30:28 2015 +0100 @@ -34,6 +34,7 @@ extern SDL_Surface *PAN_surface; extern int my_shutdown; +extern int debug; extern uint16_t keys; @@ -122,13 +123,13 @@ SDLGui_CenterDlg(maindlg); SDLGui_DoDialogInit(maindlg); 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); + if (debug) + fprintf(stdout, "Dialog_LCDinit(%d, %d, %d, %d, %d, %d, 0) = %d\n", x, y, w, h, cols, rows, fd); socket_connect(); slcdInit(maindlg, fd, x, y, w, h, cols, rows); do { retbut = SDLGui_DoDialogLoop(maindlg); -// fprintf(stdout, "SDLGui_DoDialog retbut=%d\n", retbut); switch (retbut) { case MAINDLG_B1 + 1000: diff -r 36ecc8bbb75d -r b3895cd6edd3 brewpanel/sdlgui.c --- a/brewpanel/sdlgui.c Fri Nov 20 23:29:55 2015 +0100 +++ b/brewpanel/sdlgui.c Wed Nov 25 15:30:28 2015 +0100 @@ -42,7 +42,7 @@ static Uint32 LCDbg1 = 0; /* LCD background light */ extern int my_shutdown; - +extern int debug; /*-----------------------------------------------------------------------*/ @@ -614,6 +614,7 @@ for (i = 0; dlg[i].type != -1; i++) { if (dlg[i].type == LED) { + if (debug) fprintf(stdout, "SDLGui_LED LED=%d on=%d\n", LED, on); if (on) { dlg[i].state |= SG_SELECTED; @@ -862,7 +863,8 @@ } i++; } - fprintf(stdout, "SDLGui_LCDinit=%d LCD=%dx%d %dx%d\n", i, dlg[i].x, dlg[i].y, dlg[i].w, dlg[i].h); + if (debug) + fprintf(stdout, "SDLGui_LCDinit=%d LCD=%dx%d %dx%d\n", i, dlg[i].x, dlg[i].y, dlg[i].w, dlg[i].h); *cols = dlg[i].w; *rows = dlg[i].h; diff -r 36ecc8bbb75d -r b3895cd6edd3 brewpanel/slcd.c --- a/brewpanel/slcd.c Fri Nov 20 23:29:55 2015 +0100 +++ b/brewpanel/slcd.c Wed Nov 25 15:30:28 2015 +0100 @@ -37,6 +37,8 @@ #define SLCD_CURSOR_CTRL 0x02 #define SLCD_DISPLAY_CTRL 0x04 +extern int debug; + struct slcdDataStruct { @@ -185,7 +187,8 @@ void slcdBacklight(SGOBJ *dlg, int fd, int bl) { - fprintf(stdout, "slcdBacklight %d\n", bl); + if (debug) + fprintf(stdout, "slcdBacklight %d\n", bl); if (bl) dlg[1].state |= SG_SELECTED; else diff -r 36ecc8bbb75d -r b3895cd6edd3 brewpanel/sockio.c --- a/brewpanel/sockio.c Fri Nov 20 23:29:55 2015 +0100 +++ b/brewpanel/sockio.c Wed Nov 25 15:30:28 2015 +0100 @@ -32,6 +32,7 @@ int sock = -1; /* Unix datagram socket */ struct sockaddr_in servaddr; /* Server socket address */ uint16_t keys = SLCD_KEYS; /* Pressed keys bits */ +extern int debug; void socket_recv(SGOBJ *dlg) @@ -48,7 +49,7 @@ * Get device from data */ fd = (data & SLCD_MDEV) >> 13; - if (fd) + if (fd && debug) fprintf(stdout, "Device %d ", fd); if ((data & SLCD_MCLEAR) == SLCD_CLEAR) { slcdClear(dlg, fd); @@ -59,7 +60,8 @@ } else if ((data & 0xfe00) == SLCD_DATA) { 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)); + if (debug) + fprintf(stdout, "socket_recv leds fd=%d bits=%02x\n", fd, (data & 0x00ff)); slcdBacklight(dlg, fd, data & SLED_LCD); slcdLED(dlg, fd, SGLEDGREEN, data & SLED_TFLED); slcdLED(dlg, fd, SGLEDRED, data & SLED_HLTH); @@ -67,22 +69,23 @@ slcdLED(dlg, fd, SGLEDYELLOW, data & SLED_MLTP); } else if (data != 0x0000) { - fprintf(stdout, "socket_recv got %04x\n", data); + if (debug) + fprintf(stdout, "socket_recv got %04x\n", data); } /* * Reply with the current keys state */ if (sendto(sock, &keys, sizeof(uint16_t), MSG_DONTWAIT, (struct sockaddr *) &clntaddr, clntlen) == -1) { - fprintf(stdout, "sendto error: %s\n", strerror(errno)); + syslog(LOG_NOTICE, "socket_recv() sendto error: %s", strerror(errno)); } } else if (recv_len < 0) { my_error = errno; if (my_error != EAGAIN) { - fprintf(stdout, "socket_recv error: %s", strerror(my_error)); + syslog(LOG_NOTICE, "socket_recv() error: %s", strerror(my_error)); } } else { - fprintf(stdout, "socket_recv unknown len=%d\n", (int)recv_len); + syslog(LOG_NOTICE, "socket_recv() unknown len=%d", (int)recv_len); } }