config led in main
This commit is contained in:
parent
f6db62d0cf
commit
99f41213c3
4 changed files with 10 additions and 7 deletions
2
Makefile
2
Makefile
|
@ -53,7 +53,7 @@ tabgen: tabgen.cpp
|
||||||
table.cpp: tabgen
|
table.cpp: tabgen
|
||||||
./tabgen
|
./tabgen
|
||||||
# MODULES #
|
# MODULES #
|
||||||
main.o: main.cpp morse.pcm
|
main.o: main.cpp morse.pcm io.pcm
|
||||||
morse.o: morse.cpp table.cpp io.pcm sys.pcm
|
morse.o: morse.cpp table.cpp io.pcm sys.pcm
|
||||||
morse.pcm: morse.cpp table.cpp io.pcm sys.pcm
|
morse.pcm: morse.cpp table.cpp io.pcm sys.pcm
|
||||||
%.o: %.cpp
|
%.o: %.cpp
|
||||||
|
|
6
main.cpp
6
main.cpp
|
@ -1,8 +1,10 @@
|
||||||
/* SIMPLE EXAMPLE: LED blinking */
|
/* SIMPLE EXAMPLE: LED blinking */
|
||||||
import morse; // use module !!!
|
import morse; // use modules !!!
|
||||||
|
import io;
|
||||||
//////////////////////////////////////
|
//////////////////////////////////////
|
||||||
int main () {
|
int main () {
|
||||||
Morse morse (330);
|
const io::GpioClass led (io::GpioPortA, 10);
|
||||||
|
const Morse morse (led, 330);
|
||||||
for (;;) {
|
for (;;) {
|
||||||
morse << "Hello world";
|
morse << "Hello world";
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,11 +24,12 @@ union morse_byte {
|
||||||
*/
|
*/
|
||||||
#include "table.cpp"
|
#include "table.cpp"
|
||||||
export class Morse {
|
export class Morse {
|
||||||
const unsigned unit;
|
const unsigned unit;
|
||||||
const io::GpioClass led;
|
const io::GpioClass & led;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Morse (const unsigned ms = 100) noexcept : unit (ms), led (io::GpioPortA, 10) {
|
explicit Morse (const io::GpioClass & pin, const unsigned ms = 100) noexcept
|
||||||
|
: unit (ms), led (pin) {
|
||||||
sys::init ();
|
sys::init ();
|
||||||
}
|
}
|
||||||
void operator<< (const char * text) const;
|
void operator<< (const char * text) const;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#error "BAD ENDIAN"
|
#error "BAD ENDIAN"
|
||||||
#endif
|
#endif
|
||||||
static const char * oname = "table.cpp";
|
static const char * oname = "table.cpp";
|
||||||
static const char * const morse_code [] = { /* nedefinované znaky nahrazeny mezrou */
|
static const char * const morse_code [] = { /* nedefinované znaky nahrazeny mezerou */
|
||||||
" ", /* */ " ", /*!*/ ".-..-.", /*"*/ " ", /*#*/ " ", /*$*/
|
" ", /* */ " ", /*!*/ ".-..-.", /*"*/ " ", /*#*/ " ", /*$*/
|
||||||
" ", /*%*/ " ", /*&*/ ".----.", /*'*/ "-.--.", /*(*/ "-.--.-", /*)*/
|
" ", /*%*/ " ", /*&*/ ".----.", /*'*/ "-.--.", /*(*/ "-.--.-", /*)*/
|
||||||
" ", /***/ ".-.-.", /*+*/ "--..--", /*,*/ "-....-", /*-*/ ".-.-.-", /*.*/ "-..-." , /*/*/
|
" ", /***/ ".-.-.", /*+*/ "--..--", /*,*/ "-....-", /*-*/ ".-.-.-", /*.*/ "-..-." , /*/*/
|
||||||
|
|
Loading…
Reference in a new issue