RISC-V/V203F6P6/blink/morse.h

37 lines
778 B
C
Raw Normal View History

2025-01-29 15:29:40 +01:00
#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 << true; // LED je připojena proti GND, zde se tedy rozsvítí
gen.on ();
}
void off () {
led << false;
gen.off();
}
};
#endif // MORSE_H