Monitoring du Phytotron
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

minidigits.c 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. * DD2 Monitoring
  3. *
  4. * mini digits
  5. */
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include <string.h>
  9. #include <time.h>
  10. #include <ctype.h>
  11. #include <getopt.h>
  12. #include <ncurses.h>
  13. #include "ecran.h"
  14. extern int verbosity;
  15. /* ---------------------------------------------------------------- */
  16. static void makedot(WINDOW *win, int li, int col, int ch)
  17. {
  18. if ('_'==ch) {
  19. mvwaddch(win, li, col, ' ');
  20. mvwaddch(win, li, col+1, ' ');
  21. }
  22. else {
  23. wstandout(win);
  24. mvwaddch(win, li, col, ' ');
  25. mvwaddch(win, li, col+1, ' ');
  26. wstandend(win);
  27. }
  28. }
  29. /* ---------------------------------------------------------------- */
  30. int minidigit_0(WINDOW *win, int lig, int col, char digit, int k)
  31. {
  32. static char LX[] = "_X_X_X_X_X_X_X_";
  33. static char L0[] = "XXXX_XX_XX_XXXX";
  34. static char L1[] = "_X__X__X__X__X_";
  35. static char L2[] = "XXX__XXXXX__XXX";
  36. static char L3[] = "XXX__XXXX__XXXX";
  37. static char L4[] = "X_XX_XXXX__X__X";
  38. static char L5[] = "XXXX__XXX__XXXX";
  39. static char L6[] = "XXXX__XXXX_XXXX";
  40. static char L7[] = "XXX__X__X__X__X";
  41. static char L8[] = "XXXX_XXXXX_XXXX";
  42. static char L9[] = "XXXX_XXXX__XXXX";
  43. static char Lsp[] = "_______________"; /* space */
  44. static char Lmo[] = "______XXX______"; /* moins */
  45. static char Lco[] = "____X_____X____"; /* colomn */
  46. static char Ldp[] = "_____________X_"; /* decimal dot */
  47. char *cptr;
  48. int l, c;
  49. switch (digit) {
  50. case '0': cptr = L0; break;
  51. case '1': cptr = L1; break;
  52. case '2': cptr = L2; break;
  53. case '3': cptr = L3; break;
  54. case '4': cptr = L4; break;
  55. case '5': cptr = L5; break;
  56. case '6': cptr = L6; break;
  57. case '7': cptr = L7; break;
  58. case '8': cptr = L8; break;
  59. case '9': cptr = L9; break;
  60. case ' ': cptr = Lsp; break;
  61. case '-': cptr = Lmo; break;
  62. case ':': cptr = Lco; break;
  63. case '.': cptr = Ldp; break;
  64. default: cptr = LX; break;
  65. }
  66. for (l=0; l<5; l++) {
  67. for (c=0; c<3; c++) {
  68. makedot(win, l+lig, (c*2)+col, *cptr++);
  69. }
  70. }
  71. wrefresh(win);
  72. return 0;
  73. }
  74. /* ---------------------------------------------------------------- */
  75. int minidigit_HMS(WINDOW *win, int lig, int col, int k)
  76. {
  77. int foo;
  78. char chaine[20];
  79. struct tm *p_tms;
  80. time_t temps;
  81. temps = time(NULL);
  82. p_tms = localtime(&temps);
  83. (void)strftime(chaine, 19, "%H:%M:%S", p_tms);
  84. for (foo=0; foo<strlen(chaine); foo++) {
  85. minidigit_0(stdscr, lig, col+foo*8, chaine[foo], 0);
  86. }
  87. return 0;
  88. }
  89. /* ---------------------------------------------------------------- */