Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
arduino-esp32
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
arduino-esp32
Commits
826a4269
Unverified
Commit
826a4269
authored
Oct 06, 2023
by
Lucas Saavedra Vaz
Committed by
GitHub
Oct 06, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add printf method with FlashStringHelper argument (#8677)
parent
6091d526
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
3 deletions
+24
-3
cores/esp32/Print.cpp
cores/esp32/Print.cpp
+20
-3
cores/esp32/Print.h
cores/esp32/Print.h
+4
-0
No files found.
cores/esp32/Print.cpp
View file @
826a4269
...
...
@@ -44,13 +44,11 @@ size_t Print::write(const uint8_t *buffer, size_t size)
return
n
;
}
size_t
Print
::
printf
(
const
char
*
format
,
...
)
size_t
Print
::
vprintf
(
const
char
*
format
,
va_list
arg
)
{
char
loc_buf
[
64
];
char
*
temp
=
loc_buf
;
va_list
arg
;
va_list
copy
;
va_start
(
arg
,
format
);
va_copy
(
copy
,
arg
);
int
len
=
vsnprintf
(
temp
,
sizeof
(
loc_buf
),
format
,
copy
);
va_end
(
copy
);
...
...
@@ -74,6 +72,25 @@ size_t Print::printf(const char *format, ...)
return
len
;
}
size_t
Print
::
printf
(
const
__FlashStringHelper
*
ifsh
,
...)
{
va_list
arg
;
va_start
(
arg
,
ifsh
);
const
char
*
format
=
(
reinterpret_cast
<
const
char
*>
(
ifsh
));
size_t
ret
=
vprintf
(
format
,
arg
);
va_end
(
arg
);
return
ret
;
}
size_t
Print
::
printf
(
const
char
*
format
,
...)
{
va_list
arg
;
va_start
(
arg
,
format
);
size_t
ret
=
vprintf
(
format
,
arg
);
va_end
(
arg
);
return
ret
;
}
size_t
Print
::
print
(
const
String
&
s
)
{
return
write
(
s
.
c_str
(),
s
.
length
());
...
...
cores/esp32/Print.h
View file @
826a4269
...
...
@@ -21,6 +21,7 @@
#define Print_h
#include <stdint.h>
#include <stdio.h>
#include <stddef.h>
#include "WString.h"
...
...
@@ -72,7 +73,10 @@ public:
return
write
((
const
uint8_t
*
)
buffer
,
size
);
}
size_t
vprintf
(
const
char
*
format
,
va_list
arg
);
size_t
printf
(
const
char
*
format
,
...)
__attribute__
((
format
(
printf
,
2
,
3
)));
size_t
printf
(
const
__FlashStringHelper
*
ifsh
,
...);
// add availableForWrite to make compatible with Arduino Print.h
// default to zero, meaning "a single write may block"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment