Răsfoiți Sursa

fix some buttons snafu & power off led on suspend

philippe44 1 an în urmă
părinte
comite
66b88d186a

+ 4 - 3
components/services/audio_controls.c

@@ -192,8 +192,9 @@ static void control_handler(void *client, button_event_e event, button_press_e p
     
    	// in raw mode, we just do normal action press *and* release, there is no longpress nor shift
 	if (current_raw_controls && action_detail.action != ACTRLS_SLEEP) {
-		ESP_LOGD(TAG, "calling action %u in raw mode", key->normal[0].action);
-		if (current_controls[key->normal[0].action]) (*current_controls[key->normal[0].action])(event == BUTTON_PRESSED);
+        actrls_action_e action = key->normal[0].action != ACTRLS_NONE ? key->normal[0].action : key->normal[1].action;
+		ESP_LOGD(TAG, "calling action %u in raw mode", action);
+		if (action != ACTRLS_NONE && current_controls[action]) current_controls[action](event == BUTTON_PRESSED);
 		return;
 	}
 
@@ -218,7 +219,7 @@ static void control_handler(void *client, button_event_e event, button_press_e p
 			ESP_LOGE(TAG,"Invalid profile name %s. Cannot remap buttons",action_detail.name);
 		}	
 	} else if (action_detail.action == ACTRLS_SLEEP) {
-        ESP_LOGI(TAG, "Sleep button pressed");
+        ESP_LOGI(TAG, "special sleep button pressed");
         services_sleep_activate(SLEEP_ONKEY);
     } else if (action_detail.action != ACTRLS_NONE) {
 		ESP_LOGD(TAG, "calling action %u", action_detail.action);

+ 2 - 1
components/services/audio_controls.h

@@ -16,7 +16,8 @@ typedef enum { 	ACTRLS_NONE = -1, ACTRLS_POWER, ACTRLS_VOLUP, ACTRLS_VOLDOWN, AC
 				BCTRLS_UP, BCTRLS_DOWN, BCTRLS_LEFT, BCTRLS_RIGHT, 
 				BCTRLS_PS0,BCTRLS_PS1,BCTRLS_PS2,BCTRLS_PS3,BCTRLS_PS4,BCTRLS_PS5,BCTRLS_PS6,BCTRLS_PS7,BCTRLS_PS8,BCTRLS_PS9,
 				KNOB_LEFT, KNOB_RIGHT, KNOB_PUSH,
-				ACTRLS_REMAP, ACTRLS_SLEEP, ACTRLS_MAX 
+                ACTRLS_SLEEP,
+				ACTRLS_REMAP, ACTRLS_MAX 
 		} actrls_action_e;
 
 typedef void (*actrls_handler)(bool pressed);

+ 12 - 0
components/services/led.c

@@ -24,6 +24,7 @@
 #include "led.h"
 #include "globdefs.h"
 #include "accessors.h"
+#include "services.h"
 
 #define MAX_LED	8
 #define BLOCKTIME	10	// up to portMAX_DELAY
@@ -276,6 +277,14 @@ bool led_config(int idx, gpio_num_t gpio, int color, int bright, led_type_t type
 	return true;
 }
 
+/****************************************************************************************
+ *
+ */
+static void led_suspend(void) {
+    led_off(LED_GREEN);
+    led_off(LED_RED);
+}     
+
 /****************************************************************************************
  *
  */
@@ -326,6 +335,9 @@ void led_svc_init(void) {
 
 	led_config(LED_GREEN, green.gpio, green.color, green.bright, green.type);
 	led_config(LED_RED, red.gpio, red.color, red.bright, red.type);
+    
+    // make sure we switch off all leds (useful for gpio expanders)
+    services_sleep_setsuspend(led_suspend);
 
 	ESP_LOGI(TAG,"Configuring LEDs green:%d (on:%d rmt:%d %d%% ), red:%d (on:%d rmt:%d %d%% )",
                  green.gpio, green.color, green.type, green.bright,

+ 1 - 1
components/squeezelite/controls.c

@@ -70,7 +70,7 @@ static void sendBUTN(int code, bool pressed) {
 	pkt_header.jiffies = htonl(gettime_ms());
 	pkt_header.button = htonl(code + (pressed ? DOWN_OFS : UP_OFS));
 		
-	LOG_INFO("sending BUTN code %04x %s", code, pressed ? "down" : "up");	
+	LOG_DEBUG("sending BUTN code %04x %s", code, pressed ? "down" : "up");	
 
 	LOCK_P;
 	send_packet((uint8_t *) &pkt_header, sizeof(pkt_header));