RISC-V/hello/morse.h

25 lines
516 B
C
Raw Normal View History

2024-02-29 12:22:16 +01:00
#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