#ifndef GENERATOR_H
#define GENERATOR_H
#include "oneway.h"
extern "C" const int16_t sin_tab[];
/* Něco jako DDS, přesná frekvence není řešena (závisí na TIM1). */
class Generator {
  unsigned base, freq;
  public:
    explicit Generator () noexcept : base(0u), freq (0u) {};
    int16_t step () {
      const int16_t r = sin_tab [base >> 24];
      base += freq;
      return r;
    }
    void set (const unsigned f) {
      if (!f) base = 0u;
      freq = f;
    }
  protected:
};

#endif // GENERATOR_H