2017-03-23 18:45:29 +00:00
|
|
|
#ifndef __Stairs
|
|
|
|
#define __Stairs
|
|
|
|
|
|
|
|
#include "components/PCA9685.h"
|
2017-03-27 20:24:05 +00:00
|
|
|
#include "config.h"
|
2018-01-04 21:53:16 +00:00
|
|
|
#include "settings/steps.h"
|
2017-03-27 20:24:05 +00:00
|
|
|
|
2018-01-04 21:53:16 +00:00
|
|
|
struct Step
|
2017-03-27 20:24:05 +00:00
|
|
|
{
|
2018-01-04 21:53:16 +00:00
|
|
|
uint16_t currentValue;
|
|
|
|
uint16_t startValue;
|
|
|
|
uint16_t targetValue;
|
|
|
|
uint16_t startTime;
|
|
|
|
uint16_t endTime;
|
2017-03-27 20:24:05 +00:00
|
|
|
};
|
|
|
|
|
2017-03-23 18:45:29 +00:00
|
|
|
|
2018-01-04 21:53:16 +00:00
|
|
|
class Stairs
|
2017-03-23 18:45:29 +00:00
|
|
|
{
|
|
|
|
private:
|
2018-01-04 21:53:16 +00:00
|
|
|
PCA9685* mPWMDriver;
|
|
|
|
Step mStep[MaxStepCount];
|
2017-03-23 18:45:29 +00:00
|
|
|
|
2018-01-04 21:53:16 +00:00
|
|
|
uint32_t mTransitionStart;
|
|
|
|
bool mTick = false;
|
2017-03-27 20:24:05 +00:00
|
|
|
|
2017-03-24 22:04:58 +00:00
|
|
|
protected:
|
2018-01-04 21:53:16 +00:00
|
|
|
uint16_t getPWMValue(uint8_t step, uint8_t brightness);
|
2017-03-24 22:04:58 +00:00
|
|
|
|
2017-03-23 18:45:29 +00:00
|
|
|
public:
|
|
|
|
void init(PCA9685* pwmDriver);
|
2018-01-04 21:53:16 +00:00
|
|
|
void tick();
|
2017-03-23 18:45:29 +00:00
|
|
|
|
2018-01-04 21:53:16 +00:00
|
|
|
uint8_t get(uint8_t step, bool target = true);
|
|
|
|
void set(uint8_t step, uint8_t brightness, uint16_t transitionTime = 0, uint16_t startTime = 0);
|
|
|
|
void setAll(uint8_t brightness, uint16_t transitionTime = 0, uint16_t startTime = 0);
|
2017-03-23 18:45:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|