PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Simple-Libraries
Learn
Simple Libraries
Social
libbadgewxtools
ir_dec.c
1
#include <stdlib.h>
2
#include <propeller.h>
3
#include "
badgewxtools.h
"
4
5
jm_ir_hdserial
*irself;
6
7
int32_t ircom_dec(int32_t value)
8
{
9
int32_t i,
x
;
10
int32_t result = 0;
11
// Transmit a value in decimal format
12
// mark max negative
13
x
= -(value == (int32_t)0x80000000U);
14
if
(value < 0) {
15
// if negative
16
// make positive and adjust
17
value = abs((value +
x
));
18
// print sign
19
ircom_tx(
'-'
);
20
}
21
// set divisor
22
i = 1000000000;
23
{
24
int32_t _idx__0047;
25
for
(_idx__0047 = 0; _idx__0047 < 10; _idx__0047++) {
26
if
(value >= i) {
27
// non-zero digit for this divisor?
28
// print digit
29
ircom_tx((((value / i) +
'0'
) + (
x
* -(i == 1))));
30
// remove from value
31
value = value % i;
32
// set printing flag
33
result = -1;
34
}
else
{
35
if
((result) || (i == 1)) {
36
// if printing or last digit
37
// print zero
38
ircom_tx(
'0'
);
39
}
40
}
41
// update divisor
42
i = i / 10;
43
}
44
}
45
return
result;
46
}
47
48
/*
49
TERMS OF USE: MIT License
50
51
Permission is hereby granted, free of charge, to any person obtaining a
52
copy of this software and associated documentation files (the "Software"),
53
to deal in the Software without restriction, including without limitation
54
the rights to use, copy, modify, merge, publish, distribute, sublicense,
55
and/or sell copies of the Software, and to permit persons to whom the
56
Software is furnished to do so, subject to the following conditions:
57
58
The above copyright notice and this permission notice shall be included in
59
all copies or substantial portions of the Software.
60
61
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
62
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
63
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
64
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
65
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
66
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
67
DEALINGS IN THE SOFTWARE.
68
*/
69
badgewxtools.h
This library provides convenient functions for a variety of Parallax eBadge operations.
jm_ir_hdserial
Definition:
badgetools.h:1526
x
int x
Definition:
07 Box and Lines.c:13
Generated on Fri May 20 2022 16:48:05 for PropWare by
1.8.17