display.c 986 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #include "display.h"
  2. #include "gtext.h"
  3. void disp_num(signed int val){
  4. unsigned char disp = 0, digit;
  5. if(val < 0){
  6. putchar('-');
  7. val = -val;
  8. } else {
  9. putchar(' ');
  10. }
  11. digit = val/10000;
  12. if(digit){
  13. putchar(digit + '0');
  14. disp = 1;
  15. } else putchar(' ');
  16. digit = (val/1000)%10;
  17. if(digit || disp){
  18. putchar(digit + '0');
  19. disp = 1;
  20. } else putchar(' ');
  21. digit = (val/100)%10;
  22. if(digit || disp){
  23. putchar(digit + '0');
  24. disp = 1;
  25. } else putchar(' ');
  26. digit = (val/10)%10;
  27. if(digit || disp){
  28. putchar(digit + '0');
  29. } else putchar(' ');
  30. digit = val%10;
  31. putchar(digit + '0');
  32. }
  33. void disp_temp(signed int temp){
  34. unsigned char pos = 0;
  35. if(temp < 0){
  36. putchar('-');
  37. pos++;
  38. temp = -temp;
  39. }
  40. if(temp >= 1000){
  41. putchar(temp/1000 + '0');
  42. pos++;
  43. }
  44. if(temp >= 100){
  45. putchar((temp/100)%10 + '0');
  46. pos++;
  47. }
  48. putchar((temp/10)%10 + '0');
  49. putchar(',');
  50. putchar(temp%10 + '0');
  51. putchar(0x7b);
  52. putchar('C');
  53. pos+=5;
  54. for(; pos<8; pos++) putchar(' ');
  55. }