123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- #include "display.h"
- #include "gtext.h"
- void disp_num(signed long int val, unsigned char dec){
- unsigned char disp = 0, digit;
- if(val < 0){
- putchar('-');
- val = -val;
- } else {
- putchar(' ');
- }
- if(val > 99999999){
- putchar('!');
- disp = 1;
- } else {
- digit = (val/10000000)%10;
- if(digit){
- putchar(digit + '0');
- disp = 1;
- } else putchar(' ');
- }
- digit = (val/1000000)%10;
- if(digit || disp){
- putchar(digit + '0');
- disp = 1;
- } else putchar(' ');
- digit = (val/100000)%10;
- if(digit || disp){
- putchar(digit + '0');
- disp = 1;
- } else putchar(' ');
- digit = (val/10000)%10;
- if(digit || disp){
- putchar(digit + '0');
- disp = 1;
- } else putchar(' ');
- digit = (val/1000)%10;
- if(digit || disp || dec > 2){
- putchar(digit + '0');
- disp = 1;
- } else putchar(' ');
- digit = (val/100)%10;
- if(dec == 3)
- putchar(',');
- if(digit || disp || dec > 1){
- putchar(digit + '0');
- disp = 1;
- } else putchar(' ');
- if(dec == 2)
- putchar(',');
- digit = (val/10)%10;
- if(digit || disp || dec > 0){
- putchar(digit + '0');
- } else putchar(' ');
- if(dec == 1)
- putchar(',');
- digit = val%10;
- putchar(digit + '0');
- }
- void disp_temp(signed int temp){
- unsigned char pos = 0;
- if(temp < 0){
- putchar('-');
- pos++;
- temp = -temp;
- }
- if(temp >= 1000){
- putchar(temp/1000 + '0');
- pos++;
- }
- if(temp >= 100){
- putchar((temp/100)%10 + '0');
- pos++;
- }
- putchar((temp/10)%10 + '0');
- putchar(',');
- putchar(temp%10 + '0');
- putchar(0x7b);
- putchar('C');
- pos+=5;
- for(; pos<8; pos++) putchar(' ');
- }
|