ESP8266 Treppenlichtsteuerung mit OTA zum Firmware Upload
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

pwm.h 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #pragma once
  2. #include "PCA9685.h"
  3. #define SENSOR1 15
  4. #define SENSOR2 12
  5. #define INT_TIME 20 // interrupt intervall [ms]
  6. class Treppe {
  7. private:
  8. uint8_t stairs;
  9. uint16_t time_per_stair = 200; // dimmtime per stair [ms]
  10. uint16_t idle_brightness = 0;
  11. uint16_t active_brightness = 1048;
  12. uint8_t direction = 0;
  13. uint8_t switch_direction = 0;
  14. uint8_t state = 0;
  15. uint8_t switch_state = 0;
  16. uint8_t finish = 1;
  17. // initialize with i2c-Address 0, use Wire Library
  18. PCA9685 pwmController;
  19. uint8_t softstart_led(uint8_t led, uint16_t startval, uint16_t stopval);
  20. void ledsequence();
  21. public:
  22. Treppe(uint8_t _stairs) : stairs(_stairs){}
  23. void task(); // call periodically
  24. void setup();
  25. // Parameter section
  26. uint16_t setIdle(uint16_t _idle_brightness);
  27. uint16_t setActive(uint16_t _active_brightness);
  28. uint16_t setTime(uint16_t _time_per_stair);
  29. // Runtime Parameter section
  30. uint8_t setDirection(uint8_t _direction);
  31. uint8_t setState(uint8_t _state);
  32. uint8_t getState() { return state;};
  33. uint8_t getDirection() {return direction;};
  34. };