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 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * DD2 Monitoring
  3. *
  4. * ncurses linear vumeter display
  5. */
  6. /**********************************************************************
  7. DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
  8. Version 2, December 2004
  9. Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
  10. Everyone is permitted to copy and distribute verbatim or modified
  11. copies of this license document, and changing it is allowed as long
  12. as the name is changed.
  13. DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
  14. TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
  15. 0. You just DO WHAT THE FUCK YOU WANT TO.
  16. **********************************************************************/
  17. #include <stdio.h>
  18. #include <stdlib.h>
  19. #include <strings.h>
  20. #include <getopt.h>
  21. #include <ncurses.h>
  22. #include "ecran.h"
  23. extern int verbosity;
  24. /* ---------------------------------------------------------------- */
  25. int vumetre_0(WINDOW *win, int lig, int col, float val, int larg)
  26. {
  27. int foo, posc, c;
  28. char ligne[100];
  29. #if DEBUG_LEVEL
  30. fprintf(stderr, ">>> %s ( %p %d %d %f %d )\n",
  31. __func__, win, lig, col, val, larg);
  32. #endif
  33. posc = (int)(val * (float)(larg-5));
  34. sprintf(ligne, "%6.3f", val);
  35. mvwaddstr(win, lig, 0, ligne);
  36. for (foo=0; foo<larg; foo++) {
  37. c = col + foo + 2;
  38. if (foo<posc) {
  39. wstandout(win);
  40. mvwaddch(win, lig, c, '#');
  41. wstandend(win);
  42. }
  43. else {
  44. mvwaddch(win, lig, c, ' ');
  45. }
  46. if (!(foo%4)) {
  47. mvwaddch(win, lig-1, c, '\\');
  48. mvwaddch(win, lig+1, c, '/');
  49. }
  50. }
  51. wrefresh(win);
  52. return 0;
  53. }
  54. /* ---------------------------------------------------------------- */
  55. int vumetre_1(WINDOW *win, int lig, int col, float val, int larg)
  56. {
  57. int foo, posc;
  58. char ligne[100];
  59. #if DEBUG_LEVEL
  60. fprintf(stderr, ">>> %s ( %p %d %d %f %d )\n",
  61. __func__, win, lig, col, val, larg);
  62. #endif
  63. posc = (int)(val * (float)larg);
  64. sprintf(ligne, "%6.3f", val);
  65. mvwaddstr(win, lig, 2, ligne);
  66. for (foo=0; foo<larg; foo++) {
  67. if (foo < posc) {
  68. wstandout(win);
  69. mvwaddch(win, lig, col+foo, '|');
  70. wstandend(win);
  71. }
  72. else {
  73. mvwaddch(win, lig, col+foo, '|');
  74. }
  75. if (foo & 2) {
  76. mvwaddch(win, lig-1, col+foo, '|');
  77. mvwaddch(win, lig+1, col+foo, '|');
  78. }
  79. }
  80. wrefresh(win);
  81. return 0;
  82. }
  83. /* ---------------------------------------------------------------- */
  84. /* ---------------------------------------------------------------- */