46 lines
802 B
C++
46 lines
802 B
C++
#pragma once
|
|
#include <Arduino.h>
|
|
|
|
|
|
struct PWMOUT{
|
|
float max;
|
|
bool visionCorrected;
|
|
int resolution;
|
|
int frequency;
|
|
};
|
|
|
|
class PWM_Output {
|
|
public:
|
|
float currDuty;
|
|
bool visionCorrected;
|
|
PWM_Output(int8_t pin, uint8_t ch, uint8_t res, uint32_t freq, float maxDuty, bool visionCorrected=false);
|
|
void setOutput(float duty);
|
|
void setFreq(uint32_t fq);
|
|
int linearizeOutput(float inp);
|
|
void setMaxDuty(float duty);
|
|
float getMaxDuty(void){
|
|
return maxDuty;
|
|
}
|
|
float getDuty(void) {
|
|
return currDuty;
|
|
}
|
|
int getOutVal(void);
|
|
void setResolution(uint8_t res);
|
|
|
|
int currOutVal;
|
|
private:
|
|
uint8_t ch;
|
|
uint32_t freq;
|
|
uint8_t res;
|
|
|
|
float maxDuty;
|
|
int msecRampRate;
|
|
|
|
float standardFactor;
|
|
float visionFactor;
|
|
|
|
};
|
|
|
|
|
|
|