From 8a90dae6e4ac1fbce8a04889598d6a84271f400b Mon Sep 17 00:00:00 2001 From: Hendrik Langer Date: Mon, 8 Jan 2018 01:09:33 +0100 Subject: [PATCH] tweak magic numbers --- software/src/MyMQTT.cpp | 2 +- software/src/led.cpp | 18 +++++++++++------- software/src/shelf.cpp | 6 +++--- software/src/wifi.cpp | 2 +- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/software/src/MyMQTT.cpp b/software/src/MyMQTT.cpp index 79ec67d..cc1ce57 100644 --- a/software/src/MyMQTT.cpp +++ b/software/src/MyMQTT.cpp @@ -100,7 +100,7 @@ void MyMQTT::onMqttDisconnect(AsyncMqttClientDisconnectReason reason) { "mqttReconnectTask", /* String with name of task. */ 1024, /* Stack size in words. */ this, /* Parameter passed as input of the task */ - 1, /* Priority of the task. */ + tskIDLE_PRIORITY, /* Priority of the task. */ &mqttTaskHandle); /* Task handle. */ } diff --git a/software/src/led.cpp b/software/src/led.cpp index b24bace..13ab8cc 100644 --- a/software/src/led.cpp +++ b/software/src/led.cpp @@ -10,12 +10,10 @@ using namespace std; Led::Led(void) { index = 0; duration = 0; - change = true; - color = CRGB::Orange; } void Led::loop_rainbow(void) { - fill_rainbow(leds, NUM_LEDS, index, 7); + fill_rainbow(leds, NUM_LEDS, index, 14); } void Led::loop_confetti(void) @@ -39,6 +37,10 @@ void Led::loop_dispense(void) { fadeToBlackBy( leds, NUM_LEDS, 20); int pos = beatsin16( 13, 0, NUM_LEDS-1 ); leds[pos] += CHSV( index, 255, 192); + + leds[0] = CRGB::White; + leds[NUM_LEDS-1] = CRGB::White; + leds[NUM_LEDS-2] = CRGB::White; } void Led::loop_steady(void) { @@ -68,17 +70,19 @@ void Led::setup(void) { pinMode(LED_PIN, OUTPUT); FastLED.addLeds(leds, NUM_LEDS); FastLED.setBrightness(96); - FastLED.setCorrection(0xFF6060); + FastLED.setCorrection(0xFF5050); fill_solid(leds, NUM_LEDS, CRGB::White); - FastLED.show(); + color = CRGB::Orange; + change = true; refresh = &Led::loop_steady; + delay(100); xTaskCreate( &cTaskWrapper, /* Task function. */ "ledAnimationTask", /* String with name of task. */ - 4096, /* Stack size in words. */ + 2048, /* Stack size in words. */ this, /* Parameter passed as input of the task */ - 1, /* Priority of the task. */ + tskIDLE_PRIORITY+3, /* Priority of the task. */ &ledTaskHandle); /* Task handle. */ } diff --git a/software/src/shelf.cpp b/software/src/shelf.cpp index 3034f85..6d85f84 100644 --- a/software/src/shelf.cpp +++ b/software/src/shelf.cpp @@ -30,9 +30,9 @@ void Shelf::dispenseTask(void* parameters) { item.at(num)->quantity--; led.changeAnimation(1, 0); pusher.push(num); - delay(500); + vTaskDelay(500 / portTICK_PERIOD_MS); led.changeAnimation(2, 0); - delay(7000); + vTaskDelay(7000 / portTICK_PERIOD_MS); led.changeAnimation(0, 0); vTaskDelete(NULL); @@ -44,5 +44,5 @@ void Shelf::cTaskWrapper(void* parameters) { void Shelf::dispense(int num) { this->num = num; - xTaskCreate(&cTaskWrapper, "dispenseTask", 1024, this, 0, &dispenseTaskHandle); + xTaskCreate(&cTaskWrapper, "dispenseTask", 1024, this, tskIDLE_PRIORITY+2, &dispenseTaskHandle); } diff --git a/software/src/wifi.cpp b/software/src/wifi.cpp index 4f04cd9..86bc312 100644 --- a/software/src/wifi.cpp +++ b/software/src/wifi.cpp @@ -46,7 +46,7 @@ xTaskCreate( "wifiReconnectTask", /* String with name of task. */ 1024, /* Stack size in words. */ this, /* Parameter passed as input of the task */ - 1, /* Priority of the task. */ + tskIDLE_PRIORITY+1, /* Priority of the task. */ &wifiTaskHandle); /* Task handle. */ }