66 lines
2.0 KiB
C++
66 lines
2.0 KiB
C++
/// \file midi2stepper.h
|
|
/// \brief header file for Midi2Stepper class
|
|
/// \author GrumpyDeveloper https://contentnation.net/en/grumpydevelop
|
|
/// \license MIT
|
|
|
|
#ifndef MIDI2STEPPER_H_
|
|
#define MIDI2STEPPER_H_
|
|
|
|
// system includes
|
|
#include "Arduino.h"
|
|
|
|
class Midi2Stepper {
|
|
public:
|
|
/**
|
|
* \brief constructor
|
|
*/
|
|
Midi2Stepper();
|
|
|
|
/**
|
|
* \brief start up internal structures
|
|
*/
|
|
void begin();
|
|
|
|
/**
|
|
* \brief set power state and enable or disable pulse generation
|
|
*
|
|
* \param status new power status
|
|
*/
|
|
void power(bool status);
|
|
|
|
/**
|
|
* \brief tick function called by interrupt at 48kHz
|
|
*/
|
|
void tick();
|
|
|
|
/**
|
|
* \brief set channel A frequency and direction
|
|
*
|
|
* \param channelNum channel number
|
|
* \param freq frequency in Hz
|
|
*/
|
|
void setChannel(uint8_t channelNum, uint16_t freq);
|
|
|
|
private:
|
|
uint16_t m_counterA; ///< counter for toggling channels
|
|
uint16_t m_counterB; ///< counter for toggling channels
|
|
uint16_t m_counterC; ///< counter for toggling channels
|
|
uint16_t m_counterD; ///< counter for toggling channels
|
|
uint16_t m_counterE; ///< counter for toggling channels
|
|
uint16_t m_counterF; ///< counter for toggling channels
|
|
uint16_t m_counterG; ///< counter for toggling channels
|
|
uint16_t m_counterH; ///< counter for toggling channels
|
|
|
|
volatile uint8_t m_enable; ///< which channels are enable, one bit per channel
|
|
volatile uint16_t m_cEndA; ///< toggle output when m_counter reaches this
|
|
volatile uint16_t m_cEndB; ///< toggle output when m_counter reaches this
|
|
volatile uint16_t m_cEndC; ///< toggle output when m_counter reaches this
|
|
volatile uint16_t m_cEndD; ///< toggle output when m_counter reaches this
|
|
volatile uint16_t m_cEndE; ///< toggle output when m_counter reaches this
|
|
volatile uint16_t m_cEndF; ///< toggle output when m_counter reaches this
|
|
volatile uint16_t m_cEndG; ///< toggle output when m_counter reaches this
|
|
volatile uint16_t m_cEndH; ///< toggle output when m_counter reaches this
|
|
};
|
|
|
|
#endif // MIDI2STEPPER_H_
|