Subversion Repositories Projects

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1702 - 1
#include "dataitem.h"
2
 
3
char TimeSpanDataItem::textValue[9] = "";
4
char TimerDataItem::textValue[9] = "";
5
 
6
char* itoa2(int val, uint8_t buf_size, char *buf, int8_t base, char c)
7
{
8
    char sign = (val < 0) ? '-' : c;
9
    buf[buf_size-1] = 0;
10
 
11
    int8_t i = buf_size-2;
12
 
13
    for(; val && i ; --i, val /= base)
14
        buf[i] = "0123456789abcdef"[(val < 0) ? -(val % base) : val % base];
15
 
16
    for (; i > 0; i--)
17
        buf[i] = c;
18
 
19
    buf[0] = sign;
20
    return buf;
21
}
22
 
23
char* itoa2(uint8_t val, uint8_t buf_size, char *buf, int8_t base, char c)
24
{
25
    buf[buf_size-1] = 0;
26
 
27
    int8_t i = buf_size-2;
28
 
29
    for(; val && i>=0 ; --i, val /= base)
30
        buf[i] = "0123456789abcdef"[(val < 0) ? -(val % base) : val % base];
31
 
32
    for (; i >= 0; i--)
33
        buf[i] = c;
34
 
35
    return buf;
36
}
37
 
38
char* itoa2(uint16_t val, uint8_t buf_size, char *buf, int8_t base, char c)
39
{
40
    buf[buf_size-1] = 0;
41
 
42
    int8_t i = buf_size-2;
43
 
44
    for(; val && i>=0 ; --i, val /= base)
45
        buf[i] = "0123456789abcdef"[val % base];
46
 
47
    for (; i >= 0; i--)
48
        buf[i] = c;
49
 
50
    return buf;
51
}