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.

treppe.h~HEAD 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. <<<<<<< HEAD:lib/treppe/treppe.h
  10. uint16_t time_per_stair = 300; // dimmtime per stair [ms]
  11. uint16_t idle_brightness = 0;
  12. uint16_t active_brightness = 500;
  13. =======
  14. uint16_t time_per_stair = 200; // dimmtime per stair [ms]
  15. uint16_t idle_brightness = 0;
  16. uint16_t active_brightness = 1048;
  17. >>>>>>> master:include/pwm.h
  18. uint8_t direction = 0;
  19. uint8_t switch_direction = 0;
  20. uint8_t state = 0;
  21. uint8_t switch_state = 0;
  22. uint8_t finish = 1;
  23. uint32_t tick = 0;
  24. uint32_t stufe = 0;
  25. uint32_t ticks_treppe = 0;
  26. uint32_t ticks_pro_stufe = 0;
  27. float differenz_pwm_pro_tick = 0.0;
  28. // initialize with i2c-Address 0, use Wire Library
  29. PCA9685 pwmController;
  30. uint8_t softstart_led(uint8_t led, uint16_t startval, uint16_t stopval);
  31. void ledsequence();
  32. public:
  33. Treppe(uint8_t _stairs) : stairs(_stairs){
  34. ticks_pro_stufe = time_per_stair / 20; // [ms]
  35. ticks_treppe = ticks_pro_stufe * stairs;
  36. differenz_pwm_pro_tick = (float) (active_brightness - idle_brightness)
  37. / (float) ticks_pro_stufe;
  38. }
  39. void task(); // call periodically
  40. void setup();
  41. void elelel();
  42. // Parameter section
  43. uint16_t setIdle(uint16_t _idle_brightness);
  44. uint16_t setActive(uint16_t _active_brightness);
  45. uint16_t setTime(uint16_t _time_per_stair);
  46. void setTick(uint32_t _tick) {
  47. tick = _tick;
  48. Serial.printf("Treppe: Tick: %u!\n", tick);
  49. }
  50. uint32_t getTicks() {
  51. return ticks_treppe;
  52. }
  53. // Runtime Parameter section
  54. uint8_t setDirection(uint8_t _direction);
  55. uint8_t setState(uint8_t _state);
  56. uint8_t getState() { return state;};
  57. uint8_t getDirection() {return direction;};
  58. };