PropWare
C++ objects and CMake build system for Parallax Propeller
Home
Download
Getting Started
Documentation
Reference
About
Related Links
Namespace List
Class List
File List
Examples
Build System
File List
File Members
propsideworkspace
Learn
Simple Libraries
TextDevices
libsimpletext
printNumber.c
1
#include "simpletext.h"
2
3
int
printNumber(
text_t
*p,
unsigned
long
u,
int
base,
int
width,
int
fill_char)
4
{
5
int
r = 0;
6
static
char
obuf[32];
7
char
*t;
8
9
width = (width > 0) ? width : -1;
10
t = obuf;
11
12
do
{
13
*t++ =
"0123456789abcdef"
[u % base];
14
u /= base;
15
if
(width > -1)
16
width--;
17
}
while
(u > 0);
18
19
while
(width-- > 0) {
20
p->
txChar
(p, fill_char);
21
r++;
22
}
23
while
(t != obuf) {
24
p->
txChar
(p, *--t);
25
r++;
26
}
27
return
r;
28
}
29
30
/*
31
+--------------------------------------------------------------------
32
| TERMS OF USE: MIT License
33
+--------------------------------------------------------------------
34
Permission is hereby granted, free of charge, to any person obtaining
35
a copy of this software and associated documentation files
36
(the "Software"), to deal in the Software without restriction,
37
including without limitation the rights to use, copy, modify, merge,
38
publish, distribute, sublicense, and/or sell copies of the Software,
39
and to permit persons to whom the Software is furnished to do so,
40
subject to the following conditions:
41
42
The above copyright notice and this permission notice shall be
43
included in all copies or substantial portions of the Software.
44
45
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
46
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
47
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
48
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
49
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
50
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
51
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
52
+--------------------------------------------------------------------
53
*/
54
55
56
text_struct::txChar
int(* txChar)(struct text_struct *p, int ch)
Definition:
simpletext.h:75
text_struct
Structure that contains data used by simple text device libraries.
Definition:
simpletext.h:70
Generated on Sat Aug 27 2016 00:58:09 for PropWare by
1.8.12