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

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