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
./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

View file

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

View file

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

View file

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