display.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 || dec > 3){
  33. putchar(digit + '0');
  34. disp = 1;
  35. }// else putchar(' ');
  36. digit = (val/1000)%10;
  37. if(dec == 4)
  38. putchar(',');
  39. if(digit || disp || dec > 2){
  40. putchar(digit + '0');
  41. disp = 1;
  42. }// else putchar(' ');
  43. digit = (val/100)%10;
  44. if(dec == 3)
  45. putchar(',');
  46. if(digit || disp || dec > 1){
  47. putchar(digit + '0');
  48. disp = 1;
  49. }// else putchar(' ');
  50. if(dec == 2)
  51. putchar(',');
  52. digit = (val/10)%10;
  53. if(digit || disp || dec > 0){
  54. putchar(digit + '0');
  55. }// else putchar(' ');
  56. if(dec == 1)
  57. putchar(',');
  58. digit = val%10;
  59. putchar(digit + '0');
  60. }
  61. void disp_temp(signed int temp){
  62. unsigned char pos = 0;
  63. if(temp < 0){
  64. putchar('-');
  65. pos++;
  66. temp = -temp;
  67. }
  68. if(temp >= 1000){
  69. putchar(temp/1000 + '0');
  70. pos++;
  71. }
  72. if(temp >= 100){
  73. putchar((temp/100)%10 + '0');
  74. pos++;
  75. }
  76. putchar((temp/10)%10 + '0');
  77. putchar(',');
  78. putchar(temp%10 + '0');
  79. putchar(0x7b);
  80. putchar('C');
  81. pos+=5;
  82. for(; pos<8; pos++) putchar(' ');
  83. }