/* * width: total number to show * dot: postion of the dot, 0 is no dot, 1 :xxx.x, 2:xx.xx */ void print10L(unsigned long n, unsigned long width,char dot) { unsigned char x=0; unsigned long base=ipow(10,width);; /* =pow(10,width); */ unsigned long nb=width; //sync with base char frac=0,sf=0; while(base>=1){ //dot positon if(nb==dot){ lcd_putc('.'); sf = 1; } x=n/base; lcd_putc(hex2c(x)); if(1==base) break; n=n%base; nb-=1; base = base/10; } }
static char* unescape(char *str) { int x, y; int len = (int)strlen(str); for (x=y=0; str[y]; ++x, ++y) { if ((str[x] = str[y]) == '%') { if (y < len-2 && isxdigit(str[y+1]) && isxdigit(str[y+2])) { str[x] = (hex2c(str[y+1]) << 4) + hex2c(str[y+2]); y += 2; } } } str[x] = '\0'; return str; }
static int unescape(gh_buf *ob, const uint8_t *src, size_t size, bool unescape_plus) { size_t i = 0, org; while (i < size) { org = i; while (i < size && src[i] != '%' && src[i] != '+') i++; if (likely(i > org)) { if (unlikely(org == 0)) { if (i >= size) return 0; gh_buf_grow(ob, HOUDINI_UNESCAPED_SIZE(size)); } gh_buf_put(ob, src + org, i - org); } /* escaping */ if (i >= size) break; if (src[i++] == '+') { gh_buf_putc(ob, unescape_plus ? ' ' : '+'); continue; } if (i + 1 < size && _isxdigit(src[i]) && _isxdigit(src[i + 1])) { unsigned char new_char = (hex2c(src[i]) << 4) + hex2c(src[i + 1]); gh_buf_putc(ob, new_char); i += 2; } else { gh_buf_putc(ob, '%'); } } return 1; }
void print10(unsigned short n) { static char four[6]; //irqoff(); four[0]= hex2c( (n/10000) ); n = n%10000; four[1]= hex2c(n/1000); n = n%1000; four[2]= hex2c( (n/100) ); n = n%100; four[3]= hex2c( (n/10) ); four[4]= hex2c( (n%10) );; four[5]= 0; if(four[0] == '0') lcd_puts(four+1); else lcd_puts(four); }
void infon(char *e,char n) { lcd_cursor(8,0); lcd_puts(e); lcd_putc(hex2c(n)); }