#ifndef GENERATOR_H
#define GENERATOR_H
#include "oneway.h"
/* Něco jako DDS, přesná frekvence není řešena (závisí na TIM1). */
class Generator : public OneWay {
  const    unsigned freq;
           unsigned base, incr;
  volatile unsigned ms_count;
  public:
    explicit Generator (const unsigned f) noexcept;
    unsigned Send (uint16_t * const ptr, const unsigned len) override;

    void delay (const unsigned ms) {
      ms_count = ms;
      while (ms_count);
    }
    void on  () volatile {            incr = freq; }
    void off () volatile { base = 0u; incr = 0u;   }
  protected:
    uint16_t step ();
};

#endif // GENERATOR_H