25 lines
516 B
C
25 lines
516 B
C
|
#ifndef MORSE_H
|
||
|
#define MORSE_H
|
||
|
#include "gpio.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;
|
||
|
|
||
|
public:
|
||
|
explicit Morse (const GpioClass & pin, const unsigned ms = 100) noexcept;
|
||
|
const Morse & operator<< (const char * text) const;
|
||
|
protected:
|
||
|
void out (const morse_byte mb) const;
|
||
|
};
|
||
|
|
||
|
#endif // MORSE_H
|