/*
 * =====================功能说明=====================
 * 使用Arduino Uno开发板控制WS2812光带一个灯珠的闪烁。
 *  
 * =====================电路连接======================
 * 此示例程序中,Arduino输出控制信号引脚为3号引脚。
 * 
 */

#include "FastLED.h"            // 此示例程序需要使用FastLED库

#define NUM_LEDS 11             // LED灯珠数量
#define DATA_PIN 3              // Arduino输出控制信号引脚
#define LED_TYPE WS2812         // LED灯带型号
#define COLOR_ORDER GRB         // RGB灯珠中红色、绿色、蓝色LED的排列顺序
 

uint8_t Brightness = 200;       // LED灯带亮度
uint8_t beginHue = 80;          // Hue起始色调
uint8_t StartColor = 0;         // Palette色板起始颜色
int stepHue = 10;               // Hue色调变化步长
int LedMode = 4;                // LED灯带显示模式
CRGB leds[NUM_LEDS];            // 建立灯带名称leds

void setup() { 
  Serial.begin(9600);           // 启动串行通讯
  delay(1000);                  // 稳定性等待
  LEDS.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS);  // 初始化光带 
  FastLED.setBrightness(Brightness);    //设定初始亮度为Brightness(默认为最大值255)
}

void loop() { 
  switch(LedMode) {
  case 1:
  beginHue+=stepHue;                                  //让起始色调值以stepHue为步长在0~255范围内循环增加
  fill_rainbow(leds, NUM_LEDS, beginHue, stepHue);    //LED灯带基于HUE以彩虹色变化
                                                      //从第1个开始 同时 点亮11个灯
                                                      //起始色调为beginHue
                                                      //变化步长为stepHue
  FastLED.show();                                     //更新LED色彩
  delay(100);
  break;

  case 2:
  //fill_gradient_RGB光滑过渡显示两种RGB颜色
  fill_gradient_RGB(leds, 0, CRGB::Red, 10, CRGB::Green);   //用RGB色彩自定义开始和结束的LED灯和颜色
  //填充函数(灯带名称,起始灯,起始颜色,结束灯,结束颜色);
  FastLED.show();
  delay(100);
  break;

  case 3:
  //fill_gradient光滑过渡显示两种HUE颜色
  fill_gradient(leds, 0, CHSV(50,255,255), 10, CHSV(200,255,255), SHORTEST_HUES);   //用HSV色彩自定义开始和结束的LED灯和颜色
  //填充函数(灯带名称,起始灯,起始颜色,结束灯,结束颜色,HUE圆盘最短色彩变化路径);
  FastLED.show();
  delay(100);
  break;

  case 4:
  //fill_palette线性过渡显示一个色板里的颜色
  StartColor+=10;
  fill_palette(leds, 11, StartColor, 20, HeatColors_p, 255, LINEARBLEND);
  //填充函数(灯带名称,LED数量,起始颜色序号,变化步长,色板名称,LED亮度,线性变化);
  FastLED.show();
  delay(100);
  break;

  default:
  fill_solid(leds, NUM_LEDS, CRGB::Black);
  FastLED.show();
  delay(100);
  }
}

/*
CRGB 颜色名称列表
CRGB::AliceBlue  
CRGB::Amethyst  
CRGB::AntiqueWhite  
CRGB::Aqua  
CRGB::Aquamarine  
CRGB::Azure 
CRGB::Beige 
CRGB::Bisque  
CRGB::Black 
CRGB::BlanchedAlmond  
CRGB::Blue  
CRGB::BlueViolet  
CRGB::Brown 
CRGB::BurlyWood 
CRGB::CadetBlue 
CRGB::Chartreuse  
CRGB::Chocolate 
CRGB::Coral 
CRGB::CornflowerBlue  
CRGB::Cornsilk  
CRGB::Crimson 
CRGB::Cyan  
CRGB::DarkBlue  
CRGB::DarkCyan  
CRGB::DarkGoldenrod 
CRGB::DarkGray  
CRGB::DarkGreen 
CRGB::DarkKhaki 
CRGB::DarkMagenta 
CRGB::DarkOliveGreen  
CRGB::DarkOrange  
CRGB::DarkOrchid  
CRGB::DarkRed 
CRGB::DarkSalmon  
CRGB::DarkSeaGreen  
CRGB::DarkSlateBlue 
CRGB::DarkSlateGray 
CRGB::DarkTurquoise 
CRGB::DarkViolet  
CRGB::DeepPink  
CRGB::DeepSkyBlue 
CRGB::DimGray 
CRGB::DodgerBlue  
CRGB::FireBrick 
CRGB::FloralWhite 
CRGB::ForestGreen 
CRGB::Fuchsia 
CRGB::Gainsboro 
CRGB::GhostWhite  
CRGB::Gold  
CRGB::Goldenrod 
CRGB::Gray  
CRGB::Green 
CRGB::GreenYellow 
CRGB::Honeydew  
CRGB::HotPink 
CRGB::IndianRed 
CRGB::Indigo  
CRGB::Ivory 
CRGB::Khaki 
CRGB::Lavender  
CRGB::LavenderBlush 
CRGB::LawnGreen 
CRGB::LemonChiffon  
CRGB::LightBlue 
CRGB::LightCoral  
CRGB::LightCyan 
CRGB::LightGoldenrodYellow  
CRGB::LightGreen  
CRGB::LightGrey 
CRGB::LightPink 
CRGB::LightSalmon 
CRGB::LightSeaGreen 
CRGB::LightSkyBlue  
CRGB::LightSlateGray  
CRGB::LightSteelBlue  
CRGB::LightYellow 
CRGB::Lime  
CRGB::LimeGreen 
CRGB::Linen 
CRGB::Magenta 
CRGB::Maroon  
CRGB::MediumAquamarine  
CRGB::MediumBlue  
CRGB::MediumOrchid  
CRGB::MediumPurple  
CRGB::MediumSeaGreen  
CRGB::MediumSlateBlue 
CRGB::MediumSpringGreen 
CRGB::MediumTurquoise 
CRGB::MediumVioletRed 
CRGB::MidnightBlue  
CRGB::MintCream 
CRGB::MistyRose 
CRGB::Moccasin  
CRGB::NavajoWhite 
CRGB::Navy  
CRGB::OldLace 
CRGB::Olive 
CRGB::OliveDrab 
CRGB::Orange  
CRGB::OrangeRed 
CRGB::Orchid  
CRGB::PaleGoldenrod 
CRGB::PaleGreen 
CRGB::PaleTurquoise 
CRGB::PaleVioletRed 
CRGB::PapayaWhip  
CRGB::PeachPuff 
CRGB::Peru  
CRGB::Pink  
CRGB::Plaid 
CRGB::Plum  
CRGB::PowderBlue  
CRGB::Purple  
CRGB::Red 
CRGB::RosyBrown 
CRGB::RoyalBlue 
CRGB::SaddleBrown 
CRGB::Salmon  
CRGB::SandyBrown  
CRGB::SeaGreen  
CRGB::Seashell  
CRGB::Sienna  
CRGB::Silver  
CRGB::SkyBlue 
CRGB::SlateBlue 
CRGB::SlateGray 
CRGB::Snow  
CRGB::SpringGreen 
CRGB::SteelBlue 
CRGB::Tan 
CRGB::Teal  
CRGB::Thistle 
CRGB::Tomato  
CRGB::Turquoise 
CRGB::Violet  
CRGB::Wheat 
CRGB::White 
CRGB::WhiteSmoke  
CRGB::Yellow  
CRGB::YellowGreen 

*/


/*palette色板列表
CloudColors_p
LavaColors_p
OceanColors_p
ForestColors_p
RainbowColors_p
RainbowStripeColors_p
HeatColors_p
*/