|
@@ -5,6 +5,7 @@
|
|
|
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
|
CONDITIONS OF ANY KIND, either express or implied.
|
|
|
*/
|
|
|
+
|
|
|
#include <stdio.h>
|
|
|
#include <stdlib.h>
|
|
|
#include <unistd.h>
|
|
@@ -83,8 +84,8 @@ static void vCallbackFunction( TimerHandle_t xTimer ) {
|
|
|
*/
|
|
|
bool led_blink_core(int idx, int ontime, int offtime, bool pushed) {
|
|
|
if (!leds[idx].gpio || leds[idx].gpio < 0 ) return false;
|
|
|
-
|
|
|
- ESP_LOGD(TAG,"led_blink_core led idx %d, ontime %d, offtime %d, pushing %s. Led state: pushedon %d, pushedoff %d, timer %s, pushed %s", idx,ontime,offtime,pushed?"TRUE":"FALSE", leds[idx].pushedon,leds[idx].pushedoff,leds[idx].timer?"TRUE":"FALSE", leds[idx].pushed?"TRUE":"FALSE");
|
|
|
+
|
|
|
+ ESP_LOGD(TAG,"led_blink_core %d on:%d off:%d, pushed:%u", idx, ontime, offtime, pushed);
|
|
|
if (leds[idx].timer) {
|
|
|
// normal requests waits if a pop is pending
|
|
|
if (!pushed && leds[idx].pushed) {
|
|
@@ -97,18 +98,15 @@ bool led_blink_core(int idx, int ontime, int offtime, bool pushed) {
|
|
|
|
|
|
// save current state if not already pushed
|
|
|
if (!leds[idx].pushed) {
|
|
|
- ESP_LOGD(TAG,"Pushing state. Ontime %d->%d. Offtime %d->%d",leds[idx].pushedon,leds[idx].ontime, leds[idx].pushedoff,leds[idx].offtime);
|
|
|
leds[idx].pushedon = leds[idx].ontime;
|
|
|
leds[idx].pushedoff = leds[idx].offtime;
|
|
|
leds[idx].pushed = pushed;
|
|
|
-
|
|
|
}
|
|
|
|
|
|
// then set new one
|
|
|
leds[idx].ontime = ontime;
|
|
|
leds[idx].offtime = offtime;
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
if (ontime == 0) {
|
|
|
ESP_LOGD(TAG,"led %d, setting reverse level", idx);
|
|
|
set_level(leds + idx, false);
|
|
@@ -126,8 +124,7 @@ bool led_blink_core(int idx, int ontime, int offtime, bool pushed) {
|
|
|
ESP_LOGD(TAG,"led %d, Setting gpio %d and starting timer", idx, leds[idx].gpio);
|
|
|
if (xTimerStart(leds[idx].timer, BLOCKTIME) == pdFAIL) return false;
|
|
|
}
|
|
|
- ESP_LOGD(TAG,"led_blink_core END led idx %d, ontime %d, offtime %d, pushing %s. Led state: pushedon %d, pushedoff %d, timer %s, pushed %s", idx,ontime,offtime,pushed?"TRUE":"FALSE", leds[idx].pushedon,leds[idx].pushedoff,leds[idx].timer?"TRUE":"FALSE", leds[idx].pushed?"TRUE":"FALSE");
|
|
|
-
|
|
|
+
|
|
|
|
|
|
return true;
|
|
|
}
|
|
@@ -234,13 +231,16 @@ void led_svc_init(void) {
|
|
|
#ifndef CONFIG_LED_LOCKED
|
|
|
parse_set_GPIO(set_led_gpio);
|
|
|
#endif
|
|
|
+
|
|
|
char *nvs_item = config_alloc_get(NVS_TYPE_STR, "led_brightness"), *p;
|
|
|
if (nvs_item) {
|
|
|
if ((p = strcasestr(nvs_item, "green")) != NULL) green.pwm = atoi(strchr(p, '=') + 1);
|
|
|
if ((p = strcasestr(nvs_item, "red")) != NULL) red.pwm = atoi(strchr(p, '=') + 1);
|
|
|
free(nvs_item);
|
|
|
}
|
|
|
- ESP_LOGI(TAG,"Configuring LEDs green:%d (active:%d %d%%), red:%d (active:%d %d%%)", green.gpio, green.active, green.pwm, red.gpio, red.active, red.pwm );
|
|
|
+
|
|
|
led_config(LED_GREEN, green.gpio, green.active, green.pwm);
|
|
|
led_config(LED_RED, red.gpio, red.active, red.pwm);
|
|
|
+
|
|
|
+ ESP_LOGI(TAG,"Configuring LEDs green:%d (active:%d %d%%), red:%d (active:%d %d%%)", green.gpio, green.active, green.pwm, red.gpio, red.active, red.pwm );
|
|
|
}
|