Atm_led_TLC.cpp 908 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Atm_led_mcp.cpp
  3. *
  4. * Created on: 09.12.2017
  5. * Author: ian
  6. */
  7. #ifdef _ADAFRUIT_TLC59711_H
  8. #include <Atm_led_TLC.h>
  9. #include <Atm_led.hpp>
  10. Atm_led_TLC::Atm_led_TLC(Adafruit_TLC59711& _tlc):
  11. Atm_led(), // base class ctor would also be called implicitly, but better style to mention this explicitly :)
  12. tlc(_tlc) {
  13. // nothing to see here
  14. }
  15. void Atm_led_TLC::initLED() {
  16. tlc.setPWM(pin, 0);
  17. //Serial.printf("LED init on pin %x\n", pin);
  18. }
  19. void Atm_led_TLC::switchOn() {
  20. tlc.setPWM(pin, pwm_max);
  21. }
  22. void Atm_led_TLC::switchOff() {
  23. tlc.setPWM(pin, pwm_min);
  24. }
  25. void Atm_led_TLC::setBrightness(int value) {
  26. tlc.setPWM(pin, value);
  27. }
  28. int Atm_led_TLC::mapLevel(int level) {
  29. current_level = map( level, toLow, toHigh, pwm_min, pwm_max );
  30. return level;
  31. }
  32. Atm_led_TLC& Atm_led_TLC::setMinMax(int min, int max) {
  33. this->pwm_min = min ;
  34. this->pwm_max = max ;
  35. return *this;
  36. }
  37. #endif