PropWare
C++ objects and CMake build system for Parallax Propeller
|
For those coming from a background in Parallax's Spin language, your only concern will be syntax: the C-family of languages is wildly different. Don't worry - it's not hard.
For C developers with no background in Spin, the biggest hurdle will be learning about the famed "object-oriented programming" (still not hard).
There are lots of code examples throughout PropWare and libpropeller's source code, so please feel free to peruse them. You should also take advantage of the example projects provided in the Examples
directory.
;
=
==
, !=
, >=
, <=
and !
&&
for AND and ||
for OR&
, |
, and ^
for the bitwise operations AND, OR and XOR respectively//
/*
and */
block
of code is marked with {
and }
void
if no return) Classes. It's all about classes: organizing code into logical blocks. If you have 3 functions that all deal with a serial terminal, you might want to categorize them as Serial
. That's all a class
is - a group of functions that belong together. This code might look something like
Notice that, just like Parallax's Spin, we have visibility keywords: public
in this case. This keyword marks everything beneath it as accessible to the outside world, just like Spin's PUB
keyword before a function.
Where Spin might have some code such as
C++ would write this as
The term "Serial" can be pretty generic. Maybe David's Serial object has a max baud of 115,000 but Bob's Serial object has configurable pins (so you don't have to use the default RX and TX hardware pins). You want to use BOTH Serial objects. In order to differentiate between David's Serial
class and Bob's Serial
class, we prefix the class names with a namespace
. This looks like
Now that both classes are surrounded by a namespace, our code can use both classes without conflict!
Coming soon!