|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- #pragma once
-
- #include "PCA9685.h"
-
- #define SENSOR1 2
- #define SENSOR2 12
- #define OE 14
-
- #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 = 100;
- uint16_t active_brightness = 2048;
-
- 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;};
- };
|