config led in main

This commit is contained in:
Kizarm 2024-01-19 15:52:53 +01:00
parent f6db62d0cf
commit 99f41213c3
4 changed files with 10 additions and 7 deletions

View file

@ -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

View file

@ -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";
} }

View file

@ -25,10 +25,11 @@ 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;

View file

@ -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 */
" ", /* */ " ", /*!*/ ".-..-.", /*"*/ " ", /*#*/ " ", /*$*/ " ", /* */ " ", /*!*/ ".-..-.", /*"*/ " ", /*#*/ " ", /*$*/
" ", /*%*/ " ", /*&*/ ".----.", /*'*/ "-.--.", /*(*/ "-.--.-", /*)*/ " ", /*%*/ " ", /*&*/ ".----.", /*'*/ "-.--.", /*(*/ "-.--.-", /*)*/
" ", /***/ ".-.-.", /*+*/ "--..--", /*,*/ "-....-", /*-*/ ".-.-.-", /*.*/ "-..-." , /*/*/ " ", /***/ ".-.-.", /*+*/ "--..--", /*,*/ "-....-", /*-*/ ".-.-.-", /*.*/ "-..-." , /*/*/