2020-04-26 11:06:28 -07:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "gppwm.h"
|
|
|
|
|
|
|
|
class OutputPin;
|
|
|
|
class SimplePwm;
|
|
|
|
class ValueProvider3D;
|
|
|
|
|
|
|
|
class GppwmChannel {
|
|
|
|
public:
|
|
|
|
DECLARE_ENGINE_PTR;
|
|
|
|
|
2020-06-11 17:43:26 -07:00
|
|
|
void init(bool usePwm, SimplePwm* pwm, OutputPin* outputPin, const ValueProvider3D* table, const gppwm_channel* config);
|
2020-04-26 11:06:28 -07:00
|
|
|
void update();
|
|
|
|
|
|
|
|
private:
|
|
|
|
float getOutput() const;
|
|
|
|
void setOutput(float result);
|
|
|
|
|
|
|
|
// Store the current state so we can apply hysteresis
|
|
|
|
bool m_state = false;
|
|
|
|
|
|
|
|
// Configuration fields
|
|
|
|
const gppwm_channel* m_config = nullptr;
|
|
|
|
bool m_usePwm = false;
|
|
|
|
SimplePwm* m_pwm = nullptr;
|
2020-06-11 17:43:26 -07:00
|
|
|
OutputPin* m_output = nullptr;
|
2020-04-26 11:06:28 -07:00
|
|
|
const ValueProvider3D* m_table = nullptr;
|
|
|
|
};
|