/ src / app / app_status_led.cpp
app_status_led.cpp
  1  #include "app_status_led.h"
  2  
  3  #include "sdk_common.h"
  4  
  5  #include "display/led/display_led_apa102.h"
  6  #include "display/led/effect/display_led_effect_all_effects.h"
  7  
  8  #include "app_log_module.ii"
  9  
 10  namespace app
 11  {
 12  	using namespace display::led;
 13  
 14  	StatusLed::StatusLed()
 15  	{
 16  #if defined(DISPLAY_LED_APA102_ENABLED) && DISPLAY_LED_APA102_ENABLED == 1
 17  		static RgbLedColorBuffer<1> colorBuffer;
 18  		colors = &colorBuffer;
 19  		colors->Brightness = BRIGHTNESS;
 20  
 21  		static RgbLeds status_pixel_apa102(colors, &display_led_apa102, nullptr);
 22  		rgbLed = &status_pixel_apa102;
 23  #else
 24  		static RgbLeds null_led(nullptr, nullptr, nullptr);
 25  		rgbLed = &null_led;
 26  		colors = nullptr;
 27  #endif // DISPLAY_LED_APA102_ENABLED
 28  	}
 29  
 30  	void StatusLed::Update(float delta)
 31  	{
 32  		rgbLed->Update(delta);
 33  	}
 34  
 35  	void StatusLed::SetEffect(effect::Effect* eff)
 36  	{
 37  		eff->Reset();
 38  		colors->Brightness = BRIGHTNESS;
 39  		rgbLed->SetEffect(eff);
 40  	}
 41  
 42  	void StatusLed::SetModeBoot()
 43  	{
 44  		if (colors == nullptr)
 45  		{
 46  			return;
 47  		}
 48  
 49  		static effect::Static red(
 50  			effect::Color(SOLID_STATUS_VAL, 0, 0)
 51  		);
 52  		red.Reset();
 53  
 54  		SetEffect(&red);
 55  	}
 56  
 57  	void StatusLed::SetModeMenu()
 58  	{
 59  		if (colors == nullptr)
 60  		{
 61  			return;
 62  		}
 63  
 64  		static effect::Static green(
 65  			effect::Color(0, SOLID_STATUS_VAL, 0)
 66  		);
 67  		green.Reset();
 68  		SetEffect(&green);
 69  	}
 70  
 71  	void StatusLed::SetModeNfct()
 72  	{
 73  		if (colors == nullptr)
 74  		{
 75  			return;
 76  		}
 77  
 78  		static effect::Static blue(
 79  			effect::Color(0, 0, SOLID_STATUS_VAL)
 80  		);
 81  		blue.Reset();
 82  		SetEffect(&blue);
 83  	}
 84  
 85  	void StatusLed::SetModeFun()
 86  	{
 87  		if (colors == nullptr)
 88  		{
 89  			return;
 90  		}
 91  
 92  		static display::led::effect::Rainbow rainbow;
 93  		SetEffect(&rainbow);
 94  	}
 95  
 96  	void StatusLed::SetModeShutdown()
 97  	{
 98  		if (colors == nullptr)
 99  		{
100  			return;
101  		}
102  
103  		static effect::Static off(
104  			effect::Color(0)
105  		);
106  		off.Reset();
107  		SetEffect(&off);
108  	}
109  
110  }