|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- #pragma once
-
- #include "PCA9685.h"
-
- #define SENSOR1 15
- #define SENSOR2 12
-
- #define INT_TIME 20 // interrupt intervall [ms]
-
- 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 switch_direction = 0;
- uint8_t state = 0;
- uint8_t switch_state = 0;
- uint8_t finish = 1;
-
- // alternative
- uint32_t tick = 0;
- uint32_t stufe = 0;
- uint8_t an_aus = 0;
-
- uint32_t ticks_treppe = 0;
- uint32_t ticks_pro_stufe = 0;
- float differenz_pwm_pro_tick = 0.0;
- // alternative
-
-
- // 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();
- void rampe();
-
- 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 setup();
- void task(); // call periodically
-
- // 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
- void setDirection(uint8_t _direction);
- void setState(uint8_t _state);
- void setAnAus(uint8_t _an_aus) {
- an_aus = _an_aus;
- }
-
- uint8_t getState() { return state;};
- uint8_t getFinished() { return finish;};
- uint8_t getDirection() {return direction;};
- };
|