thermferm/thermferm.c

changeset 205
ca18ff45deba
parent 204
9a14d6b2de7f
child 206
78fb6f99e473
equal deleted inserted replaced
204:9a14d6b2de7f 205:ca18ff45deba
35 35
36 char *current_unit = NULL; 36 char *current_unit = NULL;
37 int tempA = 80; 37 int tempA = 80;
38 int tempB = 80; 38 int tempB = 80;
39 39
40 key_t key = 5680; /* key to be passed to shmget() */
41 int shmid;
42
43 int my_shutdown = FALSE; 40 int my_shutdown = FALSE;
44 static pid_t pgrp, mypid; 41 static pid_t pgrp, mypid;
45 42
46 extern int debug; 43 extern int debug;
47 extern sys_config Config; 44 extern sys_config Config;
48 #ifdef HAVE_WIRINGPI_H 45 #ifdef HAVE_WIRINGPI_H
49 extern int lcdHandle; 46 extern int lcdHandle;
50 extern unsigned char lcdbuf[MAX_LCDS][20][4]; 47 extern unsigned char lcdbuf[MAX_LCDS][20][4];
48 int setupmenu = MENU_NONE;
49
51 #endif 50 #endif
52 int lcdupdate; 51 int lcdupdate;
53 #ifndef HAVE_WIRINGPI_H 52 #ifndef HAVE_WIRINGPI_H
54 pthread_t threads[4]; 53 pthread_t threads[4];
55 #endif 54 #endif
255 int rc, run = 1, seconds = 0, minutes = 0, piddelay = 0, temp, deviation; 254 int rc, run = 1, seconds = 0, minutes = 0, piddelay = 0, temp, deviation;
256 int run_seconds, run_minutes, run_hours; 255 int run_seconds, run_minutes, run_hours;
257 float err = 0.0, sp, pv, P_err, D_err, Out; 256 float err = 0.0, sp, pv, P_err, D_err, Out;
258 #ifdef HAVE_WIRINGPI_H 257 #ifdef HAVE_WIRINGPI_H
259 struct tm *tm; 258 struct tm *tm;
260 int row; 259 int row, key;
261 #else 260 #else
262 long t = 0; 261 long t = 0;
263 #endif 262 #endif
264 263
265 if (lockprog((char *)"thermferm")) { 264 if (lockprog((char *)"thermferm")) {
563 } 562 }
564 } 563 }
565 } 564 }
566 565
567 #ifdef HAVE_WIRINGPI_H 566 #ifdef HAVE_WIRINGPI_H
568 lcd_buf_show(); 567 if (setupmenu == MENU_NONE)
569 #endif 568 lcd_buf_show();
569 #endif
570
570 if (seconds == 60) { 571 if (seconds == 60) {
571 seconds = 0; 572 seconds = 0;
572 573
573 /* 574 /*
574 * Log temperature and status every minute if unit is active. 575 * Log temperature and status every minute if unit is active.
623 } 624 }
624 } 625 }
625 } 626 }
626 627
627 #ifdef HAVE_WIRINGPI_H 628 #ifdef HAVE_WIRINGPI_H
628 // FIXME: not in editmode. 629 /*
629 lcd_buf_step(); 630 * Handle panel key events.
631 */
632 key = keycheck();
633
634 switch (setupmenu) {
635 case MENU_NONE:
636 if ((key == KEY_DOWN) || (key == KEY_UP))
637 lcd_buf_step(key);
638 if ((key == KEY_CONFIRM) && (setupmenu == MENU_NONE)) {
639 setupmenu = MENU_TOP;
640 mb_lcdClear(lcdHandle);
641 lcdPosition(lcdHandle, 0, 0);
642 mb_lcdPuts(lcdHandle, "Setup mode.");
643 lcdPosition(lcdHandle, 0, 1);
644 mb_lcdPuts(lcdHandle, "Up&Down = Escape");
645 }
646 break;
647
648 case MENU_TOP:
649 if (key == KEY_ESCAPE) {
650 setupmenu = MENU_NONE;
651 lcd_buf_show();
652 }
653 break;
654 }
655
630 #endif 656 #endif
631 657
632 usleep(100000); 658 usleep(100000);
633 659
634 } while (run); 660 } while (run);

mercurial