forked from btclock/btclock_v3
More code formatting improvements
This commit is contained in:
parent
4aab02a040
commit
86d299fd75
25 changed files with 417 additions and 467 deletions
|
@ -18,106 +18,103 @@ void ledTask(void *parameter) {
|
|||
}
|
||||
|
||||
switch (ledTaskParams) {
|
||||
case LED_POWER_TEST:
|
||||
ledRainbow(20);
|
||||
pixels.clear();
|
||||
break;
|
||||
case LED_EFFECT_WIFI_CONNECT_ERROR:
|
||||
blinkDelayTwoColor(100, 3, pixels.Color(8, 161, 236),
|
||||
pixels.Color(255, 0, 0));
|
||||
break;
|
||||
case LED_FLASH_ERROR:
|
||||
blinkDelayColor(250, 3, 255, 0, 0);
|
||||
break;
|
||||
case LED_EFFECT_HEARTBEAT:
|
||||
blinkDelayColor(150, 2, 0, 0, 255);
|
||||
break;
|
||||
case LED_EFFECT_WIFI_CONNECT_SUCCESS:
|
||||
case LED_FLASH_SUCCESS:
|
||||
blinkDelayColor(150, 3, 0, 255, 0);
|
||||
break;
|
||||
case LED_PROGRESS_100:
|
||||
pixels.setPixelColor(0, pixels.Color(0, 255, 0));
|
||||
case LED_PROGRESS_75:
|
||||
pixels.setPixelColor(1, pixels.Color(0, 255, 0));
|
||||
case LED_PROGRESS_50:
|
||||
pixels.setPixelColor(2, pixels.Color(0, 255, 0));
|
||||
case LED_PROGRESS_25:
|
||||
pixels.setPixelColor(3, pixels.Color(0, 255, 0));
|
||||
pixels.show();
|
||||
break;
|
||||
case LED_FLASH_UPDATE:
|
||||
break;
|
||||
case LED_FLASH_BLOCK_NOTIFY:
|
||||
blinkDelayTwoColor(250, 3, pixels.Color(224, 67, 0),
|
||||
pixels.Color(8, 2, 0));
|
||||
break;
|
||||
case LED_EFFECT_WIFI_WAIT_FOR_CONFIG:
|
||||
blinkDelayTwoColor(100, 1, pixels.Color(8, 161, 236),
|
||||
pixels.Color(156, 225, 240));
|
||||
break;
|
||||
case LED_EFFECT_WIFI_ERASE_SETTINGS:
|
||||
blinkDelay(100, 3);
|
||||
break;
|
||||
case LED_EFFECT_WIFI_CONNECTING:
|
||||
for (int i = NEOPIXEL_COUNT; i >= 0; i--) {
|
||||
for (int j = NEOPIXEL_COUNT; j >= 0; j--) {
|
||||
if (j == i) {
|
||||
pixels.setPixelColor(i, pixels.Color(16, 197, 236));
|
||||
} else {
|
||||
pixels.setPixelColor(j, pixels.Color(0, 0, 0));
|
||||
case LED_POWER_TEST:
|
||||
ledRainbow(20);
|
||||
pixels.clear();
|
||||
break;
|
||||
case LED_EFFECT_WIFI_CONNECT_ERROR:
|
||||
blinkDelayTwoColor(100, 3, pixels.Color(8, 161, 236),
|
||||
pixels.Color(255, 0, 0));
|
||||
break;
|
||||
case LED_FLASH_ERROR:
|
||||
blinkDelayColor(250, 3, 255, 0, 0);
|
||||
break;
|
||||
case LED_EFFECT_HEARTBEAT:
|
||||
blinkDelayColor(150, 2, 0, 0, 255);
|
||||
break;
|
||||
case LED_EFFECT_WIFI_CONNECT_SUCCESS:
|
||||
case LED_FLASH_SUCCESS:
|
||||
blinkDelayColor(150, 3, 0, 255, 0);
|
||||
break;
|
||||
case LED_PROGRESS_100:
|
||||
pixels.setPixelColor(0, pixels.Color(0, 255, 0));
|
||||
case LED_PROGRESS_75:
|
||||
pixels.setPixelColor(1, pixels.Color(0, 255, 0));
|
||||
case LED_PROGRESS_50:
|
||||
pixels.setPixelColor(2, pixels.Color(0, 255, 0));
|
||||
case LED_PROGRESS_25:
|
||||
pixels.setPixelColor(3, pixels.Color(0, 255, 0));
|
||||
pixels.show();
|
||||
break;
|
||||
case LED_FLASH_UPDATE:
|
||||
break;
|
||||
case LED_FLASH_BLOCK_NOTIFY:
|
||||
blinkDelayTwoColor(250, 3, pixels.Color(224, 67, 0),
|
||||
pixels.Color(8, 2, 0));
|
||||
break;
|
||||
case LED_EFFECT_WIFI_WAIT_FOR_CONFIG:
|
||||
blinkDelayTwoColor(100, 1, pixels.Color(8, 161, 236),
|
||||
pixels.Color(156, 225, 240));
|
||||
break;
|
||||
case LED_EFFECT_WIFI_ERASE_SETTINGS:
|
||||
blinkDelay(100, 3);
|
||||
break;
|
||||
case LED_EFFECT_WIFI_CONNECTING:
|
||||
for (int i = NEOPIXEL_COUNT; i >= 0; i--) {
|
||||
for (int j = NEOPIXEL_COUNT; j >= 0; j--) {
|
||||
if (j == i) {
|
||||
pixels.setPixelColor(i, pixels.Color(16, 197, 236));
|
||||
} else {
|
||||
pixels.setPixelColor(j, pixels.Color(0, 0, 0));
|
||||
}
|
||||
}
|
||||
pixels.show();
|
||||
vTaskDelay(pdMS_TO_TICKS(100));
|
||||
}
|
||||
pixels.show();
|
||||
vTaskDelay(pdMS_TO_TICKS(100));
|
||||
}
|
||||
break;
|
||||
case LED_EFFECT_PAUSE_TIMER:
|
||||
for (int i = NEOPIXEL_COUNT; i >= 0; i--) {
|
||||
for (int j = NEOPIXEL_COUNT; j >= 0; j--) {
|
||||
uint32_t c = pixels.Color(0, 0, 0);
|
||||
if (i == j)
|
||||
c = pixels.Color(0, 255, 0);
|
||||
pixels.setPixelColor(j, c);
|
||||
}
|
||||
break;
|
||||
case LED_EFFECT_PAUSE_TIMER:
|
||||
for (int i = NEOPIXEL_COUNT; i >= 0; i--) {
|
||||
for (int j = NEOPIXEL_COUNT; j >= 0; j--) {
|
||||
uint32_t c = pixels.Color(0, 0, 0);
|
||||
if (i == j) c = pixels.Color(0, 255, 0);
|
||||
pixels.setPixelColor(j, c);
|
||||
}
|
||||
|
||||
pixels.show();
|
||||
|
||||
delay(100);
|
||||
}
|
||||
pixels.setPixelColor(0, pixels.Color(255, 0, 0));
|
||||
pixels.show();
|
||||
|
||||
delay(100);
|
||||
}
|
||||
pixels.setPixelColor(0, pixels.Color(255, 0, 0));
|
||||
pixels.show();
|
||||
|
||||
delay(900);
|
||||
|
||||
pixels.clear();
|
||||
pixels.show();
|
||||
break;
|
||||
case LED_EFFECT_START_TIMER:
|
||||
pixels.clear();
|
||||
pixels.setPixelColor((NEOPIXEL_COUNT - 1), pixels.Color(255, 0, 0));
|
||||
pixels.show();
|
||||
|
||||
delay(900);
|
||||
|
||||
for (int i = NEOPIXEL_COUNT; i--; i > 0) {
|
||||
|
||||
for (int j = NEOPIXEL_COUNT; j--; j > 0) {
|
||||
uint32_t c = pixels.Color(0, 0, 0);
|
||||
if (i == j)
|
||||
c = pixels.Color(0, 255, 0);
|
||||
|
||||
pixels.setPixelColor(j, c);
|
||||
}
|
||||
delay(900);
|
||||
|
||||
pixels.clear();
|
||||
pixels.show();
|
||||
break;
|
||||
case LED_EFFECT_START_TIMER:
|
||||
pixels.clear();
|
||||
pixels.setPixelColor((NEOPIXEL_COUNT - 1), pixels.Color(255, 0, 0));
|
||||
pixels.show();
|
||||
|
||||
delay(100);
|
||||
}
|
||||
delay(900);
|
||||
|
||||
pixels.clear();
|
||||
pixels.show();
|
||||
break;
|
||||
for (int i = NEOPIXEL_COUNT; i--; i > 0) {
|
||||
for (int j = NEOPIXEL_COUNT; j--; j > 0) {
|
||||
uint32_t c = pixels.Color(0, 0, 0);
|
||||
if (i == j) c = pixels.Color(0, 255, 0);
|
||||
|
||||
pixels.setPixelColor(j, c);
|
||||
}
|
||||
|
||||
pixels.show();
|
||||
|
||||
delay(100);
|
||||
}
|
||||
|
||||
pixels.clear();
|
||||
pixels.show();
|
||||
break;
|
||||
}
|
||||
|
||||
// revert to previous state unless power test
|
||||
|
@ -155,7 +152,6 @@ void setupLedTask() {
|
|||
|
||||
void blinkDelay(int d, int times) {
|
||||
for (int j = 0; j < times; j++) {
|
||||
|
||||
pixels.setPixelColor(0, pixels.Color(255, 0, 0));
|
||||
pixels.setPixelColor(1, pixels.Color(0, 255, 0));
|
||||
pixels.setPixelColor(2, pixels.Color(255, 0, 0));
|
||||
|
@ -218,7 +214,6 @@ void clearLeds() {
|
|||
void setLights(int r, int g, int b) { setLights(pixels.Color(r, g, b)); }
|
||||
|
||||
void setLights(uint32_t color) {
|
||||
|
||||
bool ledStatus = true;
|
||||
|
||||
for (int i = 0; i < NEOPIXEL_COUNT; i++) {
|
||||
|
@ -282,43 +277,43 @@ void ledRainbow(int wait) {
|
|||
pixels.rainbow(firstPixelHue);
|
||||
// Above line is equivalent to:
|
||||
// strip.rainbow(firstPixelHue, 1, 255, 255, true);
|
||||
pixels.show(); // Update strip with new contents
|
||||
pixels.show(); // Update strip with new contents
|
||||
delayMicroseconds(wait);
|
||||
// vTaskDelay(pdMS_TO_TICKS(wait)); // Pause for a moment
|
||||
}
|
||||
}
|
||||
|
||||
void ledTheaterChase(uint32_t color, int wait) {
|
||||
for (int a = 0; a < 10; a++) { // Repeat 10 times...
|
||||
for (int b = 0; b < 3; b++) { // 'b' counts from 0 to 2...
|
||||
pixels.clear(); // Set all pixels in RAM to 0 (off)
|
||||
for (int a = 0; a < 10; a++) { // Repeat 10 times...
|
||||
for (int b = 0; b < 3; b++) { // 'b' counts from 0 to 2...
|
||||
pixels.clear(); // Set all pixels in RAM to 0 (off)
|
||||
// 'c' counts up from 'b' to end of strip in steps of 3...
|
||||
for (int c = b; c < pixels.numPixels(); c += 3) {
|
||||
pixels.setPixelColor(c, color); // Set pixel 'c' to value 'color'
|
||||
pixels.setPixelColor(c, color); // Set pixel 'c' to value 'color'
|
||||
}
|
||||
pixels.show(); // Update strip with new contents
|
||||
vTaskDelay(pdMS_TO_TICKS(wait)); // Pause for a moment
|
||||
pixels.show(); // Update strip with new contents
|
||||
vTaskDelay(pdMS_TO_TICKS(wait)); // Pause for a moment
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ledTheaterChaseRainbow(int wait) {
|
||||
int firstPixelHue = 0; // First pixel starts at red (hue 0)
|
||||
for (int a = 0; a < 30; a++) { // Repeat 30 times...
|
||||
for (int b = 0; b < 3; b++) { // 'b' counts from 0 to 2...
|
||||
pixels.clear(); // Set all pixels in RAM to 0 (off)
|
||||
int firstPixelHue = 0; // First pixel starts at red (hue 0)
|
||||
for (int a = 0; a < 30; a++) { // Repeat 30 times...
|
||||
for (int b = 0; b < 3; b++) { // 'b' counts from 0 to 2...
|
||||
pixels.clear(); // Set all pixels in RAM to 0 (off)
|
||||
// 'c' counts up from 'b' to end of strip in increments of 3...
|
||||
for (int c = b; c < pixels.numPixels(); c += 3) {
|
||||
// hue of pixel 'c' is offset by an amount to make one full
|
||||
// revolution of the color wheel (range 65536) along the length
|
||||
// of the strip (strip.numPixels() steps):
|
||||
int hue = firstPixelHue + c * 65536L / pixels.numPixels();
|
||||
uint32_t color = pixels.gamma32(pixels.ColorHSV(hue)); // hue -> RGB
|
||||
pixels.setPixelColor(c, color); // Set pixel 'c' to value 'color'
|
||||
uint32_t color = pixels.gamma32(pixels.ColorHSV(hue)); // hue -> RGB
|
||||
pixels.setPixelColor(c, color); // Set pixel 'c' to value 'color'
|
||||
}
|
||||
pixels.show(); // Update strip with new contents
|
||||
vTaskDelay(pdMS_TO_TICKS(wait)); // Pause for a moment
|
||||
firstPixelHue += 65536 / 90; // One cycle of color wheel over 90 frames
|
||||
pixels.show(); // Update strip with new contents
|
||||
vTaskDelay(pdMS_TO_TICKS(wait)); // Pause for a moment
|
||||
firstPixelHue += 65536 / 90; // One cycle of color wheel over 90 frames
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue