From 99f41213c357efbc8085d2707339e0b70cce4f79 Mon Sep 17 00:00:00 2001 From: Kizarm Date: Fri, 19 Jan 2024 15:52:53 +0100 Subject: [PATCH] config led in main --- Makefile | 2 +- main.cpp | 6 ++++-- morse.cpp | 7 ++++--- tabgen.cpp | 2 +- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index e111972..2d2893d 100644 --- a/Makefile +++ b/Makefile @@ -53,7 +53,7 @@ tabgen: tabgen.cpp table.cpp: tabgen ./tabgen # 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.pcm: morse.cpp table.cpp io.pcm sys.pcm %.o: %.cpp diff --git a/main.cpp b/main.cpp index fd36b75..fd48b3f 100644 --- a/main.cpp +++ b/main.cpp @@ -1,8 +1,10 @@ /* SIMPLE EXAMPLE: LED blinking */ -import morse; // use module !!! +import morse; // use modules !!! +import io; ////////////////////////////////////// int main () { - Morse morse (330); + const io::GpioClass led (io::GpioPortA, 10); + const Morse morse (led, 330); for (;;) { morse << "Hello world"; } diff --git a/morse.cpp b/morse.cpp index 3249cd0..2ee9eed 100644 --- a/morse.cpp +++ b/morse.cpp @@ -24,11 +24,12 @@ union morse_byte { */ #include "table.cpp" export class Morse { - const unsigned unit; - const io::GpioClass led; + const unsigned unit; + const io::GpioClass & led; 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 (); } void operator<< (const char * text) const; diff --git a/tabgen.cpp b/tabgen.cpp index b3451cb..39ed4ca 100644 --- a/tabgen.cpp +++ b/tabgen.cpp @@ -4,7 +4,7 @@ #error "BAD ENDIAN" #endif 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 */ " ", /* */ " ", /*!*/ ".-..-.", /*"*/ " ", /*#*/ " ", /*$*/ " ", /*%*/ " ", /*&*/ ".----.", /*'*/ "-.--.", /*(*/ "-.--.-", /*)*/ " ", /***/ ".-.-.", /*+*/ "--..--", /*,*/ "-....-", /*-*/ ".-.-.-", /*.*/ "-..-." , /*/*/