LedInterface.cpp 1011 B

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