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
Examples
Hello
Hello_Demo.cpp
Go to the documentation of this file.
1
26
#define TEST_PROPWARE
27
//#define TEST_SIMPLE
28
//#define TEST_TINYSTREAM
29
//#define TEST_TINYIO
30
//#define TEST_FDSERIAL
31
//#define TEST_LIBPROPELLER
32
33
// Includes
34
#include <
PropWare/PropWare.h
>
35
36
#ifdef TEST_PROPWARE
37
#include <
PropWare/printer/printer.h
>
38
#elif defined TEST_SIMPLE
39
#include <simpletext.h>
40
#elif defined TEST_TINYSTREAM
41
#include <tinystream>
42
namespace
std
{
43
std::stream cout;
44
}
45
#elif defined TEST_TINYIO
46
#include <tinyio.h>
47
#elif defined TEST_FDSERIAL
48
#include <fdserial.h>
49
#elif defined TEST_LIBPROPELLER
50
#include <libpropeller/serial/serial.h>
51
52
#endif
53
54
#ifndef TEST_PROPWARE
55
int
_cfg_rxpin = -1;
56
int
_cfg_txpin = -1;
57
int
_cfg_baudrate = -1;
58
#endif
59
67
int
main
() {
68
uint32_t i = 0;
69
70
#ifdef TEST_FDSERIAL
71
fdserial
*
serial
= fdserial_open(_cfg_rxpin, _cfg_txpin, 0, _cfg_baudrate);
72
#elif defined TEST_LIBPROPELLER
73
libpropeller::Serial
serial;
74
serial.
Start
(_cfg_rxpin, _cfg_txpin, _cfg_baudrate);
75
#endif
76
77
while
(1) {
78
#ifdef TEST_PROPWARE
79
pwOut
.
printf
(
"Hello, world! %03d 0x%02X\n"
, i, i);
80
#elif defined TEST_SIMPLE
81
printi(
"Hello, world! %03d 0x%02x\n"
, i, i);
82
#elif defined TEST_TINYSTREAM
83
std::cout <<
"Hello, world! "
<< i <<
' '
<< i << std::endl;
84
#elif defined TEST_TINYIO
85
printf(
"Hello, world! %03d 0x%02x\n"
, i, i);
86
#elif defined TEST_FDSERIAL
87
// Please note that FdSerial support requires the inclusion of the file
88
// `pst.dat` as a source file for this project. Because the file is no
89
// longer included as part of the Simple libraries you must copy it from
90
// this project to your own before attempting to compile.
91
dprinti(serial,
"Hello, world! %03d 0x%02x\n"
, i, i);
92
#elif defined TEST_LIBPROPELLER
93
serial.PutFormatted(
"Hello, world! %03d 0x%02X\r\n"
, i, i);
94
#endif
95
i++;
96
waitcnt(250 * MILLISECOND + CNT);
97
}
98
99
return
0;
100
}
libpropeller::Serial::Start
bool Start(const int rxpin, const int txpin, const int rate, const int ctspin=-1)
Definition:
serial.h:64
pwOut
const PropWare::Printer pwOut
Most common use of printing in PropWare applications (not thread safe; see PropWare::pwSyncOut for mu...
PropWare::Printer::printf
void printf(const char fmt[], const T first, const Targs...remaining) const
Similar in functionality to the C-standard function printf.
Definition:
printer.h:440
std
STL namespace.
main
int main(void)
Definition:
GraphicsTest.c:20
PropWare.h
text_struct
Structure that contains data used by simple text device libraries.
Definition:
simpletext.h:70
printer.h
libpropeller::Serial
Definition:
serial.h:35
Generated on Sat Aug 27 2016 00:58:03 for PropWare by
1.8.12