display.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #include "display.h"
  2. #include "gtext.h"
  3. void disp_num(signed long int val, unsigned char dec){
  4. unsigned char disp = 0, digit;
  5. if(val < 0){
  6. putchar('-');
  7. val = -val;
  8. } else {
  9. putchar(' ');
  10. }
  11. if(val > 99999999){
  12. putchar('!');
  13. disp = 1;
  14. } else {
  15. digit = (val/10000000)%10;
  16. if(digit){
  17. putchar(digit + '0');
  18. disp = 1;
  19. } else putchar(' ');
  20. }
  21. digit = (val/1000000)%10;
  22. if(digit || disp){
  23. putchar(digit + '0');
  24. disp = 1;
  25. } else putchar(' ');
  26. digit = (val/100000)%10;
  27. if(digit || disp){
  28. putchar(digit + '0');
  29. disp = 1;
  30. } else putchar(' ');
  31. digit = (val/10000)%10;
  32. if(digit || disp){
  33. putchar(digit + '0');
  34. disp = 1;
  35. } else putchar(' ');
  36. digit = (val/1000)%10;
  37. if(digit || disp || dec > 2){
  38. putchar(digit + '0');
  39. disp = 1;
  40. } else putchar(' ');
  41. digit = (val/100)%10;
  42. if(dec == 3)
  43. putchar(',');
  44. if(digit || disp || dec > 1){
  45. putchar(digit + '0');
  46. disp = 1;
  47. } else putchar(' ');
  48. if(dec == 2)
  49. putchar(',');
  50. digit = (val/10)%10;
  51. if(digit || disp || dec > 0){
  52. putchar(digit + '0');
  53. } else putchar(' ');
  54. if(dec == 1)
  55. putchar(',');
  56. digit = val%10;
  57. putchar(digit + '0');
  58. }
  59. void disp_temp(signed int temp){
  60. unsigned char pos = 0;
  61. if(temp < 0){
  62. putchar('-');
  63. pos++;
  64. temp = -temp;
  65. }
  66. if(temp >= 1000){
  67. putchar(temp/1000 + '0');
  68. pos++;
  69. }
  70. if(temp >= 100){
  71. putchar((temp/100)%10 + '0');
  72. pos++;
  73. }
  74. putchar((temp/10)%10 + '0');
  75. putchar(',');
  76. putchar(temp%10 + '0');
  77. putchar(0x7b);
  78. putchar('C');
  79. pos+=5;
  80. for(; pos<8; pos++) putchar(' ');
  81. }