1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- #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 || dec > 3){
- putchar(digit + '0');
- disp = 1;
- }// else putchar(' ');
- digit = (val/1000)%10;
- if(dec == 4)
- putchar(',');
- 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(' ');
- }
|