PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Simple-Libraries
Learn
Simple Libraries
TextDevices
libsimpletext
putStrWithNpcVals.c
1
/*
2
* @file putStrWithNpCVals.c
3
* Function to print a string to the terminal with non printable characters
4
* displayed as decimal values in brackets.
5
*
6
* Copyright (c) 2018, Parallax Inc.
7
* Written by Andy Lindsay
8
*/
9
10
#include "
simpletext.h
"
11
12
int
putStrWithNpcVals
(
const
char
*s)
13
{
14
int
size = strlen(s);
15
for
(
int
n = 0; n <= size; n++)
16
{
17
if
(s[n] <=
'~'
&& s[n] >=
' '
)
18
{
19
print
(
"%c"
, s[n]);
20
}
21
else
if
(s[n] == 0)
22
{
23
print
(
"[%d]"
, s[n]);
24
break
;
25
}
26
else
if
(s[n] ==
'\n'
|| s[n] ==
'\r'
)
27
{
28
print
(
"[%d]%c"
, s[n], s[n]);
29
}
30
else
31
{
32
print
(
"[%d]"
, s[n]);
33
}
34
//pause(10);
35
}
36
//pause(10);
37
return
size;
38
}
39
40
/*
41
+--------------------------------------------------------------------
42
| TERMS OF USE: MIT License
43
+--------------------------------------------------------------------
44
Permission is hereby granted, free of charge, to any person obtaining
45
a copy of this software and associated documentation files
46
(the "Software"), to deal in the Software without restriction,
47
including without limitation the rights to use, copy, modify, merge,
48
publish, distribute, sublicense, and/or sell copies of the Software,
49
and to permit persons to whom the Software is furnished to do so,
50
subject to the following conditions:
51
52
The above copyright notice and this permission notice shall be
53
included in all copies or substantial portions of the Software.
54
55
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
56
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
57
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
58
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
59
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
60
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
61
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
62
+--------------------------------------------------------------------
63
*/
64
65
print
int print(const char *format,...) __attribute__((format(printf
Print format "..." args to the default simple terminal device. The output is limited to 256 bytes.
putStrWithNpcVals
int putStrWithNpcVals(const char *s)
Print string to the debug port, and display all non printable characters (NPCs) as decimal ASCII valu...
Definition:
putStrWithNpcVals.c:12
simpletext.h
This library provides a collection of functions for communicating with text devices such as SimpleIDE...
Generated on Fri May 20 2022 16:48:05 for PropWare by
1.8.17