thermferm/thermferm.c

changeset 669
daa22055cd3d
parent 667
bba6ca418e09
child 675
825210ba2707
equal deleted inserted replaced
668:4df4c8b17733 669:daa22055cd3d
391 slcdPuts(slcdHandle, "Halt system"); 391 slcdPuts(slcdHandle, "Halt system");
392 break; 392 break;
393 393
394 case MENU_SYS_REBOOT: 394 case MENU_SYS_REBOOT:
395 #ifdef HAVE_WIRINGPI_H 395 #ifdef HAVE_WIRINGPI_H
396 lcdPuts(lcdHandle, "Reboot system"); 396 lcdPuts(lcdHandle, "Restart app.");
397 #endif 397 #endif
398 slcdPuts(slcdHandle, "Reboot system"); 398 slcdPuts(slcdHandle, "Restart app.");
399 break; 399 break;
400 } 400 }
401 401
402 pthread_mutex_unlock(&mutexes[LOCK_MENU]); 402 pthread_mutex_unlock(&mutexes[LOCK_MENU]);
403 pthread_mutex_unlock(&mutexes[LOCK_LCD]); 403 pthread_mutex_unlock(&mutexes[LOCK_LCD]);
872 if (key == KEY_ESCAPE) 872 if (key == KEY_ESCAPE)
873 go_menu(MENU_TOP_SYS); 873 go_menu(MENU_TOP_SYS);
874 if ((key == KEY_DOWN) || (key == KEY_UP)) 874 if ((key == KEY_DOWN) || (key == KEY_UP))
875 go_menu(MENU_SYS_HALT); 875 go_menu(MENU_SYS_HALT);
876 if (key == KEY_CONFIRM) { 876 if (key == KEY_CONFIRM) {
877 rc = system("/sbin/reboot"); 877 /*
878 syslog(LOG_NOTICE, "System reboot from panel: /sbin/reboot rc=%d", rc); 878 * Restart. The server process will restart which is handled
879 * in the main thread loop.
880 */
881 my_reboot = my_shutdown = TRUE;
882 syslog(LOG_NOTICE, "Application restart from panel");
879 go_menu(MENU_NONE); 883 go_menu(MENU_NONE);
880 } 884 }
881 break; 885 break;
882 } 886 }
883 } 887 }
940 #endif 944 #endif
941 945
942 #ifdef USE_SIMULATOR 946 #ifdef USE_SIMULATOR
943 syslog(LOG_NOTICE, "Build with simulator"); 947 syslog(LOG_NOTICE, "Build with simulator");
944 #endif 948 #endif
945
946 if ((rc = initLCD (Config.lcd_cols, Config.lcd_rows))) {
947 fprintf(stderr, "Cannot initialize LCD display, rc=%d\n", rc);
948 return 1;
949 }
950
951 #ifdef HAVE_WIRINGPI_H
952 lcdCharDef(lcdHandle, 1, degC);
953 lcdCharDef(lcdHandle, 2, SP_Symbol);
954 lcdCharDef(lcdHandle, 3, CoolONOFF);
955 lcdCharDef(lcdHandle, 4, RevCoolONOFF);
956 lcdCharDef(lcdHandle, 5, HeatONOFF);
957 lcdCharDef(lcdHandle, 6, RevHeatONOFF);
958 #endif
959 slcdCharDef(slcdHandle, 1, degC);
960 slcdCharDef(slcdHandle, 2, SP_Symbol);
961 slcdCharDef(slcdHandle, 3, CoolONOFF);
962 slcdCharDef(slcdHandle, 4, RevCoolONOFF);
963 slcdCharDef(slcdHandle, 5, HeatONOFF);
964 slcdCharDef(slcdHandle, 6, RevHeatONOFF);
965 949
966 if (foreground) { 950 if (foreground) {
967 /* 951 /*
968 * Run in foreground. 952 * Run in foreground.
969 */ 953 */
1871 units_list *unit; 1855 units_list *unit;
1872 int rc; 1856 int rc;
1873 long t = 0; 1857 long t = 0;
1874 1858
1875 syslog(LOG_NOTICE, "Server process started"); 1859 syslog(LOG_NOTICE, "Server process started");
1860
1861 if ((rc = initLCD (Config.lcd_cols, Config.lcd_rows))) {
1862 fprintf(stderr, "Cannot initialize LCD display, rc=%d\n", rc);
1863 return 1;
1864 }
1865
1866 #ifdef HAVE_WIRINGPI_H
1867 lcdCharDef(lcdHandle, 1, degC);
1868 lcdCharDef(lcdHandle, 2, SP_Symbol);
1869 lcdCharDef(lcdHandle, 3, CoolONOFF);
1870 lcdCharDef(lcdHandle, 4, RevCoolONOFF);
1871 lcdCharDef(lcdHandle, 5, HeatONOFF);
1872 lcdCharDef(lcdHandle, 6, RevHeatONOFF);
1873 #endif
1874 slcdCharDef(slcdHandle, 1, degC);
1875 slcdCharDef(slcdHandle, 2, SP_Symbol);
1876 slcdCharDef(slcdHandle, 3, CoolONOFF);
1877 slcdCharDef(slcdHandle, 4, RevCoolONOFF);
1878 slcdCharDef(slcdHandle, 5, HeatONOFF);
1879 slcdCharDef(slcdHandle, 6, RevHeatONOFF);
1880
1876 my_shutdown = my_reboot = FALSE; 1881 my_shutdown = my_reboot = FALSE;
1882 my_devices_shutdown = my_panel_shutdown = my_server_shutdown = my_one_wire_shutdown = 0;
1883 my_devices_state = my_panel_state = my_server_state = my_one_wire_state = 0;
1884 my_simulator_state = 0;
1885 #ifdef USE_SIMULATOR
1886 my_simulator_shutdown = 0;
1887 #endif
1877 if (lockprog((char *)"thermferm")) { 1888 if (lockprog((char *)"thermferm")) {
1878 syslog(LOG_NOTICE, "Can't lock"); 1889 syslog(LOG_NOTICE, "Can't lock");
1879 return 1; 1890 return 1;
1880 } 1891 }
1881 mqtt_connect(); 1892 mqtt_connect();

mercurial