Browse Source

Added fade for color change.

Vladimir N. Shilov 3 years ago
parent
commit
b97a74093d
1 changed files with 13 additions and 1 deletions
  1. 13 1
      Src/main.c

+ 13 - 1
Src/main.c

@@ -144,7 +144,19 @@ static void Color_RGB(uint8_t r, uint8_t g, uint8_t b) {
 
 /* cheng led color by time seconds */
 static void ColorCircle(void) {
-  uint8_t hue = Clock.Sec * 6;
+  static uint8_t hue = 0, stage = 0;
+
+  if (stage == 0) {
+    hue = Clock.Sec * 6;
+    RTOS_SetTask(ColorCircle, 20, 20);
+  } else if (stage > 8) {
+    RTOS_DeleteTask(ColorCircle);
+    stage = 0;
+    hue ++;
+  } else {
+    hue ++;
+    stage ++;
+  }
   HSV2LED(hue, 255, 255);
 }