|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- #pragma once
-
- #include "PCA9685.h"
-
- class Treppe {
- private:
- uint8_t stairs;
- uint16_t time_per_stair = 300; // dimmtime per stair [ms]
- uint16_t idle_brightness = 0;
- uint16_t active_brightness = 500;
-
- uint8_t direction = 0;
- uint8_t state = 0;
- uint8_t switch_state = 0;
-
- uint32_t tick = 0;
- uint32_t stufe = 0;
-
- uint32_t ticks_treppe = 0;
- uint32_t ticks_pro_stufe = 0;
- float differenz_pwm_pro_tick = 0.0;
-
- // initialize with i2c-Address 0, use Wire Library
- PCA9685 pwmController;
- uint8_t softstart_led(uint8_t led, uint16_t startval, uint16_t stopval);
- void ledsequence();
-
- public:
- Treppe(uint8_t _stairs) : stairs(_stairs){
- ticks_pro_stufe = time_per_stair / 20; // [ms]
- ticks_treppe = ticks_pro_stufe * stairs;
-
- differenz_pwm_pro_tick = (float) (active_brightness - idle_brightness)
- / (float) ticks_pro_stufe;
- }
-
- void task(); // call periodically
-
- void setup();
- void task_2();
-
- // Parameter section
- uint16_t setIdle(uint16_t _idle_brightness);
- uint16_t setActive(uint16_t _active_brightness);
- uint16_t setTime(uint16_t _time_per_stair);
-
- void setTick(uint32_t _tick) {
- tick = _tick;
- Serial.printf("Treppe: Tick: %u!\n", tick);
- }
- uint32_t getTicks() {
- return ticks_treppe;
- }
-
- // Runtime Parameter section
- uint8_t setDirection(uint8_t _direction);
- uint8_t setState(uint8_t _state);
-
- uint8_t getState() { return state;};
- uint8_t getDirection() {return direction;};
- };
|