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.

vumetre.c 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * DD2 Monitoring
  3. *
  4. * ncurses seven segment display
  5. */
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include <strings.h>
  9. #include <getopt.h>
  10. #include <ncurses.h>
  11. #include "ecran.h"
  12. extern int verbosity;
  13. /* ---------------------------------------------------------------- */
  14. int vumetre_0(WINDOW *win, int lig, int col, float val, int larg)
  15. {
  16. int foo, posc, c;
  17. char ligne[100];
  18. #if DEBUG_LEVEL
  19. fprintf(stderr, ">>> %s ( %p %d %d %f %d )\n",
  20. __func__, win, lig, col, val, larg);
  21. #endif
  22. posc = (int)(val * (float)(larg-5));
  23. sprintf(ligne, "%6.3f", val);
  24. mvwaddstr(win, lig, 0, ligne);
  25. for (foo=0; foo<larg; foo++) {
  26. c = col + foo + 2;
  27. if (foo<posc) {
  28. wstandout(win);
  29. mvwaddch(win, lig, c, '#');
  30. wstandend(win);
  31. }
  32. else {
  33. mvwaddch(win, lig, c, ' ');
  34. }
  35. if (!(foo%4)) {
  36. mvwaddch(win, lig-1, c, '\\');
  37. mvwaddch(win, lig+1, c, '/');
  38. }
  39. }
  40. wrefresh(win);
  41. return 0;
  42. }
  43. /* ---------------------------------------------------------------- */
  44. int vumetre_1(WINDOW *win, int lig, int col, float val, int larg)
  45. {
  46. int foo, posc;
  47. char ligne[100];
  48. #if DEBUG_LEVEL
  49. fprintf(stderr, ">>> %s ( %p %d %d %f %d )\n",
  50. __func__, win, lig, col, val, larg);
  51. #endif
  52. posc = (int)(val * (float)larg);
  53. sprintf(ligne, "%6.3f", val);
  54. mvwaddstr(win, lig, 2, ligne);
  55. for (foo=0; foo<larg; foo++) {
  56. if (foo < posc) {
  57. wstandout(win);
  58. mvwaddch(win, lig, col+foo, '|');
  59. wstandend(win);
  60. }
  61. else {
  62. mvwaddch(win, lig, col+foo, '|');
  63. }
  64. if (foo & 2) {
  65. mvwaddch(win, lig-1, col+foo, '|');
  66. mvwaddch(win, lig+1, col+foo, '|');
  67. }
  68. }
  69. wrefresh(win);
  70. return 0;
  71. }
  72. /* ---------------------------------------------------------------- */
  73. /* ---------------------------------------------------------------- */