display.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 > 999999){
  12. putchar('!');
  13. disp = 1;
  14. } else {
  15. digit = (val/100000)%10;
  16. if(digit){
  17. putchar(digit + '0');
  18. disp = 1;
  19. } else putchar(' ');
  20. }
  21. digit = (val/10000)%10;
  22. if(digit || disp){
  23. putchar(digit + '0');
  24. disp = 1;
  25. } else putchar(' ');
  26. digit = (val/1000)%10;
  27. if(digit || disp || dec > 2){
  28. putchar(digit + '0');
  29. disp = 1;
  30. } else putchar(' ');
  31. digit = (val/100)%10;
  32. if(dec == 3)
  33. putchar(',');
  34. if(digit || disp || dec > 1){
  35. putchar(digit + '0');
  36. disp = 1;
  37. } else putchar(' ');
  38. if(dec == 2)
  39. putchar(',');
  40. digit = (val/10)%10;
  41. if(digit || disp || dec > 0){
  42. putchar(digit + '0');
  43. } else putchar(' ');
  44. if(dec == 1)
  45. putchar(',');
  46. digit = val%10;
  47. putchar(digit + '0');
  48. }
  49. void disp_temp(signed int temp){
  50. unsigned char pos = 0;
  51. if(temp < 0){
  52. putchar('-');
  53. pos++;
  54. temp = -temp;
  55. }
  56. if(temp >= 1000){
  57. putchar(temp/1000 + '0');
  58. pos++;
  59. }
  60. if(temp >= 100){
  61. putchar((temp/100)%10 + '0');
  62. pos++;
  63. }
  64. putchar((temp/10)%10 + '0');
  65. putchar(',');
  66. putchar(temp%10 + '0');
  67. putchar(0x7b);
  68. putchar('C');
  69. pos+=5;
  70. for(; pos<8; pos++) putchar(' ');
  71. }