forked from dacarley/Arduino
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.cpp
More file actions
56 lines (43 loc) · 995 Bytes
/
Copy pathutils.cpp
File metadata and controls
56 lines (43 loc) · 995 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <Arduino.h>
#include "utils.h"
#define BUF_LEN 100
static const char * formatString_Core(const char *format, va_list args)
{
static char buf[BUF_LEN];
vsnprintf(buf, sizeof(buf), format, args);
return buf;
}
const char * formatString_P(const char *formatP, ...)
{
static char format[BUF_LEN];
int i = 0;
char ch;
do
{
ch = pgm_read_byte(formatP++);
format[i++] = ch;
} while ((i < BUF_LEN) && (ch != 0));
va_list args;
va_start(args, formatP);
const char * result = formatString_Core(format, args);
va_end(args);
return result;
}
const char * formatString(const char *format, ...)
{
va_list args;
va_start(args, format);
const char * result = formatString_Core(format, args);
va_end(args);
return result;
}
const char * toString(int n)
{
return formatString_P(PSTR("%0.2d"), n);
}
int freeRam()
{
extern int __heap_start, *__brkval;
int v;
return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
}