enhanced RGB LED control: use more than 1 LED
This commit is contained in:
		
							parent
							
								
									4c5721be53
								
							
						
					
					
						commit
						090657ac82
					
				@ -3,6 +3,11 @@
 | 
			
		||||
 | 
			
		||||
#ifdef HAS_RGB_LED
 | 
			
		||||
#include <SmartLeds.h>
 | 
			
		||||
 | 
			
		||||
#ifndef RGB_LED_COUNT
 | 
			
		||||
#define RGB_LED_COUNT 1
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
// value for HSL color
 | 
			
		||||
 | 
			
		||||
@ -14,7 +14,8 @@
 | 
			
		||||
#define CFG_sx1276_radio 1
 | 
			
		||||
 | 
			
		||||
#define HAS_LED (22)     // Green LED on board
 | 
			
		||||
#define HAS_RGB_LED SmartLed rgb_led(LED_WS2812, 1, GPIO_NUM_2) // WS2812B RGB LED on board
 | 
			
		||||
#define RGB_LED_COUNT 1 // we have 1 LED
 | 
			
		||||
#define HAS_RGB_LED SmartLed rgb_led(LED_WS2812, RGB_LED_COUNT, GPIO_NUM_2) // WS2812B RGB LED on board
 | 
			
		||||
#define HAS_BUTTON (0)   // button "FLASH" on board
 | 
			
		||||
#define DISABLE_BROWNOUT 1      // comment out if you want to keep brownout feature
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -21,7 +21,8 @@
 | 
			
		||||
 | 
			
		||||
#define CFG_sx1276_radio 1
 | 
			
		||||
#define HAS_LED NOT_A_PIN // LoPy4 has no on board mono LED, we use on board RGB LED
 | 
			
		||||
#define HAS_RGB_LED SmartLed rgb_led(LED_WS2812, 1, GPIO_NUM_0) // WS2812B RGB LED on GPIO0 (P2)
 | 
			
		||||
#define RGB_LED_COUNT 1 // we have 1 LEDs
 | 
			
		||||
#define HAS_RGB_LED SmartLed rgb_led(LED_WS2812, RGB_LED_COUNT, GPIO_NUM_0) // WS2812B RGB LED on GPIO0 (P2)
 | 
			
		||||
#define BOARD_HAS_PSRAM // use extra 4MB extern RAM
 | 
			
		||||
 | 
			
		||||
// Note: Pins for LORA chip SPI interface come from board file pins_arduino.h
 | 
			
		||||
 | 
			
		||||
@ -38,8 +38,9 @@
 | 
			
		||||
//#define BAT_MEASURE_ADC ADC1_GPIO35_CHANNEL // battery probe GPIO pin -> ADC1_CHANNEL_7
 | 
			
		||||
//#define BAT_VOLTAGE_DIVIDER 2 // voltage divider 100k/100k on board
 | 
			
		||||
 | 
			
		||||
#define HAS_LED NOT_A_PIN // no on board LED (?)
 | 
			
		||||
#define HAS_RGB_LED SmartLed rgb_led(LED_SK6812, 10, GPIO_NUM_15) // LED_SK6812 RGB LED on GPIO15
 | 
			
		||||
#define HAS_LED NOT_A_PIN // no on board LED
 | 
			
		||||
#define RGB_LED_COUNT 5 // we use 5 of 10 LEDs (1 side)
 | 
			
		||||
#define HAS_RGB_LED SmartLed rgb_led(LED_SK6812, RGB_LED_COUNT, GPIO_NUM_15) // LED_SK6812 RGB LED on GPIO15
 | 
			
		||||
#define HAS_BUTTON (39) // on board button A
 | 
			
		||||
 | 
			
		||||
// GPS settings
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										11
									
								
								src/led.cpp
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								src/led.cpp
									
									
									
									
									
								
							@ -63,9 +63,11 @@ RGBColor rgb_hsl2rgb(float h, float s, float l) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void rgb_set_color(uint16_t hue) {
 | 
			
		||||
  int i = RGB_LED_COUNT;
 | 
			
		||||
  if (hue == COLOR_NONE) {
 | 
			
		||||
    // Off
 | 
			
		||||
    rgb_led[0] = Rgb(0, 0, 0);
 | 
			
		||||
    while (i--)
 | 
			
		||||
      rgb_led[i] = Rgb(0, 0, 0);
 | 
			
		||||
  } else {
 | 
			
		||||
    // see http://www.workwithcolor.com/blue-color-hue-range-01.htm
 | 
			
		||||
    // H (is color from 0..360) should be between 0.0 and 1.0
 | 
			
		||||
@ -74,7 +76,8 @@ void rgb_set_color(uint16_t hue) {
 | 
			
		||||
    // cfg.rgblum is between 0 and 100 (percent)
 | 
			
		||||
    RGBColor target = rgb_hsl2rgb(hue / 360.0f, 1.0f, 0.005f * cfg.rgblum);
 | 
			
		||||
    // uint32_t color = target.R<<16 | target.G<<8 | target.B;
 | 
			
		||||
    rgb_led[0] = Rgb(target.R, target.G, target.B);
 | 
			
		||||
    while (i--)
 | 
			
		||||
      rgb_led[i] = Rgb(target.R, target.G, target.B);
 | 
			
		||||
  }
 | 
			
		||||
  // Show
 | 
			
		||||
  rgb_led.show();
 | 
			
		||||
@ -211,7 +214,7 @@ void ledLoop(void *parameter) {
 | 
			
		||||
    }
 | 
			
		||||
    // give yield to CPU
 | 
			
		||||
    delay(2);
 | 
			
		||||
  }                         // while(1)
 | 
			
		||||
};                          // ledloop()
 | 
			
		||||
  } // while(1)
 | 
			
		||||
};  // ledloop()
 | 
			
		||||
 | 
			
		||||
#endif // #if (HAS_LED != NOT_A_PIN) || defined(HAS_RGB_LED)
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user