LedInterface.cpp 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #include "LedInterface.h"
  2. LedInterface::LedInterface() {
  3. }
  4. void LedInterface::RunSetup() {
  5. Serial.println("Setting neopixel to black...");
  6. strip.setBrightness(0);
  7. strip.begin();
  8. strip.setPixelColor(0, strip.Color(0, 0, 0));
  9. strip.show();
  10. delay(100);
  11. strip.setBrightness(50);
  12. strip.setPixelColor(0, strip.Color(0, 0, 0));
  13. strip.show();
  14. this->initTime = millis();
  15. }
  16. void LedInterface::main(uint32_t currentTime) {
  17. strip.setPixelColor(0, this->Wheel((0 * 256 / 100 + this->wheel_pos) % 256));
  18. strip.show();
  19. this->current_fade_itter++;
  20. this->wheel_pos = this->wheel_pos - this->wheel_speed;
  21. if (this->wheel_pos < 0)
  22. this->wheel_pos = 255;
  23. };
  24. uint32_t LedInterface::Wheel(byte WheelPos) {
  25. WheelPos = 255 - WheelPos;
  26. if(WheelPos < 85) {
  27. return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  28. }
  29. if(WheelPos < 170) {
  30. WheelPos -= 85;
  31. return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  32. }
  33. WheelPos -= 170;
  34. return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
  35. }