37 lines
778 B
C
37 lines
778 B
C
|
#ifndef MORSE_H
|
||
|
#define MORSE_H
|
||
|
#include "gpio.h"
|
||
|
#include "generator.h"
|
||
|
#include "pwmclass.h"
|
||
|
union morse_byte {
|
||
|
struct {
|
||
|
unsigned char bits : 5;
|
||
|
unsigned char mlen : 3;
|
||
|
};
|
||
|
unsigned char byte;
|
||
|
explicit constexpr morse_byte () noexcept : byte (0u) {}
|
||
|
};
|
||
|
|
||
|
class Morse {
|
||
|
const unsigned unit;
|
||
|
const GpioClass & led;
|
||
|
Generator gen;
|
||
|
PwmClass pwm;
|
||
|
|
||
|
public:
|
||
|
explicit Morse (const GpioClass & pin, const unsigned ms = 100u) noexcept;
|
||
|
const Morse & operator<< (const char * text);
|
||
|
protected:
|
||
|
void out (const morse_byte mb);
|
||
|
void on () {
|
||
|
led << false; // LED je připojena proti VCC, zde se tedy rozsvítí
|
||
|
gen.on ();
|
||
|
}
|
||
|
void off () {
|
||
|
led << true;
|
||
|
gen.off();
|
||
|
}
|
||
|
};
|
||
|
|
||
|
#endif // MORSE_H
|